60 #define THIS_NAME "SIM"
62 #define TRACE_OFF 0x0000
63 #define TRACE_TSs 1 << 1
64 #define TRACE_TSr 1 << 2
65 #define TRACE_TAF 1 << 3
66 #define TRACE_MMIO 1 << 4
67 #define TRACE_ALL 0xFFFF
68 #define DEBUG_LEVEL (TRACE_OFF)
108 stream<TcpAppData> &siTAF_Data,
109 stream<TcpSessId> &siTAF_SessId,
110 stream<TcpDatLen> &siTAF_DatLen,
111 ofstream &rawFileStream,
112 ofstream &tcpFileStream,
117 static int tsr_startOfSegCount = 0;
124 if (!siTAF_SessId.empty() and !siTAF_DatLen.empty()) {
125 siTAF_SessId.read(tcpSessId);
126 siTAF_DatLen.read(tcpDatLen);
127 tsr_startOfSegCount++;
128 if (tsr_startOfSegCount > 1) {
129 printWarn(myName,
"Metadata and data streams did not arrive in expected order!\n");
132 printInfo(myName,
"Received SessId=%d and DatLen=%d\n",
133 tcpSessId.to_uint(), tcpDatLen.to_uint());
137 if (!siTAF_Data.empty()) {
138 siTAF_Data.read(currChunk);
141 tsr_startOfSegCount--;
168 stream<TcpAppData> &soTAF_Data,
169 stream<TcpSessId> &soTAF_SessId,
170 stream<TcpDatLen> &soTAF_DatLen,
171 ifstream &inpFileStream,
172 ofstream &outGoldStream,
178 static bool tss_startOfTcpSeg =
true;
179 static bool tss_idlingReq =
false;
180 static unsigned int tss_idleCycReq = 0;
181 static unsigned int tss_idleCycCnt = 0;
187 vector<string> stringVector;
194 if (tss_idlingReq ==
true) {
195 if (tss_idleCycCnt >= tss_idleCycReq) {
197 tss_idlingReq =
false;
199 printInfo(myName,
"End of Tx idling phase. \n");
211 if (tss_simAppData.
size() != 0) {
212 if (!soTAF_Data.full()) {
215 soTAF_Data.write(appChunk);
224 while (!inpFileStream.eof()) {
226 getline(inpFileStream, strLine);
229 if (!strLine.empty()) {
231 if (stringVector[0].length() == 1) {
237 if (stringVector[0] ==
"#") {
241 else if (stringVector[0] ==
">") {
244 if (stringVector[1] ==
"IDLE") {
246 tss_idleCycReq = strtol(stringVector[2].c_str(), &pEnd, 10);
247 tss_idlingReq =
true;
249 printInfo(myName,
"Request to idle for %d cycles. \n", tss_idleCycReq);
254 if (stringVector[1] ==
"SET") {
255 printWarn(myName,
"The 'SET' command is not yet implemented...");
259 printFatal(myName,
"Read unknown command \"%s\" from TSIF.\n", stringVector[0].c_str());
264 bool firstChunkFlag =
true;
265 int writtenBytes = 0;
267 if (firstChunkFlag ==
false) {
268 getline(inpFileStream, strLine);
272 if (stringVector[0] ==
"#") {
278 firstChunkFlag =
false;
287 soTAF_SessId.write(
TcpSessId(tss_tcpSessId));
316 #
if defined TAF_USE_NON_FIFO_IO
317 ap_uint<2> poTAF_EchoCtrl,
320 stream<TcpAppData> &soTAF_Data,
321 stream<TcpSessId> &soTAF_SessId,
322 stream<TcpDatLen> &soTAF_DatLen,
324 stream<TcpAppData> &siTAF_Data,
325 stream<TcpSessId> &siTAF_SessId,
326 stream<TcpDatLen> &siTAF_DatLen)
331 static bool tsif_doneWithPassThroughTest1 =
false;
332 static int tsif_txSegCnt = 0;
333 static int tsif_rxSegCnt = 0;
334 static int tsif_graceTime1 = 25;
336 static ifstream ifSHL_Data;
337 static ofstream ofRawFile1;
338 static ofstream ofRawGold1;
339 static ofstream ofTcpFile1;
340 static ofstream ofRawFile2;
341 static ofstream ofTcpFile2;
346 string ifSHL_DataName =
"../../../../test/testVectors/siTSIF_Data.dat";
347 string ofRawFileName1 =
"../../../../test/simOutFiles/soTAF_Shl_Echo_Path_Thru_Data.dat";
348 string ofRawGoldName1 =
"../../../../test/simOutFiles/soTAF_Shl_Echo_Path_Thru_Data_Gold.dat";
349 string ofTcpFileName1 =
"../../../../test/simOutFiles/soTAF_Shl_Echo_Path_Thru_Data.tcp";
350 string ofRawFileName2 =
"../../../../test/simOutFiles/soTAF_Shl_Echo_Off_Data.dat";
351 string ofTcpFileName2 =
"../../../../test/simOutFiles/soTAF_Shl_Echo_Off_Data.tcp";
356 if (tsif_doneWithPassThroughTest1) {
367 printf(
"\n## PART-1 : TEST OF THE PASS-THROUGH MODE ####################\n");
371 std::remove(ofRawFileName1.c_str());
372 std::remove(ofRawGoldName1.c_str());
373 std::remove(ofRawFileName2.c_str());
374 std::remove(ofTcpFileName1.c_str());
375 std::remove(ofTcpFileName2.c_str());
378 if (!ifSHL_Data.is_open()) {
379 ifSHL_Data.open (ifSHL_DataName.c_str(), ifstream::in);
381 printFatal(myName,
"Could not open the input data file \'%s\'. \n", ifSHL_DataName.c_str());
383 tsif_doneWithPassThroughTest1 =
true;
388 if (!ofRawFile1.is_open()) {
391 printFatal(myName,
"Could not open the output Raw data file \'%s\'. \n", ofRawFileName1.c_str());
393 tsif_doneWithPassThroughTest1 =
true;
397 if (!ofRawGold1.is_open()) {
400 printFatal(myName,
"Could not open the output Raw gold file \'%s\'. \n", ofRawGoldName1.c_str());
402 tsif_doneWithPassThroughTest1 =
true;
406 if (!ofTcpFile1.is_open()) {
409 printFatal(myName,
"Could not open the Tcp output data file \'%s\'. \n", ofTcpFileName1.c_str());
411 tsif_doneWithPassThroughTest1 =
true;
416 else if (tsif_graceTime1) {
436 if ((rcSend !=
OK) or (rcRecv !=
OK)) {
444 if (tsif_graceTime1 == 0) {
445 if (ofRawFile1.tellp() != 0) {
446 int rc1 = system((
"diff --brief -w " + std::string(ofRawFileName1) +
" " + std::string(ofRawGoldName1) +
" ").c_str());
448 printError(myName,
"File '%s' does not match '%s'.\n", ofRawFileName1.c_str(), ofRawGoldName1.c_str());
451 tsif_doneWithPassThroughTest1 =
true;
void pushChunk(AxisApp appChunk)
bool readAxisRawFromLine(AxisRaw &axisRaw, string stringBuffer)
Retrieve an AxisRaw chunk from a string.
vector< string > myTokenizer(string strBuff, char delimiter)
Brakes a string into tokens by using the 'delimiter' character.
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
int writeAxisAppToFile(AxisApp &axisApp, ofstream &outFile)
Dump a TCP or UDP application data chunk into a file. The data are stored as a stream of bytes which ...
#define printError(callerName, format,...)
A macro to print an error message.
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
#define printInfo(callerName, format,...)
A macro to print an information message.
#define printWarn(callerName, format,...)
A macro to print a warning message.
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
void stepSim()
Increment the simulation counter.
bool pTSIF_Send(int &nrError, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, ifstream &inpFileStream, ofstream &outGoldStream, int &nrSegments)
Emulate the sending part of the TSIF process.
unsigned int gMaxSimCycles
void increaseSimTime(unsigned int cycles)
Increase the simulation time of the testbench.
bool pTSIF_Recv(int &nrErr, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, ofstream &rawFileStream, ofstream &tcpFileStream, int &nrSegments)
Emulate the receiving part of the TSIF process.
void pTSIF(int &nrErr, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen)
Emulate the behavior of TSIF.
: Simulation environment for the TCP Application Flash (TAF).