16 #ifndef __SIGNAL_TARGET_MIXIN_H__
17 #define __SIGNAL_TARGET_MIXIN_H__
19 #include "scc/utilities.h"
22 #include <tlm/scc/tlm_signal.h>
31 using tlm_signal_type =
typename BASE_TYPE::tlm_signal_type;
32 using transaction_type =
typename BASE_TYPE::transaction_type;
33 using phase_type =
typename BASE_TYPE::phase_type;
34 using sync_enum_type = tlm::tlm_sync_enum;
50 , error_if_no_callback(true)
55 using BASE_TYPE::bind;
61 void register_nb_transport(std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)> cb) {
62 fw_if.set_nb_transport_ptr(cb);
72 void register_nb_transport(std::function<sync_enum_type(
unsigned int, transaction_type&, phase_type&, sc_core::sc_time&)> cb,
74 fw_if.set_nb_transport_ptr(cb, tag);
77 bool error_if_no_callback;
81 sync_enum_type bw_nb_transport(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) {
82 return BASE_TYPE::operator->()->nb_transport_bw(trans, phase, t);
85 class fw_process_if :
public fw_interface_type {
87 using transport_fct = std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)>;
88 using transport_tagged_fct = std::function<sync_enum_type(
unsigned int, transaction_type&, phase_type&, sc_core::sc_time&)>;
90 fw_process_if(
const signal_target_mixin* p_own)
93 void set_nb_transport_ptr(transport_fct p) {
94 if(m_transport_ptr || m_transport_tagged_ptr) {
96 s << m_owner->name() <<
": non-blocking callback allready registered";
97 SC_REPORT_WARNING(
"/OSCI_TLM-2/signal_target_mixin", s.str().c_str());
103 void set_nb_transport_ptr(transport_tagged_fct p,
unsigned int tag) {
104 if(m_transport_ptr || m_transport_tagged_ptr) {
106 s << m_owner->name() <<
": non-blocking callback allready registered";
107 SC_REPORT_WARNING(
"/OSCI_TLM-2/signal_target_mixin", s.str().c_str());
109 m_transport_tagged_ptr = p;
115 sync_enum_type nb_transport_fw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) {
116 if(m_transport_ptr) {
118 return m_transport_ptr(trans, phase, t);
119 }
else if(m_transport_tagged_ptr) {
121 return m_transport_tagged_ptr(tag, trans, phase, t);
122 }
else if(m_owner->error_if_no_callback) {
124 s << m_owner->name() <<
": no transport callback registered";
125 SC_REPORT_ERROR(
"/OSCI_TLM-2/signal_target_mixin", s.str().c_str());
127 return tlm::TLM_COMPLETED;
131 const signal_target_mixin* m_owner;
132 unsigned int tag = 0;
133 transport_fct m_transport_ptr =
nullptr;
134 transport_tagged_fct m_transport_tagged_ptr =
nullptr;
143 #include <sysc/datatypes/bit/sc_logic.h>
146 using tlm_signal_bool_in = signal_target_mixin<tlm_signal_target_socket<bool>>;
147 using tlm_signal_logic_in = signal_target_mixin<tlm_signal_target_socket<sc_dt::sc_logic>>;
148 using tlm_signal_bool_opt_in = signal_target_mixin<tlm_signal_opt_target_socket<bool>>;
149 using tlm_signal_logic_opt_in = signal_target_mixin<tlm_signal_opt_target_socket<sc_dt::sc_logic>>;
void register_nb_transport(std::function< sync_enum_type(transaction_type &, phase_type &, sc_core::sc_time &)> cb)
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_fw call
signal_target_mixin(const char *n)