SURF  1.0
RssiPkg.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : RssiPkg.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-08-09
5 -- Last update: 2016-07-12
6 -------------------------------------------------------------------------------
7 -- Description: RSSI Package File
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 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 
21 use work.StdRtlPkg.all;
22 use work.SsiPkg.all;
23 use work.AxiStreamPkg.all;
24 
25 package RssiPkg is
26 --! @file
27  --! @ingroup protocols_rssi
28 
29  --------------------------------------------------------------------------
30  -- Common constant definitions
31  --------------------------------------------------------------------------
32  constant RSSI_WORD_WIDTH_C : positive := 8; -- 64 bit word (FIXED)
34  ssiAxiStreamConfig(
35  dataBytes => RSSI_WORD_WIDTH_C,
36  tKeepMode => TKEEP_COMP_C,
37  tUserMode => TUSER_FIRST_LAST_C,
38  tDestBits => 0,
39  tUserBits => 2);
40 
41  -- Header sizes
42  constant SYN_HEADER_SIZE_C : natural := 24;
43  constant ACK_HEADER_SIZE_C : natural := 8;
44  constant EACK_HEADER_SIZE_C : natural := 8;
45  constant RST_HEADER_SIZE_C : natural := 8;
46  constant NULL_HEADER_SIZE_C : natural := 8;
47  constant DATA_HEADER_SIZE_C : natural := 8;
48 
49  --------------------------------------------------------------------------
50  -- Sub-types
51  --------------------------------------------------------------------------
52  type RssiParamType is record
53  version : slv(3 downto 0);
54  chksumEn : slv(0 downto 0);
55  timeoutUnit : slv(7 downto 0);
56 
57  maxOutsSeg : slv(7 downto 0); -- Receiver parameter
58  maxSegSize : slv(15 downto 0); -- Receiver parameter
59 
60  retransTout : slv(15 downto 0);
61  cumulAckTout : slv(15 downto 0);
62  nullSegTout : slv(15 downto 0);
63 
64  maxRetrans : slv(7 downto 0);
65  maxCumAck : slv(7 downto 0);
66 
67  maxOutofseq : slv(7 downto 0);
68 
69  connectionId : slv(31 downto 0);
70  end record RssiParamType;
71 
73  version => (others => '0'),
74  chksumEn => (others => '0'),
75  timeoutUnit => (others => '0'),
76  maxOutsSeg => (others => '0'),
77  maxSegSize => (others => '0'),
78  retransTout => (others => '0'),
79  cumulAckTout => (others => '0'),
80  nullSegTout => (others => '0'),
81  maxRetrans => (others => '0'),
82  maxCumAck => (others => '0'),
83  maxOutofseq => (others => '0'),
84  connectionId => (others => '0'));
85 
86  type flagsType is record
87  syn : sl;
88  ack : sl;
89  eack : sl;
90  rst : sl;
91  nul : sl;
92  data : sl;
93  busy : sl;
94  eofe : sl;
95  end record flagsType;
96 
97  type WindowType is record
98  seqN : slv(7 downto 0);
99  segType : slv(2 downto 0);
100  keep : slv(15 downto 0);
101  segSize : natural;
103  end record WindowType;
104 
105  constant WINDOW_INIT_C : WindowType := (
106  seqN => (others => '0'),
107  segType => (others => '0'),
108  keep => (others => '1'),
109  segSize => 0,
110  occupied => '0');
111 
112  -- Arrays
113  type WindowTypeArray is array (natural range<>) of WindowType;
114 
115  --------------------------------------------------------------------------
116  -- Function declarations
117  --------------------------------------------------------------------------
118  -- Swap little and big endians
119  -- 64-bit header word
120  function endianSwap64(data_slv : slv(63 downto 0)) return std_logic_vector;
121 
122 end RssiPkg;
123 
124 package body RssiPkg is
125 
126  --------------------------------------------------------------------------
127  -- Function bodies
128  --------------------------------------------------------------------------
129  -- Swap little or big endians 64-bit header
130  function endianSwap64(data_slv : slv(63 downto 0)) return std_logic_vector is
131  variable vSlv : slv(63 downto 0);
132  begin
133  vSlv := (others => '0');
134 
135  for i in 7 downto 0 loop
136  vSlv((8*(7-i))+7 downto 8*(7-i)) := data_slv((8*i)+7 downto 8*i);
137  end loop;
138 
139  return vSlv;
140 
141  end endianSwap64;
142 --------------------------------------------------------------------------------------------
143 end package body RssiPkg;
AxiStreamConfigType :=ssiAxiStreamConfig(dataBytes => RSSI_WORD_WIDTH_C,tKeepMode => TKEEP_COMP_C,tUserMode => TUSER_FIRST_LAST_C,tDestBits => 0,tUserBits => 2) RSSI_AXIS_CONFIG_C
Definition: RssiPkg.vhd:33
sl nul
Definition: RssiPkg.vhd:91
sl occupied
Definition: RssiPkg.vhd:102
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
std_logic_vector endianSwap64data_slv,
Definition: RssiPkg.vhd:120
WindowType
Definition: RssiPkg.vhd:97
slv( 15 downto 0) nullSegTout
Definition: RssiPkg.vhd:62
sl rst
Definition: RssiPkg.vhd:90
positive := 8 RSSI_WORD_WIDTH_C
Definition: RssiPkg.vhd:32
slv( 7 downto 0) seqN
Definition: RssiPkg.vhd:98
sl syn
Definition: RssiPkg.vhd:87
RssiParamType :=(version =>( others => '0'),chksumEn =>( others => '0'),timeoutUnit =>( others => '0'),maxOutsSeg =>( others => '0'),maxSegSize =>( others => '0'),retransTout =>( others => '0'),cumulAckTout =>( others => '0'),nullSegTout =>( others => '0'),maxRetrans =>( others => '0'),maxCumAck =>( others => '0'),maxOutofseq =>( others => '0'),connectionId =>( others => '0')) RSSI_PARAM_INIT_C
Definition: RssiPkg.vhd:72
natural := 8 ACK_HEADER_SIZE_C
Definition: RssiPkg.vhd:43
sl data
Definition: RssiPkg.vhd:92
slv( 7 downto 0) maxRetrans
Definition: RssiPkg.vhd:64
flagsType
Definition: RssiPkg.vhd:86
natural := 8 EACK_HEADER_SIZE_C
Definition: RssiPkg.vhd:44
slv( 7 downto 0) maxOutofseq
Definition: RssiPkg.vhd:67
slv( 15 downto 0) retransTout
Definition: RssiPkg.vhd:60
slv( 7 downto 0) maxCumAck
Definition: RssiPkg.vhd:65
slv( 2 downto 0) segType
Definition: RssiPkg.vhd:99
sl eofe
Definition: RssiPkg.vhd:94
natural := 24 SYN_HEADER_SIZE_C
Definition: RssiPkg.vhd:42
natural := 8 RST_HEADER_SIZE_C
Definition: RssiPkg.vhd:45
slv( 15 downto 0) cumulAckTout
Definition: RssiPkg.vhd:61
slv( 7 downto 0) maxOutsSeg
Definition: RssiPkg.vhd:57
sl ack
Definition: RssiPkg.vhd:88
sl eack
Definition: RssiPkg.vhd:89
slv( 15 downto 0) maxSegSize
Definition: RssiPkg.vhd:58
_library_ ieeeieee
natural := 8 NULL_HEADER_SIZE_C
Definition: RssiPkg.vhd:46
RssiParamType
Definition: RssiPkg.vhd:52
slv( 0 downto 0) chksumEn
Definition: RssiPkg.vhd:54
natural segSize
Definition: RssiPkg.vhd:101
array(natural range <> ) of WindowType WindowTypeArray
Definition: RssiPkg.vhd:113
natural := 8 DATA_HEADER_SIZE_C
Definition: RssiPkg.vhd:47
sl busy
Definition: RssiPkg.vhd:93
WindowType :=(seqN =>( others => '0'),segType =>( others => '0'),keep =>( others => '1'),segSize => 0,occupied => '0') WINDOW_INIT_C
Definition: RssiPkg.vhd:105
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
slv( 7 downto 0) timeoutUnit
Definition: RssiPkg.vhd:55