17 #ifndef __SIGNAL_INITIATOR_MIXIN_H__
18 #define __SIGNAL_INITIATOR_MIXIN_H__
20 #include "scc/utilities.h"
23 #include <tlm/scc/tlm_signal.h>
32 using tlm_signal_type =
typename BASE_TYPE::tlm_signal_type;
33 using transaction_type =
typename BASE_TYPE::transaction_type;
34 using phase_type =
typename BASE_TYPE::phase_type;
35 using sync_enum_type = tlm::tlm_sync_enum;
45 , error_if_no_callback(
false)
50 using BASE_TYPE::bind;
52 void write_now(tlm_signal_type value) {
54 gp->set_command(tlm::TLM_WRITE_COMMAND);
57 tlm::tlm_phase phase{tlm::BEGIN_REQ};
58 sc_core::sc_time delay{sc_core::SC_ZERO_TIME};
59 (*this)->nb_transport_fw(*gp, phase, delay);
63 template <
typename EXT_TYPE>
void write_now(tlm_signal_type value, EXT_TYPE* ext) {
65 gp->set_command(tlm::TLM_WRITE_COMMAND);
68 gp->set_extension(ext);
70 tlm::tlm_phase phase{tlm::BEGIN_REQ};
71 sc_core::sc_time delay{sc_core::SC_ZERO_TIME};
72 (*this)->nb_transport_fw(*gp, phase, delay);
80 void register_nb_transport(std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)> cb) {
81 bw_if.set_nb_transport_ptr(cb);
91 void register_nb_transport(std::function<sync_enum_type(
unsigned int, transaction_type&, phase_type&, sc_core::sc_time&)> cb,
93 bw_if.set_nb_transport_ptr(cb);
96 bool error_if_no_callback;
99 class bw_transport_if :
public bw_interface_type {
101 using transport_fct = std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)>;
102 using transport_tagged_fct = std::function<sync_enum_type(
unsigned int, transaction_type&, phase_type&, sc_core::sc_time&)>;
107 void set_nb_transport_ptr(transport_fct p) {
108 if(m_transport_ptr || m_transport_tagged_ptr) {
110 s << m_owner->name() <<
": non-blocking callback allready registered";
111 SC_REPORT_WARNING(
"/OSCI_TLM-2/signal_initiator_mixin", s.str().c_str());
117 void set_nb_transport_ptr(transport_fct p,
unsigned int tag) {
118 if(m_transport_ptr || m_transport_tagged_ptr) {
120 s << m_owner->name() <<
": non-blocking callback allready registered";
121 SC_REPORT_WARNING(
"/OSCI_TLM-2/signal_initiator_mixin", s.str().c_str());
123 m_transport_tagged_ptr = p;
128 sync_enum_type nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) {
130 return m_transport_ptr(trans, phase, t);
131 else if(m_transport_tagged_ptr)
132 return m_transport_tagged_ptr(tag, trans, phase, t);
133 else if(m_owner->error_if_no_callback) {
135 s << m_owner->name() <<
": no transport callback registered";
136 SC_REPORT_ERROR(
"/OSCI_TLM-2/signal_initiator_mixin", s.str().c_str());
138 return tlm::TLM_COMPLETED;
142 const signal_initiator_mixin* m_owner;
143 unsigned int tag = 0;
144 transport_fct m_transport_ptr =
nullptr;
145 transport_tagged_fct m_transport_tagged_ptr =
nullptr;
149 bw_transport_if bw_if;
154 #include <sysc/datatypes/bit/sc_logic.h>
157 using tlm_signal_bool_out = signal_initiator_mixin<tlm_signal_initiator_socket<bool>>;
158 using tlm_signal_logic_out = signal_initiator_mixin<tlm_signal_initiator_socket<sc_dt::sc_logic>>;
159 using tlm_signal_bool_opt_out = signal_initiator_mixin<tlm_signal_opt_initiator_socket<bool>>;
160 using tlm_signal_logic_opt_out = signal_initiator_mixin<tlm_signal_opt_initiator_socket<sc_dt::sc_logic>>;
void register_nb_transport(std::function< sync_enum_type(unsigned int, transaction_type &, phase_type &, sc_core::sc_time &)> cb, unsigned int tag)
register a functor for nb_transport_bw call
void register_nb_transport(std::function< sync_enum_type(transaction_type &, phase_type &, sc_core::sc_time &)> cb)