From 0e5cf3fb3ac199a47f073f2bcee0abd4b3951896 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 28 Jul 2018 09:41:07 +0200 Subject: [PATCH] Extracted tlm_signal into separate file and added signal interface --- incl/tlm/tlm_signal.h | 94 +++++++++++++++++++++++++++++++++++ incl/tlm/tlm_signal_sockets.h | 72 --------------------------- 2 files changed, 94 insertions(+), 72 deletions(-) diff --git a/incl/tlm/tlm_signal.h b/incl/tlm/tlm_signal.h index c7bd9fd0..2e2ae724 100644 --- a/incl/tlm/tlm_signal.h +++ b/incl/tlm/tlm_signal.h @@ -11,4 +11,98 @@ #include "tlm_signal_gp.h" #include "tlm_signal_sockets.h" +namespace tlm { + +template, int N = 32> +struct tlm_signal: + public sc_core::sc_module, + public tlm_signal_fw_transport_if, + public tlm_signal_bw_transport_if, + sc_core::sc_signal_in_if +{ + using tlm_signal_type = SIG; + using protocol_types = TYPES; + using payload_type = typename TYPES::tlm_payload_type; + using phase_type = typename TYPES::tlm_phase_type; + + SC_HAS_PROCESS(tlm_signal); + + tlm_signal_opt_target_socket in; + + tlm_signal_opt_initiator_socket out; + + tlm_signal(sc_core::sc_module_name nm) + : sc_core::sc_module(nm) + , in(sc_core::sc_gen_unique_name("in")) + , out(sc_core::sc_gen_unique_name("out")) + { + in.bind(*(tlm_signal_fw_transport_if*)this); + out.bind(*(tlm_signal_bw_transport_if*)this); + SC_METHOD(que_cb); + sensitive< que; + sc_core::sc_signal value; +}; + +template +void tlm_signal::trace(sc_core::sc_trace_file* tf) const { + sc_trace(tf, value, name()); +} + + +template +tlm_sync_enum tlm::tlm_signal::nb_transport_fw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) { + que.notify(gp.get_value(), delay); + auto& p = out.get_base_port(); + for(size_t i=0; inb_transport_fw(gp, phase, delay); + } +} + +template +tlm_sync_enum tlm::tlm_signal::nb_transport_bw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) { + auto& p = in.get_base_port(); + for(size_t i=0; inb_transport_bw(gp, phase, delay); + } +} + +template +void tlm::tlm_signal::que_cb(){ + while(auto oi = que.get_next()) + value.write(oi.value()); +} + +} #endif /* _TLM_TLM_SIGNAL_H_ */ diff --git a/incl/tlm/tlm_signal_sockets.h b/incl/tlm/tlm_signal_sockets.h index 9defd61d..d5b670a7 100644 --- a/incl/tlm/tlm_signal_sockets.h +++ b/incl/tlm/tlm_signal_sockets.h @@ -121,78 +121,6 @@ struct tlm_signal_target_socket : template , int N = 1> using tlm_signal_opt_target_socket = struct tlm_signal_target_socket; - -template, int N = 32> -struct tlm_signal: - public sc_core::sc_module, - public tlm_signal_fw_transport_if, - public tlm_signal_bw_transport_if -{ - using tlm_signal_type = SIG; - using protocol_types = TYPES; - using payload_type = typename TYPES::tlm_payload_type; - using phase_type = typename TYPES::tlm_phase_type; - - SC_HAS_PROCESS(tlm_signal); - - tlm_signal_opt_target_socket in; - - tlm_signal_opt_initiator_socket out; - - tlm_signal(sc_core::sc_module_name nm) - : sc_core::sc_module(nm) - , in(sc_core::sc_gen_unique_name("in")) - , out(sc_core::sc_gen_unique_name("out")) - { - in.bind(*(tlm_signal_fw_transport_if*)this); - out.bind(*(tlm_signal_bw_transport_if*)this); - SC_METHOD(que_cb); - sensitive< que; - tlm_signal_type value; -}; - -template -void tlm_signal::trace(sc_core::sc_trace_file* tf) const { - sc_trace(tf, value, name()); -} - - -template -tlm_sync_enum tlm::tlm_signal::nb_transport_fw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) { - que.notify(gp.get_value(), delay); - auto& p = out.get_base_port(); - for(size_t i=0; inb_transport_fw(gp, phase, delay); - } -} - -template -tlm_sync_enum tlm::tlm_signal::nb_transport_bw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) { - auto& p = in.get_base_port(); - for(size_t i=0; inb_transport_bw(gp, phase, delay); - } -} - -template -void tlm::tlm_signal::que_cb(){ - while(auto oi = que.get_next()) - value=oi.value(); -} - } #endif /* _TLM_TLM_SIGNAL_SOCKETS_H_ */