1 ------------------------------------------------------------------------------- 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2015-08-09 5 -- Last update: 2016-01-27 6 ------------------------------------------------------------------------------- 8 -- Handles RSSI counters, timeouts, and statuses: 9 -- - Re-transmission timeout and request, 10 -- - NULL segment transmission (Client), 11 -- - NULL timeout detection (Server), 12 -- - Acknowledgment timeout and request, 13 -- - Valid segment counter, 14 -- - Dropped segment counter. 17 -- statusReg_o(0) : Connection Active 18 -- statusReg_o(1) : Maximum retransmissions exceeded r.retransMax and 19 -- statusReg_o(2) : Null timeout reached (server) r.nullTout; 20 -- statusReg_o(3) : Error in acknowledgment mechanism 21 -- statusReg_o(4) : SSI Frame length too long 22 -- statusReg_o(5) : Connection to peer timed out 23 -- statusReg_o(6) : Client rejected the connection (parameters out of range) 24 -- Server proposed new parameters (parameters out of range) 25 ------------------------------------------------------------------------------- 26 -- This file is part of 'SLAC Firmware Standard Library'. 27 -- It is subject to the license terms in the LICENSE.txt file found in the 28 -- top-level directory of this distribution and at: 29 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 30 -- No part of 'SLAC Firmware Standard Library', including this file, 31 -- may be copied, modified, propagated, or distributed except according to 32 -- the terms contained in the LICENSE.txt file. 33 ------------------------------------------------------------------------------- 36 use ieee.std_logic_1164.
all;
37 use ieee.std_logic_unsigned.
all;
38 use ieee.std_logic_arith.
all;
44 --! @ingroup protocols_rssi 61 -- Connection FSM indicating active connection 64 -- Timeout and counter values 67 -- Flags from Rx module 74 -- Do not request resend if tx buffer empty 77 -- Valid received packet 87 -- Internal Errors and Timeouts 93 -- Packet transmission requests 98 -- Connection close request 115 type RegType is record 123 -- Null packet send/timeout 128 -- Ack packet cumulative/timeout 130 lastAckSeqN : slv(7 downto 0);
133 -- For detecting rising edge on connActive 145 constant REG_INIT_C : RegType := ( 147 retransToutCnt => (others=>'0'), 150 retransCnt => (others=>'0'), 153 -- Null packet send/timeout 154 nullToutCnt => (others=>'0'), 158 -- Ack packet cumulative/timeout 159 ackToutCnt => (others=>'0'), 160 lastAckSeqN => (others=>'0'), 163 -- For detecting rising edge on connActive 167 status => (others=>'0'), 168 validCnt => (others=>'0'), 169 dropCnt => (others=>'0'), 170 reconCnt => (others=>'0'), 171 resendCnt => (others=>'0') 174 signal r : RegType := REG_INIT_C;
175 signal rin : RegType;
180 s_status(0) <= r.retransMax and r.sndResend and not r.sndResendD1;
181 s_status(1) <= r.nullTout;
187 comb :
process (r,
rst_i,
rxFlags_i,
rssiParam_i,
rxValid_i,
rxDrop_i,
dataHeadSt_i,
rstHeadSt_i,
nullHeadSt_i,
ackHeadSt_i,
189 variable v : RegType;
193 -- DFF the connActive for rising edge detection 196 -- ///////////////////////////////////////////////////////// 197 ------------------------------------------------------------ 198 -- Retransmission timeout 199 ------------------------------------------------------------ 200 -- ///////////////////////////////////////////////////////// 202 -- Retransmission Timeout counter 212 v.retransToutCnt := (others=>'0');
214 v.retransToutCnt := r.retransToutCnt+1;
217 -- Resend request SRFF 231 -- Pipeline sndResend for edge detection 232 v.sndResendD1 := r.sndResend;
234 -- ///////////////////////////////////////////////////////// 235 ------------------------------------------------------------ 236 -- Retransmission counter 237 ------------------------------------------------------------ 238 -- ///////////////////////////////////////////////////////// 239 -- Counter of consecutive retransmissions 240 -- Reset when connection is broken or a valid ACK is received 244 v.retransCnt := (others=>'0');
245 elsif (r.sndResend = '1' and r.sndResendD1 = '0') then -- Rising edge 246 v.retransCnt := r.retransCnt+1;
249 -- Retransmission exceeded close connection request SRFF 258 -- ///////////////////////////////////////////////////////// 259 ------------------------------------------------------------ 260 -- Null Segment transmit/timeout 261 ------------------------------------------------------------ 262 -- ///////////////////////////////////////////////////////// 264 -- Null Segment transmission (Client) 266 -- Null transmission counter 274 v.nullToutCnt := (others=>'0');
276 v.nullToutCnt := r.nullToutCnt+1;
285 elsif (r.nullToutCnt >= (conv_integer(rssiParam_i.nullSegTout) * SAMPLES_PER_TIME_DIV3_C) ) then -- send null segments if timeout/2 reached 289 -- Timeout not applicable 292 -- Null timeout (Server) 294 -- Null timeout counter 302 v.nullToutCnt := (others=>'0');
304 v.nullToutCnt := r.nullToutCnt+1;
314 -- Null sending not applicable 318 -- ///////////////////////////////////////////////////////// 319 ------------------------------------------------------------ 320 -- Acknowledgment cumulative/timeout 321 ------------------------------------------------------------ 322 -- ///////////////////////////////////////////////////////// 324 -- Ack seqN registering when it is sent 335 v.lastAckSeqN := r.lastAckSeqN;
346 v.ackToutCnt := (others=>'0');
351 v.ackToutCnt := r.ackToutCnt+1;
354 -- Ack packet request SRFF 363 -- Timeout acknowledgment request 367 -- Cumulative acknowledgment request 371 -- Null segment ACK as soon as NUL received 376 -- ///////////////////////////////////////////////////////// 377 ------------------------------------------------------------ 378 -- Status register and valid and drop counters 379 ------------------------------------------------------------ 380 -- ///////////////////////////////////////////////////////// 382 -- Register statuses until new connection is established 384 v.status := (others=>'0');
385 elsif (s_status /= (s_status'range => '0') ) then 386 v.status := r.status or s_status;
389 -- Count valid packets 391 v.validCnt := (others=>'0');
393 v.validCnt := r.validCnt+1;
396 -- Count dropped packets 398 v.dropCnt := (others=>'0');
400 v.dropCnt := r.dropCnt+1;
403 -- Count all retransmissions within the active connection 405 v.resendCnt := (others=>'0');
406 elsif (r.sndResend = '1' and r.sndResendD1 = '0') then -- Rising edge 407 v.resendCnt := r.resendCnt+1;
410 -- Count all reconnections from reset 412 v.reconCnt := r.reconCnt+1;
415 -- ///////////////////////////////////////////////////////// 416 if (rst_i = '1') then 421 ----------------------------------------------------------- 424 seq :
process (
clk_i)
is 426 if (rising_edge(clk_i)) then 427 r <= rin after TPD_G;
430 --------------------------------------------------------------------- 431 sndResend_o <= r.sndResend and not r.retransMax;
-- Request retransmission if max retransmissions not reached 434 closeRq_o <= (r.retransMax and r.sndResend and not r.sndResendD1) or -- Close connection when exceeded resend is requested 435 r.nullTout or -- Close connection when null timeouts 436 ackErr_i or -- Close if acknowledgment error occurs 437 lenErr_i;
-- Close if SSI input frame length error occurs 443 --------------------------------------------------------------------- 444 end architecture rtl;
out dropCnt_oslv( CNT_WIDTH_G- 1 downto 0)
out reconCnt_oslv( CNT_WIDTH_G- 1 downto 0)
in rxLastSeqN_islv( 7 downto 0)
CLK_FREQUENCY_Greal := 100.0E6
RETRANSMIT_ENABLE_Gboolean := true
WINDOW_ADDR_SIZE_Gpositive := 7
in rssiParam_iRssiParamType
in rxWindowSize_iinteger range 1 to 2**( WINDOW_ADDR_SIZE_G)
STATUS_WIDTH_Gpositive := 6
out statusReg_oslv( STATUS_WIDTH_G downto 0)
CNT_WIDTH_Gpositive := 32
out resendCnt_oslv( CNT_WIDTH_G- 1 downto 0)
TIMEOUT_UNIT_Greal := 1.0E-6
out validCnt_oslv( CNT_WIDTH_G- 1 downto 0)