1
|
library ieee;
|
2
|
use ieee.std_logic_1164.all;
|
3
|
|
4
|
|
5
|
library ieee;
|
6
|
use ieee.numeric_std.all;
|
7
|
|
8
|
entity bit_set_mask is
|
9
|
port (
|
10
|
clk : in std_logic;
|
11
|
ra0_addr : in std_logic_vector(4 downto 0);
|
12
|
ra0_data : out std_logic_vector(31 downto 0)
|
13
|
);
|
14
|
end bit_set_mask;
|
15
|
architecture augh of bit_set_mask is
|
16
|
|
17
|
-- Embedded RAM
|
18
|
|
19
|
type ram_type is array (0 to 31) of std_logic_vector(31 downto 0);
|
20
|
signal ram : ram_type := (
|
21
|
"00000000000000000000000000000001", "00000000000000000000000000000010", "00000000000000000000000000000100",
|
22
|
"00000000000000000000000000001000", "00000000000000000000000000010000", "00000000000000000000000000100000",
|
23
|
"00000000000000000000000001000000", "00000000000000000000000010000000", "00000000000000000000000100000000",
|
24
|
"00000000000000000000001000000000", "00000000000000000000010000000000", "00000000000000000000100000000000",
|
25
|
"00000000000000000001000000000000", "00000000000000000010000000000000", "00000000000000000100000000000000",
|
26
|
"00000000000000001000000000000000", "00000000000000010000000000000000", "00000000000000100000000000000000",
|
27
|
"00000000000001000000000000000000", "00000000000010000000000000000000", "00000000000100000000000000000000",
|
28
|
"00000000001000000000000000000000", "00000000010000000000000000000000", "00000000100000000000000000000000",
|
29
|
"00000001000000000000000000000000", "00000010000000000000000000000000", "00000100000000000000000000000000",
|
30
|
"00001000000000000000000000000000", "00010000000000000000000000000000", "00100000000000000000000000000000",
|
31
|
"01000000000000000000000000000000", "10000000000000000000000000000000"
|
32
|
);
|
33
|
|
34
|
|
35
|
-- Little utility functions to make VHDL syntactically correct
|
36
|
-- with the syntax to_integer(unsigned(vector)) when 'vector' is a std_logic.
|
37
|
-- This happens when accessing arrays with <= 2 cells, for example.
|
38
|
|
39
|
function to_integer(B: std_logic) return integer is
|
40
|
variable V: std_logic_vector(0 to 0);
|
41
|
begin
|
42
|
V(0) := B;
|
43
|
return to_integer(unsigned(V));
|
44
|
end;
|
45
|
|
46
|
function to_integer(V: std_logic_vector) return integer is
|
47
|
begin
|
48
|
return to_integer(unsigned(V));
|
49
|
end;
|
50
|
|
51
|
begin
|
52
|
|
53
|
-- The component is a ROM.
|
54
|
-- There is no Write side.
|
55
|
|
56
|
-- The Read side (the outputs)
|
57
|
|
58
|
ra0_data <= ram( to_integer(ra0_addr) );
|
59
|
|
60
|
end architecture;
|