adds quantum_keeper_mt test
Some checks failed
SCC Test/pipeline/head There was a failure building this commit

This commit is contained in:
2025-11-25 06:53:11 +01:00
parent bd032c08ce
commit 3082b3c98b
5 changed files with 29 additions and 10 deletions

5
.vscode/launch.json vendored
View File

@@ -8,7 +8,10 @@
"type": "gdb", "type": "gdb",
"request": "launch", "request": "launch",
"name": "quantum_keeper_mt", "name": "quantum_keeper_mt",
"program": "${workspaceFolder}/build/Debug/tests/quantum_keeper_mt/quantum_keeper_mt" "program": "${workspaceFolder}/build/Debug/tests/quantum_keeper_mt/quantum_keeper_mt",
"environment": {
"SCC_TEST_VERBOSE": "7"
}
}, },
{ {
"name": "cppdbg quantum_keeper_mt", "name": "cppdbg quantum_keeper_mt",

2
scc

Submodule scc updated: cc35ebf490...df0b69632d

View File

@@ -1,5 +1,5 @@
if(SC_VERSION_MAJOR GREATER 2) if(SC_VERSION_MAJOR GREATER 2)
add_executable (quantum_keeper_mt sc_main.cpp) add_executable (quantum_keeper_mt sc_main.cpp)
target_link_libraries (quantum_keeper_mt LINK_PUBLIC scc-sysc) target_link_libraries (quantum_keeper_mt LINK_PUBLIC scc::components)
add_test(NAME quantum_keeper_mt COMMAND quantum_keeper_mt) add_test(NAME quantum_keeper_mt COMMAND quantum_keeper_mt)
endif() endif()

View File

@@ -7,6 +7,7 @@
#include <scc/report.h> #include <scc/report.h>
#include <scc/trace.h> #include <scc/trace.h>
#include <scc/tracer.h> #include <scc/tracer.h>
#include <sysc/kernel/sc_simcontext.h>
#include <sysc/utils/sc_report.h> #include <sysc/utils/sc_report.h>
#include <sysc/utils/sc_report_handler.h> #include <sysc/utils/sc_report_handler.h>
#include <tlm_utils/tlm_quantumkeeper.h> #include <tlm_utils/tlm_quantumkeeper.h>
@@ -38,6 +39,8 @@ int sc_main(int argc, char* argv[]) {
top_module top_mod("top_module_inst"); top_module top_mod("top_module_inst");
// Start the simulation // Start the simulation
sc_core::sc_start(20_us); sc_core::sc_start(20_us);
if(sc_core::sc_is_running())
sc_core::sc_stop();
SCCINFO() << "Simulation finished"; SCCINFO() << "Simulation finished";
} else { } else {
SCCERR() << "Some error occured"; SCCERR() << "Some error occured";

View File

@@ -1,11 +1,13 @@
#ifndef _TOP_MODULE_H_ #ifndef _TOP_MODULE_H_
#define _TOP_MODULE_H_ #define _TOP_MODULE_H_
#include "scc/mt19937_rng.h"
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <scc/async_queue.h> #include <scc/async_queue.h>
#include <scc/async_thread.h> #include <scc/async_thread.h>
#include <scc/report.h> #include <scc/report.h>
#include <scc/router.h>
#include <sysc/kernel/sc_initializer_function.h> #include <sysc/kernel/sc_initializer_function.h>
#include <sysc/kernel/sc_module.h> #include <sysc/kernel/sc_module.h>
#include <sysc/kernel/sc_simcontext.h> #include <sysc/kernel/sc_simcontext.h>
@@ -17,13 +19,15 @@
#include <tlm_utils/simple_initiator_socket.h> #include <tlm_utils/simple_initiator_socket.h>
#include <tlm_utils/simple_target_socket.h> #include <tlm_utils/simple_target_socket.h>
#include <util/logging.h> #include <util/logging.h>
enum { CLIENT_DELAY = 100, SC_DELAY = 10 }; enum { CLIENT_DELAY = 100, SC_DELAY = 10 };
struct initiator : ::sc_core ::sc_module { struct initiator : ::sc_core ::sc_module {
tlm_utils::simple_initiator_socket<initiator, scc::LT> isckt{"isckt"}; tlm_utils::simple_initiator_socket<initiator, scc::LT> isckt{"isckt"};
initiator(sc_core::sc_module_name nm) initiator(sc_core::sc_module_name nm, sc_core::sc_time period = 1_us)
: sc_core::sc_module(nm) { : sc_core::sc_module(nm)
, period(period) {
SC_THREAD(run); SC_THREAD(run);
} }
@@ -55,7 +59,7 @@ private:
quantum_keeper.inc(t); quantum_keeper.inc(t);
} }
} else { } else {
quantum_keeper.check_and_sync(1_us); quantum_keeper.check_and_sync(period);
} }
SCCDEBUG(SCMOD) << "local time now " << quantum_keeper.get_local_absolute_time(); SCCDEBUG(SCMOD) << "local time now " << quantum_keeper.get_local_absolute_time();
} }
@@ -64,17 +68,23 @@ private:
} }
tlm::scc::quantumkeeper_mt quantum_keeper; tlm::scc::quantumkeeper_mt quantum_keeper;
scc::async_thread core_executor; scc::async_thread core_executor;
const sc_core::sc_time period{1_us};
}; };
// top_module // top_module
struct top_module : ::sc_core ::sc_module { struct top_module : ::sc_core ::sc_module {
initiator core{"core"}; initiator core0{"core0"};
initiator core1{"core1", 1500_ns};
scc::router<scc::LT> router{"router", 1, 2};
tlm_utils::simple_target_socket<top_module, scc::LT> tsckt{"tsckt"}; tlm_utils::simple_target_socket<top_module, scc::LT> tsckt{"tsckt"};
top_module(sc_core::sc_module_name nm) top_module(sc_core::sc_module_name nm)
: sc_core::sc_module(nm) { : sc_core::sc_module(nm) {
core.isckt(tsckt); core0.isckt(router.target[0]);
core1.isckt(router.target[1]);
router.initiator[0](tsckt);
router.set_default_target(0);
tsckt.register_b_transport(this, &top_module::b_transport); tsckt.register_b_transport(this, &top_module::b_transport);
SC_THREAD(run); SC_THREAD(run);
} }
@@ -83,7 +93,8 @@ struct top_module : ::sc_core ::sc_module {
void b_transport(tlm::tlm_generic_payload& gp, sc_core::sc_time& t) { void b_transport(tlm::tlm_generic_payload& gp, sc_core::sc_time& t) {
SCCDEBUG(SCMOD) << "Received b_transport call at local time " << t; SCCDEBUG(SCMOD) << "Received b_transport call at local time " << t;
t += 5_us; auto cycles = rng.uniform(0, 5);
t += sc_core::sc_time(cycles, sc_core::SC_US);
gp.set_response_status(tlm::TLM_OK_RESPONSE); gp.set_response_status(tlm::TLM_OK_RESPONSE);
} }
@@ -91,8 +102,10 @@ struct top_module : ::sc_core ::sc_module {
wait(sc_core::SC_ZERO_TIME); wait(sc_core::SC_ZERO_TIME);
while(true) { while(true) {
std::this_thread::sleep_for(std::chrono::milliseconds(SC_DELAY)); std::this_thread::sleep_for(std::chrono::milliseconds(SC_DELAY));
wait(1500_ns); wait(500_ns);
} }
} }
scc::MT19937 rng;
}; };
#endif // _TOP_MODULE_H_ #endif // _TOP_MODULE_H_