Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / vhdl_json / vhdl_files / 2-exportOK / ghdl / ghdl / testsuite / gna / bug040 / lmask.vhd @ 2051e520

History | View | Annotate | Download (2.15 KB)

1 2051e520 Arnaud Dieumegard
library ieee;
2
use ieee.std_logic_1164.all;
3
4
5
library ieee;
6
use ieee.numeric_std.all;
7
8
entity lmask 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 lmask;
15
architecture augh of lmask 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", "00000000000000000000000000000011", "00000000000000000000000000000111",
22
		"00000000000000000000000000001111", "00000000000000000000000000011111", "00000000000000000000000000111111",
23
		"00000000000000000000000001111111", "00000000000000000000000011111111", "00000000000000000000000111111111",
24
		"00000000000000000000001111111111", "00000000000000000000011111111111", "00000000000000000000111111111111",
25
		"00000000000000000001111111111111", "00000000000000000011111111111111", "00000000000000000111111111111111",
26
		"00000000000000001111111111111111", "00000000000000011111111111111111", "00000000000000111111111111111111",
27
		"00000000000001111111111111111111", "00000000000011111111111111111111", "00000000000111111111111111111111",
28
		"00000000001111111111111111111111", "00000000011111111111111111111111", "00000000111111111111111111111111",
29
		"00000001111111111111111111111111", "00000011111111111111111111111111", "00000111111111111111111111111111",
30
		"00001111111111111111111111111111", "00011111111111111111111111111111", "00111111111111111111111111111111",
31
		"01111111111111111111111111111111", "11111111111111111111111111111111"
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;