17 #ifndef _TLM_TLM_SIGNAL_H_
18 #define _TLM_TLM_SIGNAL_H_
20 #include "tlm_signal_gp.h"
21 #include "tlm_signal_sockets.h"
29 template <
typename SIG =
bool,
typename TYPES = tlm_signal_baseprotocol_types<SIG>,
int N = 32>
33 sc_core::sc_signal_in_if<SIG> {
34 using tlm_signal_type = SIG;
35 using protocol_types = TYPES;
36 using payload_type =
typename TYPES::tlm_payload_type;
37 using phase_type =
typename TYPES::tlm_phase_type;
46 : sc_core::sc_module(nm)
47 , in(sc_core::sc_gen_unique_name(
"in"))
48 , out(sc_core::sc_gen_unique_name(
"out")) {
52 sensitive << que.
event();
55 void trace(sc_core::sc_trace_file* tf)
const override;
57 const char* kind()
const override {
return "tlm_signal"; }
59 tlm_sync_enum nb_transport_fw(payload_type&, phase_type&, sc_core::sc_time&)
override;
61 tlm_sync_enum nb_transport_bw(payload_type&, phase_type&, sc_core::sc_time&)
override;
64 const sc_core::sc_event& value_changed_event()
const override {
return value.value_changed_event(); }
66 const SIG& read()
const override {
return value.read(); }
68 const SIG& get_data_ref()
const override {
return value.get_data_ref(); }
70 bool event()
const override {
return false; }
72 const sc_core::sc_event& default_event()
const override {
return value.default_event(); }
74 const sc_core::sc_event& posedge_event()
const override {
return value.posedge_event(); }
76 const sc_core::sc_event& negedge_event()
const override {
return value.negedge_event(); }
78 bool posedge()
const override {
return value.posedge(); }
80 bool negedge()
const override {
return value.posedge(); };
85 sc_core::sc_signal<tlm_signal_type> value;
89 sc_trace(tf, value, name());
92 template <
typename SIG,
typename TYPES,
int N>
93 tlm_sync_enum tlm_signal<SIG, TYPES, N>::nb_transport_fw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) {
94 que.notify(gp.get_value(), delay);
95 auto& p = out.get_base_port();
96 for(
size_t i = 0; i < p.size(); ++i) {
97 p.get_interface(i)->nb_transport_fw(gp, phase, delay);
102 template <
typename SIG,
typename TYPES,
int N>
103 tlm_sync_enum tlm_signal<SIG, TYPES, N>::nb_transport_bw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) {
104 auto& p = in.get_base_port();
105 for(
size_t i = 0; i < p.size(); ++i) {
106 p.get_interface(i)->nb_transport_bw(gp, phase, delay);
108 return TLM_COMPLETED;
111 template <
typename SIG,
typename TYPES,
int N>
void tlm_signal<SIG, TYPES, N>::que_cb() {
112 while(
auto oi = que.get_next())
113 value.write(oi.get());
sc_core::sc_event & event()
get the available event