56 #define THIS_NAME "TB_USIF"
74 int main(
int argc,
char *argv[]) {
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");
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");
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");
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");
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");
119 string ofUOE_DataName =
"../../../../test/simOutFiles/soUOE_Data.dat";
120 string ofUOE_MetaName =
"../../../../test/simOutFiles/soUOE_Meta.dat";
121 ofstream ofUOE_DataGold;
122 ofstream ofUOE_MetaGold;
123 string ofUOE_DataGoldName =
"../../../../test/simOutFiles/soUOE_DataGold.dat";
124 string ofUOE_MetaGoldName =
"../../../../test/simOutFiles/soUOE_MetaGold.dat";
126 const int defaultLenOfDatagramEcho = 42;
127 const int defaultDestHostIpv4Test = 0xC0A80096;
128 const int defaultDestHostPortTest = 2718;
129 const int defaultLenOfDatagramTest = 43;
131 int echoLenOfDatagram = defaultLenOfDatagramEcho;
132 ap_uint<32> testDestHostIpv4 = defaultDestHostIpv4Test;
133 ap_uint<16> testDestHostPort = defaultDestHostIpv4Test;
134 int testLenOfDatagram = defaultLenOfDatagramTest;
140 echoLenOfDatagram = atoi(argv[1]);
141 if ((echoLenOfDatagram < 1) or (echoLenOfDatagram >= 0x10000)) {
151 testDestHostIpv4 = atoi(argv[2]);
153 if ((testDestHostIpv4 < 0x00000000) or (testDestHostIpv4 > 0xFFFFFFFF)) {
159 testDestHostPort = atoi(argv[3]);
160 if ((testDestHostPort < 0x0000) or (testDestHostPort >= 0x10000)) {
166 testLenOfDatagram = atoi(argv[4]);
167 if ((testLenOfDatagram <= 0) or (testLenOfDatagram >= 0x10000)) {
173 SockAddr testSock(testDestHostIpv4, testDestHostPort);
178 remove(ofUOE_DataName.c_str());
179 if (!ofUOE_Data.is_open()) {
186 remove(ofUOE_MetaName.c_str());
187 if (!ofUOE_Meta.is_open()) {
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) {
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) {
212 "############################################################################\n");
214 "## TESTBENCH 'test_udp_shell' STARTS HERE ##\n");
216 "############################################################################\n\n");
219 "This testbench will be executed with the following parameters: \n");
220 for (
int i = 1; i < argc; i++) {
316 ofUOE_DataGold.close();
318 ofUOE_MetaGold.close();
321 printf(
"-- [@%4.4d] -----------------------------\n",
gSimCycCnt);
322 printf(
"############################################################################\n");
323 printf(
"## TESTBENCH 'test_udp_shell_if' ENDS HERE ##\n");
324 printf(
"############################################################################\n");
330 printInfo(
THIS_NAME,
"This testbench was executed with the following parameters: \n");
331 for (
int i=1; i<argc; i++) {
340 std::string(ofUOE_DataGoldName));
343 ofUOE_DataName.c_str(), ofUOE_DataGoldName.c_str());
347 std::string(ofUOE_MetaGoldName));
350 ofUOE_MetaName.c_str(), ofUOE_MetaGoldName.c_str());
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");
359 printInfo(
THIS_NAME,
"FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
362 printInfo(
THIS_NAME,
"#############################################################\n");
364 printInfo(
THIS_NAME,
"#############################################################\n");
void stepSim()
Increment the simulation counter.
bool isDottedDecimal(string ipStr)
Checks if a string contains an IP address represented in dot-decimal notation.
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 printError(callerName, format,...)
A macro to print an error message.
#define printInfo(callerName, format,...)
A macro to print an information message.
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
void pMMIO(StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
Emulate the behavior of the SHELL & MMIO.
int main(int argc, char *argv[])
Main function for the test of the UDP Shell Interface (USIF).
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 gMaxSimCycles
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).
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).
: Testbench for the UDP Shell Interface (USIF).