2024-12-11 09:16:04 +01:00
|
|
|
#define SC_INCLUDE_FX
|
2024-12-11 09:18:37 +01:00
|
|
|
#include <cxs/tlm_network_cxs.h>
|
2024-12-11 09:16:04 +01:00
|
|
|
#include <scc/cci_util.h>
|
|
|
|
#include <scc/configurer.h>
|
|
|
|
#include <scc/observer.h>
|
|
|
|
#include <scc/sc_variable.h>
|
|
|
|
#include <scc/tracer.h>
|
|
|
|
#include <string>
|
|
|
|
#include <systemc>
|
|
|
|
|
|
|
|
using namespace sc_dt;
|
|
|
|
using namespace std;
|
|
|
|
using namespace cxs;
|
|
|
|
|
2024-12-11 09:18:37 +01:00
|
|
|
enum { PHIT_WIDTH = 664 };
|
2024-12-11 09:16:04 +01:00
|
|
|
struct testbench : public sc_core::sc_module,
|
2024-12-11 09:18:37 +01:00
|
|
|
public tlm::nw::tlm_network_fw_transport_if<tlm_network_cxs_types>,
|
|
|
|
public tlm::nw::tlm_network_bw_transport_if<tlm_network_cxs_types> {
|
2024-12-11 09:16:04 +01:00
|
|
|
|
|
|
|
using transaction_type = tlm_network_cxs_types::tlm_payload_type;
|
|
|
|
using phase_type = tlm_network_cxs_types::tlm_phase_type;
|
|
|
|
|
|
|
|
sc_core::sc_clock clk{"clk", 1_ns};
|
|
|
|
tlm_network_cxs_initiator_socket<PHIT_WIDTH> isck{"isck"};
|
|
|
|
cxs_channel<PHIT_WIDTH> cxs_chan{"cxs_chan"};
|
|
|
|
tlm_network_cxs_target_socket<PHIT_WIDTH> tsck{"tsck"};
|
|
|
|
|
|
|
|
testbench(sc_core::sc_module_name const& nm)
|
|
|
|
: sc_module(nm) {
|
|
|
|
isck(*this);
|
|
|
|
tsck(*this);
|
|
|
|
cxs_chan.rcv_clk_i(clk);
|
|
|
|
isck(cxs_chan.tsck);
|
|
|
|
cxs_chan.isck(tsck);
|
|
|
|
SC_HAS_PROCESS(testbench);
|
|
|
|
SC_THREAD(run);
|
|
|
|
cxs_chan.channel_delay.set_value(100_ns);
|
|
|
|
}
|
|
|
|
|
|
|
|
void run() {
|
|
|
|
cxs::tlm_network_cxs_payload trans;
|
|
|
|
trans.set_command(cxs::CXS_CMD::DATA);
|
|
|
|
sc_core::sc_time t = sc_core::SC_ZERO_TIME;
|
|
|
|
isck->b_transport(trans, t);
|
|
|
|
tlm_cxs_shared_ptr trans_ptr = tlm_mm_cxs::get().allocate();
|
|
|
|
auto phase{tlm::nw::REQUEST};
|
|
|
|
auto status = isck->nb_transport_fw(*trans_ptr, phase, t);
|
|
|
|
if(status == tlm::TLM_UPDATED) {
|
2024-12-11 09:18:37 +01:00
|
|
|
sc_assert(phase == tlm::nw::CONFIRM);
|
2024-12-11 09:16:04 +01:00
|
|
|
}
|
|
|
|
wait(target_received_evt);
|
|
|
|
sc_core::sc_stop();
|
|
|
|
}
|
|
|
|
|
2024-12-11 09:18:37 +01:00
|
|
|
void b_transport(transaction_type& trans, sc_core::sc_time& t) override { SCCINFO(SCMOD) << "Received blocking transaction"; }
|
2024-12-11 09:16:04 +01:00
|
|
|
|
|
|
|
tlm::tlm_sync_enum nb_transport_fw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) override {
|
2024-12-11 09:18:37 +01:00
|
|
|
if(phase == tlm::nw::INDICATION) {
|
|
|
|
SCCINFO(SCMOD) << "Received non-blocking transaction with phase " << phase.get_name();
|
2024-12-11 09:16:04 +01:00
|
|
|
target_received_evt.notify(sc_core::SC_ZERO_TIME);
|
|
|
|
phase = tlm::nw::RESPONSE;
|
|
|
|
return tlm::TLM_UPDATED;
|
|
|
|
}
|
|
|
|
throw std::runtime_error("illegal request in forward path");
|
|
|
|
}
|
|
|
|
|
|
|
|
tlm::tlm_sync_enum nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) override {
|
2024-12-11 09:18:37 +01:00
|
|
|
if(phase == tlm::nw::CONFIRM) {
|
2024-12-11 09:16:04 +01:00
|
|
|
return tlm::TLM_ACCEPTED;
|
|
|
|
}
|
|
|
|
throw std::runtime_error("illegal response in backward path");
|
|
|
|
}
|
|
|
|
|
2024-12-11 09:18:37 +01:00
|
|
|
unsigned int transport_dbg(transaction_type& trans) override { return 0; }
|
2024-12-11 09:16:04 +01:00
|
|
|
|
|
|
|
sc_core::sc_event target_received_evt;
|
|
|
|
};
|
|
|
|
|
|
|
|
int sc_main(int sc_argc, char* sc_argv[]) {
|
|
|
|
scc::init_logging(scc::log::INFO);
|
|
|
|
scc::configurer cfg("");
|
|
|
|
scc::tracer trc("cxs_tlm");
|
|
|
|
testbench tb("tb");
|
|
|
|
sc_core::sc_start();
|
|
|
|
SCCINFO("sc_main") << "End Simulation.";
|
|
|
|
|
|
|
|
return sc_core::sc_report_handler::get_count(sc_core::SC_ERROR) + sc_core::sc_report_handler::get_count(sc_core::SC_WARNING);
|
|
|
|
} // End of 'sc_main'
|