SURF  1.0
UdpEngineWrapper.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : UdpEngineWrapper.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-08-20
5 -- Last update: 2016-11-02
6 -------------------------------------------------------------------------------
7 -- Description: Wrapper for UdpEngine
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 use ieee.std_logic_unsigned.all;
21 use ieee.std_logic_arith.all;
22 
23 use work.StdRtlPkg.all;
24 use work.AxiLitePkg.all;
25 use work.AxiStreamPkg.all;
26 use work.EthMacPkg.all;
27 
28 --! @see entity
29  --! @ingroup ethernet_UdpEngine
31  generic (
32  -- Simulation Generics
33  TPD_G : time := 1 ns;
34  -- UDP Server Generics
35  SERVER_EN_G : boolean := true;
36  SERVER_SIZE_G : positive := 1;
37  SERVER_PORTS_G : PositiveArray := (0 => 8192);
38  -- UDP Client Generics
39  CLIENT_EN_G : boolean := true;
40  CLIENT_SIZE_G : positive := 1;
41  CLIENT_PORTS_G : PositiveArray := (0 => 8193);
42  CLIENT_EXT_CONFIG_G : boolean := false;
44  -- General IPv4/ARP/DHCP Generics
45  DHCP_G : boolean := false;
46  CLK_FREQ_G : real := 156.25E+06; -- In units of Hz
47  COMM_TIMEOUT_G : positive := 30; -- In units of seconds, Client's Communication timeout before re-ARPing or DHCP discover/request
48  TTL_G : slv(7 downto 0) := x"20"; -- IPv4's Time-To-Live (TTL)
49  VLAN_G : boolean := false); -- true = VLAN support
50  port (
51  -- Local Configurations
52  localMac : in slv(47 downto 0); -- big-Endian configuration
53  localIp : in slv(31 downto 0); -- big-Endian configuration
54  -- Remote Configurations
55  clientRemotePort : in Slv16Array(CLIENT_SIZE_G-1 downto 0) := (others => x"0000");
56  clientRemoteIp : in Slv32Array(CLIENT_SIZE_G-1 downto 0) := (others => x"00000000");
57  -- Interface to Ethernet Media Access Controller (MAC)
62  -- Interface to UDP Server engine(s)
63  obServerMasters : out AxiStreamMasterArray(SERVER_SIZE_G-1 downto 0); -- tData is big-Endian configuration
66  ibServerSlaves : out AxiStreamSlaveArray(SERVER_SIZE_G-1 downto 0); -- tData is big-Endian configuration
67  -- Interface to UDP Client engine(s)
68  obClientMasters : out AxiStreamMasterArray(CLIENT_SIZE_G-1 downto 0); -- tData is big-Endian configuration
71  ibClientSlaves : out AxiStreamSlaveArray(CLIENT_SIZE_G-1 downto 0); -- tData is big-Endian configuration
72  -- AXI-Lite Interface
77  -- Clock and Reset
78  clk : in sl;
79  rst : in sl);
80 end UdpEngineWrapper;
81 
82 architecture rtl of UdpEngineWrapper is
83 
84  type RegType is record
89  end record;
90 
91  constant REG_INIT_C : RegType := (
92  clientRemotePort => (others => (others => '0')),
93  clientRemoteIp => (others => (others => '0')),
96 
97  signal r : RegType := REG_INIT_C;
98  signal rin : RegType;
99 
100  signal arpReqMasters : AxiStreamMasterArray(CLIENT_SIZE_G-1 downto 0);
101  signal arpReqSlaves : AxiStreamSlaveArray(CLIENT_SIZE_G-1 downto 0);
102  signal arpAckMasters : AxiStreamMasterArray(CLIENT_SIZE_G-1 downto 0);
103  signal arpAckSlaves : AxiStreamSlaveArray(CLIENT_SIZE_G-1 downto 0);
104 
105  signal ibUdpMaster : AxiStreamMasterType;
106  signal ibUdpSlave : AxiStreamSlaveType;
107  signal obUdpMaster : AxiStreamMasterType;
108  signal obUdpSlave : AxiStreamSlaveType;
109 
110  signal serverRemotePort : Slv16Array(SERVER_SIZE_G-1 downto 0);
111  signal serverRemoteIp : Slv32Array(SERVER_SIZE_G-1 downto 0);
112  signal dhcpIp : slv(31 downto 0);
113 
114 begin
115 
116  ------------------
117  -- IPv4/ARP Engine
118  ------------------
119  IpV4Engine_Inst : entity work.IpV4Engine
120  generic map (
121  TPD_G => TPD_G,
122  PROTOCOL_SIZE_G => 1,
123  PROTOCOL_G => (0 => UDP_C),
126  VLAN_G => VLAN_G)
127  port map (
128  -- Local Configurations
129  localMac => localMac,
130  localIp => dhcpIp,
131  -- Interface to Ethernet Media Access Controller (MAC)
136  -- Interface to Protocol Engine(s)
137  obProtocolMasters(0) => obUdpMaster,
138  obProtocolSlaves(0) => obUdpSlave,
139  ibProtocolMasters(0) => ibUdpMaster,
140  ibProtocolSlaves(0) => ibUdpSlave,
141  -- Interface to Client Engine(s)
142  arpReqMasters => arpReqMasters,
143  arpReqSlaves => arpReqSlaves,
144  arpAckMasters => arpAckMasters,
145  arpAckSlaves => arpAckSlaves,
146  -- Clock and Reset
147  clk => clk,
148  rst => rst);
149 
150  -------------
151  -- UDP Engine
152  -------------
153  UdpEngine_Inst : entity work.UdpEngine
154  generic map (
155  -- Simulation Generics
156  TPD_G => TPD_G,
157  -- UDP Server Generics
161  -- UDP Client Generics
165  -- UDP ARP/DHCP Generics
166  DHCP_G => DHCP_G,
169  port map (
170  -- Local Configurations
171  localMac => localMac,
172  localIpIn => localIp,
173  dhcpIpOut => dhcpIp,
174  -- Interface to IPV4 Engine
175  obUdpMaster => obUdpMaster,
176  obUdpSlave => obUdpSlave,
177  ibUdpMaster => ibUdpMaster,
178  ibUdpSlave => ibUdpSlave,
179  -- Interface to ARP Engine
180  arpReqMasters => arpReqMasters,
181  arpReqSlaves => arpReqSlaves,
182  arpAckMasters => arpAckMasters,
183  arpAckSlaves => arpAckSlaves,
184  -- Interface to UDP Server engine(s)
185  serverRemotePort => serverRemotePort,
186  serverRemoteIp => serverRemoteIp,
191  -- Interface to UDP Client engine(s)
192  clientRemotePort => r.clientRemotePort,
193  clientRemoteIp => r.clientRemoteIp,
198  -- Clock and Reset
199  clk => clk,
200  rst => rst);
201 
203  localMac, r, rst, serverRemoteIp, serverRemotePort) is
204  variable v : RegType;
205  variable regCon : AxiLiteEndPointType;
206  variable i : natural;
207  begin
208  -- Latch the current value
209  v := r;
210 
211  -- Determine the transaction type
212  axiSlaveWaitTxn(regCon, axilWriteMaster, axilReadMaster, v.axilWriteSlave, v.axilReadSlave);
213 
214  -- Map the read/write registers
215  for i in CLIENT_SIZE_G-1 downto 0 loop
216  axiSlaveRegister(regCon, toSlv((8*i)+0, 12), 0, v.clientRemotePort(i)); -- big-Endian configuration
217  axiSlaveRegister(regCon, toSlv((8*i)+4, 12), 0, v.clientRemoteIp(i)); -- big-Endian configuration
218  end loop;
219  -- Map the read only registers
220  for i in SERVER_SIZE_G-1 downto 0 loop
221  axiSlaveRegisterR(regCon, toSlv((8*i)+0+2048, 12), 0, serverRemotePort(i)); -- big-Endian configuration
222  axiSlaveRegisterR(regCon, toSlv((8*i)+4+2048, 12), 0, serverRemoteIp(i)); -- big-Endian configuration
223  end loop;
224 
225  axiSlaveRegisterR(regCon, x"FF4", 0, dhcpIp);
226  axiSlaveRegisterR(regCon, x"FF8", 0, localMac);
227 
228  -- Closeout the transaction
229  axiSlaveDefault(regCon, v.axilWriteSlave, v.axilReadSlave, AXI_ERROR_RESP_G);
230 
231  -- Synchronous Reset
232  if (rst = '1') then
233  v := REG_INIT_C;
234  end if;
235 
236  -- Check for external configuration
237  if (CLIENT_EXT_CONFIG_G = true) then
240  end if;
241 
242  -- Register the variable for next clock cycle
243  rin <= v;
244 
245  -- Outputs
248 
249  end process comb;
250 
251  seq : process (clk) is
252  begin
253  if (rising_edge(clk)) then
254  r <= rin after TPD_G;
255  end if;
256  end process seq;
257 
258 end rtl;
out serverRemotePortSlv16Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:58
array(natural range <> ) of AxiStreamSlaveType AxiStreamSlaveArray
in axilReadMasterAxiLiteReadMasterType := AXI_LITE_READ_MASTER_INIT_C
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_DECERR_C
array(natural range <> ) of slv( 31 downto 0) Slv32Array
Definition: StdRtlPkg.vhd:379
in ibServerMastersAxiStreamMasterArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:62
out ibServerSlavesAxiStreamSlaveArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:63
in localIpInslv( 31 downto 0)
Definition: UdpEngine.vhd:45
CLK_FREQ_Greal := 156.25E+06
Definition: UdpEngine.vhd:40
PROTOCOL_SIZE_Gpositive := 1
Definition: IpV4Engine.vhd:30
CLK_FREQ_Greal := 156.25E+06
in obMacMasterAxiStreamMasterType
out ibServerSlavesAxiStreamSlaveArray( SERVER_SIZE_G- 1 downto 0)
in obServerSlavesAxiStreamSlaveArray( SERVER_SIZE_G- 1 downto 0) :=( others => AXI_STREAM_SLAVE_FORCE_C)
VLAN_Gboolean := false
PROTOCOL_GSlv8Array :=( 0=> UDP_C)
Definition: IpV4Engine.vhd:31
SERVER_PORTS_GPositiveArray :=( 0=> 8192)
Definition: UdpEngine.vhd:33
in ibServerMastersAxiStreamMasterArray( SERVER_SIZE_G- 1 downto 0) :=( others => AXI_STREAM_MASTER_INIT_C)
in rstsl
Definition: IpV4Engine.vhd:57
CLIENT_SIZE_Gpositive := 1
CLIENT_PORTS_GPositiveArray :=( 0=> 8193)
Definition: UdpEngine.vhd:37
SERVER_PORTS_GPositiveArray :=( 0=> 8192)
in ibClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:69
out ibMacMasterAxiStreamMasterType
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
in arpReqSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:54
out ibMacMasterAxiStreamMasterType
Definition: IpV4Engine.vhd:43
AxiStreamMasterType :=(tValid => '0',tData =>( others => '0'),tStrb =>( others => '1'),tKeep =>( others => '1'),tLast => '0',tDest =>( others => '0'),tId =>( others => '0'),tUser =>( others => '0')) AXI_STREAM_MASTER_INIT_C
SERVER_SIZE_Gpositive := 1
Definition: UdpEngine.vhd:32
VLAN_Gboolean := false
Definition: IpV4Engine.vhd:35
in obServerSlavesAxiStreamSlaveArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:61
in clientRemoteIpSlv32Array( CLIENT_SIZE_G- 1 downto 0) :=( others => x"00000000")
COMM_TIMEOUT_Gpositive := 30
Definition: UdpEngine.vhd:41
CLIENT_PORTS_GPositiveArray :=( 0=> 8193)
_library_ ieeeieee
Definition: UdpEngineTx.vhd:19
out arpAckSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:56
CLIENT_EXT_CONFIG_Gboolean := false
CLIENT_SIZE_Gpositive := 1
Definition: UdpEngine.vhd:36
TTL_Gslv( 7 downto 0) := x"20"
in clientRemoteIpSlv32Array( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:66
in axilWriteMasterAxiLiteWriteMasterType := AXI_LITE_WRITE_MASTER_INIT_C
SERVER_EN_Gboolean := true
CLIENT_EN_Gboolean := true
out arpAckMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: IpV4Engine.vhd:53
TPD_Gtime := 1 ns
Definition: UdpEngine.vhd:29
in localMacslv( 47 downto 0)
in clksl
Definition: UdpEngine.vhd:72
slv( 1 downto 0) := "11" AXI_RESP_DECERR_C
Definition: AxiLitePkg.vhd:49
in clksl
Definition: IpV4Engine.vhd:56
out axilWriteSlaveAxiLiteWriteSlaveType
in localIpslv( 31 downto 0)
out arpReqMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:53
DHCP_Gboolean := false
out obMacSlaveAxiStreamSlaveType
Definition: IpV4Engine.vhd:42
array(natural range <> ) of positive PositiveArray
Definition: StdRtlPkg.vhd:35
out dhcpIpOutslv( 31 downto 0)
Definition: UdpEngine.vhd:46
in clientRemotePortSlv16Array( CLIENT_SIZE_G- 1 downto 0) :=( others => x"0000")
out arpReqSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: IpV4Engine.vhd:52
CLIENT_EN_Gboolean := true
Definition: UdpEngine.vhd:35
SERVER_SIZE_Gpositive := 1
out serverRemoteIpSlv32Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:59
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
in obUdpSlaveAxiStreamSlaveType
Definition: UdpEngine.vhd:49
in ibClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0) :=( others => AXI_STREAM_MASTER_INIT_C)
DHCP_Gboolean := false
Definition: UdpEngine.vhd:39
out obUdpMasterAxiStreamMasterType
Definition: UdpEngine.vhd:48
out obServerMastersAxiStreamMasterArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:60
out ibClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:70
in arpReqMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: IpV4Engine.vhd:51
in arpAckSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: IpV4Engine.vhd:54
out ibUdpSlaveAxiStreamSlaveType
Definition: UdpEngine.vhd:51
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:95
out obClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
out ibClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
TPD_Gtime := 1 ns
Definition: IpV4Engine.vhd:29
array(natural range <> ) of AxiStreamMasterType AxiStreamMasterArray
array(natural range <> ) of slv( 15 downto 0) Slv16Array
Definition: StdRtlPkg.vhd:395
in ibUdpMasterAxiStreamMasterType
Definition: UdpEngine.vhd:50
in localIpslv( 31 downto 0)
Definition: IpV4Engine.vhd:39
AxiLiteReadMasterType :=(araddr =>( others => '0'),arprot =>( others => '0'),arvalid => '0',rready => '1') AXI_LITE_READ_MASTER_INIT_C
Definition: AxiLitePkg.vhd:69
in obMacMasterAxiStreamMasterType
Definition: IpV4Engine.vhd:41
out axilReadSlaveAxiLiteReadSlaveType
in arpAckMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:55
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
in clientRemotePortSlv16Array( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:65
AxiLiteWriteMasterType :=(awaddr =>( others => '0'),awprot =>( others => '0'),awvalid => '0',wdata =>( others => '0'),wstrb =>( others => '1'),wvalid => '0',bready => '1') AXI_LITE_WRITE_MASTER_INIT_C
Definition: AxiLitePkg.vhd:125
in rstsl
Definition: UdpEngine.vhd:73
CLK_FREQ_Greal := 156.25E+06
Definition: IpV4Engine.vhd:33
COMM_TIMEOUT_Gpositive := 30
CLIENT_SIZE_Gpositive := 1
Definition: IpV4Engine.vhd:32
AxiStreamSlaveType :=(tReady => '1') AXI_STREAM_SLAVE_FORCE_C
out obClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:67
in localMacslv( 47 downto 0)
Definition: IpV4Engine.vhd:38
slv( 7 downto 0) := x"11" UDP_C
Definition: EthMacPkg.vhd:39
in ibMacSlaveAxiStreamSlaveType
Definition: IpV4Engine.vhd:44
in obClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0) :=( others => AXI_STREAM_SLAVE_FORCE_C)
out obMacSlaveAxiStreamSlaveType
SERVER_EN_Gboolean := true
Definition: UdpEngine.vhd:31
in obClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:68
in ibMacSlaveAxiStreamSlaveType
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:156
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out obServerMastersAxiStreamMasterArray( SERVER_SIZE_G- 1 downto 0)
in localMacslv( 47 downto 0)
Definition: UdpEngine.vhd:44