20 #ifndef __SIMPLESWITCHAT_H__ 21 #define __SIMPLESWITCHAT_H__ 25 #include "tlm_utils/multi_passthrough_initiator_socket.h" 26 #include "tlm_utils/multi_passthrough_target_socket.h" 29 #include "tlm_utils/instance_specific_extensions.h" 30 #include "tlm_utils/peq_with_cb_and_phase.h" 98 target_socket(
"target_socket"),
99 initiator_socket(
"initiator_socket"),
118 m_addrMap.
insert(low, high, m_target_count++);
119 m_masks.push_back(
mask);
124 return m_addrMap.
decode(address);
129 m_pendingReqs.resize(initiator_socket.
size());
130 m_pendingResps.resize(target_socket.
size());
140 bool added_mm=!trans.
has_mm();
159 void free(transaction_type* txn){
171 unsigned int tgtSocketNumber){
172 switch (initiator_socket[tgtSocketNumber]->nb_transport_fw(trans, phase, t)) {
179 m_bwPEQ.
notify(trans,phase,t);
189 m_bwPEQ.
notify(trans, phase, t);
198 transaction_type& trans,
204 m_fwPEQ.
notify(trans,phase,t);
210 connInfo->
bwID=initiator_id;
225 transaction_type& trans,
230 std::cout <<
"ERROR: '" <<
name()
231 <<
"': Illegal phase received from target." << std::endl;
235 m_bwPEQ.
notify(trans,phase,t);
239 void bwPEQcb(transaction_type& trans,
const phase_type& phase){
248 bool doCall=btag==NULL;
252 m_pendingReqs[connInfo->
fwID].pop_front();
253 if (m_pendingReqs[connInfo->
fwID].size()){
261 m_pendingResps[connInfo->
bwID].push_back(&trans);
262 doCall=m_pendingResps[connInfo->
bwID].size()==1;
268 m_fwPEQ.
notify(trans, ph, t);
271 switch (target_socket[connInfo->
bwID]->nb_transport_bw(trans, p, t)){
278 m_fwPEQ.
notify(trans, ph, t);
290 void fwPEQcb(transaction_type& trans,
const phase_type& phase){
298 m_pendingReqs[connInfo->
fwID].push_back(&trans);
299 if (m_pendingReqs[connInfo->
fwID].size()==1){
310 sync_enum_type tmp=initiator_socket[connInfo->
fwID]->nb_transport_fw(trans, ph, t);
314 m_pendingResps[connInfo->
bwID].pop_front();
315 if (m_pendingResps[connInfo->
bwID].size()){
317 m_bwPEQ.
notify(*m_pendingResps[connInfo->
bwID].front(),ph,
t);
319 m_connInfoPool.
free(connInfo);
326 <<
" Number of connected initiators: "<<target_socket.
size()<<std::endl
327 <<
" Number of connected targets: "<<initiator_socket.
size()<<std::endl
328 <<
" Pending requests:"<<std::endl;
329 for (
unsigned int i=0;
i<m_pendingReqs.size();
i++)
330 std::cout<<
" "<<m_pendingReqs[
i].size()<<
" pending requests for target number "<<
i<<std::endl;
331 std::cout<<
" Pending responses:"<<std::endl;
332 for (
unsigned int i=0;
i<m_pendingResps.size();
i++)
333 std::cout<<
" "<<m_pendingResps[
i].size()<<
" pending responses for initiator number "<<
i<<std::endl;
334 std::cout<<
" The address map is:"<<std::endl;
MultiSocketSimpleSwitchAT(sc_core::sc_module_name name)
SC_HAS_PROCESS(MultiSocketSimpleSwitchAT)
unsigned int decode(sc_dt::uint64 address_)
Decode slave address.
tlm::tlm_generic_payload transaction_type
tlm_utils::multi_passthrough_target_socket< MultiSocketSimpleSwitchAT > target_socket_type
std::vector< std::deque< transaction_type * > > m_pendingReqs
Simple address map implementation for the generic protocol.
void register_b_transport(MODULE *mod, b_cb cb)
base_type::base_target_socket_type base_target_socket_type
void notify(tlm_payload_type &t, const tlm_phase_type &p, const sc_core::sc_time &when)
const char * name() const
sync_enum_type initiatorNBTransport(int initiator_id, transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
initiator_socket_type initiator_socket
sc_dt::uint64 get_address() const
sync_enum_type targetNBTransport(int portId, transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
tlm_utils::peq_with_cb_and_phase< MultiSocketSimpleSwitchAT > m_fwPEQ
void set_address(const sc_dt::uint64 address)
tlm_utils::peq_with_cb_and_phase< MultiSocketSimpleSwitchAT > m_bwPEQ
void register_nb_transport_bw(MODULE *mod, sync_enum_type(MODULE::*cb)(int, transaction_type &, phase_type &, sc_core::sc_time &))
void insert(sc_dt::uint64 baseAddress_, sc_dt::uint64 highAddress_, unsigned int portNumber_)
Insert a slave into the address map.
std::vector< sc_dt::uint64 > m_masks
tlm_utils::multi_passthrough_initiator_socket< MultiSocketSimpleSwitchAT > initiator_socket_type
target_socket_type target_socket
std::vector< std::deque< transaction_type * > > m_pendingResps
tlm::tlm_sync_enum sync_enum_type
void register_nb_transport_fw(MODULE *mod, nb_cb cb)
void initiatorNBTransport_core(transaction_type &trans, phase_type &phase, sc_core::sc_time &t, unsigned int tgtSocketNumber)
const sc_time & sc_time_stamp()
void free(transaction_type *txn)
const sc_time SC_ZERO_TIME
void fwPEQcb(transaction_type &trans, const phase_type &phase)
tlm::tlm_phase phase_type
SimpleAddressMap m_addrMap
void set_mm(tlm_mm_interface *mm)
int get_ref_count() const
ExtensionPool< ConnectionInfo > m_connInfoPool
unsigned int decode(const sc_dt::uint64 &address)
void bindTargetSocket(initiator_socket_type::base_target_socket_type &target, sc_dt::uint64 low, sc_dt::uint64 high, sc_dt::uint64 mask=0xffffffffffffffffULL)
void bwPEQcb(transaction_type &trans, const phase_type &phase)
unsigned int m_target_count
tlm::tlm_phase tlm_phase_type
ConnectionInfo tlm_payload_type
tlm_utils::instance_specific_extension_accessor accessMySpecificExtensions
void b_transport(int initiator_id, transaction_type &trans, sc_core::sc_time &t)
void start_of_simulation()