diff --git a/CMakePresets.json b/CMakePresets.json index 7db4d33..d2c6882 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,6 +18,15 @@ "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"cmake-conan/conan_provider.cmake" } }, + { + "name": "DebugCXX11", + "cacheVariables": { + "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_CXX_STANDARD": "11", + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"cmake-conan/conan_provider.cmake" + } + }, { "name": "RelWithDebInfo", "cacheVariables": { diff --git a/scc b/scc index 66d3b8f..8b9784d 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 66d3b8f9ee209d7343448bf259b93cc4ab85218b +Subproject commit 8b9784da1cd849e86df6a22b55bdaeec3572d762 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1e275dc..7004527 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(ace_pin_level) add_subdirectory(configuration) add_subdirectory(configurer) add_subdirectory(sc_fixed_tracing) +add_subdirectory(cxs_tlm) if(FULL_TEST_SUITE) add_subdirectory(sim_performance) endif() diff --git a/tests/cxs_tlm/CMakeLists.txt b/tests/cxs_tlm/CMakeLists.txt new file mode 100644 index 0000000..1a68c5b --- /dev/null +++ b/tests/cxs_tlm/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable (cxs_tlm sc_main.cpp) +target_link_libraries (cxs_tlm LINK_PUBLIC busses scc-sysc) +add_test(NAME cxs_tlm COMMAND cxs_tlm ) \ No newline at end of file diff --git a/tests/cxs_tlm/sc_main.cpp b/tests/cxs_tlm/sc_main.cpp new file mode 100644 index 0000000..8474fb9 --- /dev/null +++ b/tests/cxs_tlm/sc_main.cpp @@ -0,0 +1,92 @@ +#define SC_INCLUDE_FX +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace sc_dt; +using namespace std; +using namespace cxs; + +enum {PHIT_WIDTH=664}; +struct testbench : public sc_core::sc_module, +public tlm::nw::tlm_network_fw_transport_if, +public tlm::nw::tlm_network_bw_transport_if { + + 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 isck{"isck"}; + cxs_channel cxs_chan{"cxs_chan"}; + tlm_network_cxs_target_socket 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) { + sc_assert(phase==tlm::nw::CONFIRM); + } + wait(target_received_evt); + sc_core::sc_stop(); + } + + void b_transport(transaction_type& trans, sc_core::sc_time& t) override { + SCCINFO(SCMOD)<<"Received blocking transaction"; + } + + tlm::tlm_sync_enum nb_transport_fw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) override { + if(phase==tlm::nw::INDICATION) { + SCCINFO(SCMOD)<<"Received non-blocking transaction with phase " << phase.get_name(); + 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 { + if(phase==tlm::nw::CONFIRM) { + return tlm::TLM_ACCEPTED; + } + throw std::runtime_error("illegal response in backward path"); + } + + unsigned int transport_dbg(transaction_type& trans) override { + return 0; + } + + 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'