blob: c45aff9541380dc8f626d2f29b1abb8a835cd13f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity top is
port(
sel : in unsigned(1 downto 0);
data : in std_logic_vector(3 downto 0);
q : out std_logic
);
end entity;
architecture arch of top is
type record_t is record
x : std_logic_vector(1 downto 0);
y : std_logic_vector(1 downto 0);
end record;
type array_t is array (0 to 1) of record_t;
signal a : array_t;
begin
a <= (("11", data(1 downto 0)), ("11", data(3 downto 2)));
q <= a(to_integer(sel(1 downto 1))).y(to_integer(sel(0 downto 0)));
end architecture;
-- A0 A1
-- Y1 Y0 X1 X0 Y1 Y0 X1 X0
-- A + sel1*4 + 2 + sel0*1
|