51 #define THIS_NAME "TB_TSIF_TOP"
58 #define TRACE_OFF 0x0000
59 #define TRACE_DDC 1 << 1
60 #define TRACE_ALL 0xFFFF
62 #define DEBUG_LEVEL (TRACE_OFF)
79 while (!(ss.empty())) {
81 if (currCount != prevCount) {
83 printInfo(myName,
"Detected a change on stream '%s' (currCounter=%d). \n",
84 ssName.c_str(), currCount.to_uint());
87 prevCount = currCount;
103 int main(
int argc,
char *argv[]) {
124 stream<TcpAppData> ssTAF_TSIF_Data (
"ssTAF_TSIF_Data");
125 stream<TcpSessId> ssTAF_TSIF_SessId(
"ssTAF_TSIF_SessId");
126 stream<TcpDatLen> ssTAF_TSIF_DatLen(
"ssTAF_TSIF_DatLen");
128 stream<TcpAppData> ssTSIF_TAF_Data (
"ssTSIF_TAF_Data");
129 stream<TcpSessId> ssTSIF_TAF_SessId(
"ssTSIF_TAF_SessId");
130 stream<TcpDatLen> ssTSIF_TAF_DatLen(
"ssTSIF_TAF_DatLen");
132 stream<TcpAppNotif> ssTOE_TSIF_Notif (
"ssTOE_TSIF_Notif");
133 stream<TcpAppData> ssTOE_TSIF_Data (
"ssTOE_TSIF_Data");
134 stream<TcpAppMeta> ssTOE_TSIF_Meta (
"ssTOE_TSIF_Meta");
136 stream<TcpAppRdReq> ssTSIF_TOE_DReq (
"ssTSIF_TOE_DReq");
138 stream<TcpAppLsnRep> ssTOE_TSIF_LsnRep(
"ssTOE_TSIF_LsnRep");
140 stream<TcpAppLsnReq> ssTSIF_TOE_LsnReq(
"ssTSIF_TOE_LsnReq");
142 stream<TcpAppSndRep> ssTOE_TSIF_SndRep(
"ssTOE_TSIF_SndRep");
144 stream<TcpAppData> ssTSIF_TOE_Data (
"ssTSIF_TOE_Data");
145 stream<TcpAppSndReq> ssTSIF_TOE_SndReq(
"ssTSIF_TOE_SndReq");
147 stream<TcpAppOpnRep> ssTOE_TSIF_OpnRep(
"ssTOE_TSIF_OpnRep");
149 stream<TcpAppOpnReq> ssTSIF_TOE_OpnReq(
"ssTSIF_TOE_OpnReq");
150 stream<TcpAppClsReq> ssTSIF_TOE_ClsReq(
"ssTSIF_TOE_ClsReq");
152 stream<ap_uint<32> > ssTSIF_DBG_SinkCnt(
"ssTSIF_DBG_SinkCnt");
153 stream<ap_uint<16> > ssTSIF_DBG_InpBufSpace(
"ssTSIF_DBG_InpBufSpace");
160 const char *ofTAF_DataName =
"../../../../test/simOutFiles/soTAF.dat";
162 const char *ofTAF_GoldName =
"../../../../test/simOutFiles/soTAF.gold";
164 const char *ofTOE_DataName =
"../../../../test/simOutFiles/soTOE_Data.dat";
166 const char *ofTOE_GoldName =
"../../../../test/simOutFiles/soTOE_Gold.dat";
168 const int defaultLenOfSegmentEcho = 42;
169 const int defaultDestHostIpv4Test = 0xC0A80096;
170 const int defaultDestHostPortTest = 2718;
171 const int defaultLenOfSegmentTest = 43;
173 int echoLenOfSegment = defaultLenOfSegmentEcho;
174 ap_uint<32> testDestHostIpv4 = defaultDestHostIpv4Test;
175 ap_uint<16> testDestHostPort = defaultDestHostIpv4Test;
176 int testLenOfSegment = defaultLenOfSegmentTest;
182 if ((atoi(argv[1]) < 1) or (atoi(argv[1]) > 0x4000)) {
184 "Argument 'len' is out of range [1:16384].\n");
187 echoLenOfSegment = atoi(argv[1]);
194 testDestHostIpv4 = atoi(argv[2]);
196 if ((testDestHostIpv4 < 0x00000000)
197 or (testDestHostIpv4 > 0xFFFFFFFF)) {
199 "Argument 'IPv4' is out of range [0x00000000:0xFFFFFFFF].\n");
204 testDestHostPort = atoi(argv[3]);
205 if ((testDestHostPort < 0x0000) or (testDestHostPort >= 0x10000)) {
207 "Argument 'port' is out of range [0:65535].\n");
212 testLenOfSegment = atoi(argv[4]);
213 if ((testLenOfSegment < 1) or (testLenOfSegment > 0x4000)) {
215 "Argument 'len' is out of range [1:16384].\n");
223 int totalRxBytes = (
cNrSessToSend * (testLenOfSegment + 8 + 8 + 2*echoLenOfSegment));
225 printFatal(
THIS_NAME,
"The total amount of Rx bytes (%d) exceeds the size of the input TSIF read buffer (%d).\n",
229 printFatal(
THIS_NAME,
"The length of the test segment (%d) exceeds the size of the input TSIF read buffer (%d).\n",
236 SockAddr testSock(testDestHostIpv4, testDestHostPort);
244 remove(ofTAF_DataName);
245 ofTAF_Data.open(ofTAF_DataName);
248 "Cannot open the Application Tx file: \n\t %s \n",
252 remove(ofTAF_GoldName);
253 ofTAF_Gold.open(ofTAF_GoldName);
256 "Cannot open the Application Tx gold file: \n\t %s \n",
260 remove(ofTOE_DataName);
261 if (!ofTOE_Data.is_open()) {
268 remove(ofTOE_GoldName);
269 if (!ofTOE_Gold.is_open()) {
279 "############################################################################\n");
281 "## TESTBENCH 'test_tcp_shell' STARTS HERE ##\n");
283 "############################################################################\n\n");
286 "This testbench will be executed with the following parameters: \n");
287 for (
int i = 1; i < argc; i++) {
299 pTOE(nrErr, ofTAF_Gold, ofTOE_Gold, ofTOE_Data, echoLenOfSegment,
300 testSock, testLenOfSegment,
304 ssTOE_TSIF_Notif, ssTSIF_TOE_DReq,
305 ssTOE_TSIF_Data, ssTOE_TSIF_Meta,
307 ssTSIF_TOE_LsnReq, ssTOE_TSIF_LsnRep,
309 ssTSIF_TOE_Data, ssTSIF_TOE_SndReq, ssTOE_TSIF_SndRep,
311 ssTSIF_TOE_OpnReq, ssTOE_TSIF_OpnRep);
329 ssTAF_TSIF_Data, ssTAF_TSIF_SessId, ssTAF_TSIF_DatLen,
330 ssTSIF_TAF_Data, ssTSIF_TAF_SessId, ssTSIF_TAF_DatLen,
332 ssTOE_TSIF_Notif, ssTSIF_TOE_DReq, ssTOE_TSIF_Data,
335 ssTSIF_TOE_LsnReq, ssTOE_TSIF_LsnRep,
337 ssTSIF_TOE_Data, ssTSIF_TOE_SndReq, ssTOE_TSIF_SndRep,
339 ssTSIF_TOE_OpnReq, ssTOE_TSIF_OpnRep,
344 ssTSIF_DBG_InpBufSpace);
351 ssTSIF_TAF_Data, ssTSIF_TAF_SessId, ssTSIF_TAF_DatLen,
353 ssTAF_TSIF_Data, ssTAF_TSIF_SessId, ssTAF_TSIF_DatLen);
363 "############################################################################\n");
365 "## TESTBENCH 'test_tcp_shell_if' ENDS HERE ##\n");
367 "############################################################################\n");
385 if (ofTAF_Data.tellp() != 0) {
387 (
"diff --brief -w " + std::string(ofTAF_DataName) +
" "
388 + std::string(ofTAF_GoldName) +
" ").c_str());
391 ofTAF_DataName, ofTAF_GoldName);
398 if (ofTOE_Data.tellp() != 0) {
400 (
"diff --brief -w " + std::string(ofTOE_DataName) +
" "
401 + std::string(ofTOE_GoldName) +
" ").c_str());
404 ofTOE_DataName, ofTOE_GoldName);
417 "This testbench was executed with the following parameters: \n");
418 for (
int i = 1; i < argc; i++) {
425 "###########################################################\n");
427 "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n",
430 "###########################################################\n");
433 "#############################################################\n");
435 "#### SUCCESSFUL END OF TEST ####\n");
437 "#############################################################\n");
void pTOE(int &nrErr, stream< TcpAppNotif > &soTRIF_Notif, stream< TcpAppRdReq > &siTRIF_DReq, stream< TcpAppData > &soTRIF_Data, stream< TcpAppMeta > &soTRIF_SessId, stream< TcpAppLsnReq > &siTRIF_LsnReq, stream< TcpAppLsnRep > &soTRIF_LsnAck, stream< TcpAppData > &siTRIF_Data, stream< TcpAppSndReq > &siTRIF_SndReq, stream< TcpAppSndRep > &soTRIF_SndRep, stream< TcpAppOpnReq > &siTRIF_OpnReq, stream< TcpAppOpnRep > &soTRIF_OpnRep)
void stepSim()
Increment the simulation counter.
bool isDottedDecimal(string ipStr)
Checks if a string contains an IP address represented in dot-decimal notation.
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 concat3(firstCharConst, secondCharConst, thirdCharConst)
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
bool drainDebugSpaceCounter(stream< ap_uint< 16 > > &ss, string ssName)
Empty the DebugSpaceCounter stream and check its last value.
void pMMIO(StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
Emulate the behavior of the SHELL & MMIO.
unsigned int gMaxSimCycles
bool drainDebugSinkCounter(stream< ap_uint< 32 > > &ss, string ssName)
Empty the DebugSinkCounter stream and throw it away.
bool drainDebugCounter(stream< T > &ss, string ssName)
Empty a debug stream and throw it away.
void pTAF(ofstream &ofTAF_Data, stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DatLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_Meta, stream< TcpSessId > &soTSIF_DLen)
Emulate the behavior of the ROLE/TcpAppFlash (TAF).
void tcp_shell_if_top(CmdBit *piSHL_Mmio_En, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppRdReq > &soSHL_DReq, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq, stream< ap_uint< 32 > > &soDBG_SinkCnt, stream< ap_uint< 16 > > &soDBG_InpBufSpace)
Top of TCP Shell Interface (TSIF)
: Testbench for the toplevel of TCP Shell Interface (TSIF).