SURF  1.0
UdpEngine.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : UdpEngine.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-08-20
5 -- Last update: 2016-09-30
6 -------------------------------------------------------------------------------
7 -- Description: Top-Level UDP/DHCP Module
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.AxiStreamPkg.all;
23 
24 --! @see entity
25  --! @ingroup ethernet_UdpEngine
26 entity UdpEngine is
27  generic (
28  -- Simulation Generics
29  TPD_G : time := 1 ns;
30  -- UDP Server Generics
31  SERVER_EN_G : boolean := true;
32  SERVER_SIZE_G : positive := 1;
33  SERVER_PORTS_G : PositiveArray := (0 => 8192);
34  -- UDP Client Generics
35  CLIENT_EN_G : boolean := true;
36  CLIENT_SIZE_G : positive := 1;
37  CLIENT_PORTS_G : PositiveArray := (0 => 8193);
38  -- General UDP/ARP/DHCP Generics
39  DHCP_G : boolean := false;
40  CLK_FREQ_G : real := 156.25E+06; -- In units of Hz
41  COMM_TIMEOUT_G : positive := 30); -- In units of seconds, Client's Communication timeout before re-ARPing or DHCP discover/request
42  port (
43  -- Local Configurations
44  localMac : in slv(47 downto 0); -- big-Endian configuration
45  localIpIn : in slv(31 downto 0); -- big-Endian configuration
46  dhcpIpOut : out slv(31 downto 0); -- big-Endian configuration
47  -- Interface to IPV4 Engine
52  -- Interface to ARP Engine
57  -- Interface to UDP Server engine(s)
58  serverRemotePort : out Slv16Array(SERVER_SIZE_G-1 downto 0); -- big-Endian configuration
59  serverRemoteIp : out Slv32Array(SERVER_SIZE_G-1 downto 0); -- big-Endian configuration
60  obServerMasters : out AxiStreamMasterArray(SERVER_SIZE_G-1 downto 0); -- tData is big-Endian configuration
63  ibServerSlaves : out AxiStreamSlaveArray(SERVER_SIZE_G-1 downto 0); -- tData is big-Endian configuration
64  -- Interface to UDP Client engine(s)
65  clientRemotePort : in Slv16Array(CLIENT_SIZE_G-1 downto 0); -- big-Endian configuration
66  clientRemoteIp : in Slv32Array(CLIENT_SIZE_G-1 downto 0); -- big-Endian configuration
67  obClientMasters : out AxiStreamMasterArray(CLIENT_SIZE_G-1 downto 0); -- tData is big-Endian configuration
70  ibClientSlaves : out AxiStreamSlaveArray(CLIENT_SIZE_G-1 downto 0); -- tData is big-Endian configuration
71  -- Clock and Reset
72  clk : in sl;
73  rst : in sl);
74 end UdpEngine;
75 
76 architecture mapping of UdpEngine is
77 
78  signal clientRemoteDet : slv(CLIENT_SIZE_G-1 downto 0);
80 
81  signal remotePort : Slv16Array(SERVER_SIZE_G-1 downto 0);
82  signal remoteIp : Slv32Array(SERVER_SIZE_G-1 downto 0);
84 
85  signal obUdpMasters : AxiStreamMasterArray(1 downto 0);
86  signal obUdpSlaves : AxiStreamSlaveArray(1 downto 0);
87 
90 
93 
94  signal localIp : slv(31 downto 0);
95 
96 begin
97 
98  assert ((SERVER_EN_G = true) or (CLIENT_EN_G = true)) report
99  "UdpEngine: Either SERVER_EN_G or CLIENT_EN_G must be true" severity failure;
100 
101  serverRemotePort <= remotePort; -- Debug Only
102  serverRemoteIp <= remoteIp; -- Debug Only
103  dhcpIpOut <= localIp;
104 
105  U_UdpEngineRx : entity work.UdpEngineRx
106  generic map (
107  TPD_G => TPD_G,
108  DHCP_G => DHCP_G,
115  port map (
116  -- Local Configurations
117  localIp => localIp,
118  -- Interface to IPV4 Engine
121  -- Interface to UDP Server engine(s)
127  -- Interface to UDP Client engine(s)
131  -- Interface to DHCP Engine
134  -- Clock and Reset
135  clk => clk,
136  rst => rst);
137 
138  GEN_DHCP : if (DHCP_G = true) generate
139 
140  U_UdpEngineDhcp : entity work.UdpEngineDhcp
141  generic map (
142  -- Simulation Generics
143  TPD_G => TPD_G,
144  -- UDP ARP/DHCP Generics
147  port map (
148  -- Local Configurations
149  localMac => localMac,
150  localIp => localIpIn,
151  dhcpIp => localIp,
152  -- Interface to DHCP Engine
157  -- Clock and Reset
158  clk => clk,
159  rst => rst);
160 
161  end generate;
162 
163  BYPASS_DHCP : if (DHCP_G = false) generate
164 
165  localIp <= localIpIn;
168 
169  end generate;
170 
171  GEN_SERVER : if (SERVER_EN_G = true) generate
172 
173  U_UdpEngineTx : entity work.UdpEngineTx
174  generic map (
175  TPD_G => TPD_G,
178  port map (
179  -- Interface to IPV4 Engine
181  obUdpSlave => obUdpSlaves(0),
182  -- Interface to User Application
183  localIp => localIp,
185  remoteIp => remoteIp,
189  -- Interface to DHCP Engine
192  -- Clock and Reset
193  clk => clk,
194  rst => rst);
195 
196  end generate;
197 
198  GEN_CLIENT : if (CLIENT_EN_G = true) generate
199 
200  U_UdpEngineArp : entity work.UdpEngineArp
201  generic map (
202  TPD_G => TPD_G,
206  port map (
207  -- Local Configurations
208  localIp => localIp,
209  -- Interface to ARP Engine
214  -- Interface to UDP Client engine(s)
218  -- Clock and Reset
219  clk => clk,
220  rst => rst);
221 
222  U_UdpEngineTx : entity work.UdpEngineTx
223  generic map (
224  TPD_G => TPD_G,
227  port map (
228  -- Interface to IPV4 Engine
230  obUdpSlave => obUdpSlaves(1),
231  -- Interface to User Application
232  localIp => localIp,
238  -- Clock and Reset
239  clk => clk,
240  rst => rst);
241 
242  end generate;
243 
244  GEN_MUX : if ((SERVER_EN_G = true) and (CLIENT_EN_G = true)) generate
245 
246  U_AxiStreamMux : entity work.AxiStreamMux
247  generic map (
248  TPD_G => TPD_G,
249  NUM_SLAVES_G => 2)
250  port map (
251  -- Clock and reset
252  axisClk => clk,
253  axisRst => rst,
254  -- Slaves
257  -- Master
259  mAxisSlave => obUdpSlave);
260 
261  end generate;
262 
263  NO_CLIENT : if ((SERVER_EN_G = true) and (CLIENT_EN_G = false)) generate
264 
265  -- Pass the server buses
267  obUdpSlaves(0) <= obUdpSlave;
268 
269  -- Terminated the client buses
273  arpAckSlaves <= (others => AXI_STREAM_SLAVE_FORCE_C);
274  clientRemoteMac <= (others => (others => '0'));
275 
276  end generate;
277 
278  NO_SERVER : if ((SERVER_EN_G = false) and (CLIENT_EN_G = true)) generate
279 
280  -- Pass the client buses
282  obUdpSlaves(1) <= obUdpSlave;
283 
284  -- Terminated the server buses
287 
288  end generate;
289 
290 end mapping;
Slv32Array( SERVER_SIZE_G- 1 downto 0) remoteIp
Definition: UdpEngine.vhd:82
out serverRemoteMacSlv48Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:54
out serverRemotePortSlv16Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:58
out dhcpIpslv( 31 downto 0)
TPD_Gtime := 1 ns
in ibDhcpMasterAxiStreamMasterType
out serverRemoteIpSlv32Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:53
array(natural range <> ) of AxiStreamSlaveType AxiStreamSlaveArray
SERVER_EN_Gboolean := true
Definition: UdpEngineRx.vhd:38
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
TPD_Gtime := 1 ns
out obServerMastersAxiStreamMasterArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:55
SERVER_PORTS_GPositiveArray :=( 0=> 8192)
Definition: UdpEngine.vhd:33
CLIENT_PORTS_GPositiveArray :=( 0=> 8193)
Definition: UdpEngineRx.vhd:44
out obDhcpMasterAxiStreamMasterType
out clientRemoteMacSlv48Array( CLIENT_SIZE_G- 1 downto 0)
in localIpslv( 31 downto 0)
Definition: UdpEngineTx.vhd:43
CLIENT_EN_Gboolean := true
Definition: UdpEngineRx.vhd:42
CLIENT_PORTS_GPositiveArray :=( 0=> 8193)
Definition: UdpEngine.vhd:37
in ibClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:69
std_logic sl
Definition: StdRtlPkg.vhd:28
in arpReqSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:54
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
array(natural range <> ) of slv( 47 downto 0) Slv48Array
Definition: StdRtlPkg.vhd:363
in ibUdpMasterAxiStreamMasterType
Definition: UdpEngineRx.vhd:49
SERVER_SIZE_Gpositive := 1
Definition: UdpEngine.vhd:32
in obServerSlavesAxiStreamSlaveArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:61
in remoteIpSlv32Array( SIZE_G- 1 downto 0)
Definition: UdpEngineTx.vhd:45
out obDhcpSlaveAxiStreamSlaveType
Definition: UdpEngineTx.vhd:51
CLIENT_SIZE_Gpositive := 1
COMM_TIMEOUT_Gpositive := 30
Definition: UdpEngine.vhd:41
in localIpslv( 31 downto 0)
Definition: UdpEngineRx.vhd:47
PORT_GPositiveArray :=( 0=> 8192)
Definition: UdpEngineTx.vhd:37
out arpAckSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:56
out ibSlavesAxiStreamSlaveArray( SIZE_G- 1 downto 0)
Definition: UdpEngineTx.vhd:48
TPD_Gtime := 1 ns
CLIENT_SIZE_Gpositive := 1
Definition: UdpEngine.vhd:36
slv( CLIENT_SIZE_G- 1 downto 0) clientRemoteDet
Definition: UdpEngine.vhd:78
AxiStreamMasterType obDhcpMaster
Definition: UdpEngine.vhd:91
CLK_FREQ_Greal := 156.25E+06
in clientRemoteDetslv( CLIENT_SIZE_G- 1 downto 0)
AxiStreamMasterType ibDhcpMaster
Definition: UdpEngine.vhd:88
in clientRemoteIpSlv32Array( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:66
Slv48Array( CLIENT_SIZE_G- 1 downto 0) clientRemoteMac
Definition: UdpEngine.vhd:79
out ibDhcpSlaveAxiStreamSlaveType
SERVER_SIZE_Gpositive := 1
Definition: UdpEngineRx.vhd:39
out clientRemoteDetslv( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:58
TPD_Gtime := 1 ns
Definition: UdpEngine.vhd:29
in ibMastersAxiStreamMasterArray( SIZE_G- 1 downto 0)
Definition: UdpEngineTx.vhd:47
in clksl
Definition: UdpEngine.vhd:72
in localIpslv( 31 downto 0)
AxiStreamSlaveType ibDhcpSlave
Definition: UdpEngine.vhd:89
AxiStreamSlaveType obDhcpSlave
Definition: UdpEngine.vhd:92
in localMacslv( 47 downto 0)
out arpReqMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:53
out mAxisMasterAxiStreamMasterType
NUM_SLAVES_Ginteger range 1 to 32:= 4
array(natural range <> ) of positive PositiveArray
Definition: StdRtlPkg.vhd:35
out dhcpIpOutslv( 31 downto 0)
Definition: UdpEngine.vhd:46
CLIENT_EN_Gboolean := true
Definition: UdpEngine.vhd:35
out serverRemoteIpSlv32Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:59
AxiStreamMasterArray( 1 downto 0) obUdpMasters
Definition: UdpEngine.vhd:85
in obUdpSlaveAxiStreamSlaveType
Definition: UdpEngine.vhd:49
DHCP_Gboolean := false
Definition: UdpEngine.vhd:39
out obUdpMasterAxiStreamMasterType
Definition: UdpEngine.vhd:48
in sAxisMastersAxiStreamMasterArray( NUM_SLAVES_G- 1 downto 0)
CLK_FREQ_Greal := 156.25E+06
out obServerMastersAxiStreamMasterArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:60
in remoteMacSlv48Array( SIZE_G- 1 downto 0)
Definition: UdpEngineTx.vhd:46
out ibClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:70
out arpReqMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
out ibUdpSlaveAxiStreamSlaveType
Definition: UdpEngine.vhd:51
in remotePortSlv16Array( SIZE_G- 1 downto 0)
Definition: UdpEngineTx.vhd:44
array(natural range <> ) of AxiStreamMasterType AxiStreamMasterArray
out sAxisSlavesAxiStreamSlaveArray( NUM_SLAVES_G- 1 downto 0)
Slv16Array( SERVER_SIZE_G- 1 downto 0) remotePort
Definition: UdpEngine.vhd:81
CLIENT_SIZE_Gpositive := 1
Definition: UdpEngineRx.vhd:43
array(natural range <> ) of slv( 15 downto 0) Slv16Array
Definition: StdRtlPkg.vhd:395
TPD_Gtime := 1 ns
Definition: UdpEngineRx.vhd:34
out ibDhcpMasterAxiStreamMasterType
Definition: UdpEngineRx.vhd:62
COMM_TIMEOUT_Gpositive := 30
in ibUdpMasterAxiStreamMasterType
Definition: UdpEngine.vhd:50
AxiStreamSlaveArray( 1 downto 0) obUdpSlaves
Definition: UdpEngine.vhd:86
in arpAckMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:55
in clientRemoteIpSlv32Array( CLIENT_SIZE_G- 1 downto 0)
COMM_TIMEOUT_Gpositive := 30
in clientRemotePortSlv16Array( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:65
in obDhcpMasterAxiStreamMasterType := AXI_STREAM_MASTER_INIT_C
Definition: UdpEngineTx.vhd:50
Slv48Array( SERVER_SIZE_G- 1 downto 0) serverRemoteMac
Definition: UdpEngine.vhd:83
in rstsl
Definition: UdpEngine.vhd:73
TPD_Gtime := 1 ns
Definition: UdpEngineTx.vhd:34
AxiStreamSlaveType :=(tReady => '1') AXI_STREAM_SLAVE_FORCE_C
out obClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:67
SIZE_Gpositive := 1
Definition: UdpEngineTx.vhd:36
in localIpslv( 31 downto 0)
in arpReqSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
in obClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:60
SERVER_EN_Gboolean := true
Definition: UdpEngine.vhd:31
out arpAckSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
in obClientSlavesAxiStreamSlaveArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngine.vhd:68
slv( 31 downto 0) localIp
Definition: UdpEngine.vhd:94
SERVER_PORTS_GPositiveArray :=( 0=> 8192)
Definition: UdpEngineRx.vhd:40
DHCP_Gboolean := false
Definition: UdpEngineRx.vhd:36
in mAxisSlaveAxiStreamSlaveType
in obServerSlavesAxiStreamSlaveArray( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:56
in ibDhcpSlaveAxiStreamSlaveType
Definition: UdpEngineRx.vhd:63
in arpAckMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out serverRemotePortSlv16Array( SERVER_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:52
out ibUdpSlaveAxiStreamSlaveType
Definition: UdpEngineRx.vhd:50
in localMacslv( 47 downto 0)
Definition: UdpEngine.vhd:44
out obClientMastersAxiStreamMasterArray( CLIENT_SIZE_G- 1 downto 0)
Definition: UdpEngineRx.vhd:59
in obUdpSlaveAxiStreamSlaveType
Definition: UdpEngineTx.vhd:41
out obUdpMasterAxiStreamMasterType
Definition: UdpEngineTx.vhd:40
in obDhcpSlaveAxiStreamSlaveType