adds multi-packet CXS test case
This commit is contained in:
parent
1eba464c61
commit
085423620d
2
scc
2
scc
@ -1 +1 @@
|
|||||||
Subproject commit dd8a539df05a14ab320f81af08b0db17faf489cb
|
Subproject commit 331b6d77ea5f9aed99bd0963a3bb234cf7c98b07
|
@ -4,10 +4,11 @@
|
|||||||
#include <tlm/scc/tlm_gp_shared.h>
|
#include <tlm/scc/tlm_gp_shared.h>
|
||||||
#undef CHECK
|
#undef CHECK
|
||||||
#include <catch2/catch_all.hpp>
|
#include <catch2/catch_all.hpp>
|
||||||
|
#include <deque>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace sc_core;
|
using namespace sc_core;
|
||||||
|
namespace cxs {
|
||||||
factory::add<testbench<256>> tb8;
|
factory::add<testbench<256>> tb8;
|
||||||
factory::add<testbench<512>> tb9;
|
factory::add<testbench<512>> tb9;
|
||||||
factory::add<testbench<1024>> tb10;
|
factory::add<testbench<1024>> tb10;
|
||||||
@ -22,22 +23,34 @@ template <unsigned WIDTH, typename STATE> unsigned run_scenario(STATE& state) {
|
|||||||
|
|
||||||
auto run1 = sc_spawn([&dut, &state]() {
|
auto run1 = sc_spawn([&dut, &state]() {
|
||||||
auto burst_cnt{0};
|
auto burst_cnt{0};
|
||||||
|
std::deque<cxs_pkt_shared_ptr> expected_pkt;
|
||||||
for(auto size : state.packet_sizes) {
|
for(auto size : state.packet_sizes) {
|
||||||
cxs_pkt_shared_ptr tx_pkt = cxs_pkt_mm::get().allocate();
|
cxs_pkt_shared_ptr tx_pkt = cxs_pkt_mm::get().allocate();
|
||||||
tx_pkt->get_data().resize(size);
|
tx_pkt->get_data().resize(size);
|
||||||
|
SCCDEBUG("run_scenario") << "Transmitting packet with size " << size;
|
||||||
auto phase{tlm::nw::REQUEST};
|
auto phase{tlm::nw::REQUEST};
|
||||||
sc_core::sc_time t = sc_core::SC_ZERO_TIME;
|
sc_core::sc_time t = sc_core::SC_ZERO_TIME;
|
||||||
auto status = dut.isck->nb_transport_fw(*tx_pkt, phase, t);
|
auto status = dut.isck->nb_transport_fw(*tx_pkt, phase, t);
|
||||||
|
expected_pkt.emplace_back(tx_pkt);
|
||||||
|
tx_pkt = nullptr;
|
||||||
REQUIRE(status == tlm::TLM_UPDATED);
|
REQUIRE(status == tlm::TLM_UPDATED);
|
||||||
REQUIRE(phase == tlm::nw::CONFIRM);
|
REQUIRE(phase == tlm::nw::CONFIRM);
|
||||||
if(++burst_cnt == state.granularity) {
|
if(++burst_cnt == state.granularity) {
|
||||||
::sc_core::wait(dut.recv.data_written_event());
|
auto rec_cnt = 0u;
|
||||||
while(!dut.recv.empty()) {
|
while(rec_cnt < burst_cnt) {
|
||||||
auto recv_pkt = dut.recv.front();
|
::sc_core::wait(dut.recv.data_written_event());
|
||||||
dut.recv.pop_front();
|
while(!dut.recv.empty()) {
|
||||||
REQUIRE(tx_pkt == recv_pkt);
|
auto recv_pkt = dut.recv.front();
|
||||||
REQUIRE(recv_pkt->get_data().size() == state.packet_sizes[state.resp_cnt]);
|
dut.recv.pop_front();
|
||||||
state.resp_cnt++;
|
tx_pkt = expected_pkt.front();
|
||||||
|
expected_pkt.pop_front();
|
||||||
|
REQUIRE(tx_pkt == recv_pkt);
|
||||||
|
REQUIRE(recv_pkt->get_data().size() == state.packet_sizes[state.resp_cnt]);
|
||||||
|
state.resp_cnt++;
|
||||||
|
rec_cnt++;
|
||||||
|
SCCDEBUG("run_scenario") << "Received packet with size " << recv_pkt->get_data().size()
|
||||||
|
<< ", total number of packets is " << state.resp_cnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
burst_cnt = 0;
|
burst_cnt = 0;
|
||||||
}
|
}
|
||||||
@ -89,24 +102,26 @@ TEST_CASE("single-packet", "[CXS][tlm-level]") {
|
|||||||
REQUIRE(state.resp_cnt == state.packet_sizes.size());
|
REQUIRE(state.resp_cnt == state.packet_sizes.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
TEST_CASE("flit-alignment", "[CXS][tlm-level]") {
|
TEST_CASE("multi-packet", "[CXS][tlm-level]") {
|
||||||
struct {
|
struct {
|
||||||
unsigned int reset_cycles{4};
|
unsigned int reset_cycles{4};
|
||||||
|
unsigned int max_cycles = 5000;
|
||||||
std::vector<unsigned int> packet_sizes;
|
std::vector<unsigned int> packet_sizes;
|
||||||
unsigned granularity{2};
|
unsigned granularity{2};
|
||||||
unsigned resp_cnt{0};
|
unsigned resp_cnt{0};
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
state.packet_sizes.assign({4, 32, 32, 8, 64, 128});
|
state.packet_sizes.assign({4, 8, 16, 32, 16, 64, 16, 128, 16, 256, 16, 1024});
|
||||||
state.resp_cnt = 0;
|
for(auto width = 8; width < 11; ++width) {
|
||||||
auto cycles = run_scenario(8, state);
|
state.resp_cnt = 0;
|
||||||
|
auto cycles = run_scenario(width, state);
|
||||||
|
|
||||||
REQUIRE(cycles < 1000);
|
REQUIRE(cycles < state.max_cycles);
|
||||||
REQUIRE(sc_report_handler::get_count(SC_ERROR) == 0);
|
REQUIRE(sc_report_handler::get_count(SC_ERROR) == 0);
|
||||||
REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0);
|
REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0);
|
||||||
|
|
||||||
REQUIRE(state.resp_cnt == state.packet_sizes.size());
|
REQUIRE(state.resp_cnt == state.packet_sizes.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} // namespace cxs
|
||||||
*/
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
using namespace sc_core;
|
using namespace sc_core;
|
||||||
using namespace sc_dt;
|
using namespace sc_dt;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cxs;
|
namespace cxs {
|
||||||
|
|
||||||
const char* sc_gen_unique_name(const char*, bool preserve_first);
|
const char* sc_gen_unique_name(const char*, bool preserve_first);
|
||||||
template <unsigned PHIT_WIDTH> struct testbench : public sc_core::sc_module {
|
template <unsigned PHIT_WIDTH> struct testbench : public sc_core::sc_module {
|
||||||
@ -72,5 +72,5 @@ template <unsigned PHIT_WIDTH> struct testbench : public sc_core::sc_module {
|
|||||||
sc_core::sc_event confirmation_evt;
|
sc_core::sc_event confirmation_evt;
|
||||||
scc::fifo_w_cb<cxs_pkt_shared_ptr> recv;
|
scc::fifo_w_cb<cxs_pkt_shared_ptr> recv;
|
||||||
};
|
};
|
||||||
|
} // namespace cxs
|
||||||
#endif // _TESTBENCH_H_
|
#endif // _TESTBENCH_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user