cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_rlb.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 
30 #include "test_rlb.hpp"
31 
32 using namespace hls;
33 using namespace std;
34 
35 //---------------------------------------------------------
36 // HELPERS FOR THE DEBUGGING TRACES
37 // .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)
38 //---------------------------------------------------------
39 #define THIS_NAME "TB"
40 
41 #define TRACE_OFF 0x0000
42 #define TRACE_CGRF 1 << 1
43 #define TRACE_CGTF 1 << 2
44 #define TRACE_DUMTF 1 << 3
45 #define TRACE_ALL 0xFFFF
46 #define DEBUG_LEVEL (TRACE_OFF)
47 
48 
51 void stepSim() {
52  gSimCycCnt++;
53  if (gTraceEvent || ((gSimCycCnt % 1000) == 0)) {
54  printInfo(THIS_NAME, "-- [@%4.4d] -----------------------------\n", gSimCycCnt);
55  gTraceEvent = false;
56  }
57  else if (0) {
58  printInfo(THIS_NAME, "------------------- [@%d] ------------\n", gSimCycCnt);
59  }
60 }
61 
62 
63 
66 int main(int argc, char *argv[]) {
67 
68  gSimCycCnt = 0;
69 
70  //------------------------------------------------------
71  //-- TESTBENCH LOCAL VARIABLES
72  //------------------------------------------------------
73  int nrErr = 0; // Tb error counter.
74 
75  //------------------------------------------------------
76  //-- DUT SIGNAL INTERFACES and RELATED VARIABLEs
77  //------------------------------------------------------
78  StsBit sRLB_MMIO_Ready;
79 
80  //------------------------------------------------------
81  //-- DUT STREAM INTERFACES and RELATED VARIABLEs
82  //------------------------------------------------------
83  stream<StsBool> ssTOE_RLB_Data ("ssTOE_RLB_Data");
84  stream<StsBool> ssUOE_RLB_Data ("ssUOE_RLB_Data");
85 
86 
87  printInfo(THIS_NAME, "############################################################################\n");
88  printInfo(THIS_NAME, "## TESTBENCH 'test_rlb' STARTS HERE ##\n");
89  printInfo(THIS_NAME, "############################################################################\n");
90  printf("\n");
91 
92  for (int i=0; i<gMaxSimCycles; i++) {
93  switch(i) {
94  case 1:
95  ssTOE_RLB_Data.write(false);
96  ssUOE_RLB_Data.write(false);
97  break;
98  case 10:
99  if (sRLB_MMIO_Ready != false) {
100  printError(THIS_NAME, "The ready signal is expected inactive (false) but was found to be active (true).\n");
101  nrErr++;
102  }
103  break;
104  case 25:
105  ssTOE_RLB_Data.write(true);
106  break;
107  case 50:
108  ssUOE_RLB_Data.write(true);
109  break;
110  case 75:
111  if (sRLB_MMIO_Ready != true) {
112  printError(THIS_NAME, "The ready signal is expected active (true) but was found to be inactive (false).\n");
113  nrErr++;
114  }
115  break;
116  default:
117  break;
118  }
119  //-- RUN one cycle of the DUT
120  rlb(
121  //-- MMIO Interface
122  &sRLB_MMIO_Ready,
123  //-- UOE / Data Stream Interface
124  ssUOE_RLB_Data,
125  //-- TOE / Data Stream Interface
126  ssTOE_RLB_Data
127  );
128  stepSim();
129  }
130 
131  printInfo(THIS_NAME, "############################################################################\n");
132  printInfo(THIS_NAME, "## TESTBENCH 'test_rlb' ENDS HERE ##\n");
133  printInfo(THIS_NAME, "############################################################################\n");
134  stepSim();
135 
136  if (nrErr) {
137  printError(THIS_NAME, "###########################################################\n");
138  printError(THIS_NAME, "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
139  printError(THIS_NAME, "###########################################################\n\n");
140 
141  printInfo(THIS_NAME, "FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
142  }
143  else {
144  printInfo(THIS_NAME, "#############################################################\n");
145  printInfo(THIS_NAME, "#### SUCCESSFUL END OF TEST ####\n");
146  printInfo(THIS_NAME, "#############################################################\n");
147  }
148 
149  return nrErr;
150 
151  return 0;
152 }
153 
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
bool gTraceEvent
Definition: tb_nal.cpp:151
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69
int main(int argc, char *argv[])
Main function.
Definition: test_rlb.cpp:66
void stepSim()
Increment the simulation counter.
Definition: test_rlb.cpp:51
#define THIS_NAME
Definition: test_rlb.cpp:39
void rlb(StsBit *poMMIO_Ready, stream< StsBool > &siUOE_Ready, stream< StsBool > &siTOE_Ready)
Main process of the Ready Logic Barrier (RLB).
Definition: rlb.cpp:62
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
ap_uint< 1 > StsBit
Definition: nts_types.hpp:116
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
: Testbench for the UDP Offload Engine (UOE).