updates ace_pin_level testcase with snoop and updates scc

This commit is contained in:
2023-10-04 22:17:38 +02:00
parent 50bd12b4ec
commit e30a569cfa
3 changed files with 112 additions and 28 deletions

View File

@@ -10,6 +10,21 @@ using namespace sc_core;
factory::add<testbench> tb;
struct {
unsigned int ResetCycles{4};
unsigned int BurstLengthByte{16};
// unsigned int BurstLengthByte{32};
unsigned int BurstSizeBytes{8};
// unsigned int NumberOfIterations{8};
unsigned int NumberOfIterations{2};
std::unordered_map<unsigned, std::pair<std::vector<tlm::scc::tlm_gp_shared_ptr>, std::vector<tlm::scc::tlm_gp_shared_ptr>>> read_tx;
std::unordered_map<unsigned, std::pair<std::vector<tlm::scc::tlm_gp_shared_ptr>, std::vector<tlm::scc::tlm_gp_shared_ptr>>> write_tx;
std::unordered_map<unsigned, std::pair<std::vector<tlm::scc::tlm_gp_shared_ptr>, std::vector<tlm::scc::tlm_gp_shared_ptr>>> snoop_tx;
unsigned resp_cnt{0};
} state;
int snoop_id=0;
bool operator==(tlm::tlm_generic_payload const& a, tlm::tlm_generic_payload const& b){
auto ret = true;
ret &= a.get_command() == b.get_command();
@@ -78,6 +93,31 @@ inline void randomize(tlm::tlm_generic_payload& gp) {
req_cnt++;
}
unsigned testbench::transport(tlm::tlm_generic_payload& trans) {
SCCDEBUG(__FUNCTION__)<<" update trans for snoop, with snoop_id = " << snoop_id;
// SCCDEBUG(__FUNCTION__)<<" in transport with trans " << trans;
// extracting address and snoop_e from ac_trans and pack them into cache data trans
auto ac_address = trans.get_address();
auto ext = trans.get_extension<ace_extension>();
auto ac_snoop=ext->get_snoop();
for(size_t i = 0; i < trans.get_data_length(); ++i) {
*(trans.get_data_ptr() + i) = i % 2 ? 123 : 128;
}
SCCDEBUG(__FUNCTION__)<<" vector size " <<state.snoop_tx[snoop_id].second.size();
state.snoop_tx[snoop_id].second.emplace_back(&trans);
/*
ext->set_snoop_data_transfer(true);
ext->set_snoop_error(false);
ext->set_pass_dirty(false);
ext->set_shared(false);
ext->set_snoop_was_unique(false);
*/
return 1;
}
template<typename STATE>
unsigned run_scenario(STATE& state){
auto& dut = factory::get<testbench>();
@@ -97,8 +137,6 @@ unsigned run_scenario(STATE& state){
return 0;
});
dut.rst.write(false);
sc_start(state.ResetCycles*dut.clk.period());
dut.rst.write(true);
@@ -116,7 +154,7 @@ unsigned run_scenario(STATE& state){
StartAddr += state.BurstSizeBytes;
}
});
/*
auto run2 = sc_spawn([&dut, &state](){
unsigned int StartAddr{0x2000};
for(int i = 0; i < state.NumberOfIterations; ++i) {
@@ -152,10 +190,26 @@ unsigned run_scenario(STATE& state){
StartAddr += state.BurstSizeBytes;
}
});
*/
auto run5 = sc_spawn([&dut, &state](){
unsigned int StartAddr{0x0};
for(int i = 0; i < state.NumberOfIterations; ++i) {
// tlm::scc::tlm_gp_shared_ptr trans = prepare_trans<testbench::bus_cfg>(StartAddr, 4, state.BurstLengthByte, state.BurstSizeBytes, 1);
tlm::scc::tlm_gp_shared_ptr trans = prepare_trans_ace<testbench::bus_cfg>(StartAddr, 4, state.BurstLengthByte, state.BurstSizeBytes, 1);
trans->set_command(tlm::TLM_READ_COMMAND);
SCCDEBUG(__FUNCTION__) << "run1, iteration " << i << "snoop_id = " << snoop_id <<" TX: "<<*trans;
dut.ace_tgt_pe.snoop(*trans);
state.snoop_tx[snoop_id].first.emplace_back(trans);
snoop_id++;
StartAddr += state.BurstSizeBytes;
}
});
unsigned cycles{0};
// while(cycles<1000 && !(run1.terminated() && run2.terminated() && run3.terminated() && run4.terminated())){
while(cycles<1000 && !(run1.terminated())){
while(cycles<1000 && !(run1.terminated() && run2.terminated() && run3.terminated() && run4.terminated())){
// while(cycles<1000 && !(run1.terminated())){
sc_start(10 * dut.clk.period());
cycles+=10;
}
@@ -163,25 +217,16 @@ unsigned run_scenario(STATE& state){
}
TEST_CASE("ace_burst_alignment", "[AXI][pin-level]") {
struct {
unsigned int ResetCycles{4};
// unsigned int BurstLengthByte{16};
unsigned int BurstLengthByte{32};
unsigned int BurstSizeBytes{8};
// unsigned int NumberOfIterations{8};
unsigned int NumberOfIterations{1};
std::unordered_map<unsigned, std::pair<std::vector<tlm::scc::tlm_gp_shared_ptr>, std::vector<tlm::scc::tlm_gp_shared_ptr>>> read_tx;
std::unordered_map<unsigned, std::pair<std::vector<tlm::scc::tlm_gp_shared_ptr>, std::vector<tlm::scc::tlm_gp_shared_ptr>>> write_tx;
unsigned resp_cnt{0};
} state;
state.resp_cnt=0;
auto cycles = run_scenario(state);
REQUIRE(cycles<1000);
REQUIRE(sc_report_handler::get_count(SC_ERROR) == 0);
REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0);
REQUIRE(state.resp_cnt==4*state.NumberOfIterations);
REQUIRE(state.resp_cnt==4*state.NumberOfIterations);
// REQUIRE(state.resp_cnt==1*state.NumberOfIterations);
for(auto& e: state.write_tx) {
auto const& send_tx = e.second.first;
auto const& recv_tx = e.second.second;
@@ -192,22 +237,40 @@ TEST_CASE("ace_burst_alignment", "[AXI][pin-level]") {
}
}
for(auto& e: state.read_tx) {
auto const& send_tx = e.second.first;
auto const& recv_tx = e.second.second;
REQUIRE(send_tx.size() == recv_tx.size());
for(auto i = 0; i<send_tx.size(); ++i){
REQUIRE(send_tx[i]->get_response_status() == tlm::TLM_OK_RESPONSE);
SCCDEBUG(__FUNCTION__) << " index = " << i ;
// SCCDEBUG(__FUNCTION__) <<" send value = "<<*send_tx[i];
// SCCDEBUG(__FUNCTION__) <<" received value = "<<*recv_tx[i];
CHECK(*send_tx[i] == *recv_tx[i]);
}
}
for(auto& e: state.snoop_tx) {
auto const& snoop_tx = e.second.first;
auto const& recv_tx = e.second.second;
REQUIRE(snoop_tx.size() == recv_tx.size());
for(auto i = 0; i<snoop_tx.size(); ++i){
REQUIRE(snoop_tx[i]->get_response_status() == tlm::TLM_OK_RESPONSE);
SCCDEBUG(__FUNCTION__) << " index = " << i ;
SCCDEBUG(__FUNCTION__) <<" send snoop value = "<<*snoop_tx[i];
SCCDEBUG(__FUNCTION__) <<" received value = "<<*recv_tx[i];
// CHECK(*snoop_tx[i] == *recv_tx[i]);
}
}
}
TEST_CASE("axi4_narrow_burst", "[AXI][pin-level]") {
struct {
/* struct {
unsigned int ResetCycles{4};
unsigned int BurstLengthByte{32};
// unsigned int BurstLengthByte{16};
// unsigned int BurstLengthByte{32};
unsigned int BurstLengthByte{16};
unsigned int BurstSizeBytes{4};
// unsigned int NumberOfIterations{8};
unsigned int NumberOfIterations{1};
@@ -215,7 +278,8 @@ TEST_CASE("axi4_narrow_burst", "[AXI][pin-level]") {
std::unordered_map<unsigned, std::pair<std::vector<tlm::scc::tlm_gp_shared_ptr>, std::vector<tlm::scc::tlm_gp_shared_ptr>>> write_tx;
unsigned resp_cnt{0};
} state;
*/
state.resp_cnt=0;
auto cycles = run_scenario(state);
REQUIRE(cycles<1000);
@@ -240,3 +304,5 @@ TEST_CASE("axi4_narrow_burst", "[AXI][pin-level]") {
}
}