1 ------------------------------------------------------------------------------- 2 -- File : EthMacRxImportXgmii.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2008-02-11 5 -- Last update: 2016-09-14 6 ------------------------------------------------------------------------------- 7 -- Description: 10GbE Import MAC core with GMII interface 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 ------------------------------------------------------------------------------- 19 use ieee.std_logic_1164.
all;
20 use ieee.std_logic_arith.
all;
21 use ieee.std_logic_unsigned.
all;
28 --! @ingroup ethernet_EthMacCore 41 -- Configuration and status 45 end EthMacRxImportXgmii;
60 signal frameShift0 : sl;
61 signal frameShift1 : sl;
62 signal frameShift2 : sl;
63 signal frameShift3 : sl;
64 signal frameShift4 : sl;
65 signal frameShift5 : sl;
67 signal dlyRxd : slv(31 downto 0);
68 signal crcDataWidth : slv(2 downto 0);
69 signal nxtCrcWidth : slv(2 downto 0);
70 signal nxtCrcValid : sl;
71 signal crcDataValid : sl;
72 signal crcFifoIn : slv(63 downto 0);
73 signal crcFifoOut : slv(63 downto 0);
74 signal phyRxcDly : slv(7 downto 0);
75 signal crcWidthDly0 : slv(2 downto 0);
76 signal crcWidthDly1 : slv(2 downto 0);
77 signal crcWidthDly2 : slv(2 downto 0);
78 signal crcWidthDly3 : slv(2 downto 0);
79 signal crcShift0 : sl;
80 signal crcShift1 : sl;
81 signal endDetect : sl;
82 signal endShift0 : sl;
83 signal endShift1 : sl;
85 signal intLastLine : sl;
86 signal intFirstLine : sl;
87 signal intAdvance : sl;
89 signal crcIn : slv(63 downto 0);
92 signal crcOut : slv(31 downto 0);
93 signal macData : slv(63 downto 0);
94 signal macSize : slv(2 downto 0);
97 attribute dont_touch : ;
99 attribute dont_touch of frameShift0 : signal is "true";
100 attribute dont_touch of frameShift1 : signal is "true";
101 attribute dont_touch of frameShift2 : signal is "true";
102 attribute dont_touch of frameShift3 : signal is "true";
103 attribute dont_touch of frameShift4 : signal is "true";
104 attribute dont_touch of frameShift5 : signal is "true";
105 attribute dont_touch of rxdAlign : signal is "true";
106 attribute dont_touch of dlyRxd : signal is "true";
107 attribute dont_touch of crcDataWidth : signal is "true";
108 attribute dont_touch of nxtCrcWidth : signal is "true";
109 attribute dont_touch of nxtCrcValid : signal is "true";
110 attribute dont_touch of crcDataValid : signal is "true";
111 attribute dont_touch of crcFifoIn : signal is "true";
112 attribute dont_touch of crcFifoOut : signal is "true";
113 attribute dont_touch of phyRxcDly : signal is "true";
114 attribute dont_touch of crcWidthDly0 : signal is "true";
115 attribute dont_touch of crcWidthDly1 : signal is "true";
116 attribute dont_touch of crcWidthDly2 : signal is "true";
117 attribute dont_touch of crcWidthDly3 : signal is "true";
118 attribute dont_touch of crcShift0 : signal is "true";
119 attribute dont_touch of crcShift1 : signal is "true";
120 attribute dont_touch of endDetect : signal is "true";
121 attribute dont_touch of endShift0 : signal is "true";
122 attribute dont_touch of endShift1 : signal is "true";
123 attribute dont_touch of crcGood : signal is "true";
124 attribute dont_touch of intLastLine : signal is "true";
125 attribute dont_touch of intFirstLine : signal is "true";
126 attribute dont_touch of intAdvance : signal is "true";
127 attribute dont_touch of lastSOF : signal is "true";
128 attribute dont_touch of crcIn : signal is "true";
129 attribute dont_touch of crcInit : signal is "true";
130 attribute dont_touch of crcReset : signal is "true";
131 attribute dont_touch of crcOut : signal is "true";
132 attribute dont_touch of macData : signal is "true";
133 attribute dont_touch of macSize : signal is "true";
139 -- General Configurations 144 -- FIFO configurations 150 -- AXI Stream Port Configurations 157 sAxisMaster => macMaster,
-- 64-bit AXI stream interface 165 -- Convert to AXI stream 169 if rising_edge(ethClk) then 174 varMaster.tData(63 downto 0) := macData;
175 varMaster.tLast := intLastLine;
176 varMaster.tValid := intAdvance;
179 varMaster.tKeep(7 downto 0) := (others => '0');
180 varMaster.tKeep(conv_integer(macSize) downto 0) := (others => '1');
182 if intFirstLine = '1' then 183 axiStreamSetUserBit(AXI_CONFIG_C, varMaster, EMAC_SOF_BIT_C, '1', 0);
186 if intLastLine = '1' then 187 axiStreamSetUserBit(AXI_CONFIG_C, varMaster, EMAC_EOFE_BIT_C, not crcGood);
193 macMaster <= varMaster;
197 -- Errors and counter 198 rxCrcError <= intAdvance and intLastLine and (not crcGood);
199 rxCountEn <= intAdvance and intLastLine and crcGood;
201 -- Logic to dermine CRC width and valid clear timing. 202 process (crcDataValid, crcDataWidth,
phyRxc, phyRxcDly, rxdAlign)
206 if rxdAlign = '0' then 208 when x"00" => nxtCrcWidth <= "111";
nxtCrcValid <= '1';
209 when x"FE" => nxtCrcWidth <= "000";
nxtCrcValid <= '1';
210 when x"FC" => nxtCrcWidth <= "001";
nxtCrcValid <= '1';
211 when x"F8" => nxtCrcWidth <= "010";
nxtCrcValid <= '1';
212 when x"F0" => nxtCrcWidth <= "011";
nxtCrcValid <= '1';
213 when x"E0" => nxtCrcWidth <= "100";
nxtCrcValid <= '1';
214 when x"C0" => nxtCrcWidth <= "101";
nxtCrcValid <= '1';
215 when x"80" => nxtCrcWidth <= "110";
nxtCrcValid <= '1';
216 when x"FF" => nxtCrcWidth <= "000";
nxtCrcValid <= '0';
217 when others => nxtCrcWidth <= "000";
nxtCrcValid <= '0';
223 -- Some widths look at the shifted control output 225 when x"E0" => nxtCrcWidth <= "000";
nxtCrcValid <= '1';
226 when x"C0" => nxtCrcWidth <= "001";
nxtCrcValid <= '1';
227 when x"80" => nxtCrcWidth <= "010";
nxtCrcValid <= '1';
228 when x"F0" => nxtCrcWidth <= "000";
nxtCrcValid <= '0';
229 when x"FF" => nxtCrcWidth <= "000";
nxtCrcValid <= '0';
232 -- other widths look at the direct control output 234 when x"FF" => nxtCrcWidth <= "011";
nxtCrcValid <= '1';
235 when x"FE" => nxtCrcWidth <= "100";
nxtCrcValid <= '1';
236 when x"FC" => nxtCrcWidth <= "101";
nxtCrcValid <= '1';
237 when x"F8" => nxtCrcWidth <= "110";
nxtCrcValid <= '1';
238 when others => nxtCrcWidth <= crcDataWidth;
nxtCrcValid <= crcDataValid;
240 when others => nxtCrcWidth <= "000";
nxtCrcValid <= '0';
246 -- Delay stages and input to CRC block 249 if rising_edge(ethClk) then 251 frameShift0 <= '0' after TPD_G;
252 frameShift1 <= '0' after TPD_G;
253 frameShift2 <= '0' after TPD_G;
254 frameShift3 <= '0' after TPD_G;
255 frameShift4 <= '0' after TPD_G;
256 frameShift5 <= '0' after TPD_G;
257 rxdAlign <= '0' after TPD_G;
258 lastSOF <= '0' after TPD_G;
259 dlyRxd <= (others => '0') after TPD_G;
260 crcDataValid <= '0' after TPD_G;
261 crcDataWidth <= "000" after TPD_G;
262 endDetect <= '0' after TPD_G;
263 crcFifoIn <= (others => '0') after TPD_G;
264 phyRxcDly <= (others => '0') after TPD_G;
267 -- Delayed copy of control signals 270 -- Detect SOF in shifted position 271 if phyRxC(4) = '1' and phyRxd(39 downto 32) = x"FB" then 272 lastSOF <= '1' after TPD_G;
274 lastSOF <= '0' after TPD_G;
277 -- Detect start of frame 279 if phyRxC(0) = '1' and phyRxd(7 downto 0) = x"FB" and phyReady = '1' then 280 frameShift0 <= '1' after TPD_G;
281 rxdAlign <= '0' after TPD_G;
284 elsif lastSOF = '1' and phyReady = '1' then 285 frameShift0 <= '1' after TPD_G;
286 rxdAlign <= '1' after TPD_G;
288 -- Detect end of frame 289 elsif phyRxc /= 0 and frameShift0 = '1' then 290 frameShift0 <= '0' after TPD_G;
293 -- Frame shift register 294 frameShift1 <= frameShift0 after TPD_G;
295 frameShift2 <= frameShift1 after TPD_G;
296 frameShift3 <= frameShift2 after TPD_G;
297 frameShift4 <= frameShift3 after TPD_G;
298 frameShift5 <= frameShift4 after TPD_G;
300 -- Delayed copy of upper data 304 if frameShift0 = '1' and frameShift1 = '0' then 305 crcDataValid <= '1' after TPD_G;
306 crcDataWidth <= "111" after TPD_G;
309 -- Clear valid when width is not zero 310 if crcDataWidth /= 7 then 311 crcDataValid <= '0' after TPD_G;
312 crcDataWidth <= (others => '0') after TPD_G;
314 crcDataValid <= nxtCrcValid after TPD_G;
315 crcDataWidth <= nxtCrcWidth after TPD_G;
320 if (crcDataWidth /= 7 or nxtCrcValid = '0') and crcDataValid = '1' then 321 endDetect <= '1' after TPD_G;
323 endDetect <= '0' after TPD_G;
326 -- CRC & FIFO Input data 327 if rxdAlign = '0' then 330 crcFifoIn(63 downto 32) <= phyRxd(31 downto 0) after TPD_G;
331 crcFifoIn(31 downto 0) <= dlyRxd after TPD_G;
339 crcInit <= frameShift0 and (not frameShift1);
342 U_CrcFifo :
entity work.
Fifo 362 wr_en => crcDataValid,
381 -- Delay stages for output of CRC delay chain 384 if rising_edge(ethClk) then 386 macSize <= (others => '0') after TPD_G;
387 macData <= (others => '0') after TPD_G;
388 crcShift0 <= '0' after TPD_G;
389 crcShift1 <= '0' after TPD_G;
390 endShift0 <= '0' after TPD_G;
391 endShift1 <= '0' after TPD_G;
392 crcWidthDly0 <= (others => '0') after TPD_G;
393 crcWidthDly1 <= (others => '0') after TPD_G;
394 crcWidthDly2 <= (others => '0') after TPD_G;
395 crcWidthDly3 <= (others => '0') after TPD_G;
396 intLastLine <= '0' after TPD_G;
397 intFirstLine <= '0' after TPD_G;
398 intAdvance <= '0' after TPD_G;
399 crcGood <= '0' after TPD_G;
402 -- Detect good CRC, only on FIFO reads 403 if crcShift1 = '1' then 404 if crcOut = X"1cdf4421" then 405 crcGood <= '1' after TPD_G;
407 crcGood <= '0' after TPD_G;
411 -- CRC output shift stages 412 crcShift0 <= crcDataValid after TPD_G;
413 crcShift1 <= crcShift0 after TPD_G;
415 -- CRC Width Delay Stages 416 crcWidthDly0 <= crcDataWidth after TPD_G;
417 crcWidthDly1 <= crcWidthDly0 after TPD_G;
418 crcWidthDly2 <= crcWidthDly1 after TPD_G;
419 crcWidthDly3 <= crcWidthDly2 after TPD_G;
422 endShift0 <= endDetect after TPD_G;
423 endShift1 <= endShift0 after TPD_G;
426 macData <= crcFifoOut after TPD_G;
428 -- Determine when data is output 429 if frameShift4 = '1' and frameShift5 = '0' then 430 intAdvance <= '1' after TPD_G;
431 intFirstLine <= '1' after TPD_G;
432 elsif intLastLine = '1' then 433 intAdvance <= '0' after TPD_G;
434 intFirstLine <= '0' after TPD_G;
436 intFirstLine <= '0' after TPD_G;
439 -- Determine Last Line 440 if endShift0 = '1' and crcWidthDly1 = 0 then 441 macSize <= "100" after TPD_G;
442 intLastLine <= '1' after TPD_G;
443 elsif endShift0 = '1' and crcWidthDly1 = 1 then 444 macSize <= "101" after TPD_G;
445 intLastLine <= '1' after TPD_G;
446 elsif endShift0 = '1' and crcWidthDly1 = 2 then 447 macSize <= "110" after TPD_G;
448 intLastLine <= '1' after TPD_G;
449 elsif endShift0 = '1' and crcWidthDly1 = 3 then 450 macSize <= "111" after TPD_G;
451 intLastLine <= '1' after TPD_G;
452 elsif endShift1 = '1' and crcWidthDly2 = 4 then 453 macSize <= "000" after TPD_G;
454 intLastLine <= '1' after TPD_G;
455 elsif endShift1 = '1' and crcWidthDly2 = 5 then 456 macSize <= "001" after TPD_G;
457 intLastLine <= '1' after TPD_G;
458 elsif endShift1 = '1' and crcWidthDly2 = 6 then 459 macSize <= "010" after TPD_G;
460 intLastLine <= '1' after TPD_G;
461 elsif endShift1 = '1' and crcWidthDly2 = 7 then 462 macSize <= "011" after TPD_G;
463 intLastLine <= '1' after TPD_G;
465 macSize <= "111" after TPD_G;
466 intLastLine <= '0' after TPD_G;
473 ------------------------------------------ 475 ------------------------------------------ 479 crcIn(63 downto 56) <= crcFifoIn(7 downto 0);
480 crcIn(55 downto 48) <= crcFifoIn(15 downto 8);
481 crcIn(47 downto 40) <= crcFifoIn(23 downto 16);
482 crcIn(39 downto 32) <= crcFifoIn(31 downto 24);
483 crcIn(31 downto 24) <= crcFifoIn(39 downto 32);
484 crcIn(23 downto 16) <= crcFifoIn(47 downto 40);
485 crcIn(15 downto 8) <= crcFifoIn(55 downto 48);
486 crcIn(7 downto 0) <= crcFifoIn(63 downto 56);
SYNC_STAGES_Ginteger range 3 to ( 2** 24):= 3
in dinslv( DATA_WIDTH_G- 1 downto 0)
out macIbMasterAxiStreamMasterType
FIFO_ADDR_WIDTH_Ginteger range 4 to 48:= 9
out wr_data_countslv( ADDR_WIDTH_G- 1 downto 0)
natural range 0 to 8 TDEST_BITS_C
XIL_DEVICE_Gstring := "7SERIES"
EMPTY_THRES_Ginteger range 1 to ( 2** 24):= 1
PIPE_STAGES_Gnatural range 0 to 16:= 1
out crcOutslv( 31 downto 0)
FWFT_EN_Gboolean := false
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
in crcDataWidthslv( 2 downto 0)
FULL_THRES_Ginteger range 1 to ( 2** 24):= 1
in phyRxdslv( 63 downto 0)
SLAVE_READY_EN_Gboolean := true
RST_ASYNC_Gboolean := false
natural range 1 to 16 TDATA_BYTES_C
USE_DSP48_Gstring := "no"
GEN_SYNC_FIFO_Gboolean := false
TkeepModeType TKEEP_MODE_C
natural range 0 to 8 TID_BITS_C
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
integer := 0 EMAC_EOFE_BIT_C
integer := 1 EMAC_SOF_BIT_C
in phyRxcslv( 7 downto 0)
TUserModeType TUSER_MODE_C
natural range 0 to 8 TUSER_BITS_C
GEN_SYNC_FIFO_Gboolean := false
out sAxisSlaveAxiStreamSlaveType
out doutslv( DATA_WIDTH_G- 1 downto 0)
in rstsl :=not RST_POLARITY_G
in sAxisMasterAxiStreamMasterType
ADDR_WIDTH_Ginteger range 4 to 48:= 4
out mAxisMasterAxiStreamMasterType
in crcInslv(( BYTE_WIDTH_G* 8- 1) downto 0)
USE_BUILT_IN_Gboolean := false
AxiStreamSlaveType :=(tReady => '1') AXI_STREAM_SLAVE_FORCE_C
in mAxisSlaveAxiStreamSlaveType
CASCADE_SIZE_Ginteger range 1 to ( 2** 24):= 1
USE_BUILT_IN_Gboolean := false
VALID_THOLD_Ginteger range 0 to ( 2** 24):= 1
out rd_data_countslv( ADDR_WIDTH_G- 1 downto 0)
MASTER_AXI_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
AxiStreamConfigType :=(TSTRB_EN_C => false,TDATA_BYTES_C => 16,TDEST_BITS_C => 8,TID_BITS_C => 0,TKEEP_MODE_C => TKEEP_COMP_C,TUSER_BITS_C => 4,TUSER_MODE_C => TUSER_FIRST_LAST_C) EMAC_AXIS_CONFIG_C