52 #define THIS_NAME "TB_UAF"
62 int main(
int argc,
char *argv[]) {
92 ap_uint<1> sSHL_UAF_Mmio_PostPktEn = 0;
93 ap_uint<1> sSHL_UAF_Mmio_CaptPktEn = 0;
96 ap_uint<1> sSHL_UAF_Mmio_PostPktEn = 0;
97 ap_uint<1> sSHL_UAF_Mmio_CaptPktEn = 0;
100 ap_uint<1> sSHL_UAF_Mmio_PostPktEn = 0;
101 ap_uint<1> sSHL_UAF_Mmio_CaptPktEn = 0;
103 ap_uint<2> sSHL_UAF_Mmio_EchoCtrl =
ECHO_OFF;
104 ap_uint<1> sSHL_UAF_Mmio_PostPktEn = 0;
105 ap_uint<1> sSHL_UAF_Mmio_CaptPktEn = 0;
111 stream<UdpAppData> ssUSIF_UAF_Data (
"ssUSIF_UAF_Data");
112 stream<UdpAppMeta> ssUSIF_UAF_Meta (
"ssUSIF_UAF_Meta");
113 stream<UdpAppDLen> ssUSIF_UAF_DLen (
"ssUSIF_UAF_DLen");
114 stream<UdpAppData> ssUAF_USIF_Data (
"ssUAF_USIF_Data");
115 stream<UdpAppMeta> ssUAF_USIF_Meta (
"ssUAF_USIF_Meta");
116 stream<UdpAppDLen> ssUAF_USIF_DLen (
"ssUAF_USIF_DLen");
122 printFatal(
THIS_NAME,
"Expected a minimum of 2 parameters with the following synopsis:\n \t\t mode(0|1|2) siUAF_<Filename>.dat\n");
124 tbCtrlMode =
EchoCtrl(atoi(argv[1]));
125 if (tbCtrlMode != sSHL_UAF_Mmio_EchoCtrl) {
126 printFatal(
THIS_NAME,
"tbCtrlMode (%d) does not match TB_MODE (%d). Modify the CFLAG and re-compile.\n", tbCtrlMode, TB_MODE);
129 switch (tbCtrlMode) {
135 printFatal(
THIS_NAME,
"The 'ECHO' mode %d is no longer supported since the removal of the MMIO EchoCtrl bits. \n", tbCtrlMode);
141 printf(
"#####################################################\n");
142 printf(
"## TESTBENCH STARTS HERE ##\n");
143 printf(
"#####################################################\n");
144 printInfo(
THIS_NAME,
"This testbench will be executed with the following parameters: \n");
146 for (
int i=2; i<argc; i++) {
154 ofstream ofsUSIF_Data;
155 const char *ofsUSIF_Data_FileName =
"../../../../test/simOutFiles/soUSIF_Data.dat";
156 ofstream ofsUSIF_Meta;
157 const char *ofsUSIF_Meta_FileName =
"../../../../test/simOutFiles/soUSIF_Meta.dat";
158 ofstream ofsUSIF_DLen;
159 const char *ofsUSIF_DLen_FileName =
"../../../../test/simOutFiles/soUSIF_DLen.dat";
161 string ofsUSIF_Data_Gold_FileName =
"../../../../test/simOutFiles/soUSIF_Data_Gold.dat";
162 string ofsUSIF_Meta_Gold_FileName =
"../../../../test/simOutFiles/soUSIF_Meta_Gold.dat";
163 string ofsUSIF_DLen_Gold_FileName =
"../../../../test/simOutFiles/soUSIF_DLen_Gold.dat";
169 if (not
isDatFile(ofsUSIF_Data_FileName)) {
174 remove(ofsUSIF_Data_FileName);
176 if (not
isDatFile(ofsUSIF_Meta_FileName)) {
181 remove(ofsUSIF_Meta_FileName);
182 if (!ofsUSIF_Meta.is_open()) {
190 if (not
isDatFile(ofsUSIF_DLen_FileName)) {
195 remove(ofsUSIF_DLen_FileName);
196 if (!ofsUSIF_DLen.is_open()) {
206 queue<UdpAppMeta> udpMetaQueue;
207 queue<UdpAppDLen> udpDLenQueue;
209 ofsUSIF_Data_Gold_FileName, ofsUSIF_Meta_Gold_FileName, ofsUSIF_DLen_Gold_FileName) !=
NTS_OK) {
215 int nrUSIF_UAF_Chunks=0;
217 ssUSIF_UAF_Meta,
"ssUSIF_UAF_Meta",
218 ssUSIF_UAF_DLen,
"ssUSIF_UAF_DLen",
220 udpMetaQueue, udpDLenQueue,
221 nrUSIF_UAF_Chunks)) {
226 int tbRun = (nrErr == 0) ? (nrUSIF_UAF_Chunks +
TB_GRACE_TIME) : 0;
230 &sSHL_UAF_Mmio_Enable,
246 printInfo(
THIS_NAME,
"############################################################################\n");
248 printInfo(
THIS_NAME,
"############################################################################\n");
252 int nrUAF_USIF_DataChunks=0, nrUAF_USIF_DataGrams=0, nrUAF_USIF_DataBytes=0;
254 ofsUSIF_Data_FileName, nrUAF_USIF_DataChunks, nrUAF_USIF_DataGrams, nrUAF_USIF_DataBytes)) {
260 printInfo(
THIS_NAME,
"\tReceived %d chunks in %d datagrams, for a total of %d bytes.\n\n",
261 nrUAF_USIF_DataChunks, nrUAF_USIF_DataGrams, nrUAF_USIF_DataBytes);
264 int nrUAF_USIF_MetaChunks=0, nrUAF_USIF_MetaGrams=0, nrUAF_USIF_MetaBytes=0;
266 ofsUSIF_Meta_FileName, nrUAF_USIF_MetaChunks, nrUAF_USIF_MetaGrams, nrUAF_USIF_MetaBytes)) {
271 int nrUAF_USIF_DLenChunks=0, nrUAF_USIF_DLenGrams=0, nrUAF_USIF_DLenBytes=0;
273 ofsUSIF_DLen_FileName, nrUAF_USIF_DLenChunks, nrUAF_USIF_DLenGrams, nrUAF_USIF_DLenBytes)) {
282 ifsFile.open(ofsUSIF_Data_FileName, ofstream::in);
287 else if (not (ifsFile.peek() == ifstream::traits_type::eof())) {
289 std::string(ofsUSIF_Data_Gold_FileName));
292 ofsUSIF_Data_FileName, ofsUSIF_Data_Gold_FileName.c_str());
302 ifsFile.open(ofsUSIF_DLen_FileName, ofstream::in);
307 else if (not (ifsFile.peek() == ifstream::traits_type::eof())) {
309 std::string(ofsUSIF_DLen_Gold_FileName));
312 ofsUSIF_DLen_FileName, ofsUSIF_DLen_Gold_FileName.c_str());
329 printInfo(
THIS_NAME,
"This testbench was executed with the following parameters: \n");
331 for (
int i=2; i<argc; i++) {
337 printError(
THIS_NAME,
"#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
340 printInfo(
THIS_NAME,
"FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
343 printInfo(
THIS_NAME,
"#############################################################\n");
345 printInfo(
THIS_NAME,
"#############################################################\n");
void stepSim()
Increment the simulation counter.
bool isDatFile(string fileName)
Checks if a file has a ".dat" extension.
bool drainAxisToFile(stream< AXIS_T > &ss, const string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Empty an Axi4-Stream (Axis) to a DAT file.
int myDiffTwoFiles(string dataFileName, string goldFileName)
Compares 2 files line-by-line, up to length of the 2nd file.
int createGoldenTxFiles(string inpData_FileName, string outData_GoldName, queue< UdpAppMeta > &udpMetaQueue, queue< UdpAppDLen > &updDLenQueue, char tbMode)
Create the golden IPTX reference file from an input UAIF test file.
bool drainUdpDLenStreamToFile(stream< UdpAppDLen > &ss, string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Empty an UdpDLen stream to a DAT file.
bool drainUdpMetaStreamToFile(stream< UdpAppMeta > &ss, string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Empty an UdpMeta stream to a DAT file.
#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.
int main(int argc, char *argv[])
Main function for the test of the UDP Application Flash (UAF).
unsigned int gMaxSimCycles
int createUdpRxTraffic(stream< AxisApp > &ssData, const string ssDataName, stream< UdpAppMeta > &ssMeta, const string ssMetaName, stream< UdpAppDLen > &ssDLen, const string ssMDLenName, string datFile, queue< UdpAppMeta > &metaQueue, queue< UdpAppDLen > &dlenQueue, int &nrFeededChunks)
Create the UDP Rx traffic as streams from an input test file.
void udp_app_flash(CmdBit *piSHL_Mmio_En, stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppDLen > &siUSIF_DLen, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen)
Main process of the UDP Application Flash (UAF)
: Testbench for the UDP Application Flash (UAF).