1 -- Xilinx dualport BRAM template, write-first mode, no delay
3 use ieee.std_logic_1164.all;
4 use ieee.numeric_std.all;
5 use work.lx_rocon_pkg.all;
7 entity xilinx_dualport_bram_no_change is
10 -- Not all combinations are plausible for BRAMs
11 -- byte width: 8, 9, 32, 36
12 -- we_width: 1, 2, 3, 4
13 byte_width : positive := 8;
14 address_width : positive := 8;
15 we_width : positive := 4
22 wea : in std_logic_vector((we_width-1) downto 0);
23 addra : in std_logic_vector((address_width-1) downto 0);
24 dina : in std_logic_vector(((byte_width*we_width)-1) downto 0);
25 douta : out std_logic_vector(((byte_width*we_width)-1) downto 0);
29 web : in std_logic_vector((we_width-1) downto 0);
30 addrb : in std_logic_vector((address_width-1) downto 0);
31 dinb : in std_logic_vector(((byte_width*we_width)-1) downto 0);
32 doutb : out std_logic_vector(((byte_width*we_width)-1) downto 0)
34 end xilinx_dualport_bram_no_change;
36 architecture Behavioral of xilinx_dualport_bram_no_change is
37 type ram is array (0 to ((2**address_width) - 1)) of std_logic_vector(((byte_width*we_width)-1) downto 0);
38 shared variable ram_block : ram := (others => (others => '0'));
47 wait until clka'event and clka = '1';
51 for i in 0 to (we_width-1) loop
53 ram_block(to_integer(unsigned(addra)))(((i+1)*byte_width-1) downto (i*byte_width))
54 := dina(((i+1)*byte_width-1) downto (i*byte_width));
58 if to_integer(unsigned(wea)) = 0 then
60 douta <= (others => '0');
62 douta <= ram_block(to_integer(unsigned(addra)));
75 wait until clkb'event and clkb = '1';
79 for i in 0 to (we_width-1) loop
81 ram_block(to_integer(unsigned(addrb)))(((i+1)*byte_width-1) downto (i*byte_width))
82 := dinb(((i+1)*byte_width-1) downto (i*byte_width));
86 if to_integer(unsigned(web)) = 0 then
88 doutb <= (others => '0');
90 doutb <= ram_block(to_integer(unsigned(addrb)));