cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
udp_shell_if

This module handles the control flow interface between the SHELL and the ROLE. More...

Collaboration diagram for udp_shell_if:

Files

file  udp_shell_if.cpp
 : UDP Shell Interface (USIF)
 
file  udp_shell_if.hpp
 : UDP Shell Interface (USIF).
 
file  udp_shell_if_top.cpp
 : Top level with I/O ports for UDP Shell Interface (USIF)
 
file  udp_shell_if_top.hpp
 : Top of UDP Shell Interface (USIF).
 
file  simu_udp_shell_if_env.cpp
 : Testbench for the UDP Shell Interface (USIF).
 
file  simu_udp_shell_if_env.hpp
 : Simulation environment for the UDP Shell Interface (USIF).
 
file  test_udp_shell_if.cpp
 : Testbench for the UDP Shell Interface (USIF).
 
file  test_udp_shell_if.hpp
 : Testbench for the UDP Shell Interface (USIF).
 
file  test_udp_shell_if_top.cpp
 : Testbench for the toplevel of the UDP Shell Interface (USIF).
 
file  test_udp_shell_if_top.hpp
 : Testbench for the toplevel of UDP Shell Interface (USIF).
 

Macros

#define THIS_NAME   "USIF"
 
#define TRACE_OFF   0x0000
 
#define TRACE_RDP   1 << 1
 
#define TRACE_WRP   1 << 2
 
#define TRACE_SAM   1 << 3
 
#define TRACE_LSN   1 << 4
 
#define TRACE_CLS   1 << 5
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 
#define DEFAULT_FPGA_LSN_PORT   0x2263
 
#define RECV_MODE_LSN_PORT   8800
 
#define XMIT_MODE_LSN_PORT   8801
 
#define ECHO_MOD2_LSN_PORT   8802
 
#define ECHO_MODE_LSN_PORT   8803
 
#define IPERF_LSN_PORT   5001
 
#define IPREF3_LSN_PORT   5201
 
#define GEN_CHK0   0x48692066726f6d20
 
#define GEN_CHK1   0x464d4b553630210a
 
#define THIS_NAME   "SIM"
 
#define TRACE_OFF   0x0000
 
#define TRACE_UOE   1 << 1
 
#define TRACE_UAF   1 << 2
 
#define TRACE_MMIO   1 << 3
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_UOE)
 
#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801
 
#define DEFAULT_FPGA_LSN_PORT   0x2263
 
#define DEFAULT_FPGA_SND_PORT   0xA263
 
#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832
 
#define DEFAULT_HOST_LSN_PORT   0x80
 
#define DEFAULT_HOST_SND_PORT   0x8080
 
#define DEFAULT_DATAGRAM_LEN   32
 
#define THIS_NAME   "TB_USIF"
 
#define THIS_NAME   "TB_USIF_TOP"
 

Enumerations

enum  DropCmd { KEEP_CMD =false , DROP_CMD , KEEP_CMD =false , DROP_CMD }
 

Functions

void pListen (CmdBit *piSHL_Enable, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep)
 Listen(LSn) More...
 
void pClose (CmdBit *piSHL_Enable, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep)
 Request the SHELL/NTS/UOE to close a previously opened port. More...
 
void pReadPath (CmdBit *piSHL_Enable, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen, stream< SocketPair > &soWRp_SockPair, stream< UdpAppDLen > &soWRp_DReq)
 Read Path (RDp) - From SHELL/UOE to ROLE/UAF. More...
 
void pWritePath (CmdBit *piSHL_Enable, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< SocketPair > &siRDp_SockPair, stream< UdpAppDLen > &siRDp_DReq, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen)
 Write Path (WRp) - From ROLE/UAF to SHELL/NTS/UOE. More...
 
void udp_shell_if (CmdBit *piSHL_Mmio_En, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen)
 Main process of the UDP Shell Interface (USIF). More...
 
void udp_shell_if_top (CmdBit *piSHL_Mmio_En, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen)
 Top of UDP Shell Interface (USIF) More...
 
void stepSim ()
 Increment the simulation counter. More...
 
void increaseSimTime (unsigned int cycles)
 Increase the simulation time of the testbench. More...
 
void pUAF (stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen)
 Emulate the behavior of the ROLE/UdpAppFlash (UAF). More...
 
void pMMIO (StsBit *piSHL_Ready, CmdBit *poUSIF_Enable)
 Emulate the behavior of the SHELL & MMIO. More...
 
void pUOE (int &nrErr, ofstream &dataGoldFile, ofstream &dataFile, ofstream &metaGoldFile, ofstream &metaFile, int echoDgrmLen, SockAddr testSock, int testDgrmLen, StsBit *poMMIO_Ready, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen, stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppDLen > &siUSIF_DLen, stream< UdpPort > &siUSIF_LsnReq, stream< StsBool > &soUSIF_LsnRep, stream< UdpPort > &siUSIF_ClsReq)
 Emulate behavior of the SHELL/NTS/UDP Offload Engine (UOE). More...
 
int main (int argc, char *argv[])
 Main function for the test of the UDP Shell Interface (USIF). More...
 

Variables

bool gTraceEvent
 
unsigned int gSimCycCnt
 
bool gTraceEvent
 
bool gFatalError
 
unsigned int gMaxSimCycles
 
const int cUoeInitCycles = 100
 
const int cGraceTime = 500
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int gMaxSimCycles = cUoeInitCycles + cGraceTime
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int gMaxSimCycles = cUoeInitCycles + cGraceTime
 

Detailed Description

This module handles the control flow interface between the SHELL and the ROLE.

Macro Definition Documentation

◆ DEBUG_LEVEL [1/2]

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 70 of file udp_shell_if.cpp.

◆ DEBUG_LEVEL [2/2]

#define DEBUG_LEVEL   (TRACE_UOE)

Definition at line 72 of file simu_udp_shell_if_env.cpp.

◆ DEFAULT_DATAGRAM_LEN

#define DEFAULT_DATAGRAM_LEN   32

Definition at line 59 of file simu_udp_shell_if_env.hpp.

◆ DEFAULT_FPGA_IP4_ADDR

#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801

Definition at line 52 of file simu_udp_shell_if_env.hpp.

◆ DEFAULT_FPGA_LSN_PORT [1/2]

#define DEFAULT_FPGA_LSN_PORT   0x2263

Definition at line 81 of file udp_shell_if.cpp.

◆ DEFAULT_FPGA_LSN_PORT [2/2]

#define DEFAULT_FPGA_LSN_PORT   0x2263

Definition at line 53 of file simu_udp_shell_if_env.hpp.

◆ DEFAULT_FPGA_SND_PORT

#define DEFAULT_FPGA_SND_PORT   0xA263

Definition at line 54 of file simu_udp_shell_if_env.hpp.

◆ DEFAULT_HOST_IP4_ADDR

#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832

Definition at line 55 of file simu_udp_shell_if_env.hpp.

◆ DEFAULT_HOST_LSN_PORT

#define DEFAULT_HOST_LSN_PORT   0x80

Definition at line 56 of file simu_udp_shell_if_env.hpp.

◆ DEFAULT_HOST_SND_PORT

#define DEFAULT_HOST_SND_PORT   0x8080

Definition at line 57 of file simu_udp_shell_if_env.hpp.

◆ ECHO_MOD2_LSN_PORT

#define ECHO_MOD2_LSN_PORT   8802

Definition at line 62 of file udp_shell_if.hpp.

◆ ECHO_MODE_LSN_PORT

#define ECHO_MODE_LSN_PORT   8803

Definition at line 63 of file udp_shell_if.hpp.

◆ GEN_CHK0

#define GEN_CHK0   0x48692066726f6d20

Definition at line 73 of file udp_shell_if.hpp.

◆ GEN_CHK1

#define GEN_CHK1   0x464d4b553630210a

Definition at line 74 of file udp_shell_if.hpp.

◆ IPERF_LSN_PORT

#define IPERF_LSN_PORT   5001

Definition at line 64 of file udp_shell_if.hpp.

◆ IPREF3_LSN_PORT

#define IPREF3_LSN_PORT   5201

Definition at line 65 of file udp_shell_if.hpp.

◆ RECV_MODE_LSN_PORT

#define RECV_MODE_LSN_PORT   8800

Definition at line 60 of file udp_shell_if.hpp.

◆ THIS_NAME [1/4]

#define THIS_NAME   "USIF"

Definition at line 61 of file udp_shell_if.cpp.

◆ THIS_NAME [2/4]

#define THIS_NAME   "SIM"

Definition at line 64 of file simu_udp_shell_if_env.cpp.

◆ THIS_NAME [3/4]

#define THIS_NAME   "TB_USIF"

Definition at line 56 of file test_udp_shell_if.cpp.

◆ THIS_NAME [4/4]

#define THIS_NAME   "TB_USIF_TOP"

Definition at line 51 of file test_udp_shell_if_top.cpp.

◆ TRACE_ALL [1/2]

#define TRACE_ALL   0xFFFF

Definition at line 69 of file udp_shell_if.cpp.

◆ TRACE_ALL [2/2]

#define TRACE_ALL   0xFFFF

Definition at line 70 of file simu_udp_shell_if_env.cpp.

◆ TRACE_CLS

#define TRACE_CLS   1 << 5

Definition at line 68 of file udp_shell_if.cpp.

◆ TRACE_LSN

#define TRACE_LSN   1 << 4

Definition at line 67 of file udp_shell_if.cpp.

◆ TRACE_MMIO

#define TRACE_MMIO   1 << 3

Definition at line 69 of file simu_udp_shell_if_env.cpp.

◆ TRACE_OFF [1/2]

#define TRACE_OFF   0x0000

Definition at line 63 of file udp_shell_if.cpp.

◆ TRACE_OFF [2/2]

#define TRACE_OFF   0x0000

Definition at line 66 of file simu_udp_shell_if_env.cpp.

◆ TRACE_RDP

#define TRACE_RDP   1 << 1

Definition at line 64 of file udp_shell_if.cpp.

◆ TRACE_SAM

#define TRACE_SAM   1 << 3

Definition at line 66 of file udp_shell_if.cpp.

◆ TRACE_UAF

#define TRACE_UAF   1 << 2

Definition at line 68 of file simu_udp_shell_if_env.cpp.

◆ TRACE_UOE

#define TRACE_UOE   1 << 1

Definition at line 67 of file simu_udp_shell_if_env.cpp.

◆ TRACE_WRP

#define TRACE_WRP   1 << 2

Definition at line 65 of file udp_shell_if.cpp.

◆ XMIT_MODE_LSN_PORT

#define XMIT_MODE_LSN_PORT   8801

Definition at line 61 of file udp_shell_if.hpp.

