Skip to content

Commit

Permalink
Use CMOD_ASSERT in testbenches, not NVHLS_ASSERT
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-k committed Aug 21, 2024
1 parent 04db271 commit 387617d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmod/include/axi/AxiMasterGate/testbench/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ SC_MODULE(Host) {
<< "\t data = " << hex << rdResp.data
<< "\t expected = " << hex << rd_data_expected
<< std::endl, kDebugLevel);
NVHLS_ASSERT_MSG(rdResp.data == rd_data_expected, "Read response data did not match expected value");
CMOD_ASSERT_MSG(rdResp.data == rd_data_expected, "Read response data did not match expected value");

if (rdResp.last == 1) ctr++;
if (ctr == read_count) done_read = 1;
Expand Down
20 changes: 10 additions & 10 deletions cmod/include/axi/testbench/MasterFromFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ template <typename axiCfg, bool enable_interrupts = false> class MasterFromFile
std::vector< std::vector<std::string> > dataList = reader.readCSV();
for (unsigned int i=0; i < dataList.size(); i++) {
std::vector<std::string> vec = dataList[i];
NVHLS_ASSERT_MSG(vec.size() == 5, "Each request must have five elements");
CMOD_ASSERT_MSG(vec.size() == 5, "Each request must have five elements");
if (!burst_inflight) delay_q.push(atoi(vec[0].c_str()));
if (vec[1] == "R") {
if (!burst_inflight) {
Expand All @@ -118,8 +118,8 @@ template <typename axiCfg, bool enable_interrupts = false> class MasterFromFile
sc_uint<axi4_::ALEN_WIDTH> len;
ss_len << hex << vec[4];
ss_len >> len;
if (len) NVHLS_ASSERT_MSG(axiCfg::useBurst, "A burst transaction was requested but the AXI config does not support bursts");
NVHLS_ASSERT_MSG(axiCfg::maxBurstSize >= len, "A burst transaction was requested that is longer than the maximum allowed by the AXI config");
if (len) CMOD_ASSERT_MSG(axiCfg::useBurst, "A burst transaction was requested but the AXI config does not support bursts");
CMOD_ASSERT_MSG(axiCfg::maxBurstSize >= len, "A burst transaction was requested that is longer than the maximum allowed by the AXI config");
addr_pld.len = 0;
addr_pld.len = static_cast<typename axi4_::BeatNum>(len);
raddr_q.push(addr_pld);
Expand All @@ -144,8 +144,8 @@ template <typename axiCfg, bool enable_interrupts = false> class MasterFromFile
sc_uint<axi4_::ALEN_WIDTH> len;
ss_len << hex << vec[4];
ss_len >> len;
if (len) NVHLS_ASSERT_MSG(axiCfg::useBurst, "A burst transaction was requested but the AXI config does not support bursts");
NVHLS_ASSERT_MSG(axiCfg::maxBurstSize >= len, "A burst transaction was requested that is longer than the maximum allowed by the AXI config");
if (len) CMOD_ASSERT_MSG(axiCfg::useBurst, "A burst transaction was requested but the AXI config does not support bursts");
CMOD_ASSERT_MSG(axiCfg::maxBurstSize >= len, "A burst transaction was requested that is longer than the maximum allowed by the AXI config");
addr_pld.len = static_cast<typename axi4_::BeatNum>(len);
waddr_q.push(addr_pld);
burst_inflight = int(len);
Expand All @@ -165,10 +165,10 @@ template <typename axiCfg, bool enable_interrupts = false> class MasterFromFile
}
wdata_q.push(wr_data_pld);
} else if (vec[1] == "Q") {
NVHLS_ASSERT_MSG(enable_interrupts, "Interrupt command read, but interrupts are not enabled");
CMOD_ASSERT_MSG(enable_interrupts, "Interrupt command read, but interrupts are not enabled");
req_q.push(2);
} else {
NVHLS_ASSERT_MSG(1, "Requests must be R or W or Q");
CMOD_ASSERT_MSG(1, "Requests must be R or W or Q");
}
}

Expand All @@ -192,7 +192,7 @@ template <typename axiCfg, bool enable_interrupts = false> class MasterFromFile
if (delay > 0) wait(delay);
delay_q.pop();
if (req_q.front() == 2) {
NVHLS_ASSERT_MSG(enable_interrupts,"Interrupt command found, but interrupts are not enabled");
CMOD_ASSERT_MSG(enable_interrupts,"Interrupt command found, but interrupts are not enabled");
CDCOUT(sc_time_stamp() << " " << name() << " Beginning wait for interrupt"
<< endl, kDebugLevel);
while (interrupt.read() == 0) wait();
Expand Down Expand Up @@ -226,11 +226,11 @@ template <typename axiCfg, bool enable_interrupts = false> class MasterFromFile
CDCOUT(sc_time_stamp() << " " << name() << " Received read response: ["
<< data_pld << "]"
<< endl, kDebugLevel);
NVHLS_ASSERT_MSG(data_pld.data == rresp_q.front(),"Read response did not match expected value");
CMOD_ASSERT_MSG(data_pld.data == rresp_q.front(),"Read response did not match expected value");
rresp_q.pop();
} while (!data_pld.last);
} else {
NVHLS_ASSERT_MSG(0,"Unexpected value in req_q");
CMOD_ASSERT_MSG(0,"Unexpected value in req_q");
}
req_q.pop();
}
Expand Down
4 changes: 2 additions & 2 deletions cmod/include/axi/testbench/Slave.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Slave : public sc_module {
typename axi4_::AddrPayload rd_addr_pld;
if (if_rd.nb_aread(rd_addr_pld)) {
typename axi4_::Addr addr = rd_addr_pld.addr;
NVHLS_ASSERT_MSG(addr % bytesPerBeat == 0, "Addresses must be word aligned");
CMOD_ASSERT_MSG(addr % bytesPerBeat == 0, "Addresses must be word aligned");
CDCOUT(sc_time_stamp() << " " << name() << " Received read request: ["
<< rd_addr_pld << "]"
<< endl, kDebugLevel);
Expand Down Expand Up @@ -174,7 +174,7 @@ class Slave : public sc_module {

// Grab a write request (addr) and put it in the local queue
if (if_wr.aw.PopNB(wr_addr_pld)) {
NVHLS_ASSERT_MSG(wr_addr_pld.addr.to_uint64() % bytesPerBeat == 0, "Addresses must be word aligned");
CMOD_ASSERT_MSG(wr_addr_pld.addr.to_uint64() % bytesPerBeat == 0, "Addresses must be word aligned");
wr_addr.push(wr_addr_pld);
CDCOUT(sc_time_stamp() << " " << name() << " Received write request: ["
<< wr_addr_pld << "]"
Expand Down
2 changes: 1 addition & 1 deletion cmod/include/axi/testbench/SlaveFromFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ template <typename axiCfg> class SlaveFromFile : public sc_module {
std::vector< std::vector<std::string> > dataList = reader.readCSV();
for (unsigned int i=0; i < dataList.size(); i++) {
std::vector<std::string> vec = dataList[i];
NVHLS_ASSERT_MSG(vec.size() == 2, "Each request must have two elements");
CMOD_ASSERT_MSG(vec.size() == 2, "Each request must have two elements");
std::stringstream ss;
sc_uint<axi4_::ADDR_WIDTH> addr_sc_uint;
ss << hex << vec[0];
Expand Down

0 comments on commit 387617d

Please sign in to comment.