1 ------------------------------------------------------------------------------- 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2015-08-09 5 -- Last update: 2016-06-23 6 ------------------------------------------------------------------------------- 7 -- Description: Connection establishment mechanism: 8 -- - Connection open/close request, 9 -- - Parameter negotiation, 10 -- - Server-client mode (More comments below). 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 ------------------------------------------------------------------------------- 22 use ieee.std_logic_1164.
all;
23 use ieee.std_logic_unsigned.
all;
24 use ieee.std_logic_arith.
all;
30 --! @ingroup protocols_rssi 38 -- Time the module waits for the response until it retransmits SYN segment 43 SEGMENT_ADDR_SIZE_G : positive := 7 -- 2^SEGMENT_ADDR_SIZE_G = Number of 64 bit wide data words 49 -- Connection request (open/close) 53 -- Parameters received from peer (Server) 56 -- Parameters set by high level App or generic (Client) 59 -- Negotiated parameters 62 -- Flags from Rx module 65 -- Valid received packet 73 -- Connection FSM indicating active connection 76 -- FSM in closed state (indicating when to initialize seqN) 86 -- Window size and buffer size different for Rx and Tx 115 type RegType is record 139 constant REG_INIT_C : RegType := ( 162 signal r : RegType := REG_INIT_C;
163 signal rin : RegType;
171 variable v : RegType;
175 -- ///////////////////////////////////////////////////////// 176 ------------------------------------------------------------ 178 -- Synchronization and parameter negotiation 179 ------------------------------------------------------------ 180 -- ///////////////////////////////////////////////////////// 183 ---------------------------------------------------------------------- 186 -- Initialize parameters 189 -- Next state condition 190 -- Initiated by high level App and depends on whether it is a 193 v.state := LISTEN_S;
-- Server Passive open 195 v.state := SEND_SYN_S;
-- Client Active open 197 ---------------------------------------------------------------------- 199 -- Actively open connection 200 -- Propose parameters 201 -- Accept parameters from server or close connection 202 ---------------------------------------------------------------------- 212 v.paramReject := '0';
215 -- Send the Client proposed parameters 219 v.state := WAIT_SYN_S;
222 ---------------------------------------------------------------------- 230 v.timeoutCntr := r.timeoutCntr + 1;
239 -- Accept the parameters from the server 244 -- Check the sizes and saturate to MAX if bigger 255 v.state := SEND_ACK_S;
257 -- Reject parameters and reset the connection 258 v.paramReject := '1';
259 v.rssiParam := r.rssiParam;
261 v.state := SEND_RST_S;
270 v.closed := '1';
-- Signal closed to reset seqN (Resend SYN with the initial seqN) 271 v.resendCntr := r.resendCntr + 1;
272 v.state := SEND_SYN_S;
275 ---------------------------------------------------------------------- 285 v.paramReject := '0';
287 v.rssiParam := r.rssiParam;
294 ---------------------------------------------------------------------- 296 -- Passively open connection. Go to listen state and wait for SYN. 297 -- Check clients parameters: 298 -- If valid accept parameters, 299 -- If not valid propose new parameters. 300 ---------------------------------------------------------------------- 313 -- Accept the parameters from the client 317 -- Set the receiver side information to be sent 321 -- Check the sizes and saturate to MAX if bigger 331 v.paramReject := '0';
333 -- Check parameters that have to match 340 -- Propose different parameters (overwrite) 345 v.paramReject := '1';
348 v.state := SEND_SYN_ACK_S;
350 --------------------------------------------------------------------- 351 when SEND_SYN_ACK_S => 359 v.paramReject := '0';
362 -- Send the Server parameters 363 v.rssiParam := r.rssiParam;
366 v.state := WAIT_ACK_S;
376 v.paramReject := '0';
378 v.timeoutCntr := r.timeoutCntr+1;
381 v.rssiParam := r.rssiParam;
392 v.closed := '1';
-- Signal closed to reset seqN (Resend SYN with the initial seqN) 393 v.resendCntr := r.resendCntr + 1;
394 v.state := SEND_SYN_ACK_S;
398 ---------------------------------------------------------------------- 402 ---------------------------------------------------------------------- 410 v.paramReject := '0';
415 v.rssiParam := r.rssiParam;
419 v.state := SEND_RST_S;
421 v.state := SEND_RST_S;
424 ---------------------------------------------------------------------- 425 -- Reset the connection 426 -- - Send Rst segment 428 ---------------------------------------------------------------------- 431 v.connActive := r.connActive;
436 v.paramReject := '0';
438 v.rssiParam := r.rssiParam;
445 ---------------------------------------------------------------------- 448 ---------------------------------------------------------------------- 451 if (rst_i = '1') then 456 ----------------------------------------------------------- 459 seq :
process (
clk_i)
is 461 if (rising_edge(clk_i)) then 462 r <= rin after TPD_G;
466 ------------------------------------------------------------------------------ 475 -- Parameters for receiver (have to be correctly set by the app) 478 -- Parameters for transmitter are received by the peer and checked by FSM 485 --------------------------------------------------------------------- 486 end architecture rtl;
out rssiParam_oRssiParamType
out rxBufferSize_ointeger range 1 to 2**( SEGMENT_ADDR_SIZE_G)
CLK_FREQUENCY_Greal := 100.0E6
in appRssiParam_iRssiParamType
TIMEOUT_UNIT_Greal := 1.0E-6
out txWindowSize_ointeger range 1 to 2**( WINDOW_ADDR_SIZE_G)
out rxWindowSize_ointeger range 1 to 2**( WINDOW_ADDR_SIZE_G)
in rxRssiParam_iRssiParamType
SEGMENT_ADDR_SIZE_Gpositive := 7
WINDOW_ADDR_SIZE_Gpositive := 3
MAX_RETRANS_CNT_Gpositive := 2
out txBufferSize_ointeger range 1 to 2**( SEGMENT_ADDR_SIZE_G)
RETRANS_TOUT_Gpositive := 50