1 ------------------------------------------------------------------------------- 2 -- File : SsiPrbsTx.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2014-04-02 5 -- Last update: 2016-10-25 6 ------------------------------------------------------------------------------- 7 -- Description: This module generates 8 -- PseudoRandom Binary Sequence (PRBS) on Virtual Channel Lane. 9 ------------------------------------------------------------------------------- 10 -- This file is part of 'SLAC Firmware Standard Library'. 11 -- It is subject to the license terms in the LICENSE.txt file found in the 12 -- top-level directory of this distribution and at: 13 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 14 -- No part of 'SLAC Firmware Standard Library', including this file, 15 -- may be copied, modified, propagated, or distributed except according to 16 -- the terms contained in the LICENSE.txt file. 17 ------------------------------------------------------------------------------- 20 use ieee.std_logic_1164.
all;
21 use ieee.std_logic_unsigned.
all;
22 use ieee.std_logic_arith.
all;
30 --! @ingroup protocols_ssi 33 -- General Configurations 36 -- FIFO Configurations 48 -- PRBS Configurations 52 -- AXI Stream Configurations 56 -- Master Port (mAxisClk) 61 -- Trigger Signal (locClk domain) 63 locRst :
in sl := '0';
70 -- Optional: Axi-Lite Register Interface (locClk domain) 95 type RegType is record 98 length : slv(31 downto 0);
100 dataCnt : slv(31 downto 0);
115 constant REG_INIT_C : RegType := ( 118 length => (others => '0'), 120 dataCnt => (others => '0'), 121 eventCnt => (others => '0'), 122 randomData => (others => '0'), 134 signal r : RegType := REG_INIT_C;
135 signal rin : RegType;
142 -- assert (PRBS_SEED_SIZE_G mod 8 = 0) report "PRBS_SEED_SIZE_G must be a multiple of 8" severity failure; 145 trig, txCtrl, txSlave)
is 146 variable v : RegType;
148 variable axilWriteResp : slv(1 downto 0);
149 variable axilReadResp : slv(1 downto 0);
151 -- Latch the current value 154 -- Reset the one shot 157 ---------------------------------------------------------------------------------------------- 158 -- Axi-Lite interface 159 ---------------------------------------------------------------------------------------------- 168 -- BIT2 reserved for busy 169 -- BIT3 reserved for overflow 192 -- BIT4 reserved for oneShot 219 -- Override axi settings if axi not enabled 220 if (v.axiEn = '0') then 227 -- Check for overflow condition or forced EOFE 229 -- Latch the overflow error bit for the data packet 233 -- Check the AXIS flow control 234 if txSlave.tReady = '1' then 235 v.txAxisMaster.tValid := '0';
236 v.txAxisMaster.tLast := '0';
237 v.txAxisMaster.tUser := (others => '0');
238 v.txAxisMaster.tKeep := (others => '1');
243 ---------------------------------------------------------------------- 245 -- Reset the busy flag 247 -- Check for a trigger 248 if (r.trig = '1') or (r.oneShot = '1') then 249 -- Latch the generator seed 250 v.randomData := r.eventCnt;
253 -- Reset the overflow flag 255 -- Latch the configuration 257 v.txAxisMaster.tId := r.tId;
258 -- Check the packet length request value 260 -- Force minimum packet length of 2 (+1) 261 v.length := toSlv(2, 32);
263 -- Force minimum packet length of 2 (+1) 264 v.length := toSlv(2, 32);
269 v.state := SEED_RAND_S;
271 ---------------------------------------------------------------------- 273 -- Check if the FIFO is ready 274 if v.txAxisMaster.tvalid = '0' then 275 -- Send the random seed word 276 v.txAxisMaster.tvalid := '1';
278 -- Generate the next random data word 279 -- for i in 0 to PRBS_SEED_SIZE_G-1 loop 280 v.randomData := lfsrShift(v.randomData, PRBS_TAPS_G, '0');
282 -- Increment the counter 283 v.eventCnt := r.eventCnt + 1;
284 -- Increment the counter 285 v.dataCnt := r.dataCnt + 1;
287 ssiSetUserSof(PRBS_SSI_CONFIG_C, v.txAxisMaster, '1');
291 ---------------------------------------------------------------------- 293 -- Check if the FIFO is ready 294 if v.txAxisMaster.tvalid = '0' then 295 -- Send the upper packetLength value 296 v.txAxisMaster.tvalid := '1';
297 v.txAxisMaster.tData(31 downto 0) := r.length;
298 -- Increment the counter 299 v.dataCnt := r.dataCnt + 1;
303 ---------------------------------------------------------------------- 305 -- Check if the FIFO is ready 306 if v.txAxisMaster.tvalid = '0' then 307 -- Send the random data word 308 v.txAxisMaster.tValid := '1';
309 -- Check if we are sending PRBS or counter data 310 if r.cntData = '0' then 316 v.txAxisMaster.tData(31 downto 0) := r.dataCnt;
318 -- Generate the next random data word 319 -- for i in 0 to PRBS_SEED_SIZE_G-1 loop 320 v.randomData := lfsrShift(v.randomData, PRBS_TAPS_G, '0');
322 -- Increment the counter 323 v.dataCnt := r.dataCnt + 1;
325 if r.dataCnt = r.length then 327 v.dataCnt := (others => '0');
329 v.txAxisMaster.tLast := '1';
331 ssiSetUserEofe(PRBS_SSI_CONFIG_C, v.txAxisMaster, r.overflow);
332 -- Reset the busy flag 338 ---------------------------------------------------------------------- 346 -- Register the variable for next clock cycle 358 if rising_edge(locClk) then 359 r <= rin after TPD_G;
365 -- General Configurations 372 -- FIFO configurations 384 -- AXI Stream Port Configurations
PRBS_INCREMENT_Gboolean := false
VALID_THOLD_Ginteger range 0 to ( 2** 24):= 1
FIFO_ADDR_WIDTH_Ginteger range 4 to 48:= 9
natural range 0 to 8 TDEST_BITS_C
out sAxisCtrlAxiStreamCtrlType
ALTERA_RAM_Gstring := "M9K"
PIPE_STAGES_Gnatural range 0 to 16:= 1
CASCADE_SIZE_Gnatural range 1 to ( 2** 24):= 1
AxiStreamMasterType :=(tValid => '0',tData =>( others => '0'),tStrb =>( others => '1'),tKeep =>( others => '1'),tLast => '0',tDest =>( others => '0'),tId =>( others => '0'),tUser =>( others => '0')) AXI_STREAM_MASTER_INIT_C
SLAVE_AXI_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
MASTER_AXI_STREAM_CONFIG_GAxiStreamConfigType := ssiAxiStreamConfig( 16, TKEEP_COMP_C)
in mAxisSlaveAxiStreamSlaveType
SLAVE_READY_EN_Gboolean := true
FIFO_FIXED_THRESH_Gboolean := true
in axilReadMasterAxiLiteReadMasterType := AXI_LITE_READ_MASTER_INIT_C
natural range 1 to 16 TDATA_BYTES_C
in tIdslv( 7 downto 0) := X"00"
USE_BUILT_IN_Gboolean := false
GEN_SYNC_FIFO_Gboolean := false
VALID_BURST_MODE_Gboolean := false
TkeepModeType TKEEP_MODE_C
MASTER_AXI_PIPE_STAGES_Gnatural range 0 to 16:= 0
FIFO_ADDR_WIDTH_Gnatural range 4 to 48:= 9
XIL_DEVICE_Gstring := "7SERIES"
out axilReadSlaveAxiLiteReadSlaveType
GEN_SYNC_FIFO_Gboolean := false
natural range 0 to 8 TID_BITS_C
PRBS_SEED_SIZE_Gnatural range 8 to 128:= 32
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
in tDestslv( 7 downto 0) := X"00"
INT_PIPE_STAGES_Gnatural range 0 to 16:= 0
array(natural range <> ) of natural NaturalArray
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
in packetLengthslv( 31 downto 0) := X"FFFFFFFF"
TUserModeType TUSER_MODE_C
in axilWriteMasterAxiLiteWriteMasterType := AXI_LITE_WRITE_MASTER_INIT_C
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
natural range 0 to 8 TUSER_BITS_C
out sAxisSlaveAxiStreamSlaveType
ALTERA_SYN_Gboolean := false
AxiLiteReadMasterType :=(araddr =>( others => '0'),arprot =>( others => '0'),arvalid => '0',rready => '1') AXI_LITE_READ_MASTER_INIT_C
VALID_BURST_MODE_Gboolean := false
out mAxisMasterAxiStreamMasterType
AxiLiteWriteMasterType :=(awaddr =>( others => '0'),awprot =>( others => '0'),awvalid => '0',wdata =>( others => '0'),wstrb =>( others => '1'),wvalid => '0',bready => '1') AXI_LITE_WRITE_MASTER_INIT_C
in sAxisMasterAxiStreamMasterType
ALTERA_RAM_Gstring := "M9K"
ALTERA_SYN_Gboolean := false
out mAxisMasterAxiStreamMasterType
slv( 1 downto 0) := "00" AXI_RESP_OK_C
PRBS_TAPS_GNaturalArray :=( 0=> 31, 1=> 6, 2=> 2, 3=> 1)
in mAxisSlaveAxiStreamSlaveType
CASCADE_SIZE_Ginteger range 1 to ( 2** 24):= 1
USE_BUILT_IN_Gboolean := false
XIL_DEVICE_Gstring := "7SERIES"
FIFO_PAUSE_THRESH_Ginteger range 1 to ( 2** 24):= 1
VALID_THOLD_Ginteger range 0 to ( 2** 24):= 1
out axilWriteSlaveAxiLiteWriteSlaveType
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C
MASTER_AXI_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
CASCADE_PAUSE_SEL_Ginteger range 0 to ( 2** 24):= 0
FIFO_PAUSE_THRESH_Gnatural range 1 to ( 2** 24):= 2** 8