SURF  1.0
SsiPrbsRateGen.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : SsiPrbsRateGen.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2017-04-28
5 -------------------------------------------------------------------------------
6 -- Description:
7 -------------------------------------------------------------------------------
8 -- This file is part of 'SLAC Firmware Standard Library'.
9 -- It is subject to the license terms in the LICENSE.txt file found in the
10 -- top-level directory of this distribution and at:
11 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
12 -- No part of 'SLAC Firmware Standard Library', including this file,
13 -- may be copied, modified, propagated, or distributed except according to
14 -- the terms contained in the LICENSE.txt file.
15 -------------------------------------------------------------------------------
16 
17 library ieee;
18 use ieee.std_logic_1164.all;
19 use ieee.std_logic_unsigned.all;
20 use ieee.std_logic_arith.all;
21 
22 use work.StdRtlPkg.all;
23 use work.AxiLitePkg.all;
24 use work.AxiStreamPkg.all;
25 use work.SsiPkg.all;
26 
27 --! @see entity
28  --! @ingroup protocols_ssi
29 entity SsiPrbsRateGen is
30  generic (
31  -- General Configurations
32  TPD_G : time := 1 ns;
34  -- PRBS TX FIFO Configurations
35  VALID_THOLD_G : integer range 0 to (2**24) := 1;
36  VALID_BURST_MODE_G : boolean := false;
37  BRAM_EN_G : boolean := true;
38  XIL_DEVICE_G : string := "7SERIES";
39  USE_BUILT_IN_G : boolean := false;
40  CASCADE_SIZE_G : natural range 1 to (2**24) := 1;
41  FIFO_ADDR_WIDTH_G : natural range 4 to 48 := 9;
42  -- AXI Stream Configurations
43  AXIS_CLK_FREQ_G : real := 156.25E+6; -- units of Hz
45  port (
46  -- Master Port (mAxisClk)
47  mAxisClk : in sl;
48  mAxisRst : in sl;
55 end SsiPrbsRateGen;
56 
57 architecture rtl of SsiPrbsRateGen is
58 
59  type RegType is record
62  trig : sl;
63  packetLength : slv(31 downto 0);
64  genPeriod : slv(31 downto 0);
65  genEnable : sl;
66  genOne : sl;
67  genMissed : slv(31 downto 0);
68  genCount : slv(31 downto 0);
69  frameCount : slv(31 downto 0);
70  statReset : sl;
71  end record RegType;
72 
73  constant REG_INIT_C : RegType := (
76  trig => '0',
77  packetLength => (others=>'0'),
78  genPeriod => (others=>'0'),
79  genEnable => '0',
80  genOne => '0',
81  genMissed => (others=>'0'),
82  genCount => (others=>'0'),
83  frameCount => (others=>'0'),
84  statReset => '1');
85 
86  signal r : RegType := REG_INIT_C;
87  signal rin : RegType;
88 
89  signal iAxisMaster : AxiStreamMasterType;
90  signal iAxisSlave : AxiStreamSlaveType;
91  signal frameRate : slv(31 downto 0);
92  signal frameRateMax : slv(31 downto 0);
93  signal frameRateMin : slv(31 downto 0);
94  signal bandwidth : slv(63 downto 0);
95  signal bandwidthMax : slv(63 downto 0);
96  signal bandwidthMin : slv(63 downto 0);
97  signal busy : sl;
98 
99 begin
100 
101  mAxisMaster <= iAxisMaster;
102  iAxisSlave <= mAxisSlave;
103 
104  U_PrbsTx: entity work.SsiPrbsTx
105  generic map (
106  TPD_G => TPD_G,
109  BRAM_EN_G => BRAM_EN_G,
112  GEN_SYNC_FIFO_G => true,
116  port map (
117  mAxisClk => mAxisClk,
118  mAxisRst => mAxisRst,
119  mAxisMaster => iAxisMaster,
120  mAxisSlave => iAxisSlave,
121  locClk => mAxisClk,
122  locRst => mAxisRst,
123  trig => r.trig,
124  busy => busy,
125  packetLength => r.packetLength);
126 
127  U_Monitor: entity work.AxiStreamMon
128  generic map (
129  TPD_G => TPD_G,
130  COMMON_CLK_G => true,
133  port map (
134  axisClk => mAxisClk,
135  axisRst => mAxisRst,
136  axisMaster => iAxisMaster,
137  axisSlave => iAxisSlave,
138  statusClk => mAxisClk,
139  statusRst => r.statReset,
140  frameRate => frameRate,
141  frameRateMax => frameRateMax,
142  frameRateMin => frameRateMin,
143  bandwidth => bandwidth,
144  bandwidthMax => bandwidthMax,
145  bandwidthMin => bandwidthMin);
146 
147 
148  comb : process (axilReadMaster, axilWriteMaster, r, mAxisRst, busy,
149  frameRate, frameRateMax, frameRateMin,
150  bandwidth, bandwidthMax, bandwidthMin,
151  iAxisMaster, iAxisSlave ) is
152  variable v : RegType;
153  variable axilEp : AxiLiteEndPointType;
154  begin
155 
156  -- Latch the current value
157  v := r;
158 
159  -- Clear
160  --v.statReset := '0';
161  v.trig := '0';
162  v.genOne := '0';
163 
164  -- Start transaction block
165  axiSlaveWaitTxn(axilEp, axilWriteMaster, axilReadMaster, v.axilWriteSlave, v.axilReadSlave);
166 
167  -- Map the registers
168  axiSlaveRegister(axilEp, x"000", 0, v.statReset);
169  axiSlaveRegister(axilEp, x"004", 0, v.packetLength);
170  axiSlaveRegister(axilEp, x"008", 0, v.genPeriod);
171  axiSlaveRegister(axilEp, x"00C", 0, v.genEnable);
172  axiSlaveRegister(axilEp, x"00C", 1, v.genOne);
173 
174  axiSlaveRegisterR(axilEp, x"010", 0, r.genMissed);
175  axiSlaveRegisterR(axilEp, x"014", 0, frameRate);
176  axiSlaveRegisterR(axilEp, x"018", 0, frameRateMax);
177  axiSlaveRegisterR(axilEp, x"01C", 0, frameRateMin);
178  axiSlaveRegisterR(axilEp, x"020", 0, bandwidth(31 downto 0));
179  axiSlaveRegisterR(axilEp, x"024", 0, bandwidth(63 downto 32));
180  axiSlaveRegisterR(axilEp, x"028", 0, bandwidthMax(31 downto 0));
181  axiSlaveRegisterR(axilEp, x"02C", 0, bandwidthMax(63 downto 32));
182  axiSlaveRegisterR(axilEp, x"030", 0, bandwidthMin(31 downto 0));
183  axiSlaveRegisterR(axilEp, x"034", 0, bandwidthMin(63 downto 32));
184 
185  axiSlaveRegisterR(axilEp, x"040", 0, r.frameCount);
186 
187  -- End transaction block
188  axiSlaveDefault(axilEp, v.axilWriteSlave, v.axilReadSlave, AXI_RESP_OK_C);
189 
190  -- Frame generation
191  if r.genEnable = '0' then
192  v.genCount := (others=>'0');
193  v.trig := '0';
194  else
195  v.genCount := r.genCount + 1;
196 
197  if r.genOne = '1' then
198  v.trig := '1';
199 
200  elsif r.genCount = r.genPeriod then
201  v.genCount := (others=>'0');
202  v.trig := '1';
203 
204  if busy = '1' then
205  v.trig := '0';
206  v.genMissed := r.genMissed + 1;
207  else
208  v.frameCount := r.frameCount + 1;
209  end if;
210  end if;
211  end if;
212 
213  if r.statReset = '1' then
214  v.genMissed := (others=>'0');
215  end if;
216 
217  -- Reset
218  if (mAxisRst = '1') then
219  v := REG_INIT_C;
220  end if;
221 
222  -- Register the variable for next clock cycle
223  rin <= v;
224 
225  -- Outputs
228 
229  end process comb;
230 
231  seq : process (mAxisClk) is
232  begin
233  if (rising_edge(mAxisClk)) then
234  r <= rin after TPD_G;
235  end if;
236  end process seq;
237 
238 end rtl;
VALID_THOLD_Ginteger range 0 to ( 2** 24):= 1
Definition: SsiPrbsTx.vhd:37
COMMON_CLK_Gboolean := false
in axisSlaveAxiStreamSlaveType
in mAxisRstsl
Definition: SsiPrbsTx.vhd:58
out bandwidthMaxslv( 63 downto 0)
AXIS_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
TPD_Gtime := 1 ns
VALID_THOLD_Ginteger range 0 to ( 2** 24):= 1
CASCADE_SIZE_Gnatural range 1 to ( 2** 24):= 1
Definition: SsiPrbsTx.vhd:45
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
_library_ ieeeieee
Definition: SsiPkg.vhd:18
MASTER_AXI_STREAM_CONFIG_GAxiStreamConfigType := ssiAxiStreamConfig( 16, TKEEP_COMP_C)
Definition: SsiPrbsTx.vhd:53
in mAxisSlaveAxiStreamSlaveType
Definition: SsiPrbsTx.vhd:60
AXIS_CLK_FREQ_Greal := 156.25E+6
out bandwidthMinslv( 63 downto 0)
TPD_Gtime := 1 ns
Definition: SsiPrbsTx.vhd:34
out frameRateslv( 31 downto 0)
VALID_BURST_MODE_Gboolean := false
USE_BUILT_IN_Gboolean := false
Definition: SsiPrbsTx.vhd:41
in mAxisClksl
Definition: SsiPrbsTx.vhd:57
VALID_BURST_MODE_Gboolean := false
Definition: SsiPrbsTx.vhd:38
FIFO_ADDR_WIDTH_Gnatural range 4 to 48:= 9
Definition: SsiPrbsTx.vhd:46
in locClksl
Definition: SsiPrbsTx.vhd:62
AXIS_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
GEN_SYNC_FIFO_Gboolean := false
Definition: SsiPrbsTx.vhd:42
USE_BUILT_IN_Gboolean := false
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
TPD_Gtime := 1 ns
in axilWriteMasterAxiLiteWriteMasterType
BRAM_EN_Gboolean := true
BRAM_EN_Gboolean := true
Definition: SsiPrbsTx.vhd:39
out frameRateMaxslv( 31 downto 0)
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
out busysl
Definition: SsiPrbsTx.vhd:67
in mAxisSlaveAxiStreamSlaveType
in packetLengthslv( 31 downto 0) := X"FFFFFFFF"
Definition: SsiPrbsTx.vhd:65
out axilReadSlaveAxiLiteReadSlaveType
out bandwidthslv( 63 downto 0)
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:95
AXIS_CLK_FREQ_Greal := 156.25E+6
CASCADE_SIZE_Gnatural range 1 to ( 2** 24):= 1
in trigsl := '1'
Definition: SsiPrbsTx.vhd:64
AxiStreamConfigType :=(TSTRB_EN_C => false,TDATA_BYTES_C => 16,TDEST_BITS_C => 4,TID_BITS_C => 0,TKEEP_MODE_C => TKEEP_NORMAL_C,TUSER_BITS_C => 4,TUSER_MODE_C => TUSER_NORMAL_C) AXI_STREAM_CONFIG_INIT_C
out mAxisMasterAxiStreamMasterType
Definition: SsiPrbsTx.vhd:59
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
FIFO_ADDR_WIDTH_Gnatural range 4 to 48:= 9
slv( 1 downto 0) := "00" AXI_RESP_OK_C
Definition: AxiLitePkg.vhd:31
in axisMasterAxiStreamMasterType
in locRstsl := '0'
Definition: SsiPrbsTx.vhd:63
XIL_DEVICE_Gstring := "7SERIES"
Definition: SsiPrbsTx.vhd:40
out axilWriteSlaveAxiLiteWriteSlaveType
out frameRateMinslv( 31 downto 0)
XIL_DEVICE_Gstring := "7SERIES"
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:156
in axilReadMasterAxiLiteReadMasterType
out mAxisMasterAxiStreamMasterType
std_logic_vector slv
Definition: StdRtlPkg.vhd:29