cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_tcp_app_flash.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
43 #include "test_tcp_app_flash.hpp"
44 
45 using namespace hls;
46 using namespace std;
47 
48 //---------------------------------------------------------
49 // HELPERS FOR THE DEBUGGING TRACES
50 //---------------------------------------------------------
51 #define THIS_NAME "TB_TAF"
52 
53 #ifndef __SYNTHESIS__
54  extern unsigned int gSimCycCnt;
55  extern unsigned int gMaxSimCycles;
56 #endif
57 
58 
61 int main(int argc, char *argv[]) {
62 
63  //------------------------------------------------------
64  //-- TESTBENCH GLOBAL VARIABLES
65  //------------------------------------------------------
66  gSimCycCnt = 0; // Simulation cycle counter as a global variable
67 
68  //------------------------------------------------------
69  //-- DUT SIGNAL INTERFACES
70  //------------------------------------------------------
71  //-- MMIO/ Configuration Interfaces
72  #if defined TAF_USE_NON_FIFO_IO
73  ap_uint<2> sMMIO_TAF_EchoCtrl;
74  #endif
75  //[NOT_USED] CmdBit sMMIO_TAF_PostSegEn;
76  //[NOT_USED] CmdBit sMMIO_TAF_CaptSegEn;
77 
78  //------------------------------------------------------
79  //-- DUT STREAM INTERFACES
80  //------------------------------------------------------
81  //-- TSIF / TCP Data Interfaces
82  stream<TcpAppData> ssTSIF_TAF_Data ("ssTSIF_TAF_Data");
83  stream<TcpSessId> ssTSIF_TAF_SessId ("ssTSIF_TAF_SessId");
84  stream<TcpDatLen> ssTSIF_TAF_DatLen ("ssTSIF_TAF_DatLen");
85  stream<TcpAppData> ssTAF_TSIF_Data ("ssTAF_TSIF_Data");
86  stream<TcpSessId> ssTAF_TSIF_SessId ("ssTAF_TSIF_SessId");
87  stream<TcpDatLen> ssTAF_TSIF_DatLen ("ssTAF_TSIF_DatLen");
88 
89  //------------------------------------------------------
90  //-- TESTBENCH VARIABLES
91  //------------------------------------------------------
92  int nrErr = 0;
93  int segCnt = 0;
94 
95  printInfo(THIS_NAME, "############################################################################\n");
96  printInfo(THIS_NAME, "## TESTBENCH 'test_tcp_app_flash' STARTS HERE ##\n");
97  printInfo(THIS_NAME, "############################################################################\n");
98  printInfo(THIS_NAME, "This testbench will be executed with the following parameters: \n");
99  for (int i=1; i<argc; i++) {
100  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i-1), argv[i]);
101  }
102  printf("\n\n");
103 
104  //-----------------------------------------------------
105  //-- MAIN LOOP
106  //-----------------------------------------------------
107  do {
108  //-------------------------------------------------
109  //-- EMULATE TSIF
110  //-------------------------------------------------
111  pTSIF(
112  nrErr,
113  //-- MMIO / Configuration Interfaces
114  #if defined TAF_USE_NON_FIFO_IO
115  sMMIO_TAF_EchoCtrl,
116  #endif
117  //-- TAF / TCP Data Interfaces
118  ssTSIF_TAF_Data,
119  ssTSIF_TAF_SessId,
120  ssTSIF_TAF_DatLen,
121  //-- TAF / TCP Data Interface
122  ssTAF_TSIF_Data,
123  ssTAF_TSIF_SessId,
124  ssTAF_TSIF_DatLen);
125 
126  //-------------------------------------------------
127  //-- RUN DUT
128  //-------------------------------------------------
130  #if defined TAF_USE_NON_FIFO_IO
131  //-- MMIO / Configuration Interfaces
132  sMMIO_TAF_EchoCtrl,
133  #endif
134  //-- TSIF / TCP Rx Data Interface
135  ssTSIF_TAF_Data,
136  ssTSIF_TAF_SessId,
137  ssTSIF_TAF_DatLen,
138  //-- TSIF / TCP Tx Data Interface
139  ssTAF_TSIF_Data,
140  ssTAF_TSIF_SessId,
141  ssTAF_TSIF_DatLen);
142 
143  //------------------------------------------------------
144  //-- INCREMENT SIMULATION COUNTER
145  //------------------------------------------------------
146  stepSim();
147 
148  } while ( (gSimCycCnt < gMaxSimCycles) and
149  !gFatalError and
150  (nrErr < 10) );
151 
152  //---------------------------------------------------------------
153  //-- PRINT TESTBENCH STATUS
154  //---------------------------------------------------------------
155  printf("\n\n");
156  if (argc > 1) {
157  printInfo(THIS_NAME, "This testbench was executed with the following test-file: \n");
158  printInfo(THIS_NAME, "\t==> %s\n\n", argv[1]);
159  }
160 
161  if (nrErr) {
162  printError(THIS_NAME, "###########################################################\n");
163  printError(THIS_NAME, "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
164  printError(THIS_NAME, "###########################################################\n\n");
165 
166  printInfo(THIS_NAME, "FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
167  }
168  else {
169  printInfo(THIS_NAME, "#############################################################\n");
170  printInfo(THIS_NAME, "#### SUCCESSFUL END OF TEST ####\n");
171  printInfo(THIS_NAME, "#############################################################\n");
172  }
173 
174  return(nrErr);
175 
176 }
177 
int segCnt
Definition: tb_nal.cpp:830
bool gFatalError
Definition: tb_nal.cpp:152
void stepSim()
Increment the simulation counter.
Definition: test_arp.cpp:54
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
int main(int argc, char *argv[])
Main function for the test of the TCP Application Flash (TAF).
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
#define THIS_NAME
void tcp_app_flash(stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DataLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_SessId, stream< TcpDatLen > &soTSIF_DatLen)
Main process of the TCP Application Flash (TAF)
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.
: Testbench for TCP Application Flash.