Enumeration Type Documentation

◆ DropCmd

enum DropCmd
Enumerator
KEEP_CMD 
DROP_CMD 
KEEP_CMD 
DROP_CMD 

Definition at line 72 of file udp_shell_if.cpp.

72 {KEEP_CMD=false, DROP_CMD};
@ KEEP_CMD
@ DROP_CMD

Function Documentation

◆ increaseSimTime()

void increaseSimTime ( unsigned int  cycles)

Increase the simulation time of the testbench.

Parameters
[in]Thenumber of cycles to increase.

Definition at line 93 of file simu_udp_shell_if_env.cpp.

93  {
94  gMaxSimCycles += cycles;
95 }
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function for the test of the UDP Shell Interface (USIF).

Main function for the test of the TOP of UDP Shell Interface (USIF).

Parameters
[in]Thenumber of bytes to generate in 'Echo' mode [1:65535].
[in]TheIP4 destination address of the remote host.
[in]TheUDP destination port of the remote host.
[in]Thenumber of bytes to generate in or "Test' mode [1:65535].

@info Usage example --> "512 10.11.12.13 2718 1024"

Definition at line 74 of file test_udp_shell_if.cpp.

74  {
75 
76  //------------------------------------------------------
77  //-- TESTBENCH GLOBAL VARIABLES
78  //------------------------------------------------------
79  gSimCycCnt = 0; // Simulation cycle counter as a global variable
80 
81  //------------------------------------------------------
82  //-- DUT SIGNAL INTERFACES
83  //------------------------------------------------------
84  //-- SHL / Mmio Interface
85  CmdBit sMMIO_USIF_Enable;
86  //-- UOE->MMIO / Ready Signal
87  StsBit sUOE_MMIO_Ready;
88  //------------------------------------------------------
89  //-- DUT STREAM INTERFACES
90  //------------------------------------------------------
91  //-- UAF->USIF / UDP Tx Data Interface
92  stream<UdpAppData> ssUAF_USIF_Data ("ssUAF_USIF_Data");
93  stream<UdpAppMeta> ssUAF_USIF_Meta ("ssUAF_USIF_Meta");
94  stream<UdpAppDLen> ssUAF_USIF_DLen ("ssUAF_USIF_DLen");
95  //-- USIF->UOE / UDP Tx Data Interface
96  stream<UdpAppData> ssUSIF_UOE_Data ("ssUSIF_UOE_Data");
97  stream<UdpAppMeta> ssUSIF_UOE_Meta ("ssUSIF_UOE_Meta");
98  stream<UdpAppDLen> ssUSIF_UOE_DLen ("ssUSIF_UOE_DLen");
99  //-- UOE->USIF / UDP Rx Data Interface
100  stream<UdpAppData> ssUOE_USIF_Data ("ssUOE_USIF_Data");
101  stream<UdpAppMeta> ssUOE_USIF_Meta ("ssUOE_USIF_Meta");
102  stream<UdpAppDLen> ssUOE_USIF_DLen ("ssUOE_USIF_DLen");
103  //-- USIF->UAF / UDP Rx Data Interface
104  stream<UdpAppData> ssUSIF_UAF_Data ("ssUSIF_UAF_Data");
105  stream<UdpAppMeta> ssUSIF_UAF_Meta ("ssUSIF_UAF_Meta");
106  stream<UdpAppDLen> ssUSIF_UAF_DLen ("ssUSIF_UAF_DLen");
107  //-- UOE / Control Port Interfaces
108  stream<UdpPort> ssUSIF_UOE_LsnReq ("ssUSIF_UOE_LsnReq");
109  stream<StsBool> ssUOE_USIF_LsnRep ("ssUOE_USIF_LsnRep");
110  stream<UdpPort> ssUSIF_UOE_ClsReq ("ssUSIF_UOE_ClsReq");
111  stream<StsBool> ssUOE_USIF_ClsRep ("ssUOE_USIF_ClsRep");
112 
113  //------------------------------------------------------
114  //-- TESTBENCH VARIABLES
115  //------------------------------------------------------
116  int nrErr = 0; // Total number of testbench errors
117  ofstream ofUOE_Data; // Data streams delivered to UOE
118  ofstream ofUOE_Meta; // Meta streams delivered to UOE
119  string ofUOE_DataName = "../../../../test/simOutFiles/soUOE_Data.dat";
120  string ofUOE_MetaName = "../../../../test/simOutFiles/soUOE_Meta.dat";
121  ofstream ofUOE_DataGold; // Data gold streams to compare with
122  ofstream ofUOE_MetaGold; // Meta gold streams to compare with
123  string ofUOE_DataGoldName = "../../../../test/simOutFiles/soUOE_DataGold.dat";
124  string ofUOE_MetaGoldName = "../../../../test/simOutFiles/soUOE_MetaGold.dat";
125 
126  const int defaultLenOfDatagramEcho = 42;
127  const int defaultDestHostIpv4Test = 0xC0A80096; // 192.168.0.150
128  const int defaultDestHostPortTest = 2718;
129  const int defaultLenOfDatagramTest = 43;
130 
131  int echoLenOfDatagram = defaultLenOfDatagramEcho;
132  ap_uint<32> testDestHostIpv4 = defaultDestHostIpv4Test;
133  ap_uint<16> testDestHostPort = defaultDestHostIpv4Test;
134  int testLenOfDatagram = defaultLenOfDatagramTest;
135 
136  //------------------------------------------------------
137  //-- PARSING THE TESBENCH ARGUMENTS
138  //------------------------------------------------------
139  if (argc >= 2) {
140  echoLenOfDatagram = atoi(argv[1]);
141  if ((echoLenOfDatagram < 1) or (echoLenOfDatagram >= 0x10000)) {
142  printFatal(THIS_NAME, "Argument 'len' is out of range [1:65535].\n");
143  return NTS_KO;
144  }
145  }
146  if (argc >= 3) {
147  if (isDottedDecimal(argv[2])) {
148  testDestHostIpv4 = myDottedDecimalIpToUint32(argv[2]);
149  }
150  else {
151  testDestHostIpv4 = atoi(argv[2]);
152  }
153  if ((testDestHostIpv4 < 0x00000000) or (testDestHostIpv4 > 0xFFFFFFFF)) {
154  printFatal(THIS_NAME, "Argument 'IPv4' is out of range [0x00000000:0xFFFFFFFF].\n");
155  return NTS_KO;
156  }
157  }
158  if (argc >= 4) {
159  testDestHostPort = atoi(argv[3]);
160  if ((testDestHostPort < 0x0000) or (testDestHostPort >= 0x10000)) {
161  printFatal(THIS_NAME, "Argument 'port' is out of range [0:65535].\n");
162  return NTS_KO;
163  }
164  }
165  if (argc >= 5) {
166  testLenOfDatagram = atoi(argv[4]);
167  if ((testLenOfDatagram <= 0) or (testLenOfDatagram >= 0x10000)) {
168  printFatal(THIS_NAME, "Argument 'len' is out of range [0:65535].\n");
169  return NTS_KO;
170  }
171  }
172 
173  SockAddr testSock(testDestHostIpv4, testDestHostPort);
174 
175  //------------------------------------------------------
176  //-- REMOVE PREVIOUS OLD SIM FILES and OPEN NEW ONES
177  //------------------------------------------------------
178  remove(ofUOE_DataName.c_str());
179  if (!ofUOE_Data.is_open()) {
180  ofUOE_Data.open(ofUOE_DataName.c_str(), ofstream::out);
181  if (!ofUOE_Data) {
182  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n", ofUOE_DataName.c_str());
183  return(NTS_KO);
184  }
185  }
186  remove(ofUOE_MetaName.c_str());
187  if (!ofUOE_Meta.is_open()) {
188  ofUOE_Meta.open(ofUOE_MetaName.c_str(), ofstream::out);
189  if (!ofUOE_Meta) {
190  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n", ofUOE_MetaName.c_str());
191  return(NTS_KO);
192  }
193  }
194  remove(ofUOE_DataGoldName.c_str());
195  if (!ofUOE_DataGold.is_open()) {
196  ofUOE_DataGold.open(ofUOE_DataGoldName.c_str(), ofstream::out);
197  if (!ofUOE_DataGold) {
198  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n", ofUOE_DataGoldName.c_str());
199  return(NTS_KO);
200  }
201  }
202  remove(ofUOE_MetaGoldName.c_str());
203  if (!ofUOE_MetaGold.is_open()) {
204  ofUOE_MetaGold.open(ofUOE_MetaGoldName.c_str(), ofstream::out);
205  if (!ofUOE_MetaGold) {
206  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n", ofUOE_MetaGoldName.c_str());
207  return(NTS_KO);
208  }
209  }
210 
212  "############################################################################\n");
214  "## TESTBENCH 'test_udp_shell' STARTS HERE ##\n");
216  "############################################################################\n\n");
217  if (argc > 1) {
219  "This testbench will be executed with the following parameters: \n");
220  for (int i = 1; i < argc; i++) {
221  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i - 1), argv[i]);
222  }
223  }
224 
225  //-----------------------------------------------------
226  //-- MAIN LOOP
227  //-----------------------------------------------------
228  do {
229  //-------------------------------------------------
230  //-- EMULATE SHELL/NTS/UOE
231  //-------------------------------------------------
232  pUOE(
233  nrErr,
234  ofUOE_DataGold,
235  ofUOE_Data,
236  ofUOE_MetaGold,
237  ofUOE_Meta,
238  echoLenOfDatagram,
239  testSock,
240  testLenOfDatagram,
241  //-- UOE / Ready Signal
242  &sUOE_MMIO_Ready,
243  //-- UOE->USIF / UDP Rx Data Interfaces
244  ssUOE_USIF_Data,
245  ssUOE_USIF_Meta,
246  ssUOE_USIF_DLen,
247  //-- USIF->UOE / UDP Tx Data Interfaces
248  ssUSIF_UOE_Data,
249  ssUSIF_UOE_Meta,
250  ssUSIF_UOE_DLen,
251  //-- USIF<->UOE / Listen Interfaces
252  ssUSIF_UOE_LsnReq,
253  ssUOE_USIF_LsnRep,
254  //-- USIF<->UOE / Close Interfaces
255  ssUSIF_UOE_ClsReq);
256 
257  //-------------------------------------------------
258  //-- EMULATE SHELL/MMIO
259  //-------------------------------------------------
260  pMMIO(
261  //-- UOE / Ready Signal
262  &sUOE_MMIO_Ready,
263  //-- MMIO / Enable Layer-7 (.i.e APP alias ROLE)
264  &sMMIO_USIF_Enable);
265 
266  //-------------------------------------------------
267  //-- RUN DUT
268  //-------------------------------------------------
269  udp_shell_if(
270  //-- SHELL / Mmio Interface
271  &sMMIO_USIF_Enable,
272  //-- SHELL / Control Port Interfaces
273  ssUSIF_UOE_LsnReq,
274  ssUOE_USIF_LsnRep,
275  ssUSIF_UOE_ClsReq,
276  ssUOE_USIF_ClsRep,
277  //-- SHELL / Rx Data Interfaces
278  ssUOE_USIF_Data,
279  ssUOE_USIF_Meta,
280  ssUOE_USIF_DLen,
281  //-- SHELL / Tx Data Interfaces
282  ssUSIF_UOE_Data,
283  ssUSIF_UOE_Meta,
284  ssUSIF_UOE_DLen,
285  //-- UAF / Tx Data Interfaces
286  ssUAF_USIF_Data,
287  ssUAF_USIF_Meta,
288  ssUAF_USIF_DLen,
289  //-- UAF / Rx Data Interfaces
290  ssUSIF_UAF_Data,
291  ssUSIF_UAF_Meta,
292  ssUSIF_UAF_DLen);
293 
294  //-------------------------------------------------
295  //-- EMULATE ROLE/UdpApplicationFlash (UAF)
296  //-------------------------------------------------
297  pUAF(
298  //-- USIF / Data Interface
299  ssUSIF_UAF_Data,
300  ssUSIF_UAF_Meta,
301  //-- UAF / Data Interface
302  ssUAF_USIF_Data,
303  ssUAF_USIF_Meta,
304  ssUAF_USIF_DLen);
305 
306  //------------------------------------------------------
307  //-- INCREMENT SIMULATION COUNTER
308  //------------------------------------------------------
309  stepSim();
310 
311  } while ( (gSimCycCnt < gMaxSimCycles) or gFatalError or (nrErr > 10) );
312 
313  //---------------------------------
314  //-- CLOSING OPEN FILES
315  //---------------------------------
316  ofUOE_DataGold.close();
317  ofUOE_Data.close();
318  ofUOE_MetaGold.close();
319  ofUOE_Meta.close();
320 
321  printf("-- [@%4.4d] -----------------------------\n", gSimCycCnt);
322  printf("############################################################################\n");
323  printf("## TESTBENCH 'test_udp_shell_if' ENDS HERE ##\n");
324  printf("############################################################################\n");
325 
326  //---------------------------------------------------------------
327  //-- PRINT TESTBENCH STATUS
328  //---------------------------------------------------------------
329  printf("\n");
330  printInfo(THIS_NAME, "This testbench was executed with the following parameters: \n");
331  for (int i=1; i<argc; i++) {
332  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i-1), argv[i]);
333  }
334  printf("\n");
335 
336  //---------------------------------------------------------------
337  //-- COMPARE THE RESULTS FILES WITH GOLDEN FILES
338  //---------------------------------------------------------------
339  int res = myDiffTwoFiles(std::string(ofUOE_DataName),
340  std::string(ofUOE_DataGoldName));
341  if (res) {
342  printError(THIS_NAME, "File \'%s\' does not match \'%s\'.\n", \
343  ofUOE_DataName.c_str(), ofUOE_DataGoldName.c_str());
344  nrErr += 1;
345  }
346  res = myDiffTwoFiles(std::string(ofUOE_MetaName),
347  std::string(ofUOE_MetaGoldName));
348  if (res) {
349  printError(THIS_NAME, "File \'%s\' does not match \'%s\'.\n", \
350  ofUOE_MetaName.c_str(), ofUOE_MetaGoldName.c_str());
351  nrErr += 1;
352  }
353 
354  if (nrErr) {
355  printError(THIS_NAME, "###############################################################################\n");
356  printError(THIS_NAME, "#### TESTBENCH 'test_udp_shell_if' FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
357  printError(THIS_NAME, "###############################################################################\n");
358 
359  printInfo(THIS_NAME, "FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
360  }
361  else {
362  printInfo(THIS_NAME, "#############################################################\n");
363  printInfo(THIS_NAME, "#### SUCCESSFUL END OF 'test_udp_shell_if' ####\n");
364  printInfo(THIS_NAME, "#############################################################\n");
365  }
366 
367  return(nrErr);
368 
369 }
bool gFatalError
Definition: tb_nal.cpp:152
void stepSim()
Increment the simulation counter.
Definition: test_arp.cpp:54
bool isDottedDecimal(string ipStr)
Checks if a string contains an IP address represented in dot-decimal notation.
Definition: SimNtsUtils.cpp:72
int myDiffTwoFiles(string dataFileName, string goldFileName)
Compares 2 files line-by-line, up to length of the 2nd file.
ap_uint< 32 > myDottedDecimalIpToUint32(string ipStr)
Converts an IPv4 address represented with a dotted-decimal string into an UINT32.
#define NTS_KO
Definition: nts_types.hpp:56
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
ap_uint< 1 > StsBit
Definition: nts_types.hpp:116
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
ap_uint< 1 > CmdBit
Definition: nts_types.hpp:108
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
Definition: nts_utils.hpp:208
void pMMIO(StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
Emulate the behavior of the SHELL & MMIO.
void pUAF(stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen)
Emulate the behavior of the ROLE/UdpAppFlash (UAF).
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
void udp_shell_if(CmdBit *piSHL_Mmio_En, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen)
Main process of the UDP Shell Interface (USIF).
#define THIS_NAME
void pUOE(int &nrErr, ofstream &dataGoldFile, ofstream &dataFile, ofstream &metaGoldFile, ofstream &metaFile, int echoDgrmLen, SockAddr testSock, int testDgrmLen, StsBit *poMMIO_Ready, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen, stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppDLen > &siUSIF_DLen, stream< UdpPort > &siUSIF_LsnReq, stream< StsBool > &soUSIF_LsnRep, stream< UdpPort > &siUSIF_ClsReq)
Emulate behavior of the SHELL/NTS/UDP Offload Engine (UOE).
out
Definition: test.py:12
Here is the call graph for this function:

◆ pClose()

void pClose ( CmdBit piSHL_Enable,
stream< UdpPort > &  soSHL_ClsReq,
stream< StsBool > &  siSHL_ClsRep 
)

Request the SHELL/NTS/UOE to close a previously opened port.

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[out]soSHL_ClsReqClose port request to [SHELL].
[in]siSHL_ClsRepClose port reply from [SHELL].

Definition at line 227 of file udp_shell_if.cpp.

231 {
232  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
233  #pragma HLS INLINE off
234  #pragma HLS PIPELINE II=1 enable_flush
235 
236  const char *myName = concat3(THIS_NAME, "/", "CLs");
237 
238  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
239  static enum FsmStates { CLS_IDLE, CLS_SEND_REQ, CLS_WAIT_REP, CLS_DONE } \
240  cls_fsmState=CLS_IDLE;
241  #pragma HLS reset variable=cls_fsmState
242 
243  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
244 
245  switch (cls_fsmState) {
246  case CLS_IDLE:
247  if (*piSHL_Enable != 1) {
248  if (!siSHL_ClsRep.empty()) {
249  // Drain any potential status data
250  siSHL_ClsRep.read();
251  printWarn(myName, "Draining unexpected residue from the \'ClsRep\' stream.\n");
252  }
253  return;
254  }
255  else {
256  cls_fsmState = CLS_SEND_REQ;
257  }
258  break;
259  case CLS_SEND_REQ:
260  if (!soSHL_ClsReq.full()) {
261  // [FIXME-Must take the port # from a CfgReg] - DEFAULT_FPGA_LSN_PORT;
262  // In the mean time, close a fake port to avoid the logic to be synthesized away.
263  UdpPort udpClosePort = 0xDEAD;
264  soSHL_ClsReq.write(udpClosePort);
265  if (DEBUG_LEVEL & TRACE_CLS) {
266  printInfo(myName, "SHELL/NTS/USIF is requesting to close port #%d (0x%4.4X).\n",
267  udpClosePort.to_int(), udpClosePort.to_int());
268  }
269  cls_fsmState = CLS_WAIT_REP;
270  }
271  else {
272  printWarn(myName, "Cannot send a listen port request to [UOE] because stream is full!\n");
273  }
274  break;
275  case CLS_WAIT_REP:
276  if (!siSHL_ClsRep.empty()) {
277  StsBool isOpened;
278  siSHL_ClsRep.read(isOpened);
279  if (not isOpened) {
280  printInfo(myName, "Received close acknowledgment from [UOE].\n");
281  cls_fsmState = CLS_DONE;
282  }
283  else {
284  printWarn(myName, "UOE denied closing the port %d (0x%4.4X) which is still opened.\n",
286  cls_fsmState = CLS_SEND_REQ;
287  }
288  }
289  break;
290  case CLS_DONE:
291  break;
292  }
293 } // End-of: pClose()
bool StsBool
Definition: nal.hpp:246
ap_uint< 16 > UdpPort
Definition: nal.hpp:249
@ CLS_IDLE
Definition: nal.hpp:162
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
#define DEFAULT_FPGA_LSN_PORT
#define TRACE_CLS
#define DEBUG_LEVEL
Here is the caller graph for this function:

◆ pListen()

void pListen ( CmdBit piSHL_Enable,
stream< UdpPort > &  soSHL_LsnReq,
stream< StsBool > &  siSHL_LsnRep 
)

Listen(LSn)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[out]soSHL_LsnReqListen port request to [SHELL].
[in]siSHL_LsnRepListen reply from [SHELL].

This process requests the SHELL/NTS/UOE to open a specific port in receive mode. Although the notion of 'listening' does not exist for unconnected UDP mode, we keep that name for this process because it puts an FPGA receive port on hold and ready accept incoming traffic (.i.e, it opens a connection in server mode). By default, the port numbers 5001, 5201, 8800, 8801 and 8803 will always be opened in listen mode at startup. Later on, we should be able to open more ports if we provide some configuration register for the user to specify new ones. As opposed to the TCP Offload engine (TOE), the UOE supports a total of 65,535 (0xFFFF) connections in listening mode.

Definition at line 104 of file udp_shell_if.cpp.

108 {
109  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
110  #pragma HLS INLINE off
111  #pragma HLS PIPELINE II=1 enable_flush
112 
113  const char *myName = concat3(THIS_NAME, "/", "LSn");
114 
115  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
116  static enum FsmStates { LSN_IDLE, LSN_SEND_REQ, LSN_WAIT_REP, LSN_DONE } \
117  lsn_fsmState=LSN_IDLE;
118  #pragma HLS reset variable=lsn_fsmState
119  static ap_uint<3> lsn_i = 0;
120  #pragma HLS reset variable=lsn_i
121 
122  //-- STATIC ARRAYS --------------------------------------------------------
123  static const UdpPort LSN_PORT_TABLE[6] = { RECV_MODE_LSN_PORT, XMIT_MODE_LSN_PORT,
126  #pragma HLS RESOURCE variable=LSN_PORT_TABLE core=ROM_1P
127 
128  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
129  static ap_uint<8> lsn_watchDogTimer;
130 
131  switch (lsn_fsmState) {
132  case LSN_IDLE:
133  if (*piSHL_Enable != 1) {
134  return;
135  }
136  else {
137  if (lsn_i == 0) {
138  lsn_fsmState = LSN_SEND_REQ;
139  }
140  else {
141  //-- Port are already opened
142  lsn_fsmState = LSN_DONE;
143  }
144  }
145  break;
146  case LSN_SEND_REQ:
147  if (!soSHL_LsnReq.full()) {
148  switch (lsn_i) {
149  case 0:
150  soSHL_LsnReq.write(RECV_MODE_LSN_PORT);
151  break;
152  case 1:
153  soSHL_LsnReq.write(XMIT_MODE_LSN_PORT);
154  break;
155  case 2:
156  soSHL_LsnReq.write(ECHO_MOD2_LSN_PORT);
157  break;
158  case 3:
159  soSHL_LsnReq.write(ECHO_MODE_LSN_PORT);
160  break;
161  case 4:
162  soSHL_LsnReq.write(IPERF_LSN_PORT);
163  break;
164  case 5:
165  soSHL_LsnReq.write(IPREF3_LSN_PORT);
166  break;
167  }
168  if (DEBUG_LEVEL & TRACE_LSN) {
169  printInfo(myName, "Server is requested to listen on port #%d (0x%4.4X).\n",
170  LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
171  }
172  #ifndef __SYNTHESIS__
173  lsn_watchDogTimer = 10;
174  #else
175  lsn_watchDogTimer = 100;
176  #endif
177  lsn_fsmState = LSN_WAIT_REP;
178  }
179  else {
180  printWarn(myName, "Cannot send a listen port request to [UOE] because stream is full!\n");
181  }
182  break;
183  case LSN_WAIT_REP:
184  lsn_watchDogTimer--;
185  if (!siSHL_LsnRep.empty()) {
186  UdpAppLsnRep listenDone;
187  siSHL_LsnRep.read(listenDone);
188  if (listenDone) {
189  printInfo(myName, "Received OK listen reply from [UOE] for port %d.\n", LSN_PORT_TABLE[lsn_i].to_uint());
190  if (lsn_i == sizeof(LSN_PORT_TABLE)/sizeof(LSN_PORT_TABLE[0])-1) {
191  lsn_fsmState = LSN_DONE;
192  }
193  else {
194  //-- Set next listen port number
195  lsn_i += 1;
196  lsn_fsmState = LSN_SEND_REQ;
197  }
198  }
199  else {
200  printWarn(myName, "UOE denied listening on port %d (0x%4.4X).\n",
201  LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
202  lsn_fsmState = LSN_SEND_REQ;
203  }
204  }
205  else {
206  if (lsn_watchDogTimer == 0) {
207  printError(myName, "Timeout: Server failed to listen on port %d %d (0x%4.4X).\n",
208  LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
209  //-- Try next listen port number
210  lsn_i += 1;
211  lsn_fsmState = LSN_SEND_REQ;
212  }
213  }
214  break;
215  case LSN_DONE:
216  break;
217  } // End-of: switch()
218 } // End-of: pListen()
@ LSN_IDLE
Definition: nal.hpp:146
@ LSN_SEND_REQ
Definition: nal.hpp:146
@ LSN_DONE
Definition: nal.hpp:146
StsBool UdpAppLsnRep
Definition: nts.hpp:259
#define RECV_MODE_LSN_PORT
#define XMIT_MODE_LSN_PORT
#define ECHO_MOD2_LSN_PORT
#define IPERF_LSN_PORT
#define IPREF3_LSN_PORT
#define ECHO_MODE_LSN_PORT
#define TRACE_LSN
Here is the caller graph for this function:

◆ pMMIO()

void pMMIO ( StsBit piSHL_Ready,
CmdBit poUSIF_Enable 
)

Emulate the behavior of the SHELL & MMIO.

Parameters
[in]piSHL_ReadyReady Signal from [SHELL].
[out]poUSIF_EnableEnable signal to USIF.

Definition at line 163 of file simu_udp_shell_if_env.cpp.

168 {
169  const char *myName = concat3(THIS_NAME, "/", "MMIO");
170 
171  static bool mmio_printOnce = true;
172 
173  if (*piSHL_Ready) {
174  *poUSIF_Enable = 1;
175  if (mmio_printOnce) {
176  printInfo(myName, "[SHELL/NTS/UOE] is ready -> Enabling operation of the UDP Shell Interface (USIF).\n");
177  mmio_printOnce = false;
178  }
179  }
180  else {
181  *poUSIF_Enable = 0;
182  }
183 }

◆ pReadPath()

void pReadPath ( CmdBit piSHL_Enable,
stream< UdpAppData > &  siSHL_Data,
stream< UdpAppMeta > &  siSHL_Meta,
stream< UdpAppDLen > &  siSHL_DLen,
stream< UdpAppData > &  soUAF_Data,
stream< UdpAppMeta > &  soUAF_Meta,
stream< UdpAppDLen > &  soUAF_DLen,
stream< SocketPair > &  soWRp_SockPair,
stream< UdpAppDLen > &  soWRp_DReq 
)

Read Path (RDp) - From SHELL/UOE to ROLE/UAF.

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siSHL_DataDatagram from [SHELL].
[in]siSHL_MetaMetadata from [SHELL].
[in]siSHL_DLendata len from [SHELL].
[out]soUAF_DataDatagram to [UAF].
[out]soUAF_MetaMetadata to [UAF].
[out]soUAF_DLendata len to [UAF].
[out]soWRp_MetaMetadata to WritePath (WRp).
[out]soWRp_DReqData length request to [WRp].

This process waits for a new metadata to read and performs 3 possibles tasks depending on the value of the UDP destination port. 1) If DstPort==8800, the incoming datagram is dumped. This mode is used to the UOE in receive mode. 2) If DstPort==8801, it extract the address of the remote socket to connect to as well as the number of bytes to transmit, out of the 64 first incoming bits of the data stream. Next, it sends these 3 fields to the the TxWritePath (WRp) which will start sending this amount of bytes to the specified destination socket. 3) Otherwise, incoming metadata and data are forwarded to the UAF.

Definition at line 321 of file udp_shell_if.cpp.

331 {
332  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
333  #pragma HLS INLINE off
334  #pragma HLS PIPELINE II=1 enable_flush
335 
336  const char *myName = concat3(THIS_NAME, "/", "RDp");
337 
338  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
339  static enum FsmStates { RDP_IDLE=0, RDP_FWD_META, RDP_FWD_STREAM, RDP_SINK_STREAM, RDP_8801 } \
340  rdp_fsmState = RDP_IDLE;
341  #pragma HLS reset variable=rdp_fsmState
342 
343  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
344  static UdpAppMeta rdp_appMeta;
345  static UdpAppDLen rdp_appDLen;
346 
347  //-- DYNAMIC VARIABLES -----------------------------------------------------
348  UdpAppData appData;
349 
350  if (*piSHL_Enable != 1) {
351  return;
352  }
353 
354  switch (rdp_fsmState ) {
355  case RDP_IDLE:
356  if (!siSHL_Meta.empty() and !siSHL_DLen.empty()) {
357  siSHL_Meta.read(rdp_appMeta);
358  siSHL_DLen.read(rdp_appDLen);
359  switch (rdp_appMeta.udpDstPort) {
360  case RECV_MODE_LSN_PORT:
361  // (DstPort == 8800) Sink this traffic stream
362  if (DEBUG_LEVEL & TRACE_RDP) { printInfo(myName, "Entering Rx test mode (DstPort=%4.4d)\n", rdp_appMeta.udpDstPort.to_uint()); }
363  rdp_fsmState = RDP_SINK_STREAM;
364  break;
365  case XMIT_MODE_LSN_PORT:
366  // (DstPort == 8801) Enter the Tx test mode
367  if (DEBUG_LEVEL & TRACE_RDP) { printInfo(myName, "Entering Tx test mode (DstPort=%4.4d)\n", rdp_appMeta.udpDstPort.to_uint()); }
368  rdp_fsmState = RDP_8801;
369  break;
370  default:
371  // Forward the incoming stream to [TAF]
372  rdp_fsmState = RDP_FWD_META;
373  break;
374  }
375  }
376  break;
377  case RDP_FWD_META:
378  if (!soUAF_Meta.full() and !soUAF_DLen.full()) {
379  soUAF_Meta.write(rdp_appMeta);
380  soUAF_DLen.write(rdp_appDLen);
381  rdp_fsmState = RDP_FWD_STREAM;
382  }
383  break;
384  case RDP_FWD_STREAM:
385  if (!siSHL_Data.empty() and !soUAF_Data.full()) {
386  siSHL_Data.read(appData);
387  soUAF_Data.write(appData);
388  if (appData.getLE_TLast()) {
389  rdp_fsmState = RDP_IDLE;
390  }
391  if (DEBUG_LEVEL & TRACE_RDP) { printAxisRaw(myName, "soUAF_Data =", appData); }
392  }
393  break;
394  case RDP_SINK_STREAM:
395  if (!siSHL_Data.empty()) {
396  siSHL_Data.read(appData);
397  if (appData.getLE_TLast()) {
398  rdp_fsmState = RDP_IDLE;
399  }
400  if (DEBUG_LEVEL & TRACE_RDP) { printAxisRaw(myName, "Dropping siSHL_Data =", appData); }
401  }
402  break;
403  case RDP_8801:
404  if (!siSHL_Data.empty() and !soWRp_SockPair.full() and !soWRp_DReq.full()) {
405  // Extract the remote socket address and the requested #bytes to transmit
406  siSHL_Data.read(appData);
407  SockAddr srcSockAddr(rdp_appMeta.ip4DstAddr, rdp_appMeta.udpDstPort);
408  SockAddr dstSockAddr(byteSwap32(appData.getLE_TData(31, 0)), // IP4 address
409  byteSwap16(appData.getLE_TData(47, 32))); // TCP port
410  Ly4Len bytesToSend = byteSwap16(appData.getLE_TData(63, 48));
411  // Forward socket-pair information to [WRp]
412  soWRp_SockPair.write(SocketPair(srcSockAddr, dstSockAddr));
413  // Forward the extracted number of bytes to transmit
414  soWRp_DReq.write(bytesToSend);
415  if (DEBUG_LEVEL & TRACE_RDP) {
416  printInfo(myName, "Received request for Tx test mode to generate a segment of length=%d and to send it to socket:\n",
417  bytesToSend.to_int());
418  printSockAddr(myName, dstSockAddr);
419  }
420  if (appData.getLE_TLast()) {
421  rdp_fsmState = RDP_IDLE;
422  }
423  else {
424  rdp_fsmState = RDP_SINK_STREAM;
425  }
426  }
427  }
428 } // End-of: pReadPath()
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
Ly4Port udpDstPort
Definition: nts.hpp:229
Ip4Addr ip4DstAddr
Definition: nts.hpp:228
UdpLen UdpAppDLen
Definition: nal.hpp:255
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
Definition: nts_utils.cpp:46
ap_uint< 16 > Ly4Len
Definition: nts_types.hpp:202
void printSockAddr(const char *callerName, SockAddr sockAddr)
Print a socket address.
Definition: nts_utils.cpp:174
#define TRACE_RDP
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
Definition: udp.cpp:78
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)
Definition: udp.cpp:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pUAF()

void pUAF ( stream< UdpAppData > &  siUSIF_Data,
stream< UdpAppMeta > &  siUSIF_Meta,
stream< UdpAppData > &  soUSIF_Data,
stream< UdpAppMeta > &  soUSIF_Meta,
stream< UdpAppDLen > &  soUSIF_DLen 
)

Emulate the behavior of the ROLE/UdpAppFlash (UAF).

Parameters
[in]siUSIF_DataData from UdpShellInterface (USIF).
[in]siUSIF_MetaMetadata from [USIF].
[out]soUSIF_DataData to [USIF].
[out]soUSIF_MetaMetadata to [USIF].
[out]soUSIF_DLenData len to [USIF].

ALWAYS READ INCOMING DATA STREAM AND ECHO IT BACK. Warning: For sake of simplicity, this testbench is operated in streaming mode by setting the 'DLen' interface to zero.

SIMULATION ENVIRONMENT FUNCTIONS

Definition at line 111 of file simu_udp_shell_if_env.cpp.

119 {
120 
121  const char *myRxName = concat3(THIS_NAME, "/", "UAF-Rx");
122  const char *myTxName = concat3(THIS_NAME, "/", "UAF-Tx");
123 
124  static enum RxFsmStates { RX_IDLE=0, RX_STREAM } uaf_rxFsmState=RX_IDLE;
125 
126  UdpAppData appData;
127  UdpAppMeta appMeta;
128 
129  switch (uaf_rxFsmState ) {
130  case RX_IDLE:
131  if (!siUSIF_Meta.empty() and !soUSIF_Meta.full()) {
132  siUSIF_Meta.read(appMeta);
133  // Swap IP_SA/IP_DA and update UPD_SP/UDP_DP
134  UdpAppMeta swappedMeta(appMeta.ip4DstAddr, DEFAULT_FPGA_SND_PORT,
136  soUSIF_Meta.write(swappedMeta);
137  soUSIF_DLen.write(0);
138  uaf_rxFsmState = RX_STREAM;
139  }
140  break;
141  case RX_STREAM:
142  if (!siUSIF_Data.empty() and !soUSIF_Data.full()) {
143  siUSIF_Data.read(appData);
144  if (DEBUG_LEVEL & TRACE_UAF) {
145  printAxisRaw(myRxName, "Received data: ", appData);
146  }
147  soUSIF_Data.write(appData);
148  if (appData.getTLast()) {
149  uaf_rxFsmState = RX_IDLE;
150  }
151  }
152  break;
153  }
154 }
tLast getTLast() const
Definition: AxisRaw.hpp:219
Ip4Addr ip4SrcAddr
Definition: nts.hpp:226
#define DEFAULT_HOST_LSN_PORT
Definition: tb_nal.cpp:73
RxFsmStates
Definition: tb_nal.cpp:681
@ RX_STREAM
Definition: tb_nal.cpp:681
#define DEFAULT_FPGA_SND_PORT
#define TRACE_UAF
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pUOE()

void pUOE ( int &  nrErr,
ofstream &  dataGoldFile,
ofstream &  dataFile,
ofstream &  metaGoldFile,
ofstream &  metaFile,
int  echoDgrmLen,
SockAddr  testSock,
int  testDgrmLen,
StsBit poMMIO_Ready,
stream< UdpAppData > &  soUSIF_Data,
stream< UdpAppMeta > &  soUSIF_Meta,
stream< UdpAppDLen > &  soUSIF_DLen,
stream< UdpAppData > &  siUSIF_Data,
stream< UdpAppMeta > &  siUSIF_Meta,
stream< UdpAppDLen > &  siUSIF_DLen,
stream< UdpPort > &  siUSIF_LsnReq,
stream< StsBool > &  soUSIF_LsnRep,
stream< UdpPort > &  siUSIF_ClsReq 
)

Emulate behavior of the SHELL/NTS/UDP Offload Engine (UOE).

Parameters
[in]nrErrA ref to the error counter of main.
[in]dataGoldFileA ref to the file storing the DUT gold data.
[in]dataFileA ref to the file storing the DUT output data.
[in]metaGoldFileA ref to the file storing the DUT gold meta.
[in]metaFileA ref to the file storing the DUT output meta.
[in]dgrmLenThe length of the test datatagram to generate.
[out]poMMIO_ReadyReady signal to [MMIO].
[out]soUSIF_DataThe UDP datagram to [USIF].
[out]soUSIF_MetaThe UDP metadata to [USIF].
[out]soUSIF_DLenThe UDP data len to [USIF].
[in]siUSIF_DataThe UDP datagram from [USIF].
[in]siUSIF_MetaThe UDP metadata from [USIF].
[in]siUSIF_DLenThe UDP data len from [USIF].
[in]siUSIF_LsnReqThe listen port request from [USIF].
[out]soUSIF_LsnRepThe listen port reply to [USIF].
[in]siUSIF_ClsReqThe close port request from [USIF].

Definition at line 206 of file simu_udp_shell_if_env.cpp.

230 {
231 
232  static enum LsnStates { LSN_WAIT_REQ, LSN_SEND_REP } uoe_lsnState = LSN_WAIT_REQ;
233  static enum RxpStates { RXP_SEND_META, RXP_SEND_DATA, \
234  RXP_SEND_8801, RXP_DONE } uoe_rxpState = RXP_SEND_META;
235  static enum TxpStates { TXP_WAIT_META, TXP_RECV_DATA } uoe_txpState = TXP_WAIT_META;
236 
237  static int uoe_startupDelay = cUoeInitCycles;
238  static int uoe_rxpStartupDelay = 50; // Wait until all the listen port are opened
239  static int uoe_txpStartupDelay = 0;
240  static bool uoe_isReady = false;
241  static bool uoe_rxpIsReady = false;
242  static bool uoe_txpIsReady = false;
243 
244  const char *myLsnName = concat3(THIS_NAME, "/", "UOE/Listen");
245  const char *myRxpName = concat3(THIS_NAME, "/", "UOE/RxPath");
246  const char *myTxpName = concat3(THIS_NAME, "/", "UOE/TxPath");
247 
248  //------------------------------------------------------
249  //-- FSM #0 - STARTUP DELAYS
250  //------------------------------------------------------
251  if (uoe_startupDelay) {
252  *poMMIO_Ready = 0;
253  uoe_startupDelay--;
254  }
255  else {
256  *poMMIO_Ready = 1;
257  if (uoe_rxpStartupDelay)
258  uoe_rxpStartupDelay--;
259  else
260  uoe_rxpIsReady = true;
261  if (uoe_txpStartupDelay)
262  uoe_txpStartupDelay--;
263  else
264  uoe_txpIsReady = true;
265  }
266 
267  //------------------------------------------------------
268  //-- FSM #1 - LISTENING
269  //------------------------------------------------------
270  static UdpPort uoe_lsnPortReq;
271  switch (uoe_lsnState) {
272  case LSN_WAIT_REQ: // CHECK IF A LISTENING REQUEST IS PENDING
273  if (!siUSIF_LsnReq.empty()) {
274  siUSIF_LsnReq.read(uoe_lsnPortReq);
275  printInfo(myLsnName, "Received a listen port request #%d from [USIF].\n",
276  uoe_lsnPortReq.to_int());
277  uoe_lsnState = LSN_SEND_REP;
278  }
279  break;
280  case LSN_SEND_REP: // SEND REPLY BACK TO [USIF]
281  if (!soUSIF_LsnRep.full()) {
282  soUSIF_LsnRep.write(OK);
283  uoe_lsnState = LSN_WAIT_REQ;
284  }
285  else {
286  printWarn(myLsnName, "Cannot send listen reply back to [USIF] because stream is full.\n");
287  }
288  break;
289  } // End-of: switch (uoe_lsnState) {
290 
291  //------------------------------------------------------
292  //-- FSM #2 - RX DATA PATH
293  //------------------------------------------------------
294  UdpAppData appData;
295  static UdpAppMeta uoe_rxMeta;
296  static int uoe_rxByteCnt;
297  static Ly4Len uoe_txByteCnt;
298  static int uoe_dgmCnt=0;
299  static int uoe_waitEndOfTxTest=0;
300  const int nrDgmToSend=7;
301  if (uoe_rxpIsReady) {
302  switch (uoe_rxpState) {
303  case RXP_SEND_META: // SEND METADATA TO [USIF]
304  if (!soUSIF_Meta.full() and !soUSIF_DLen.full()) {
305  if (uoe_waitEndOfTxTest) {
306  // Give USIF the time to finish sending all the requested bytes
307  uoe_waitEndOfTxTest--;
308  }
309  else if (uoe_dgmCnt == nrDgmToSend) {
310  uoe_rxpState = RXP_DONE;
311  }
312  else {
313  uoe_rxMeta.ip4SrcAddr = DEFAULT_HOST_IP4_ADDR;
314  uoe_rxMeta.udpSrcPort = DEFAULT_HOST_SND_PORT;
315  uoe_rxMeta.ip4DstAddr = DEFAULT_FPGA_IP4_ADDR;
316  switch (uoe_dgmCnt) {
317  case 1:
318  case 3:
319  uoe_rxMeta.udpDstPort = RECV_MODE_LSN_PORT;
320  uoe_rxByteCnt = echoDgrmLen;
321  gMaxSimCycles += (echoDgrmLen / 8);
322  uoe_waitEndOfTxTest = 0;
323  uoe_rxpState = RXP_SEND_DATA;
324  break;
325  case 2:
326  case 4:
327  uoe_rxMeta.udpDstPort = XMIT_MODE_LSN_PORT;
328  uoe_txByteCnt = testDgrmLen;
329  gMaxSimCycles += (testDgrmLen / 8);
330  uoe_waitEndOfTxTest = (testDgrmLen / 8) + 1;
331  uoe_rxpState = RXP_SEND_8801;
332  break;
333  default:
334  uoe_rxMeta.udpDstPort = ECHO_MODE_LSN_PORT;
335  uoe_rxByteCnt = echoDgrmLen;
336  gMaxSimCycles += (echoDgrmLen / 8);
337  uoe_waitEndOfTxTest = 0;
338  uoe_rxpState = RXP_SEND_DATA;
339  // Swap IP_SA/IP_DA and update UPD_SP/UDP_DP
340  SocketPair udpGldMeta(SockAddr(uoe_rxMeta.ip4DstAddr, DEFAULT_FPGA_SND_PORT),
342  // Dump this socket pair to a gold file
343  writeSocketPairToFile(udpGldMeta, metaGoldFile);
344  break;
345  }
346  soUSIF_Meta.write(uoe_rxMeta);
347  soUSIF_DLen.write(uoe_rxByteCnt);
348  if (DEBUG_LEVEL & TRACE_UOE) {
349  printInfo(myRxpName, "Sending metadata to [USIF].\n");
350  SocketPair udpRxMeta(SockAddr(uoe_rxMeta.ip4SrcAddr, uoe_rxMeta.udpSrcPort),
351  SockAddr(uoe_rxMeta.ip4DstAddr, uoe_rxMeta.udpDstPort));
352  printSockPair(myRxpName, udpRxMeta);
353  }
354  uoe_dgmCnt += 1;
355  }
356  }
357  break;
358  case RXP_SEND_DATA: // FORWARD DATA TO [USIF]
359  if (!soUSIF_Data.full()) {
360  appData.setTData((random() << 32) | random()) ;
361  if (uoe_rxByteCnt > 8) {
362  appData.setTKeep(0xFF);
363  appData.setTLast(0);
364  uoe_rxByteCnt -= 8;
365  }
366  else {
367  appData.setTKeep(lenTotKeep(uoe_rxByteCnt));
368  appData.setTLast(TLAST);
369  uoe_rxpState = RXP_SEND_META;
370  }
371  soUSIF_Data.write(appData);
372  if (DEBUG_LEVEL & TRACE_UOE) {
373  printAxisRaw(myRxpName, "Sending data chunk to [USIF]: ", appData);
374  }
375  if (uoe_rxMeta.udpDstPort != RECV_MODE_LSN_PORT) {
376  writeAxisRawToFile(appData, dataGoldFile);
377  }
378  }
379  break;
380  case RXP_SEND_8801: // FORWARD TX DATA LENGTH REQUEST TO [USIF]
381  if (!soUSIF_Data.full()) {
382  printInfo(myRxpName, "Requesting Tx test mode to generate a datagram of length=%d and to send it to socket: \n",
383  uoe_txByteCnt.to_uint());
384  printSockAddr(myRxpName, testSock);
385  appData.setLE_TData(byteSwap32(testSock.addr), 31, 0);
386  appData.setLE_TData(byteSwap16(testSock.port), 47, 32);
387  appData.setLE_TData(byteSwap16(uoe_txByteCnt), 63, 48);
388  appData.setLE_TKeep(0xFF);
389  appData.setLE_TLast(TLAST);
390  soUSIF_Data.write(appData);
391  if (DEBUG_LEVEL & TRACE_UOE) {
392  printAxisRaw(myRxpName, "Sending Tx data length request to [USIF]: ", appData);
393  }
394  //-- Update the Meta-Gold File
395  SocketPair udpGldMeta(SockAddr(DEFAULT_FPGA_IP4_ADDR, uoe_rxMeta.udpDstPort),
396  SockAddr(testSock.addr, testSock.port));
397  // Dump this socket pair to a gold file
398  writeSocketPairToFile(udpGldMeta, metaGoldFile);
399  //-- Update the Data-Gold File
400  bool firstChunk=true;
401  int txByteReq = uoe_txByteCnt;
402  while (txByteReq) {
403  UdpAppData goldChunk(0,0,0);
404  if (firstChunk) {
405  for (int i=0; i<8; i++) {
406  if (txByteReq) {
407  unsigned char byte = (GEN_CHK0 >> ((7-i)*8)) & 0xFF;
408  goldChunk.setLE_TData(byte, (i*8)+7, (i*8)+0);
409  goldChunk.setLE_TKeep(1, i, i);
410  txByteReq--;
411  }
412  }
413  firstChunk = !firstChunk;
414  }
415  else { // Second Chunk
416  for (int i=0; i<8; i++) {
417  if (txByteReq) {
418  unsigned char byte = (GEN_CHK1 >> ((7-i)*8)) & 0xFF;
419  goldChunk.setLE_TData(byte, (i*8)+7, (i*8)+0);
420  goldChunk.setLE_TKeep(1, i, i);
421  txByteReq--;
422  }
423  }
424  firstChunk = !firstChunk;
425  }
426  if (txByteReq == 0) {
427  goldChunk.setLE_TLast(TLAST);
428  }
429  writeAxisRawToFile(goldChunk, dataGoldFile);
430  }
431  uoe_rxpState = RXP_SEND_META;
432  }
433  break;
434  case RXP_DONE: // END OF THE RX PATH SEQUENCE
435  // ALL DATAGRAMS HAVE BEEN SENT
436  uoe_rxpState = RXP_DONE;
437  break;
438  } // End-of: switch())
439  }
440 
441  //------------------------------------------------------
442  //-- FSM #3 - TX DATA PATH
443  //-- (Always drain the data coming from [USIF])
444  //------------------------------------------------------
445  static UdpAppDLen uoe_appDLen;
446  if (uoe_txpIsReady) {
447  switch (uoe_txpState) {
448  case TXP_WAIT_META:
449  if (!siUSIF_Meta.empty() and !siUSIF_DLen.empty()) {
450  UdpAppMeta appMeta;
451  UdpAppDLen appDLen;
452  siUSIF_Meta.read(appMeta);
453  siUSIF_DLen.read(uoe_appDLen);
454  if (DEBUG_LEVEL & TRACE_UOE) {
455  if (uoe_appDLen == 0) {
456  printInfo(myTxpName, "This UDP Tx datagram is forwarded in streaming mode (DLen=0).\n");
457  }
458  else {
459  printInfo(myTxpName, "Receiving %d bytes of data from [USIF].\n", uoe_appDLen.to_int());
460  }
462  SockAddr(appMeta.ip4DstAddr, appMeta.udpDstPort)));
463  }
464  SocketPair appTxMeta(SockAddr(appMeta.ip4SrcAddr, appMeta.udpSrcPort),
465  SockAddr(appMeta.ip4DstAddr, appMeta.udpDstPort));
466  writeSocketPairToFile(appTxMeta, metaFile);
467  uoe_txpState = TXP_RECV_DATA;
468  }
469  break;
470  case TXP_RECV_DATA:
471  if (!siUSIF_Data.empty()) {
472  UdpAppData appData;
473  siUSIF_Data.read(appData);
474  writeAxisRawToFile(appData, dataFile);
475  if (uoe_appDLen != 0) {
476  uoe_appDLen -= appData.getLen();
477  }
478  if (DEBUG_LEVEL & TRACE_UOE) {
479  printAxisRaw(myTxpName, "Received data chunk from [USIF] ", appData);
480  }
481  if (appData.getTLast()) {
482  uoe_txpState = TXP_WAIT_META;
483  if (uoe_appDLen != 0) {
484  printWarn(myTxpName, "TLAST is set but DLen != 0.\n");
485  }
486  }
487  }
488  break;
489  }
490  }
491 }
void setTLast(tLast last)
Definition: AxisRaw.hpp:246
void setLE_TLast(LE_tLast last)
Definition: AxisRaw.hpp:280
void setLE_TData(LE_tData data, int leHi=64 -1, int leLo=0)
Definition: AxisRaw.hpp:272
void setTKeep(tKeep keep)
Definition: AxisRaw.hpp:239
int getLen() const
Definition: AxisRaw.hpp:411
void setTData(tData data)
Definition: AxisRaw.hpp:228
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
Definition: AxisRaw.hpp:276
Ip4Addr addr
Definition: nts_types.hpp:209
Ly4Port port
Definition: nts_types.hpp:210
Ly4Port udpSrcPort
Definition: nts.hpp:227
const char * myRxpName
Definition: tb_nal.cpp:837
const char * myTxpName
Definition: tb_nal.cpp:838
RxpStates
Definition: tb_nal.cpp:818
TxpStates
Definition: tb_nal.cpp:819
const char * myLsnName
Definition: tb_nal.cpp:835
#define DEFAULT_HOST_IP4_ADDR
Definition: tb_nal.cpp:72
LsnStates
Definition: tb_nal.cpp:816
#define DEFAULT_FPGA_IP4_ADDR
Definition: tb_nal.cpp:70
@ RXP_SEND_DATA
Definition: tb_nal.cpp:818
@ RXP_SEND_META
Definition: tb_nal.cpp:818
@ RXP_DONE
Definition: tb_nal.cpp:818
@ TXP_RECV_DATA
Definition: tb_nal.cpp:819
@ LSN_WAIT_REQ
Definition: tb_nal.cpp:816
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
bool writeSocketPairToFile(SocketPair &socketPair, ofstream &outFileStream)
Dump a SocketPair to a file.
#define DEFAULT_HOST_SND_PORT
tKeep lenTotKeep(ap_uint< 4 > noValidBytes)
A function to set a number of '1' in an 8-bit field. It is used here to set the number of valid bytes...
Definition: nts_utils.cpp:328
#define OK
Definition: nts_types.hpp:57
void printSockPair(const char *callerName, SocketPair sockPair)
Print a socket pair association.
Definition: nts_utils.cpp:114
#define TLAST
Definition: AxisRaw.hpp:116
#define GEN_CHK0
#define GEN_CHK1
const int cUoeInitCycles
#define TRACE_UOE
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pWritePath()

void pWritePath ( CmdBit piSHL_Enable,
stream< UdpAppData > &  siUAF_Data,
stream< UdpAppMeta > &  siUAF_Meta,
stream< UdpAppDLen > &  siUAF_DLen,
stream< SocketPair > &  siRDp_SockPair,
stream< UdpAppDLen > &  siRDp_DReq,
stream< UdpAppData > &  soSHL_Data,
stream< UdpAppMeta > &  soSHL_Meta,
stream< UdpAppDLen > &  soSHL_DLen 
)

Write Path (WRp) - From ROLE/UAF to SHELL/NTS/UOE.

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siUAF_DataUDP datagram from [ROLE/UAF].
[in]siUAF_MetaUDP metadata from [ROLE/UAF]. @Param[in] siUAF_DLen UDP data len from [ROLE/UAF].
[out]siRDp_MetaMetadata from ReadPath (RDp).
[out]siRDp_DReqData length request from [RDp].
[out]soSHL_DataUDP datagram to [SHELL].
[out]soSHL_MetaUDP metadata to [SHELL].
[in]soSHL_DLenUDP data len to [SHELL].

This process waits for a new datagram to arrive from the UadpAppFlash (UAF) and forwards it to SHELL. Alternatively, if a TX test trigger by the ReadPath (RDp), this process will generate a datagram of the specified length and forward it to the producer of this request. This mode is used to test the UOE in transmit mode.

Definition at line 451 of file udp_shell_if.cpp.

461 {
462  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
463  #pragma HLS INLINE off
464  #pragma HLS PIPELINE II=1 enable_flush
465 
466  const char *myName = concat3(THIS_NAME, "/", "WRp");
467 
468  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
469  static enum FsmStates { WRP_IDLE=0, WRP_STREAM, WRP_8801 } \
470  wrp_fsmState=WRP_IDLE;
471  #pragma HLS reset variable=wrp_fsmState
472  static enum GenChunks { CHK0=0, CHK1, } \
473  wrp_genChunk=CHK0;
474  #pragma HLS reset variable=wrp_genChunk
475 
476  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
477  static UdpAppDLen wrp_appDReq;
478 
479  //-- DYNAMIC VARIABLES -----------------------------------------------------
480  UdpAppMeta appMeta;
481  SocketPair tstSockPair;
482  UdpAppDLen appDLen;
483  UdpAppData appData;
484 
485  if (*piSHL_Enable != 1) {
486  return;
487  }
488 
489  switch (wrp_fsmState) {
490  case WRP_IDLE:
491  //-- Always give priority to the Tx test generator (for testing reasons)
492  if (!siRDp_SockPair.empty() and !siRDp_DReq.empty() and
493  !soSHL_Meta.full() and !soSHL_DLen.full()) {
494  siRDp_SockPair.read(tstSockPair);
495  siRDp_DReq.read(wrp_appDReq);
496  soSHL_Meta.write(tstSockPair);
497  soSHL_DLen.write(wrp_appDReq);
498  if (DEBUG_LEVEL & TRACE_WRP) {
499  printInfo(myName, "Received a Tx test request of length %d from RDp.\n", wrp_appDReq.to_uint());
500  printSockPair(myName, tstSockPair);
501  }
502  if (wrp_appDReq != 0) {
503  wrp_fsmState = WRP_8801;
504  wrp_genChunk = CHK0;
505  }
506  else {
507  wrp_fsmState = WRP_IDLE;
508  }
509  }
510  else if (!siUAF_Meta.empty() and !siUAF_DLen.empty() and
511  !soSHL_Meta.full() and !soSHL_DLen.full()) {
512  //-- Read the metadata and the length provided by [ROLE/UAF]
513  siUAF_Meta.read(appMeta);
514  siUAF_DLen.read(appDLen);
515  soSHL_Meta.write(appMeta);
516  soSHL_DLen.write(appDLen);
517  if (DEBUG_LEVEL & TRACE_WRP) {
518  printInfo(myName, "Received a datagram of length %d from ROLE.\n", appDLen.to_uint());
519  printSockPair(myName, SocketPair(SockAddr(appMeta.ip4SrcAddr, appMeta.udpSrcPort),
520  SockAddr(appMeta.ip4DstAddr, appMeta.udpDstPort)));
521  }
522  wrp_fsmState = WRP_STREAM;
523  }
524 
525  break;
526  case WRP_STREAM:
527  if (!siUAF_Data.empty() and !soSHL_Data.full()) {
528  siUAF_Data.read(appData);
529  soSHL_Data.write(appData);
530  if (DEBUG_LEVEL & TRACE_WRP) { printAxisRaw(myName, "soSHL_Data = ", appData); }
531  if(appData.getTLast())
532  wrp_fsmState = WRP_IDLE;
533  }
534  break;
535  case WRP_8801:
536  if (!soSHL_Data.full()) {
537  UdpAppData currChunk(0,0,0);
538  if (wrp_appDReq > 8) {
539  currChunk.setLE_TKeep(0xFF);
540  wrp_appDReq -= 8;
541  }
542  else {
543  currChunk.setLE_TKeep(lenToLE_tKeep(wrp_appDReq));
544  currChunk.setLE_TLast(TLAST);
545  wrp_fsmState = WRP_IDLE;
546  }
547  switch (wrp_genChunk) {
548  case CHK0: // Send 'Hi from '
549  currChunk.setTData(GEN_CHK0);
550  wrp_genChunk = CHK1;
551  break;
552  case CHK1: // Send 'FMKU60!\n'
553  currChunk.setTData(GEN_CHK1);
554  wrp_genChunk = CHK0;
555  break;
556  }
557  currChunk.clearUnusedBytes();
558  soSHL_Data.write(currChunk);
559  }
560  break;
561  }
562 } // End-of: pWritePath()
LE_tKeep lenToLE_tKeep(ap_uint< 4 > noValidBytes)
A function to set a number of '1' in an 8-bit field. It is used here to set the number of valid bytes...
Definition: nts_utils.cpp:307
#define TRACE_WRP
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stepSim()

void stepSim ( )

Increment the simulation counter.

SIMULATION UTILITY HELPERS

Definition at line 77 of file simu_udp_shell_if_env.cpp.

77  {
78  gSimCycCnt++;
79  if (gTraceEvent || ((gSimCycCnt % 1000) == 0)) {
80  printInfo(THIS_NAME, "-- [@%4.4d] -----------------------------\n", gSimCycCnt);
81  gTraceEvent = false;
82  }
83  else if (0) {
84  printInfo(THIS_NAME, "------------------- [@%d] ------------\n", gSimCycCnt);
85  }
86 }
bool gTraceEvent
Definition: tb_nal.cpp:151

◆ udp_shell_if()

void udp_shell_if ( CmdBit piSHL_Mmio_En,
stream< UdpPort > &  soSHL_LsnReq,
stream< StsBool > &  siSHL_LsnRep,
stream< UdpPort > &  soSHL_ClsReq,
stream< StsBool > &  siSHL_ClsRep,
stream< UdpAppData > &  siSHL_Data,
stream< UdpAppMeta > &  siSHL_Meta,
stream< UdpAppDLen > &  siSHL_DLen,
stream< UdpAppData > &  soSHL_Data,
stream< UdpAppMeta > &  soSHL_Meta,
stream< UdpAppDLen > &  soSHL_DLen,
stream< UdpAppData > &  siUAF_Data,
stream< UdpAppMeta > &  siUAF_Meta,
stream< UdpAppDLen > &  siUAF_DLen,
stream< UdpAppData > &  soUAF_Data,
stream< UdpAppMeta > &  soUAF_Meta,
stream< UdpAppDLen > &  soUAF_DLen 
)

Main process of the UDP Shell Interface (USIF).

Parameters
[in]piSHL_Mmio_EnEnable signal from [SHELL/MMIO].
[out]soSHL_LsnReqListen port request to [SHELL].
[in]siSHL_LsnRepListen port reply from [SHELL].
[out]soSHL_ClsReqClose port request to [SHELL].
[in]siSHL_ClsRepClose port reply from [SHELL].
[in]siSHL_DataUDP datagram from [SHELL].
[in]siSHL_MetaUDP metadata from [SHELL].
[in]siSHL_DLenUDP data len from [SHELL].
[out]soSHL_DataUDP datagram to [SHELL].
[out]soSHL_MetaUDP metadata to [SHELL].
[out]soSHL_DLenUDP data len to [SHELL].
[in]siUAF_DataUDP datagram from UdpAppFlash (UAF).
[in]siUAF_MetaUDP metadata from [UAF].
[in]siUAF_DLenUDP data len from [UAF].
[out]soUAF_DataUDP datagram to [UAF].
[out]soUAF_MetaUDP metadata to [UAF].
[out]soUAF_DLenUDP data len to [UAF].

@info This core is designed with non-blocking read and write streams in mind. FYI, this is the normal way of operation for an internal stream and for an interface using the 'ap_fifo' protocol.

Warning
This core will not work properly if operated with a handshake interface(ap_hs) or an AXI-Stream interface (axis) because these two interfaces do not support non-blocking accesses.

ENTITY - UDP SHELL INTERFACE (USIF)

Definition at line 594 of file udp_shell_if.cpp.

636 {
637  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
638  #pragma HLS DATAFLOW
639  #pragma HLS INLINE
640  #pragma HLS INTERFACE ap_ctrl_none port=return
641 
642  //-------------------------------------------------------------------------
643  //-- LOCAL STREAMS (Sorted by the name of the modules which generate them)
644  //-------------------------------------------------------------------------
645 
646  //-- Read Path (RDp)
647  static stream<SocketPair> ssRDpToWRp_SockPair ("ssRDpToWRp_SockPair");
648  #pragma HLS STREAM variable=ssRDpToWRp_SockPair depth=2
649  static stream<UdpAppDLen> ssRDpToWRp_DReq ("ssRDpToWRp_DReq");
650  #pragma HLS STREAM variable=ssRDpToWRp_DReq depth=2
651 
652  //-- PROCESS FUNCTIONS ----------------------------------------------------
653  pListen(
654  piSHL_Mmio_En,
655  soSHL_LsnReq,
656  siSHL_LsnRep);
657 
658  pClose(
659  piSHL_Mmio_En,
660  soSHL_ClsReq,
661  siSHL_ClsRep);
662 
663  pReadPath(
664  piSHL_Mmio_En,
665  siSHL_Data,
666  siSHL_Meta,
667  siSHL_DLen,
668  soUAF_Data,
669  soUAF_Meta,
670  soUAF_DLen,
671  ssRDpToWRp_SockPair,
672  ssRDpToWRp_DReq);
673 
674  pWritePath(
675  piSHL_Mmio_En,
676  siUAF_Data,
677  siUAF_Meta,
678  siUAF_DLen,
679  ssRDpToWRp_SockPair,
680  ssRDpToWRp_DReq,
681  soSHL_Data,
682  soSHL_Meta,
683  soSHL_DLen);
684 
685 }
void pWritePath(CmdBit *piSHL_Enable, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< SocketPair > &siRDp_SockPair, stream< UdpAppDLen > &siRDp_DReq, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen)
Write Path (WRp) - From ROLE/UAF to SHELL/NTS/UOE.
void pReadPath(CmdBit *piSHL_Enable, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen, stream< SocketPair > &soWRp_SockPair, stream< UdpAppDLen > &soWRp_DReq)
Read Path (RDp) - From SHELL/UOE to ROLE/UAF.
void pClose(CmdBit *piSHL_Enable, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep)
Request the SHELL/NTS/UOE to close a previously opened port.
void pListen(CmdBit *piSHL_Enable, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep)
Listen(LSn)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udp_shell_if_top()

void udp_shell_if_top ( CmdBit piSHL_Mmio_En,
stream< UdpPort > &  soSHL_LsnReq,
stream< StsBool > &  siSHL_LsnRep,
stream< UdpPort > &  soSHL_ClsReq,
stream< StsBool > &  siSHL_ClsRep,
stream< UdpAppData > &  siSHL_Data,
stream< UdpAppMeta > &  siSHL_Meta,
stream< UdpAppDLen > &  siSHL_DLen,
stream< UdpAppData > &  soSHL_Data,
stream< UdpAppMeta > &  soSHL_Meta,
stream< UdpAppDLen > &  soSHL_DLen,
stream< UdpAppData > &  siUAF_Data,
stream< UdpAppMeta > &  siUAF_Meta,
stream< UdpAppDLen > &  siUAF_DLen,
stream< UdpAppData > &  soUAF_Data,
stream< UdpAppMeta > &  soUAF_Meta,
stream< UdpAppDLen > &  soUAF_DLen 
)

Top of UDP Shell Interface (USIF)

INTERFACE SYNTHESIS DIRECTIVES

Parameters
[in]piSHL_Mmio_EnEnable signal from [SHELL/MMIO].
[out]soSHL_LsnReqListen port request to [SHELL].
[in]siSHL_LsnRepListen port reply from [SHELL].
[out]soSHL_ClsReqClose port request to [SHELL].
[in]siSHL_ClsRepClose port reply from [SHELL].
[in]siSHL_DataUDP datagram from [SHELL].
[in]siSHL_MetaUDP metadata from [SHELL].
[out]soSHL_DataUDP datagram to [SHELL].
[out]soSHL_MetaUDP metadata to [SHELL].
[out]soSHL_DLenUDP data len to [SHELL].
[in]siUAF_DataUDP datagram from UdpAppFlash (UAF).
[in]siUAF_MetaUDP metadata from [UAF].
[out]siUAF_DLenUDP data len from [UAF].
[out]soUAF_DataUDP datagram to [UAF].
[out]soUAF_MetaUDP metadata to [UAF].
[out]soUAF_DLenUDP data len to [UAF].

@info This toplevel exemplifies the instantiation of a core that was designed for non-blocking read and write streams, but which needs to be exported as an IP with AXI-Stream interfaces (axis). Because the 'axis' interface does not support non-blocking accesses, this toplevel implements a shim layer between the 'axis' and the 'ap_fifo' interfaces and vice versa.

ENTITY - TOP of UDP SHELL INTERFACE (USIF)

Definition at line 176 of file udp_shell_if_top.cpp.

212 {
213  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
214  #pragma HLS INTERFACE ap_ctrl_none port=return
215 
216  #if defined (USE_AP_FIFO)
217  //-- Make use of FIFOs on the UAF interfaces -------------------------------
218  #pragma HLS INTERFACE ap_stable register port=piSHL_Mmio_En name=piSHL_Mmio_En
219 
220  //-- [SHL] INTERFACES ------------------------------------------------------
221  #pragma HLS INTERFACE axis off port=soSHL_LsnReq name=soSHL_LsnReq
222  #pragma HLS INTERFACE axis off port=siSHL_LsnRep name=siSHL_LsnRep
223  #pragma HLS INTERFACE axis off port=soSHL_ClsReq name=soSHL_ClsReq
224  #pragma HLS INTERFACE axis off port=siSHL_ClsRep name=siSHL_ClsRep
225 
226  #pragma HLS INTERFACE axis off port=siSHL_Data name=siSHL_Data
227  #pragma HLS INTERFACE axis off port=siSHL_Meta name=siSHL_Meta
228  #pragma HLS DATA_PACK variable=siSHL_Meta
229  #pragma HLS INTERFACE axis off port=siSHL_DLen name=siSHL_DLen
230 
231  #pragma HLS INTERFACE axis off port=soSHL_Data name=soSHL_Data
232  #pragma HLS INTERFACE axis off port=soSHL_Meta name=soSHL_Meta
233  #pragma HLS DATA_PACK variable=soSHL_Meta
234  #pragma HLS INTERFACE axis off port=soSHL_DLen name=soSHL_DLen
235 
236  //-- [UAF] INTERFACES ------------------------------------------------------
237  #pragma HLS INTERFACE ap_fifo port=siUAF_Data name=siUAF_Data
238  #pragma HLS DATA_PACK variable=siUAF_Data
239  #pragma HLS INTERFACE ap_fifo port=siUAF_Meta name=siUAF_Meta
240  #pragma HLS DATA_PACK variable=siUAF_Meta
241  #pragma HLS INTERFACE ap_fifo port=siUAF_DLen name=siUAF_DLen
242 
243  #pragma HLS INTERFACE ap_fifo port=soUAF_Data name=soUAF_Data
244  #pragma HLS DATA_PACK variable=soUAF_Data
245  #pragma HLS INTERFACE ap_fifo port=soUAF_Meta name=soUAF_Meta
246  #pragma HLS DATA_PACK variable=soUAF_Meta
247  #pragma HLS INTERFACE ap_fifo port=soUAF_DLen name=soUAF_DLen
248  #else
249  //-- Make use of AXIS on the UAF interfaces --------------------------------
250  #pragma HLS INTERFACE ap_stable register port=piSHL_Mmio_En name=piSHL_Mmio_En
251 
252  //-- [SHL] INTERFACES ------------------------------------------------------
253  #pragma HLS INTERFACE axis off port=soSHL_LsnReq name=soSHL_LsnReq
254  #pragma HLS INTERFACE axis off port=siSHL_LsnRep name=siSHL_LsnRep
255  #pragma HLS INTERFACE axis off port=soSHL_ClsReq name=soSHL_ClsReq
256  #pragma HLS INTERFACE axis off port=siSHL_ClsRep name=siSHL_ClsRep
257 
258  #pragma HLS INTERFACE axis off port=siSHL_Data name=siSHL_Data
259  #pragma HLS INTERFACE axis off port=siSHL_Meta name=siSHL_Meta
260  #pragma HLS DATA_PACK variable=siSHL_Meta
261  #pragma HLS INTERFACE axis off port=siSHL_DLen name=siSHL_DLen
262 
263  #pragma HLS INTERFACE axis off port=soSHL_Data name=soSHL_Data
264  #pragma HLS INTERFACE axis off port=soSHL_Meta name=soSHL_Meta
265  #pragma HLS DATA_PACK variable=soSHL_Meta
266  #pragma HLS INTERFACE axis off port=soSHL_DLen name=soSHL_DLen
267 
268  //-- [UAF] INTERFACES ------------------------------------------------------
269  #pragma HLS INTERFACE axis off port=siUAF_Data name=siUAF_Data
270  #pragma HLS INTERFACE axis off port=siUAF_Meta name=siUAF_Meta
271  #pragma HLS DATA_PACK variable=siUAF_Meta
272  #pragma HLS INTERFACE axis off port=siUAF_DLen name=siUAF_DLen
273 
274  #pragma HLS INTERFACE axis off port=soUAF_Data name=soUAF_Data
275  #pragma HLS INTERFACE axis off port=soUAF_Meta name=soUAF_Meta
276  #pragma HLS DATA_PACK variable=soUAF_Meta
277  #pragma HLS INTERFACE axis off port=soUAF_DLen name=soUAF_DLen
278  #endif
279 
280  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
281  #if HLS_VERSION == 2017
282  #pragma HLS DATAFLOW
283  #else
284  #pragma HLS DATAFLOW disable_start_propagation
285  #endif
286 
287  //-- INSTANTIATE TOPLEVEL --------------------------------------------------
288  udp_shell_if(
289  //-- SHELL / Mmio Interface
290  piSHL_Mmio_En,
291  //-- SHELL / Control Port Interfaces
292  soSHL_LsnReq,
293  siSHL_LsnRep,
294  soSHL_ClsReq,
295  siSHL_ClsRep,
296  //-- SHELL / Rx Data Interfaces
297  siSHL_Data,
298  siSHL_Meta,
299  siSHL_DLen,
300  //-- SHELL / Tx Data Interfaces
301  soSHL_Data,
302  soSHL_Meta,
303  soSHL_DLen,
304  //-- UAF / Tx Data Interfaces
305  siUAF_Data,
306  siUAF_Meta,
307  siUAF_DLen,
308  //-- UAF / Rx Data Interfaces
309  soUAF_Data,
310  soUAF_Meta,
311  soUAF_DLen);
312 
313 }
Here is the call graph for this function:

Variable Documentation

◆ cGraceTime

const int cGraceTime = 500

Definition at line 44 of file simu_udp_shell_if_env.hpp.

◆ cUoeInitCycles

const int cUoeInitCycles = 100

Definition at line 43 of file simu_udp_shell_if_env.hpp.

◆ gFatalError [1/3]

bool gFatalError
extern

Definition at line 152 of file tb_nal.cpp.

◆ gFatalError [2/3]

bool gFatalError = false

Definition at line 47 of file test_udp_shell_if.hpp.

◆ gFatalError [3/3]

bool gFatalError = false

Definition at line 46 of file test_udp_shell_if_top.hpp.

◆ gMaxSimCycles [1/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [2/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [3/5]

unsigned int gMaxSimCycles = cUoeInitCycles + cGraceTime

Definition at line 48 of file test_udp_shell_if.hpp.

◆ gMaxSimCycles [4/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [5/5]

unsigned int gMaxSimCycles = cUoeInitCycles + cGraceTime

Definition at line 47 of file test_udp_shell_if_top.hpp.

◆ gSimCycCnt [1/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [2/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [3/5]

unsigned int gSimCycCnt = 0

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 45 of file test_udp_shell_if.hpp.

◆ gSimCycCnt [4/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [5/5]

unsigned int gSimCycCnt = 0

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 44 of file test_udp_shell_if_top.hpp.

◆ gTraceEvent [1/4]

bool gTraceEvent
extern

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.

◆ gTraceEvent [2/4]

bool gTraceEvent
extern

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.

◆ gTraceEvent [3/4]

bool gTraceEvent = false

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 46 of file test_udp_shell_if.hpp.

◆ gTraceEvent [4/4]

bool gTraceEvent = false

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 45 of file test_udp_shell_if_top.hpp.