SURF  1.0
JesdTxTest.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : JesdTxTest.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-14
5 -- Last update: 2015-04-24
6 -------------------------------------------------------------------------------
7 -- Description: JesdTx simple module for testing RX
8 -- Transmitter module for testing JESD RX module.
9 -- - it replaces GT core and generates a dummy data stream for JESD Rx testing.
10 -------------------------------------------------------------------------------
11 -- This file is part of 'SLAC Firmware Standard Library'.
12 -- It is subject to the license terms in the LICENSE.txt file found in the
13 -- top-level directory of this distribution and at:
14 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
15 -- No part of 'SLAC Firmware Standard Library', including this file,
16 -- may be copied, modified, propagated, or distributed except according to
17 -- the terms contained in the LICENSE.txt file.
18 -------------------------------------------------------------------------------
19 
20 library ieee;
21 use ieee.std_logic_1164.all;
22 use ieee.std_logic_arith.all;
23 use ieee.std_logic_unsigned.all;
24 
25 use work.StdRtlPkg.all;
26 use work.Jesd204bPkg.all;
27 
28 --! @see entity
29  --! @ingroup protocols_jesd204b
30 entity JesdTxTest is
31  generic (
32  TPD_G : time := 1 ns
33  );
34  port (
35 
36  -- JESD
37  -- Clocks and Resets
38  devClk_i : in sl;
39  devRst_i : in sl;
40 
41  -- JESD subclass selection: '0' or '1'(default)
42  subClass_i : in sl;
43 
44  -- Control and status register records
45  enable_i : in sl;
46 
47  -- Local multi frame clock
48  lmfc_i : in sl;
49 
50  -- Synchronization request input
51  nSync_i : in sl;
52 
53  -- Lane delay inputs
54  delay_i : in slv(3 downto 0); -- 1 to 16 clock cycles
55  align_i : in slv(GT_WORD_SIZE_C-1 downto 0); -- 0001, 0010, 0100, 1000
56 
58 
59  -- Data and character output and GT signals (simple generated)
61 
62  );
63 end JesdTxTest;
64 
65 
66 architecture rtl of JesdTxTest is
67 
68  -- Register type
69  type RegType is record
70  dataD1 : slv(r_jesdGtRx.data'range);
71  dataKD1 : slv(r_jesdGtRx.dataK'range);
72  end record RegType;
73 
74  constant REG_INIT_C : RegType := (
75  dataD1 => (others => '0'),
76  dataKD1 => (others => '0')
77  );
78 
79  signal r : RegType := REG_INIT_C;
80  signal rin : RegType;
81 
82  -- Internal signals
83 
84  -- Control signals from FSM
85  signal s_testCntr : slv(7 downto 0);
86  signal s_dataValid : sl;
87  signal s_align : sl;
88  signal s_lmfc_dly : sl;
89  signal s_nsync_dly : sl;
90  signal s_dataK : slv(r_jesdGtRx.dataK'range);
91  signal s_data : slv(r_jesdGtRx.data'range);
92  signal s_data_sel : slv(1 downto 0);
93 
94 begin
95 
96  -- Delay lmfc input (for 1 to 16 c-c) to
97  lmfcDly_INST: entity work.JesdSysrefDly
98  generic map (
99  TPD_G => TPD_G,
100  DLY_WIDTH_G => 4
101  )
102  port map (
103  clk => devClk_i,
104  rst => devRst_i,
105  dly_i => delay_i,
106  sysref_i => lmfc_i,
107  sysref_o => s_lmfc_dly
108  );
109 
110  -- Delay nsync input (for 1 to 16 c-c) to
111  nsyncDly_INST: entity work.JesdSysrefDly
112  generic map (
113  TPD_G => TPD_G,
114  DLY_WIDTH_G => 4
115  )
116  port map (
117  clk => devClk_i,
118  rst => devRst_i,
119  dly_i => delay_i,
120  sysref_i => nSync_i,
121  sysref_o => s_nsync_dly
122  );
123 
124  -- Synchronization FSM
125  syncFSM_INST : entity work.JesdSyncFsmTxTest
126  generic map (
127  TPD_G => TPD_G)
128  port map (
129  clk => devClk_i,
130  rst => devRst_i,
131  enable_i => enable_i,
132  lmfc_i => s_lmfc_dly,
133  nSync_i => s_nsync_dly,
134  testCntr_o => s_testCntr,
135  dataValid_o => s_dataValid,
136  align_o => s_align,
138  );
139 
140  comb : process (r, devRst_i,s_dataK,s_data) is
141  variable v : RegType;
142  begin
143  v := r;
144 
145  -- Buffer data and char one clock cycle
146  v.dataKD1 := s_dataK;
147  v.dataD1 := s_data;
148 
149  if (devRst_i = '1') then
150  v := REG_INIT_C;
151  end if;
152 
153  rin <= v;
154 
155  end process comb;
156 
157  seq : process (devClk_i) is
158  begin
159  if (rising_edge(devClk_i)) then
160  r <= rin after TPD_G;
161  end if;
162  end process seq;
163 
164 
165  s_data_sel <= s_dataValid & s_align;
166 
167  --GT output generation (depending on GT_WORD_SIZE_C)
168  SIZE_4_GEN: if GT_WORD_SIZE_C = 4 generate
169  ----------------------------------------------------
170  with s_data_sel select
171  s_dataK <= "1111" when "00",
172  "0001" when "01",
173  "0000" when others;
174 
175  with s_data_sel select
176  s_data <= (K_CHAR_C & K_CHAR_C & K_CHAR_C & K_CHAR_C) when "00",
177  ( (s_testCntr+3) & (s_testCntr+2) & (s_testCntr+1) & R_CHAR_C) when "01",
178  ( (s_testCntr+3) & (s_testCntr+2) & (s_testCntr+1) & (s_testCntr)) when others;
179 
180  with align_i select
181  r_jesdGtRx.dataK <= s_dataK when "0001",
182  s_dataK(2 downto 0) & r.dataKD1(3) when "0010",
183  s_dataK(1 downto 0) & r.dataKD1(3 downto 2) when "0100",
184  s_dataK(0) & r.dataKD1(3 downto 1) when "1000",
185  s_dataK when others;
186 
187  with align_i select
188  r_jesdGtRx.data <= s_data when "0001",
189  s_data(23 downto 0) & r.dataD1(31 downto 24) when "0010",
190  s_data(15 downto 0) & r.dataD1(31 downto 16) when "0100",
191  s_data(7 downto 0) & r.dataD1(31 downto 8) when "1000",
192  s_data when others;
193 
194  r_jesdGtRx.dispErr <= "0000";
195  r_jesdGtRx.decErr <= "0000";
196  r_jesdGtRx.rstDone <= '1';
197  -----------------------------------------------
198  end generate SIZE_4_GEN;
199 
200  -- GT output generation (depending on GT_WORD_SIZE_C)
201  -- SIZE_2_GEN: if GT_WORD_SIZE_C = 2 generate
202  -- ----------------------------------------------------
203  -- s_dataK <= "11" when (s_dataValid = '0' and s_align = '0') else
204  -- "00";
205  -- s_data <= (K_CHAR_C & K_CHAR_C) when (s_dataValid = '0' and s_align = '0') else
206  -- ((s_testCntr+1) & (s_testCntr));
207 
208  -- with align_i select
209  -- r_jesdGtRx.dataK <= s_dataK when "01",
210  -- s_dataK(0) & r.dataKD1(1) when "10",
211  -- s_dataK when others;
212 
213  -- with align_i select
214  -- r_jesdGtRx.data <= s_data when "01",
215  -- s_data(7 downto 0) & r.dataD1(15 downto 8) when "10",
216  -- s_data when others;
217 
218  -- r_jesdGtRx.dispErr <= "00";
219  -- r_jesdGtRx.decErr <= "00";
220  -- r_jesdGtRx.rstDone <= '1';
221  -- -----------------------------------------------
222  -- end generate SIZE_2_GEN;
223 
224 
225  -- Output assignment
226  txDataValid_o <= s_dataValid;
227  --------------------------------------------
228 end rtl;
in subClass_isl
Definition: JesdTxTest.vhd:42
TPD_Gtime := 1 ns
std_logic sl
Definition: StdRtlPkg.vhd:28
in devClk_isl
Definition: JesdTxTest.vhd:38
slv( GT_WORD_SIZE_C- 1 downto 0) dataK
Definition: Jesd204bPkg.vhd:63
in delay_islv( 3 downto 0)
Definition: JesdTxTest.vhd:54
TPD_Gtime := 1 ns
Definition: JesdTxTest.vhd:33
in devRst_isl
Definition: JesdTxTest.vhd:39
in dly_islv( DLY_WIDTH_G- 1 downto 0)
out txDataValid_osl
Definition: JesdTxTest.vhd:57
DLY_WIDTH_Gpositive := 5
slv( 7 downto 0) := x"1C" R_CHAR_C
Definition: Jesd204bPkg.vhd:37
_library_ ieeeieee
Definition: JesdTxReg.vhd:18
in enable_isl
Definition: JesdTxTest.vhd:45
in nSync_isl
Definition: JesdTxTest.vhd:51
slv( 7 downto 0) := x"BC" K_CHAR_C
Definition: Jesd204bPkg.vhd:35
in lmfc_isl
Definition: JesdTxTest.vhd:48
slv( GT_WORD_SIZE_C- 1 downto 0) dispErr
Definition: Jesd204bPkg.vhd:64
positive := 4 GT_WORD_SIZE_C
Definition: Jesd204bPkg.vhd:31
out r_jesdGtRxjesdGtRxLaneType
Definition: JesdTxTest.vhd:62
in align_islv( GT_WORD_SIZE_C- 1 downto 0)
Definition: JesdTxTest.vhd:55
slv( GT_WORD_SIZE_C- 1 downto 0) decErr
Definition: Jesd204bPkg.vhd:65
out testCntr_oslv( 7 downto 0)
slv(( GT_WORD_SIZE_C* 8)- 1 downto 0) data
Definition: Jesd204bPkg.vhd:62
std_logic_vector slv
Definition: StdRtlPkg.vhd:29