51 #define THIS_NAME "TB_USIF_TOP"
69 int main(
int argc,
char *argv[]) {
87 stream<UdpAppData> ssUAF_USIF_Data (
"ssUAF_USIF_Data");
88 stream<UdpAppMeta> ssUAF_USIF_Meta (
"ssUAF_USIF_Meta");
89 stream<UdpAppDLen> ssUAF_USIF_DLen (
"ssUAF_USIF_DLen");
91 stream<UdpAppData> ssUSIF_UOE_Data (
"ssUSIF_UOE_Data");
92 stream<UdpAppMeta> ssUSIF_UOE_Meta (
"ssUSIF_UOE_Meta");
93 stream<UdpAppDLen> ssUSIF_UOE_DLen (
"ssUSIF_UOE_DLen");
95 stream<UdpAppData> ssUOE_USIF_Data (
"ssUOE_USIF_Data");
96 stream<UdpAppMeta> ssUOE_USIF_Meta (
"ssUOE_USIF_Meta");
97 stream<UdpAppDLen> ssUOE_USIF_DLen (
"ssUOE_USIF_DLen");
99 stream<UdpAppData> ssUSIF_UAF_Data (
"ssUSIF_UAF_Data");
100 stream<UdpAppMeta> ssUSIF_UAF_Meta (
"ssUSIF_UAF_Meta");
101 stream<UdpAppDLen> ssUSIF_UAF_DLen (
"ssUSIF_UAF_DLen");
103 stream<UdpPort> ssUSIF_UOE_LsnReq (
"ssUSIF_UOE_LsnReq");
104 stream<StsBool> ssUOE_USIF_LsnRep (
"ssUOE_USIF_LsnRep");
105 stream<UdpPort> ssUSIF_UOE_ClsReq (
"ssUSIF_UOE_ClsReq");
106 stream<StsBool> ssUOE_USIF_ClsRep (
"ssUOE_USIF_ClsRep");
114 string ofUOE_DataName =
"../../../../test/simOutFiles/soUOE_Data.dat";
115 string ofUOE_MetaName =
"../../../../test/simOutFiles/soUOE_Meta.dat";
116 ofstream ofUOE_DataGold;
117 ofstream ofUOE_MetaGold;
118 string ofUOE_DataGoldName =
"../../../../test/simOutFiles/soUOE_DataGold.dat";
119 string ofUOE_MetaGoldName =
"../../../../test/simOutFiles/soUOE_MetaGold.dat";
121 const int defaultLenOfDatagramEcho = 42;
122 const int defaultDestHostIpv4Test = 0xC0A80096;
123 const int defaultDestHostPortTest = 2718;
124 const int defaultLenOfDatagramTest = 43;
126 int echoLenOfDatagram = defaultLenOfDatagramEcho;
127 ap_uint<32> testDestHostIpv4 = defaultDestHostIpv4Test;
128 ap_uint<16> testDestHostPort = defaultDestHostIpv4Test;
129 int testLenOfDatagram = defaultLenOfDatagramTest;
135 echoLenOfDatagram = atoi(argv[1]);
136 if ((echoLenOfDatagram < 1) or (echoLenOfDatagram >= 0x10000)) {
146 testDestHostIpv4 = atoi(argv[2]);
148 if ((testDestHostIpv4 < 0x00000000) or (testDestHostIpv4 > 0xFFFFFFFF)) {
154 testDestHostPort = atoi(argv[3]);
155 if ((testDestHostPort < 0x0000) or (testDestHostPort >= 0x10000)) {
161 testLenOfDatagram = atoi(argv[4]);
162 if ((testLenOfDatagram <= 0) or (testLenOfDatagram >= 0x10000)) {
168 SockAddr testSock(testDestHostIpv4, testDestHostPort);
173 remove(ofUOE_DataName.c_str());
174 if (!ofUOE_Data.is_open()) {
181 remove(ofUOE_MetaName.c_str());
182 if (!ofUOE_Meta.is_open()) {
189 remove(ofUOE_DataGoldName.c_str());
190 if (!ofUOE_DataGold.is_open()) {
191 ofUOE_DataGold.open(ofUOE_DataGoldName.c_str(),
ofstream::out);
192 if (!ofUOE_DataGold) {
197 remove(ofUOE_MetaGoldName.c_str());
198 if (!ofUOE_MetaGold.is_open()) {
199 ofUOE_MetaGold.open(ofUOE_MetaGoldName.c_str(),
ofstream::out);
200 if (!ofUOE_MetaGold) {
207 "############################################################################\n");
209 "## TESTBENCH 'test_udp_shell' STARTS HERE ##\n");
211 "############################################################################\n\n");
214 "This testbench will be executed with the following parameters: \n");
215 for (
int i = 1; i < argc; i++) {
311 ofUOE_DataGold.close();
313 ofUOE_MetaGold.close();
316 printf(
"-- [@%4.4d] -----------------------------\n",
gSimCycCnt);
317 printf(
"############################################################################\n");
318 printf(
"## TESTBENCH 'test_udp_shell_if' ENDS HERE ##\n");
319 printf(
"############################################################################\n");
325 printInfo(
THIS_NAME,
"This testbench was executed with the following parameters: \n");
326 for (
int i=1; i<argc; i++) {
335 std::string(ofUOE_DataGoldName));
338 ofUOE_DataName.c_str(), ofUOE_DataGoldName.c_str());
342 std::string(ofUOE_MetaGoldName));
345 ofUOE_MetaName.c_str(), ofUOE_MetaGoldName.c_str());
350 printError(
THIS_NAME,
"###################################################################################\n");
351 printError(
THIS_NAME,
"#### TESTBENCH 'test_udp_shell_if_top' FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
352 printError(
THIS_NAME,
"###################################################################################\n");
354 printInfo(
THIS_NAME,
"FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
357 printInfo(
THIS_NAME,
"#################################################################\n");
359 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.
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).
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)
unsigned int gMaxSimCycles
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 toplevel of UDP Shell Interface (USIF).