1 ------------------------------------------------------------------------------- 2 -- File : SimpleDualPortRam.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-07-11 5 -- Last update: 2016-05-09 6 ------------------------------------------------------------------------------- 7 -- Description: This will infer this module as either Block RAM or distributed RAM 8 ------------------------------------------------------------------------------- 9 -- This file is part of 'SLAC Firmware Standard Library'. 10 -- It is subject to the license terms in the LICENSE.txt file found in the 11 -- top-level directory of this distribution and at: 12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 13 -- No part of 'SLAC Firmware Standard Library', including this file, 14 -- may be copied, modified, propagated, or distributed except according to 15 -- the terms contained in the LICENSE.txt file. 16 ------------------------------------------------------------------------------- 19 use ieee.std_logic_1164.
all;
20 use ieee.std_logic_arith.
all;
21 use ieee.std_logic_unsigned.
all;
32 DOB_REG_G : := false;
-- Extra reg on doutb (folded into BRAM) 54 end SimpleDualPortRam;
58 -- Set byte width to word width if byte writes not enabled 59 -- Otherwise block ram parity bits wont be utilized 61 constant NUM_BYTES_C : := wordCount(DATA_WIDTH_G, BYTE_WIDTH_C);
62 constant FULL_DATA_WIDTH_C : := NUM_BYTES_C*BYTE_WIDTH_C;
64 constant INIT_C : slv(FULL_DATA_WIDTH_C-1 downto 0) := ite(INIT_G = "0", slvZero(FULL_DATA_WIDTH_C), INIT_G);
66 constant XST_BRAM_STYLE_C : := ite(BRAM_EN_G, "block", "distributed");
70 type mem_type is array ((2**ADDR_WIDTH_G)-1 downto 0) of slv(FULL_DATA_WIDTH_C-1 downto 0);
71 shared variable mem : mem_type := (others => INIT_C);
73 signal doutBInt : slv(FULL_DATA_WIDTH_C-1 downto 0);
77 -- Attribute for XST (Xilinx Synthesis) 78 attribute ram_style : ;
79 attribute ram_style of mem : variable is XST_BRAM_STYLE_C;
81 attribute ram_extract : ;
82 attribute ram_extract of mem : variable is "TRUE";
84 -- Attribute for Synplicity Synthesizer 85 attribute syn_ramstyle : ;
86 attribute syn_ramstyle of mem : variable is XST_BRAM_STYLE_C;
88 attribute syn_keep : ;
89 attribute syn_keep of mem : variable is "TRUE";
91 -- Attribute for Altera Synthesizer 92 attribute ramstyle : ;
93 attribute ramstyle of mem : variable is ALTERA_BRAM_STYLE_C;
105 report "Invalid ALTERA_RAM_G string" 113 if rising_edge(clka) then 115 for i in NUM_BYTES_C-1 downto 0 loop 116 if (weaByteInt(i) = '1') then 117 mem(conv_integer(addra))((i+1)*BYTE_WIDTH_C-1 downto i*BYTE_WIDTH_C) := 118 resize(dina(minimum(DATA_WIDTH_G-1, (i+1)*BYTE_WIDTH_C-1) downto i*BYTE_WIDTH_C), BYTE_WIDTH_C);
130 if rising_edge(clkb) then 132 doutbInt <= INIT_C after TPD_G;
134 doutBInt <= mem(conv_integer(addrb)) after TPD_G;
143 REG :
if (DOB_REG_G)
generate 146 if (rising_edge(clkb)) then 153 --------------------------------------------------------------- 154 --NOTE: rstb and enb not supported in Altera when inferring RAM 155 --------------------------------------------------------------- 160 if rising_edge(clkb) then in addrbslv( ADDR_WIDTH_G- 1 downto 0) :=( others => '0')
in rstbsl :=not ( RST_POLARITY_G)
ALTERA_RAM_Gstring := "M9K"
out doutbslv( DATA_WIDTH_G- 1 downto 0)
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
ADDR_WIDTH_Ginteger range 1 to ( 2** 24):= 4
BYTE_WR_EN_Gboolean := false
in addraslv( ADDR_WIDTH_G- 1 downto 0) :=( others => '0')
ALTERA_SYN_Gboolean := false
in weaByteslv( wordCount( DATA_WIDTH_G, BYTE_WIDTH_G)- 1 downto 0) :=( others => '0')
DOB_REG_Gboolean := false
in dinaslv( DATA_WIDTH_G- 1 downto 0) :=( others => '0')