SURF  1.0
Pgp2bRx.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Pgp2bRx.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2009-05-27
5 -- Last update: 2017-03-28
6 -------------------------------------------------------------------------------
7 -- Description:
8 -- Cell Receive interface module for the Pretty Good Protocol core.
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 -------------------------------------------------------------------------------
18 
19 LIBRARY ieee;
20 use ieee.std_logic_1164.all;
21 use ieee.std_logic_arith.all;
22 use ieee.std_logic_unsigned.all;
23 use work.StdRtlPkg.all;
24 use work.Pgp2bPkg.all;
25 use work.AxiStreamPkg.all;
26 use work.SsiPkg.all;
27 
28 --! @see entity
29  --! @ingroup protocols_pgp_pgp2b_core
30 entity Pgp2bRx is
31  generic (
32  TPD_G : time := 1 ns;
33  RX_LANE_CNT_G : integer range 1 to 2 := 1; -- Number of receive lanes, 1-2
34  PAYLOAD_CNT_TOP_G : integer := 7 -- Top bit for payload counter
35  );
36  port (
37 
38  -- System clock, reset & control
39  pgpRxClkEn : in sl := '1'; -- Master clock enable
40  pgpRxClk : in sl; -- Master clock
41  pgpRxClkRst : in sl; -- Synchronous reset input
42 
43  -- Non-VC related IO
46 
47  -- VC Output
49  remFifoStatus : out AxiStreamCtrlArray(3 downto 0);
50 
51  -- PHY interface
54  phyRxReady : in sl;
55  phyRxInit : out sl
56  );
57 end Pgp2bRx;
58 
59 -- Define architecture
60 architecture Pgp2bRx of Pgp2bRx is
61 
62  -- Local Signals
63  signal cellRxPause : sl;
64  signal cellRxSOC : sl;
65  signal cellRxSOF : sl;
66  signal cellRxEOC : sl;
67  signal cellRxEOF : sl;
68  signal cellRxEOFE : sl;
69  signal cellRxData : slv(RX_LANE_CNT_G*16-1 downto 0);
70  signal intRxLinkReady : sl;
71  signal crcRxIn : slv(RX_LANE_CNT_G*16-1 downto 0); -- Receive data for CRC
72  signal crcRxInit : sl; -- Receive CRC value init
73  signal crcRxValid : sl; -- Receive data for CRC is valid
74  signal crcRxOut : slv(31 downto 0);
75  signal crcRxOutAdjust : slv(31 downto 0);
76  signal crcRxRst : sl;
77  signal crcRxInAdjust : slv(31 downto 0);
78  signal crcRxWidthAdjust : slv(2 downto 0);
79  signal intPhyRxPolarity : slv(1 downto 0) := (others=>'0'); -- PHY receive signal polarity
80  signal intPhyRxData : slv(RX_LANE_CNT_G*16-1 downto 0); -- PHY receive data
81  signal intPhyRxDataK : slv(RX_LANE_CNT_G*2-1 downto 0); -- PHY receive data is K character
82  signal intPhyRxDispErr : slv(RX_LANE_CNT_G*2-1 downto 0); -- PHY receive data has disparity error
83  signal intPhyRxDecErr : slv(RX_LANE_CNT_G*2-1 downto 0); -- PHY receive data not in table
84  signal intRxVcValid : slv(3 downto 0);
85  signal intRxSof : sl;
86  signal intRxEof : sl;
87  signal intRxEofe : sl;
88  signal intRxData : slv((RX_LANE_CNT_G*16)-1 downto 0);
89  signal pause : slv(3 downto 0);
90  signal overflow : slv(3 downto 0);
91 
92  attribute KEEP_HIERARCHY : string;
93  attribute KEEP_HIERARCHY of
94  U_Pgp2bRxPhy,
95  U_Pgp2bRxCell,
96  Rx_CRC : label is "TRUE";
97 
98 begin
99 
100  -- Status
106 
107  -- Interface connection
108  wrap : process ( intPhyRxPolarity, phyRxLanesIn) is
109  begin
110  for i in 0 to RX_LANE_CNT_G-1 loop
112  intPhyRxData(16*i+15 downto 16*i) <= phyRxLanesIn(i).data;
113  intPhyRxDataK(2*i+1 downto 2*i) <= phyRxLanesIn(i).dataK;
114  intPhyRxDispErr(2*i+1 downto 2*i) <= phyRxLanesIn(i).dispErr;
115  intPhyRxDecErr(2*i+1 downto 2*i) <= phyRxLanesIn(i).decErr;
116  end loop;
117  end process;
118 
119 
120  -- PHY Logic
121  U_Pgp2bRxPhy: entity work.Pgp2bRxPhy
122  generic map (
123  TPD_G => TPD_G,
125  ) port map (
127  pgpRxClk => pgpRxClk,
130  pgpRxLinkDown => pgpRxOut.linkDown,
131  pgpRxLinkError => pgpRxOut.linkError,
132  pgpRxOpCodeEn => pgpRxOut.opCodeEn,
133  pgpRxOpCode => pgpRxOut.opCode,
134  pgpRemLinkReady => pgpRxOut.remLinkReady,
135  pgpRemData => pgpRxOut.remLinkData,
137  cellRxSOC => cellRxSOC,
138  cellRxSOF => cellRxSOF,
139  cellRxEOC => cellRxEOC,
140  cellRxEOF => cellRxEOF,
150  );
151 
152 
153  -- Cell Receiver
154  U_Pgp2bRxCell: entity work.Pgp2bRxCell
155  generic map (
156  TPD_G => TPD_G,
158  EN_SHORT_CELLS_G => 1,
160  ) port map (
162  pgpRxClk => pgpRxClk,
164  pgpRxFlush => pgpRxIn.flush,
166  pgpRxCellError => pgpRxOut.cellError,
168  cellRxSOC => cellRxSOC,
169  cellRxSOF => cellRxSOF,
170  cellRxEOC => cellRxEOC,
171  cellRxEOF => cellRxEOF,
179  vc0RemAlmostFull => pause(0),
180  vc0RemOverflow => overflow(0),
182  vc1RemAlmostFull => pause(1),
183  vc1RemOverflow => overflow(1),
185  vc2RemAlmostFull => pause(2),
186  vc2RemOverflow => overflow(2),
188  vc3RemAlmostFull => pause(3),
189  vc3RemOverflow => overflow(3),
190  crcRxIn => crcRxIn,
191  crcRxInit => crcRxInit,
194  );
195 
196 
197  -- Pass FIFO status
198  process ( overflow, pause ) begin
199  for i in 0 to 3 loop
200  pgpRxOut.remOverFlow(i) <= overflow(i);
202  remFifoStatus(i).pause <= pause(i);
203  end loop;
204  end process;
205 
206  -- Generate valid/vc
207  process ( pgpRxClk ) is
208  variable intMaster : AxiStreamMasterType;
209  begin
210  if rising_edge (pgpRxClk ) then
211  intMaster := AXI_STREAM_MASTER_INIT_C;
212 
213  if pgpRxClkEn = '1' then
214 
215  intMaster.tData((RX_LANE_CNT_G*16)-1 downto 0) := intRxData;
216  intMaster.tStrb(RX_LANE_CNT_G-1 downto 0) := (others=>'1');
217  intMaster.tKeep(RX_LANE_CNT_G-1 downto 0) := (others=>'1');
218 
219  intMaster.tLast := intRxEof;
220 
221  axiStreamSetUserBit(SSI_PGP2B_CONFIG_C,intMaster,SSI_EOFE_C,intRxEofe);
222  axiStreamSetUserBit(SSI_PGP2B_CONFIG_C,intMaster,SSI_SOF_C,intRxSof,0);
223 
224  pgpRxOut.frameRx <= uOr(intRxVcValid) and intRxEof and (not intRxEofe) after TPD_G;
225  pgpRxOut.frameRxErr <= uOr(intRxVcValid) and intRxEof and intRxEofe after TPD_G;
226 
227  -- Generate valid and dest values
228  case intRxVcValid is
229  when "0001" =>
230  intMaster.tValid := '1';
231  intMaster.tDest(3 downto 0) := "0000";
232  when "0010" =>
233  intMaster.tValid := '1';
234  intMaster.tDest(3 downto 0) := "0001";
235  when "0100" =>
236  intMaster.tValid := '1';
237  intMaster.tDest(3 downto 0) := "0010";
238  when "1000" =>
239  intMaster.tValid := '1';
240  intMaster.tDest(3 downto 0) := "0011";
241  when others =>
242  intMaster.tValid := '0';
243  end case;
244 
245  end if;
246 
247  if pgpRxClkRst = '1' then
248  intMaster := AXI_STREAM_MASTER_INIT_C;
249  pgpRxOut.frameRx <= '0' after TPD_G;
250  pgpRxOut.frameRxErr <= '0' after TPD_G;
251  else
252 
253  pgpRxMaster <= intMaster after TPD_G;
254 
255  end if;
256  end if;
257  end process;
258 
259 
260  -- RX CRC BLock
262  crcRxInAdjust(31 downto 24) <= crcRxIn(7 downto 0);
263  crcRxInAdjust(23 downto 16) <= crcRxIn(15 downto 8);
264  crcRxOutAdjust <= not crcRxOut;
265 
266  CRC_RX_1xLANE : if RX_LANE_CNT_G = 1 generate
267  crcRxWidthAdjust <= "001";
268  crcRxInAdjust(15 downto 0) <= (others => '0');
269  end generate CRC_RX_1xLANE;
270 
271  CRC_RX_2xLANE : if RX_LANE_CNT_G = 2 generate
272  crcRxWidthAdjust <= "011";
273  crcRxInAdjust(15 downto 8) <= crcRxIn(23 downto 16);
274  crcRxInAdjust(7 downto 0) <= crcRxIn(31 downto 24);
275  end generate CRC_RX_2xLANE;
276 
277  Rx_CRC : entity work.CRC32Rtl
278  generic map(
279  CRC_INIT => x"FFFFFFFF")
280  port map(
281  CRCOUT => crcRxOut,
282  CRCCLK => pgpRxClk,
283  CRCCLKEN => pgpRxClkEn,
286  CRCIN => crcRxInAdjust,
287  CRCRESET => crcRxRst
288  );
289 
290 end Pgp2bRx;
291 
AxiStreamConfigType := ssiAxiStreamConfig( 2, TKEEP_COMP_C) SSI_PGP2B_CONFIG_C
Definition: Pgp2bPkg.vhd:32
slv( 1 downto 0) dispErr
Definition: Pgp2bPkg.vhd:170
out pgpRxLinkErrorsl := '0'
Definition: Pgp2bRxPhy.vhd:45
out vcFrameRxEOFsl
Definition: Pgp2bRxCell.vhd:62
in CRCRESETstd_logic
Definition: CRC32Rtl.vhd:43
slv( 3 downto 0) pause
Definition: Pgp2bRx.vhd:89
slv(( RX_LANE_CNT_G* 16)- 1 downto 0) intRxData
Definition: Pgp2bRx.vhd:88
out pgpRemLinkReadysl := '0'
Definition: Pgp2bRxPhy.vhd:52
TPD_Gtime := 1 ns
Definition: Pgp2bRxPhy.vhd:30
std_logic sl
Definition: StdRtlPkg.vhd:28
integer := 1 SSI_SOF_C
Definition: SsiPkg.vhd:31
slv( 31 downto 0) crcRxInAdjust
Definition: Pgp2bRx.vhd:77
out pgpRxOpCodeEnsl
Definition: Pgp2bRxPhy.vhd:48
in cellRxSOCsl
Definition: Pgp2bRxCell.vhd:53
out vc0RemOverflowsl
Definition: Pgp2bRxCell.vhd:69
integer := 0 SSI_EOFE_C
Definition: SsiPkg.vhd:30
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
out cellRxSOFsl
Definition: Pgp2bRxPhy.vhd:58
out vcFrameRxEOFEsl
Definition: Pgp2bRxCell.vhd:63
slv( 31 downto 0) crcRxOut
Definition: Pgp2bRx.vhd:74
out vc3RemOverflowsl
Definition: Pgp2bRxCell.vhd:84
out CRCOUTstd_logic_vector( 31 downto 0)
Definition: CRC32Rtl.vhd:37
out pgpRxLinkDownsl := '0'
Definition: Pgp2bRxPhy.vhd:44
out vcFrameRxSOFsl
Definition: Pgp2bRxCell.vhd:61
slv( 15 downto 0) tStrb
in pgpRxClkRstsl
Definition: Pgp2bRxCell.vhd:40
in phyRxReadysl
Definition: Pgp2bRxPhy.vhd:70
slv( 15 downto 0) tKeep
PAYLOAD_CNT_TOP_Ginteger := 7
Definition: Pgp2bRx.vhd:35
slv( 15 downto 0) data
Definition: Pgp2bPkg.vhd:168
in CRCINstd_logic_vector( 31 downto 0)
Definition: CRC32Rtl.vhd:42
in CRCCLKENstd_logic := '1'
Definition: CRC32Rtl.vhd:39
slv( RX_LANE_CNT_G* 2- 1 downto 0) intPhyRxDecErr
Definition: Pgp2bRx.vhd:83
in phyRxLanesInPgp2bRxPhyLaneInArray( 0 to RX_LANE_CNT_G- 1)
Definition: Pgp2bRx.vhd:53
out pgpRxOutPgp2bRxOutType
Definition: Pgp2bRx.vhd:45
EN_SHORT_CELLS_Ginteger := 1
Definition: Pgp2bRxCell.vhd:32
in pgpRxClkEnsl := '1'
Definition: Pgp2bRx.vhd:39
slv( 1 downto 0) :=( others => '0') intPhyRxPolarity
Definition: Pgp2bRx.vhd:79
string KEEP_HIERARCHY
Definition: Pgp2bRx.vhd:92
out pgpRxLinkReadysl
Definition: Pgp2bRxPhy.vhd:41
out vc2RemAlmostFullsl
Definition: Pgp2bRxCell.vhd:78
TPD_Gtime := 1 ns
Definition: Pgp2bRxCell.vhd:30
RX_LANE_CNT_Ginteger range 1 to 2:= 1
Definition: Pgp2bRxPhy.vhd:32
out cellRxPausesl
Definition: Pgp2bRxPhy.vhd:56
slv( 1 downto 0) linkPolarity
Definition: Pgp2bPkg.vhd:72
PAYLOAD_CNT_TOP_Ginteger := 7
Definition: Pgp2bRxCell.vhd:34
out vc1RemAlmostFullsl
Definition: Pgp2bRxCell.vhd:73
in phyRxReadysl
Definition: Pgp2bRx.vhd:54
out cellRxEOFsl
Definition: Pgp2bRxPhy.vhd:60
slv( RX_LANE_CNT_G* 2- 1 downto 0) intPhyRxDispErr
Definition: Pgp2bRx.vhd:82
out vc2RemOverflowsl
Definition: Pgp2bRxCell.vhd:79
out pgpRxMasterAxiStreamMasterType
Definition: Pgp2bRx.vhd:48
Pgp2bRxInType
Definition: Pgp2bPkg.vhd:55
slv( 127 downto 0) tData
slv( 31 downto 0) crcRxOutAdjust
Definition: Pgp2bRx.vhd:75
out phyRxInitsl
Definition: Pgp2bRxPhy.vhd:72
slv( 3 downto 0) remOverflow
Definition: Pgp2bPkg.vhd:82
slv( 1 downto 0) dataK
Definition: Pgp2bPkg.vhd:169
in cellRxDataslv( RX_LANE_CNT_G* 16- 1 downto 0)
Definition: Pgp2bRxCell.vhd:58
out vc2FrameRxValidsl
Definition: Pgp2bRxCell.vhd:77
out vc1FrameRxValidsl
Definition: Pgp2bRxCell.vhd:72
out cellRxSOCsl
Definition: Pgp2bRxPhy.vhd:57
out vc0FrameRxValidsl
Definition: Pgp2bRxCell.vhd:67
sl polarity
Definition: Pgp2bPkg.vhd:160
out vc3FrameRxValidsl
Definition: Pgp2bRxCell.vhd:82
_library_ ieeeieee
Definition: Pgp2bPkg.vhd:19
slv( 1 downto 0) decErr
Definition: Pgp2bPkg.vhd:171
in phyRxDecErrslv( RX_LANE_CNT_G* 2- 1 downto 0)
Definition: Pgp2bRxPhy.vhd:69
out vcFrameRxDataslv( RX_LANE_CNT_G* 16- 1 downto 0)
Definition: Pgp2bRxCell.vhd:64
in pgpRxClkEnsl := '1'
Definition: Pgp2bRxPhy.vhd:36
in pgpRxClksl
Definition: Pgp2bRxCell.vhd:39
in cellRxEOFEsl
Definition: Pgp2bRxCell.vhd:57
out phyRxPolarityslv( RX_LANE_CNT_G- 1 downto 0)
Definition: Pgp2bRxPhy.vhd:65
sl frameRxErr
Definition: Pgp2bPkg.vhd:74
in pgpRxInPgp2bRxInType
Definition: Pgp2bRx.vhd:44
array(natural range <> ) of AxiStreamCtrlType AxiStreamCtrlArray
slv( RX_LANE_CNT_G* 16- 1 downto 0) cellRxData
Definition: Pgp2bRx.vhd:69
RX_LANE_CNT_Ginteger range 1 to 2:= 1
Definition: Pgp2bRx.vhd:33
out cellRxEOCsl
Definition: Pgp2bRxPhy.vhd:59
out crcRxInslv( RX_LANE_CNT_G* 16- 1 downto 0)
Definition: Pgp2bRxCell.vhd:87
array(natural range <> ) of Pgp2bRxPhyLaneOutType Pgp2bRxPhyLaneOutArray
Definition: Pgp2bPkg.vhd:163
out crcRxValidsl
Definition: Pgp2bRxCell.vhd:89
in cellRxEOCsl
Definition: Pgp2bRxCell.vhd:55
in CRCDATAVALIDstd_logic
Definition: CRC32Rtl.vhd:40
out remFifoStatusAxiStreamCtrlArray( 3 downto 0)
Definition: Pgp2bRx.vhd:49
slv( RX_LANE_CNT_G* 16- 1 downto 0) crcRxIn
Definition: Pgp2bRx.vhd:71
in pgpRxClkRstsl
Definition: Pgp2bRx.vhd:41
in pgpRxClkRstsl
Definition: Pgp2bRxPhy.vhd:38
CRC_INITbit_vector := x"FFFFFFFF"
Definition: CRC32Rtl.vhd:35
in cellRxEOFsl
Definition: Pgp2bRxCell.vhd:56
slv( 7 downto 0) tDest
out pgpRxOpCodeslv( 7 downto 0)
Definition: Pgp2bRxPhy.vhd:49
slv( 3 downto 0) remPause
Definition: Pgp2bPkg.vhd:83
in CRCDATAWIDTHstd_logic_vector( 2 downto 0)
Definition: CRC32Rtl.vhd:41
out phyRxInitsl
Definition: Pgp2bRx.vhd:56
slv( RX_LANE_CNT_G* 2- 1 downto 0) intPhyRxDataK
Definition: Pgp2bRx.vhd:81
out crcRxInitsl
Definition: Pgp2bRxCell.vhd:88
RX_LANE_CNT_Ginteger range 1 to 2:= 1
Definition: Pgp2bRxCell.vhd:31
slv( 3 downto 0) intRxVcValid
Definition: Pgp2bRx.vhd:84
in phyRxDataslv( RX_LANE_CNT_G* 16- 1 downto 0)
Definition: Pgp2bRxPhy.vhd:66
out vc3RemAlmostFullsl
Definition: Pgp2bRxCell.vhd:83
in phyRxDataKslv( RX_LANE_CNT_G* 2- 1 downto 0)
Definition: Pgp2bRxPhy.vhd:67
TPD_Gtime := 1 ns
Definition: Pgp2bRx.vhd:32
sl linkReady
Definition: Pgp2bPkg.vhd:71
slv( 2 downto 0) crcRxWidthAdjust
Definition: Pgp2bRx.vhd:78
in phyRxDispErrslv( RX_LANE_CNT_G* 2- 1 downto 0)
Definition: Pgp2bRxPhy.vhd:68
in cellRxSOFsl
Definition: Pgp2bRxCell.vhd:54
out cellRxEOFEsl
Definition: Pgp2bRxPhy.vhd:61
in pgpRxClksl
Definition: Pgp2bRx.vhd:40
sl frameRx
Definition: Pgp2bPkg.vhd:73
in cellRxPausesl
Definition: Pgp2bRxCell.vhd:52
in CRCCLKstd_logic
Definition: CRC32Rtl.vhd:38
in pgpRxClkEnsl := '1'
Definition: Pgp2bRxCell.vhd:38
array(natural range <> ) of Pgp2bRxPhyLaneInType Pgp2bRxPhyLaneInArray
Definition: Pgp2bPkg.vhd:174
in crcRxOutslv( 31 downto 0)
Definition: Pgp2bRxCell.vhd:91
out cellRxDataslv( RX_LANE_CNT_G* 16- 1 downto 0)
Definition: Pgp2bRxPhy.vhd:62
Pgp2bRxOutType
Definition: Pgp2bPkg.vhd:69
in pgpRxFlushsl
Definition: Pgp2bRxCell.vhd:43
out pgpRxCellErrorsl
Definition: Pgp2bRxCell.vhd:49
slv( RX_LANE_CNT_G* 16- 1 downto 0) intPhyRxData
Definition: Pgp2bRx.vhd:80
out vc0RemAlmostFullsl
Definition: Pgp2bRxCell.vhd:68
out phyRxLanesOutPgp2bRxPhyLaneOutArray( 0 to RX_LANE_CNT_G- 1)
Definition: Pgp2bRx.vhd:52
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
slv( 3 downto 0) overflow
Definition: Pgp2bRx.vhd:90
out vc1RemOverflowsl
Definition: Pgp2bRxCell.vhd:74
out pgpRemDataslv( 7 downto 0) :=( others => '0')
Definition: Pgp2bRxPhy.vhd:53
in pgpRxLinkReadysl
Definition: Pgp2bRxCell.vhd:46
in pgpRxClksl
Definition: Pgp2bRxPhy.vhd:37