class busmux:sc_module { public: // Use tagged sockets to be able to distinguish incoming backward path calls tlm_utils::multi_passthrough_target_sockettarg_socket; tlm_utils::multi_passthrough_initiator_socket init_socket; // Constructor busmux(sc_module_name name, uint32_t threshold); // FORWARD PATH // TLM-2 blocking transport method virtual void b_transport(int id, tlm::tlm_generic_payload &trans, sc_time &delay); uint32_t threshold; };
busmux::busmux(sc_module_name name, uint32_t threshold): sc_module(name), targ_socket("targ_socket"), init_socket("init_socket"), threshold(threshold) { // Register callbacks for incoming interface method calls targ_socket.register_b_transport(this, &busmux::b_transport); } // TLM-2 blocking transport method void busmux::b_transport(int id, tlm::tlm_generic_payload &trans, sc_time &delay) { uint32_t adr = (uint32_t) trans.get_address(); if (adr < threshold) init_socket[0]->b_transport(trans, delay); else { init_socket[1]->b_transport(trans, delay); } }