1 ------------------------------------------------------------------------------- 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2013-07-24 5 -- Last update: 2015-01-14 6 ------------------------------------------------------------------------------- 7 -- Description: Resizing FIFO module 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;
25 --! @ingroup base_fifo 29 CASCADE_SIZE_G : range 1 to (2**24) := 1;
-- number of FIFOs to cascade (if set to 1, then no FIFO cascading) 39 USE_BUILT_IN_G : := false;
-- If set to true, this module is only Xilinx compatible only!!! 53 --Write Ports (wr_clk domain) 64 --Read Ports (rd_clk domain) 65 rd_clk : in sl;
--unused if GEN_SYNC_FIFO_G = true 87 type WrRegType is record 88 count : (bitSize(WR_SIZE_C)-1 downto 0);
93 constant WR_REG_INIT_C : WrRegType := ( 94 count => (others => '0'), 95 wrData => (others => (others => '0')), 98 signal wrR, wrRin : WrRegType := WR_REG_INIT_C;
99 signal fifo_din : slv(FIFO_DATA_WIDTH_C-1 downto 0);
100 signal fifo_wr_en : sl;
109 type RdRegType is record 110 count : (bitSize(RD_SIZE_C)-1 downto 0);
111 end record RdRegType;
113 constant RD_REG_INIT_C : RdRegType := ( 114 count => (others => '0'));
118 signal rdR, rdRin : RdRegType := RD_REG_INIT_C;
119 signal fifo_dout : slv(FIFO_DATA_WIDTH_C-1 downto 0);
121 signal fifo_valid : sl;
122 signal fifo_rd_en : sl;
123 signal fifo_empty : sl;
130 report "FifoMux: Data widths must be even number multiples of each other" 134 report "FifoMux: non-FWFT mode can only be used if the read width is >= the write data width" 140 wrComb :
process (
din, wrR,
wr_en)
is 141 variable v : WrRegType;
150 if (wr_en = '1') then 151 v.wrData(to_integer(wrR.count)) := din;
152 v.count := wrR.count + 1;
153 if (wrR.count = WR_SIZE_C-1) then 154 v.count := (others => '0');
162 for i in 0 to WR_SIZE_C-1 loop 166 fifo_din(high downto low) <= wrR.wrData(i);
168 fifo_wr_en <= wrR.wrEn;
179 wrR <= WR_REG_INIT_C after TPD_G;
180 elsif (rising_edge(wr_clk)) then 182 wrR <= WR_REG_INIT_C after TPD_G;
184 wrR <= wrRin after TPD_G;
192 -- Module reset should be driven by wr_clk 193 -- Must synchronize it over to the rd_clk 194 RstSync_RdRst :
entity work.
RstSync 204 rdComb :
process (fifo_dout, fifo_empty, fifo_valid, rdR,
rd_en)
is 205 variable v : RdRegType;
206 variable rdData : RdDataArray;
213 --check for normal read 214 if (rd_en = '1' and fifo_valid = '1') then 215 v.count := rdR.count + 1;
216 if (rdR.count = RD_SIZE_C-1) then 217 v.count := (others => '0');
221 -- Separate fifo_dout into an array of RD_DATA_WIDTH_G sized vectors 222 for i in 0 to RD_SIZE_C-1 loop 226 rdData(i) := fifo_dout(high downto low);
232 fifo_rd_en <= toSl(rdR.count = (RD_SIZE_C-1));
233 dout <= rdData(to_integer(rdR.count));
245 -- If fifo is asynchronous, must use async reset on rd side. 246 rdSeq :
process (rdRst,
rd_clk)
is 249 rdR <= RD_REG_INIT_C after TPD_G;
250 elsif (rising_edge(rd_clk)) then 252 rdR <= RD_REG_INIT_C after TPD_G;
254 rdR <= rdRin after TPD_G;
304 empty => fifo_empty
);
306 end architecture rtl;
RD_DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
ALTERA_RAM_Gstring := "M9K"
out doutslv( DATA_WIDTH_G- 1 downto 0)
out doutslv( RD_DATA_WIDTH_G- 1 downto 0)
XIL_DEVICE_Gstring := "7SERIES"
RST_ASYNC_Gboolean := false
in dinslv( WR_DATA_WIDTH_G- 1 downto 0)
in dinslv( DATA_WIDTH_G- 1 downto 0)
SYNC_STAGES_Ginteger range 3 to ( 2** 24):= 3
GEN_SYNC_FIFO_Gboolean := false
PIPE_STAGES_Gnatural range 0 to 16:= 0
USE_BUILT_IN_Gboolean := false
CASCADE_SIZE_Ginteger range 1 to ( 2** 24):= 1
EMPTY_THRES_Ginteger range 1 to ( 2** 24):= 1
out wr_data_countslv( ADDR_WIDTH_G- 1 downto 0)
ALTERA_SYN_Gboolean := false
WR_DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 64
RST_ASYNC_Gboolean := false
PIPE_STAGES_Gnatural range 0 to 16:= 0
LAST_STAGE_ASYNC_Gboolean := true
ALTERA_RAM_Gstring := "M9K"
FULL_THRES_Ginteger range 1 to ( 2** 24):= 1
ALTERA_SYN_Gboolean := false
SYNC_STAGES_Ginteger range 3 to ( 2** 24):= 3
XIL_DEVICE_Gstring := "7SERIES"
ADDR_WIDTH_Ginteger range 4 to 48:= 10
GEN_SYNC_FIFO_Gboolean := false
USE_DSP48_Gstring := "no"
LAST_STAGE_ASYNC_Gboolean := true
ADDR_WIDTH_Ginteger range 4 to 48:= 4
FULL_THRES_Ginteger range 1 to ( 2** 24):= 1
LITTLE_ENDIAN_Gboolean := false
USE_DSP48_Gstring := "no"
USE_BUILT_IN_Gboolean := false
FWFT_EN_Gboolean := false
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
out rd_data_countslv( ADDR_WIDTH_G- 1 downto 0)
CASCADE_SIZE_Ginteger range 1 to ( 2** 24):= 1
out wr_data_countslv( ADDR_WIDTH_G- 1 downto 0)
EMPTY_THRES_Ginteger range 1 to ( 2** 24):= 1
out rd_data_countslv( ADDR_WIDTH_G- 1 downto 0)