1 ------------------------------------------------------------------------------- 2 -- File : SspDeframer.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2014-07-14 5 -- Last update: 2017-05-01 6 ------------------------------------------------------------------------------- 7 -- Description: SimpleStreamingProtocol - A simple protocol layer for inserting 8 -- idle and framing control characters into a raw data stream. The input of 9 -- module should be attached to an 8b10b decoder. 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 ------------------------------------------------------------------------------- 21 use ieee.std_logic_1164.
all;
22 use IEEE.STD_LOGIC_UNSIGNED.
all;
23 use IEEE.STD_LOGIC_ARITH.
all;
28 --! @ingroup protocols_ssp 57 end entity SspDeframer;
61 constant WAIT_SOF_S : sl := '0';
62 constant WAIT_EOF_S : sl := '1';
64 type RegType is record 83 constant REG_INIT_C : RegType := ( 85 iDataOut => (others => '0'), 96 signal r : RegType := REG_INIT_C;
102 variable v : RegType;
106 -- v.iDataOut := dataIn; 107 -- v.iValidOut := '0'; 111 if (r.state = WAIT_SOF_S) then 130 v.state := WAIT_EOF_S;
140 elsif (r.state = WAIT_EOF_S) then 142 -- Expect data to come 143 -- Will be overridden if IDLE char seen 147 -- sof is asserted without valid in previous state 148 -- Hold it until the first data arrives 149 if (r.iValidOut = '1') then 154 if (dataKin /= slvZero(K_SIZE_G)) then 159 v.state := WAIT_SOF_S;
162 -- Ignore idle codes that arrive mid frame 166 -- Unknown and/or incorrect K CODE 170 v.state := WAIT_SOF_S;
183 ---------------------------------------------------------------------------------------------- 184 -- Delay buffer to output SOF on first valid and EOF/EOFE on last valid 185 ---------------------------------------------------------------------------------------------- 187 if ((v.iValidOut = '1' or v.iEof = '1') and r.iValidOut = '1') then 188 -- If new data arrived an existing data is waiting, 189 -- Advance the pipeline and output the waiting data 210 -- Sequential process 211 seq :
process (
clk,
rst)
is 214 r <= REG_INIT_C after TPD_G;
215 elsif (rising_edge(clk)) then 216 r <= rin after TPD_G;
220 end architecture rtl;
out dataOutslv( WORD_SIZE_G- 1 downto 0)
RST_ASYNC_Gboolean := true
in rstsl := RST_POLARITY_G
in dataKInslv( K_SIZE_G- 1 downto 0)
in dataInslv( WORD_SIZE_G- 1 downto 0)