SURF  1.0
JesdRxReg.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : JesdRxReg.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-15
5 -- Last update: 2016-09-23
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite interface for register access
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 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.std_logic_unsigned.all;
21 use ieee.std_logic_arith.all;
22 
23 use work.StdRtlPkg.all;
24 use work.AxiLitePkg.all;
25 use work.Jesd204bPkg.all;
26 
27 --! @see entity
28  --! @ingroup protocols_jesd204b
29 entity JesdRxReg is
30  generic (
31  -- General Configurations
32  TPD_G : time := 1 ns;
34  AXI_ADDR_WIDTH_G : positive := 10;
35  -- JESD
36  -- Number of RX lanes (1 to 32)
37  L_G : positive range 1 to 32 := 2);
38  port (
39  -- AXI Clk
40  axiClk_i : in sl;
41  axiRst_i : in sl;
42 
43  -- Axi-Lite Register Interface (locClk domain)
48 
49  -- JESD devClk
50  devClk_i : in sl;
51  devRst_i : in sl;
52 
53  -- JESD registers
54  -- Status
56  rawData_i : in slv32Array(L_G-1 downto 0);
57 
58  -- Control
59  sysrefDlyRx_o : out slv(SYSRF_DLY_WIDTH_C-1 downto 0);
60  enableRx_o : out slv(L_G-1 downto 0);
62  scrEnable_o : out sl;
63  invertData_o : out slv(L_G-1 downto 0);
64  dlyTxArr_o : out Slv4Array(L_G-1 downto 0); -- 1 to 16 clock cycles
65  alignTxArr_o : out alignTxArray(L_G-1 downto 0); -- 0001, 0010, 0100, 1000
66  thresoldLowArr_o : out Slv16Array(L_G-1 downto 0); -- Test signal threshold low
67  thresoldHighArr_o : out Slv16Array(L_G-1 downto 0); -- Test signal threshold high
68  subClass_o : out sl;
69  gtReset_o : out sl;
70  clearErr_o : out sl;
72  linkErrMask_o : out slv(5 downto 0);
73  rxPolarity : out slv(L_G-1 downto 0));
74 end JesdRxReg;
75 
76 architecture rtl of JesdRxReg is
77 
78  type RegType is record
79  -- JESD Control (RW)
80  enableRx : slv(L_G-1 downto 0);
81  invertData : slv(L_G-1 downto 0);
82  commonCtrl : slv(5 downto 0);
83  linkErrMask : slv(5 downto 0);
84  sysrefDlyRx : slv(SYSRF_DLY_WIDTH_C-1 downto 0);
85  testTXItf : Slv16Array(L_G-1 downto 0);
86  testSigThr : Slv32Array(L_G-1 downto 0);
87  rxPolarity : slv(L_G-1 downto 0);
88 
89 
90  -- AXI lite
93  end record;
94 
95  constant REG_INIT_C : RegType := (
96  enableRx => (others => '0'),
97  invertData => (others => '0'),
98  commonCtrl => "010111",
99  linkErrMask => "111111",
100  sysrefDlyRx => (others => '0'),
101  testTXItf => (others => x"0000"),
102  testSigThr => (others => x"A000_5000"),
103  rxPolarity => (others => '0'),
104 
105 
108 
109  signal r : RegType := REG_INIT_C;
110  signal rin : RegType;
111 
112  -- Integer address
113  signal s_RdAddr : natural := 0;
114  signal s_WrAddr : natural := 0;
115 
116  -- Synced status signals
117  signal s_statusRxArr : rxStatuRegisterArray(L_G-1 downto 0);
118  signal s_rawData : slv32Array(L_G-1 downto 0);
119  signal s_statusCnt : SlVectorArray(L_G-1 downto 0, 31 downto 0);
120  signal s_adcValids : slv(L_G-1 downto 0);
121 
122 
123 begin
124 
125  ----------------------------------------------------------------------------------------------
126  -- Data Valid Status Counter
127  ----------------------------------------------------------------------------------------------
128  GEN_LANES : for I in L_G-1 downto 0 generate
129  s_adcValids(I) <= statusRxArr_i(I)(1);
130  end generate GEN_LANES;
131 
132 
133  U_SyncStatusVector : entity work.SyncStatusVector
134  generic map (
135  TPD_G => TPD_G,
136  OUT_POLARITY_G => '1',
137  CNT_RST_EDGE_G => true,
138  CNT_WIDTH_G => 32,
139  WIDTH_G => L_G)
140  port map (
141  -- Input Status bit Signals (wrClk domain)
142  statusIn => s_adcValids,
143  -- Output Status bit Signals (rdClk domain)
144  statusOut => open,
145  -- Status Bit Counters Signals (rdClk domain)
146  cntRstIn => r.commonCtrl(3),
147  cntOut => s_statusCnt,
148  -- Clocks and Reset Ports
149  wrClk => devClk_i,
150  rdClk => axiClk_i);
151 
152  -- Convert address to integer (lower two bits of address are always '0')
153  s_RdAddr <= slvToInt(axilReadMaster.araddr(AXI_ADDR_WIDTH_G-1 downto 2));
154  s_WrAddr <= slvToInt(axilWriteMaster.awaddr(AXI_ADDR_WIDTH_G-1 downto 2));
155 
156  comb : process (axiRst_i, axilReadMaster, axilWriteMaster, r, s_RdAddr,
157  s_WrAddr, s_statusRxArr, s_statusCnt, s_rawData) is
158  variable v : RegType;
159  variable axilStatus : AxiLiteStatusType;
160  variable axilWriteResp : slv(1 downto 0);
161  variable axilReadResp : slv(1 downto 0);
162  begin
163  -- Latch the current value
164  v := r;
165 
166  ----------------------------------------------------------------------------------------------
167  -- Axi-Lite interface
168  ----------------------------------------------------------------------------------------------
169  axiSlaveWaitTxn(axilWriteMaster, axilReadMaster, v.axilWriteSlave, v.axilReadSlave, axilStatus);
170 
171  if (axilStatus.writeEnable = '1') then
172  axilWriteResp := ite(axilWriteMaster.awaddr(1 downto 0) = "00", AXI_RESP_OK_C, AXI_ERROR_RESP_G);
173  case (s_WrAddr) is
174  when 16#00# => -- ADDR (0x00)
175  v.enableRx := axilWriteMaster.wdata(L_G-1 downto 0);
176  when 16#01# => -- ADDR (0x04)
177  v.sysrefDlyRx := axilWriteMaster.wdata(SYSRF_DLY_WIDTH_C-1 downto 0);
178  when 16#02# => -- ADDR (0x08)
179  v.rxPolarity := axilWriteMaster.wdata(L_G-1 downto 0);
180  when 16#04# => -- ADDR (0x10)
181  v.commonCtrl := axilWriteMaster.wdata(5 downto 0);
182  when 16#05# => -- ADDR (0x14)
183  v.linkErrMask := axilWriteMaster.wdata(5 downto 0);
184  when 16#06# => -- ADDR (0x18)
185  v.invertData := axilWriteMaster.wdata(L_G-1 downto 0);
186  when 16#20# to 16#2F# =>
187  for I in (L_G-1) downto 0 loop
188  if (axilWriteMaster.awaddr(5 downto 2) = I) then
189  v.testTXItf(I) := axilWriteMaster.wdata(15 downto 0);
190  end if;
191  end loop;
192  when 16#30# to 16#3F# =>
193  for I in (L_G-1) downto 0 loop
194  if (axilWriteMaster.awaddr(5 downto 2) = I) then
195  v.testSigThr(I) := axilWriteMaster.wdata(31 downto 0);
196  end if;
197  end loop;
198  when others =>
199  axilWriteResp := AXI_ERROR_RESP_G;
200  end case;
201  axiSlaveWriteResponse(v.axilWriteSlave);
202  end if;
203 
204  if (axilStatus.readEnable = '1') then
205  axilReadResp := ite(axilReadMaster.araddr(1 downto 0) = "00", AXI_RESP_OK_C, AXI_ERROR_RESP_G);
206  v.axilReadSlave.rdata := (others => '0');
207  case (s_RdAddr) is
208  when 16#00# => -- ADDR (0x0)
209  v.axilReadSlave.rdata(L_G-1 downto 0) := r.enableRx;
210  when 16#01# => -- ADDR (0x04)
211  v.axilReadSlave.rdata(SYSRF_DLY_WIDTH_C-1 downto 0) := r.sysrefDlyRx;
212  when 16#02# => -- ADDR (0x08)
213  v.axilReadSlave.rdata(L_G-1 downto 0) := r.rxPolarity;
214  when 16#04# => -- ADDR (0x10)
215  v.axilReadSlave.rdata(5 downto 0) := r.commonCtrl;
216  when 16#05# => -- ADDR (0x14)
217  v.axilReadSlave.rdata(5 downto 0) := r.linkErrMask;
218  when 16#06# => -- ADDR (0x18)
219  v.axilReadSlave.rdata(L_G-1 downto 0) := r.invertData;
220  when 16#10# to 16#1F# =>
221  for I in (L_G-1) downto 0 loop
222  if (axilReadMaster.araddr(5 downto 2) = I) then
223  v.axilReadSlave.rdata(RX_STAT_WIDTH_C-1 downto 0) := s_statusRxArr(I);
224  end if;
225  end loop;
226  when 16#20# to 16#2F# =>
227  for I in (L_G-1) downto 0 loop
228  if (axilReadMaster.araddr(5 downto 2) = I) then
229  v.axilReadSlave.rdata(15 downto 0) := r.testTXItf(I);
230  end if;
231  end loop;
232  when 16#30# to 16#3F# =>
233  for I in (L_G-1) downto 0 loop
234  if (axilReadMaster.araddr(5 downto 2) = I) then
235  v.axilReadSlave.rdata(31 downto 0) := r.testSigThr(I);
236  end if;
237  end loop;
238  when 16#40# to 16#4F# =>
239  for I in (L_G-1) downto 0 loop
240  if (axilReadMaster.araddr(5 downto 2) = I) then
241  for J in 31 downto 0 loop
242  v.axilReadSlave.rdata(J) := s_statusCnt(I, J);
243  end loop;
244  end if;
245  end loop;
246  when 16#50# to 16#5F# =>
247  for I in (L_G-1) downto 0 loop
248  if (axilReadMaster.araddr(5 downto 2) = I) then
249  v.axilReadSlave.rdata := s_rawData(I);
250  end if;
251  end loop;
252  when others =>
253  axilReadResp := AXI_ERROR_RESP_G;
254  end case;
255  axiSlaveReadResponse(v.axilReadSlave);
256  end if;
257 
258  -- Reset
259  if (axiRst_i = '1') then
260  v := REG_INIT_C;
261  end if;
262 
263  -- Register the variable for next clock cycle
264  rin <= v;
265 
266  -- Outputs
269  rxPolarity <= r.rxPolarity;
270 
271  end process comb;
272 
273  seq : process (axiClk_i) is
274  begin
275  if rising_edge(axiClk_i) then
276  r <= rin after TPD_G;
277  end if;
278  end process seq;
279 
280  -- Input assignment and synchronization
281  GEN_0 : for I in L_G-1 downto 0 generate
282  SyncFifo_IN0 : entity work.SynchronizerFifo
283  generic map (
284  TPD_G => TPD_G,
286  )
287  port map (
288  wr_clk => devClk_i,
289  din => statusRxArr_i(I),
290  rd_clk => axiClk_i,
291  dout => s_statusRxArr(I)
292  );
293 
294  SyncFifo_IN1 : entity work.SynchronizerFifo
295  generic map (
296  TPD_G => TPD_G,
297  DATA_WIDTH_G => 32
298  )
299  port map (
300  wr_clk => devClk_i,
301  din => rawData_i(I),
302  rd_clk => axiClk_i,
303  dout => s_rawData(I)
304  );
305  end generate GEN_0;
306 
307  -- Output assignment and synchronization
308  SyncFifo_OUT0 : entity work.SynchronizerFifo
309  generic map (
310  TPD_G => TPD_G,
311  PIPE_STAGES_G => 1,
313  )
314  port map (
315  wr_clk => axiClk_i,
316  din => r.sysrefDlyRx,
317  rd_clk => devClk_i,
319  );
320 
321  SyncFifo_OUT1 : entity work.SynchronizerFifo
322  generic map (
323  TPD_G => TPD_G,
324  PIPE_STAGES_G => 1,
325  DATA_WIDTH_G => L_G
326  )
327  port map (
328  wr_clk => axiClk_i,
329  din => r.enableRx,
330  rd_clk => devClk_i,
331  dout => enableRx_o
332  );
333 
334  Sync_OUT3 : entity work.Synchronizer
335  generic map (
336  TPD_G => TPD_G
337  )
338  port map (
339  clk => devClk_i,
340  rst => devRst_i,
341  dataIn => r.commonCtrl(0),
343  );
344 
345  Sync_OUT4 : entity work.Synchronizer
346  generic map (
347  TPD_G => TPD_G
348  )
349  port map (
350  clk => devClk_i,
351  rst => devRst_i,
352  dataIn => r.commonCtrl(1),
354  );
355 
356  Sync_OUT5 : entity work.Synchronizer
357  generic map (
358  TPD_G => TPD_G
359  )
360  port map (
361  clk => devClk_i,
362  rst => devRst_i,
363  dataIn => r.commonCtrl(2),
364  dataOut => gtReset_o
365  );
366 
367  Sync_OUT6 : entity work.Synchronizer
368  generic map (
369  TPD_G => TPD_G
370  )
371  port map (
372  clk => devClk_i,
373  rst => devRst_i,
374  dataIn => r.commonCtrl(3),
376  );
377 
378  Sync_OUT7 : entity work.Synchronizer
379  generic map (
380  TPD_G => TPD_G
381  )
382  port map (
383  clk => devClk_i,
384  rst => devRst_i,
385  dataIn => r.commonCtrl(4),
387  );
388 
389  Sync_OUT8 : entity work.Synchronizer
390  generic map (
391  TPD_G => TPD_G
392  )
393  port map (
394  clk => devClk_i,
395  rst => devRst_i,
396  dataIn => r.commonCtrl(5),
398  );
399 
400  Sync_OUT9 : entity work.SynchronizerVector
401  generic map (
402  TPD_G => TPD_G,
403  WIDTH_G => 6
404  )
405  port map (
406  clk => devClk_i,
407  rst => devRst_i,
408  dataIn => r.linkErrMask,
410  );
411 
412  SyncFifo_OUT9 : entity work.SynchronizerFifo
413  generic map (
414  TPD_G => TPD_G,
415  PIPE_STAGES_G => 1,
416  DATA_WIDTH_G => L_G
417  )
418  port map (
419  wr_clk => axiClk_i,
420  din => r.invertData,
421  rd_clk => devClk_i,
422  dout => invertData_o
423  );
424 
425  GEN_1 : for I in L_G-1 downto 0 generate
426  SyncFifo_OUT0 : entity work.SynchronizerFifo
427  generic map (
428  TPD_G => TPD_G,
429  PIPE_STAGES_G => 1,
430  DATA_WIDTH_G => 4
431  )
432  port map (
433  wr_clk => axiClk_i,
434  din => r.testTXItf(I) (11 downto 8),
435  rd_clk => devClk_i,
436  dout => dlyTxArr_o(I)
437  );
438 
439  SyncFifo_OUT1 : entity work.SynchronizerFifo
440  generic map (
441  TPD_G => TPD_G,
442  PIPE_STAGES_G => 1,
444  )
445  port map (
446  wr_clk => axiClk_i,
447  din => r.testTXItf(I) (GT_WORD_SIZE_C-1 downto 0),
448  rd_clk => devClk_i,
449  dout => alignTxArr_o(I)
450  );
451 
452  SyncFifo_OUT2 : entity work.SynchronizerFifo
453  generic map (
454  TPD_G => TPD_G,
455  PIPE_STAGES_G => 1,
456  DATA_WIDTH_G => 16
457  )
458  port map (
459  wr_clk => axiClk_i,
460  din => r.testSigThr(I) (31 downto 16),
461  rd_clk => devClk_i,
462  dout => thresoldHighArr_o(I)
463  );
464 
465  SyncFifo_OUT3 : entity work.SynchronizerFifo
466  generic map (
467  TPD_G => TPD_G,
468  PIPE_STAGES_G => 1,
469  DATA_WIDTH_G => 16
470  )
471  port map (
472  wr_clk => axiClk_i,
473  din => r.testSigThr(I) (15 downto 0),
474  rd_clk => devClk_i,
475  dout => thresoldLowArr_o(I)
476  );
477  end generate GEN_1;
478 ---------------------------------------------------------------------
479 end rtl;
in axiClk_isl
Definition: JesdRxReg.vhd:40
AXI_ADDR_WIDTH_Gpositive := 10
Definition: JesdRxReg.vhd:34
out alignTxArr_oalignTxArray( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:65
array(natural range <> ) of slv( 31 downto 0) Slv32Array
Definition: StdRtlPkg.vhd:379
in devClk_isl
Definition: JesdRxReg.vhd:50
out scrEnable_osl
Definition: JesdRxReg.vhd:62
out thresoldLowArr_oSlv16Array( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:66
out enableRx_oslv( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:60
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
in rstsl :=not RST_POLARITY_G
in dinslv( DATA_WIDTH_G- 1 downto 0)
TPD_Gtime := 1 ns
Definition: JesdRxReg.vhd:32
out axilWriteSlaveAxiLiteWriteSlaveType
Definition: JesdRxReg.vhd:47
slv( 31 downto 0) rdata
Definition: AxiLitePkg.vhd:89
out invertSync_osl
Definition: JesdRxReg.vhd:71
array(natural range <> ,natural range <> ) of sl SlVectorArray
Definition: StdRtlPkg.vhd:669
array(natural range <> ) of slv(( RX_STAT_WIDTH_C)- 1 downto 0) rxStatuRegisterArray
Definition: Jesd204bPkg.vhd:93
positive := 19+ 2* GT_WORD_SIZE_C RX_STAT_WIDTH_C
Definition: Jesd204bPkg.vhd:45
PIPE_STAGES_Gnatural range 0 to 16:= 0
WIDTH_Gpositive := 16
out linkErrMask_oslv( 5 downto 0)
Definition: JesdRxReg.vhd:72
in rawData_islv32Array( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:56
out clearErr_osl
Definition: JesdRxReg.vhd:70
in dataInslv( WIDTH_G- 1 downto 0)
out cntOutSlVectorArray ( WIDTH_G- 1 downto 0, CNT_WIDTH_G- 1 downto 0)
out gtReset_osl
Definition: JesdRxReg.vhd:69
slv( 31 downto 0) wdata
Definition: AxiLitePkg.vhd:117
out dataOutsl
out doutslv( DATA_WIDTH_G- 1 downto 0)
CNT_WIDTH_Gpositive := 32
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
in axilWriteMasterAxiLiteWriteMasterType := AXI_LITE_WRITE_MASTER_INIT_C
Definition: JesdRxReg.vhd:46
array(natural range <> ) of slv(( GT_WORD_SIZE_C)- 1 downto 0) alignTxArray
Definition: Jesd204bPkg.vhd:95
out subClass_osl
Definition: JesdRxReg.vhd:68
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
slv( 31 downto 0) awaddr
Definition: AxiLitePkg.vhd:113
out replEnable_osl
Definition: JesdRxReg.vhd:61
TPD_Gtime := 1 ns
positive := 4 GT_WORD_SIZE_C
Definition: Jesd204bPkg.vhd:31
out sysrefDlyRx_oslv( SYSRF_DLY_WIDTH_C- 1 downto 0)
Definition: JesdRxReg.vhd:59
out thresoldHighArr_oSlv16Array( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:67
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:95
out dataOutslv( WIDTH_G- 1 downto 0)
in axilReadMasterAxiLiteReadMasterType := AXI_LITE_READ_MASTER_INIT_C
Definition: JesdRxReg.vhd:44
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
Definition: JesdRxReg.vhd:33
out invertData_oslv( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:63
in axiRst_isl
Definition: JesdRxReg.vhd:41
array(natural range <> ) of slv( 15 downto 0) Slv16Array
Definition: StdRtlPkg.vhd:395
CNT_RST_EDGE_Gboolean := true
positive := 5 SYSRF_DLY_WIDTH_C
Definition: Jesd204bPkg.vhd:44
AxiLiteReadMasterType :=(araddr =>( others => '0'),arprot =>( others => '0'),arvalid => '0',rready => '1') AXI_LITE_READ_MASTER_INIT_C
Definition: AxiLitePkg.vhd:69
in devRst_isl
Definition: JesdRxReg.vhd:51
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
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
Definition: AxiLitePkg.vhd:125
slv( 1 downto 0) := "00" AXI_RESP_OK_C
Definition: AxiLitePkg.vhd:31
_library_ ieeeieee
Definition: JesdRxLane.vhd:51
slv( 31 downto 0) araddr
Definition: AxiLitePkg.vhd:61
in rstsl :=not RST_POLARITY_G
out dlyTxArr_oSlv4Array( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:64
out statusOutslv( WIDTH_G- 1 downto 0)
out rxPolarityslv( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:73
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:156
in statusRxArr_irxStatuRegisterArray( L_G- 1 downto 0)
Definition: JesdRxReg.vhd:55
L_Gpositive range 1 to 32:= 2
Definition: JesdRxReg.vhd:37
array(natural range <> ) of slv( 3 downto 0) Slv4Array
Definition: StdRtlPkg.vhd:407
out axilReadSlaveAxiLiteReadSlaveType
Definition: JesdRxReg.vhd:45
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
in statusInslv( WIDTH_G- 1 downto 0)