SURF  1.0
HeaderReg.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : HeaderReg.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-08-09
5 -- Last update: 2016-01-27
6 -------------------------------------------------------------------------------
7 -- Description: Combines and decodes the header values from input parameters headerValues_i
8 -- Header is selected by xxxHeadSt_i and addressed by addr_i
9 -- Outputs the addressed headerData_o and headerLength_o values with 1 Clock Cycle delay
10 -- Outputs (oth=>'0')If no header is addressed
11 -------------------------------------------------------------------------------
12 -- This file is part of 'SLAC Firmware Standard Library'.
13 -- It is subject to the license terms in the LICENSE.txt file found in the
14 -- top-level directory of this distribution and at:
15 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
16 -- No part of 'SLAC Firmware Standard Library', including this file,
17 -- may be copied, modified, propagated, or distributed except according to
18 -- the terms contained in the LICENSE.txt file.
19 -------------------------------------------------------------------------------
20 
21 library ieee;
22 use ieee.std_logic_1164.all;
23 use ieee.std_logic_unsigned.all;
24 use ieee.std_logic_arith.all;
25 
26 use work.StdRtlPkg.all;
27 use work.RssiPkg.all;
28 use ieee.math_real.all;
29 
30 --! @see entity
31  --! @ingroup protocols_rssi
32 entity HeaderReg is
33  generic (
34  TPD_G : time := 1 ns;
35 
36  SYN_HEADER_SIZE_G : natural := 24;
37  ACK_HEADER_SIZE_G : natural := 8;
38  EACK_HEADER_SIZE_G : natural := 8;
39  RST_HEADER_SIZE_G : natural := 8;
40  NULL_HEADER_SIZE_G : natural := 8;
41  DATA_HEADER_SIZE_G : natural := 8
42  );
43  port (
44  clk_i : in sl;
45  rst_i : in sl;
46 
47  -- Header control inputs (must hold values while reading header)
53  --eackHeadSt_i : in sl;
54 
55  -- Ack sequence number valid
56  ack_i : in sl;
57 
58  -- Header values
59  txSeqN_i : in slv(7 downto 0); -- Sequence number of the current packet
60  rxAckN_i : in slv(7 downto 0); -- Acknowledgment number of the recived packet handelled by receiver
61 
62  -- Negotiated or from GENERICS
64 
65  -- Out of order sequence numbers from received EACK packet
66  --eackSeqnArr_i : in Slv16Array(0 to integer(ceil(real(MAX_OUT_OF_SEQUENCE_G)/2.0))-1);
67  --eackN_i : in natural;
68 
69  addr_i : in slv(7 downto 0);
70  headerData_o : out slv( (RSSI_WORD_WIDTH_C * 8)-1 downto 0);
71  ready_o : out sl;
72  headerLength_o : out positive
73  );
74 end entity HeaderReg;
75 
76 architecture rtl of HeaderReg is
77 
78  type RegType is record
79  headerData : slv(RSSI_WORD_WIDTH_C*8-1 downto 0);
80  rdy : sl;
81 
82  -- Registered header parameters (so they don't change during the checksum calculation)
83  ack : sl;
84  txSeqN : slv(7 downto 0);
85  rxAckN : slv(7 downto 0);
86 
87  end record RegType;
88 
89  constant REG_INIT_C : RegType := (
90  headerData => (others =>'0'),
91  rdy => '0',
92 
93  ack => '0',
94  txSeqN => (others =>'0'),
95  rxAckN => (others =>'0')
96  );
97 
98  signal r : RegType := REG_INIT_C;
99  signal rin : RegType;
100 
101  signal addrInt : integer;
102 
103 begin
104 
105  -- Convert address to integer
106  addrInt <= conv_integer(addr_i);
107 
108  --
109  comb : process (r, rst_i, headerValues_i, addrInt, txSeqN_i, rxAckN_i,
111 
112  variable v : RegType;
113 
114  begin
115  v := r;
116 
117  --
118  if (synHeadSt_i = '1') then
120  case addrInt is
121  when 16#00# =>
122  v.headerData := "1" & r.ack & "000000" & toSlv(SYN_HEADER_SIZE_G, 8) &
123  txSeqN_i & r.rxAckN &
126  v.rdy := '1';
127  when 16#01# =>
128  v.headerData := headerValues_i.retransTout &
132  v.rdy := '1';
133  when 16#02# =>
135  headerValues_i.connectionId(31 downto 16) &
136  headerValues_i.connectionId(15 downto 0) &
137  x"00" & x"00"; -- Place for checksum
138  v.rdy := '1';
139  when others =>
140  v.headerData := (others=> '0');
141  v.rdy := '0';
142  end case;
143  elsif (rstHeadSt_i = '1') then
145  case addrInt is
146 
147  when 16#00# =>
148  v.headerData := "00010000" & toSlv(RST_HEADER_SIZE_G, 8) &
149  txSeqN_i & r.rxAckN &
150  x"00" & x"00" & -- Reserved
151  x"00" & x"00"; -- Place for checksum
152  v.rdy := '1';
153  when others =>
154  v.headerData := (others=> '0');
155  v.rdy := '0';
156  end case;
157  elsif (dataHeadSt_i = '1') then
159  case addrInt is
160  when 16#00# =>
161  v.headerData := "0" & r.ack & "000000" & toSlv(DATA_HEADER_SIZE_G, 8) &
162  txSeqN_i & r.rxAckN &
163  x"00" & x"00" & -- Reserved
164  x"00" & x"00"; -- Place for checksum
165  v.rdy := '1';
166  when others =>
167  v.rdy := '0';
168  v.headerData := (others=> '0');
169  end case;
170  elsif (ackHeadSt_i = '1') then
172  case addrInt is
173  when 16#00# =>
174  v.headerData := "01000000" & toSlv(DATA_HEADER_SIZE_G, 8) &
175  txSeqN_i & r.rxAckN &
176  x"00" & x"00" & -- Reserved
177  x"00" & x"00"; -- Place for checksum
178  v.rdy := '1';
179  when others =>
180  v.rdy := '0';
181  v.headerData := (others=> '0');
182  end case;
183 
184 
185  elsif (nullHeadSt_i = '1') then
187  case addrInt is
188  when 16#00# =>
189  v.headerData :="0" & r.ack & "001000" & toSlv(NULL_HEADER_SIZE_G, 8) &
190  txSeqN_i & r.rxAckN &
191  x"00" & x"00" & -- Reserved
192  x"00" & x"00"; -- Place for checksum
193  v.rdy := '1';
194  when others =>
195  v.rdy := '1';
196  v.headerData := (others=> '0');
197  end case;
198  -- elsif (eackHeadSt_i = '1') then
199  -- case addrInt is
200  -- when 16#00# =>
201  -- v.headerData := "01100000" & toSlv(EACK_HEADER_SIZE_G+r.eackN, 8);
202  -- when 16#01# =>
203  -- v.headerData := txSeqN_i & r.rxAckN;
204  -- when 16#02# to (2+MAX_OUT_OF_ORDER_G-1) =>
205  -- v.headerData := r.eackSeqnArr(addrInt-2);
206  -- when others =>
207  -- v.headerData := (others=> '0');
208  -- end case;
209  else
210  -- Register parameters when out of headers
211  v.ack := ack_i;
212  v.txSeqN := txSeqN_i;
213  v.rxAckN := rxAckN_i;
214  --
215  headerLength_o <= 1;
216  v.headerData := (others=> '0');
217  v.rdy := '0';
218  end if;
219 
220  if (rst_i = '1') then
221  v := REG_INIT_C;
222  end if;
223 
224  rin <= v;
225  -----------------------------------------------------------
226  end process comb;
227 
228  seq : process (clk_i) is
229  begin
230  if (rising_edge(clk_i)) then
231  r <= rin after TPD_G;
232  end if;
233  end process seq;
234  ---------------------------------------------------------------------
235  -- Output assignment
236  headerData_o <= r.headerData;
237  ready_o <= r.rdy;
238  ---------------------------------------------------------------------
239 end architecture rtl;
in clk_isl
Definition: HeaderReg.vhd:44
SYN_HEADER_SIZE_Gnatural := 24
Definition: HeaderReg.vhd:36
out headerData_oslv(( RSSI_WORD_WIDTH_C* 8)- 1 downto 0)
Definition: HeaderReg.vhd:70
std_logic sl
Definition: StdRtlPkg.vhd:28
slv( 3 downto 0) version
Definition: RssiPkg.vhd:53
slv( 31 downto 0) connectionId
Definition: RssiPkg.vhd:69
in headerValues_iRssiParamType
Definition: HeaderReg.vhd:63
slv( 15 downto 0) nullSegTout
Definition: RssiPkg.vhd:62
in addr_islv( 7 downto 0)
Definition: HeaderReg.vhd:69
positive := 8 RSSI_WORD_WIDTH_C
Definition: RssiPkg.vhd:32
_library_ ieeeieee
Definition: ConnFSM.vhd:21
slv( 7 downto 0) maxRetrans
Definition: RssiPkg.vhd:64
TPD_Gtime := 1 ns
Definition: HeaderReg.vhd:34
RST_HEADER_SIZE_Gnatural := 8
Definition: HeaderReg.vhd:39
in txSeqN_islv( 7 downto 0)
Definition: HeaderReg.vhd:59
slv( 7 downto 0) maxOutofseq
Definition: RssiPkg.vhd:67
in ack_isl
Definition: HeaderReg.vhd:56
slv( 15 downto 0) retransTout
Definition: RssiPkg.vhd:60
slv( 7 downto 0) maxCumAck
Definition: RssiPkg.vhd:65
in dataHeadSt_isl
Definition: HeaderReg.vhd:50
NULL_HEADER_SIZE_Gnatural := 8
Definition: HeaderReg.vhd:40
slv( 15 downto 0) cumulAckTout
Definition: RssiPkg.vhd:61
slv( 7 downto 0) maxOutsSeg
Definition: RssiPkg.vhd:57
sl ack
Definition: RssiPkg.vhd:88
slv( 15 downto 0) maxSegSize
Definition: RssiPkg.vhd:58
in rst_isl
Definition: HeaderReg.vhd:45
DATA_HEADER_SIZE_Gnatural := 8
Definition: HeaderReg.vhd:42
ACK_HEADER_SIZE_Gnatural := 8
Definition: HeaderReg.vhd:37
in rxAckN_islv( 7 downto 0)
Definition: HeaderReg.vhd:60
RssiParamType
Definition: RssiPkg.vhd:52
EACK_HEADER_SIZE_Gnatural := 8
Definition: HeaderReg.vhd:38
in synHeadSt_isl
Definition: HeaderReg.vhd:48
slv( 0 downto 0) chksumEn
Definition: RssiPkg.vhd:54
in nullHeadSt_isl
Definition: HeaderReg.vhd:51
out ready_osl
Definition: HeaderReg.vhd:71
in rstHeadSt_isl
Definition: HeaderReg.vhd:49
out headerLength_opositive
Definition: HeaderReg.vhd:73
in ackHeadSt_isl
Definition: HeaderReg.vhd:52
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
slv( 7 downto 0) timeoutUnit
Definition: RssiPkg.vhd:55