From 604ee46418af5d286e42f690b1e9e8f36a70a22d Mon Sep 17 00:00:00 2001 From: juanmanuel Date: Sun, 6 Oct 2024 10:05:08 -0500 Subject: [PATCH] fix: use of only one ni for both normal noc and circuit switching noc --- src/networkInterface/NetworkInterfaceTlm.cpp | 68 +++++++++++++++++--- src/networkInterface/NetworkInterfaceTlm.h | 19 ++++++ src/networkInterface/NetworkInterfaceTlmCS.h | 2 +- 3 files changed, 80 insertions(+), 9 deletions(-) diff --git a/src/networkInterface/NetworkInterfaceTlm.cpp b/src/networkInterface/NetworkInterfaceTlm.cpp index b93d0d1..22f3ec7 100755 --- a/src/networkInterface/NetworkInterfaceTlm.cpp +++ b/src/networkInterface/NetworkInterfaceTlm.cpp @@ -61,6 +61,11 @@ NetworkInterfaceTlm::NetworkInterfaceTlm(sc_module_name nm, Node& node, &NetworkInterfaceTlm::nb_transport_bw_cb, 0); target.register_nb_transport_fw(this, &NetworkInterfaceTlm::nb_transport_fw_cb, 0); + + initiator_cs.register_nb_transport_bw(this, + &NetworkInterfaceTlm::nb_transport_bw_cb, 0); + target_cs.register_nb_transport_fw(this, + &NetworkInterfaceTlm::nb_transport_fw_cb, 0); } NetworkInterfaceTlm::~NetworkInterfaceTlm() { @@ -157,7 +162,43 @@ void NetworkInterfaceTlm::send_flit(Packet* p, Flit* f){ sc_time delay = sc_time(REQ_INIT_DELAY, UNITS_DELAY); tlm::tlm_phase send_phase = tlm::BEGIN_REQ; - initiator->nb_transport_fw(*trans, send_phase, delay); + + if(p->dataType == TYPE_STREAM){ + initiator_cs->nb_transport_fw(*trans, send_phase, delay); + } + else{ + initiator->nb_transport_fw(*trans, send_phase, delay); + } +} + + +bool NetworkInterfaceTlm::check_cs_needed(tlm_gp& trans){ + int type = get_type_from_extension(trans); + return type == TYPE_INIT_STREAM || type == TYPE_END_STREAM; +}; + +void NetworkInterfaceTlm::send_cs_rout_conf_msg(tlm_gp& trans){ + tlm::tlm_generic_payload* new_trans = m_mm.allocate(); + new_trans->acquire(); + new_trans->set_command(tlm::TLM_WRITE_COMMAND); + new_trans->set_address(trans.get_address()); + new_trans->set_data_ptr(trans.get_data_ptr()); + new_trans->set_data_length(trans.get_data_length()); + new_trans->set_streaming_width(trans.get_streaming_width()); + new_trans->set_byte_enable_ptr(trans.get_byte_enable_ptr()); + new_trans->set_dmi_allowed(false); + new_trans->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); + + // add id to new_transaction + link_extension* ext = new link_extension(); + ext->link = dest_link; // set direction of connected router + ext->data_type = get_type_from_extension(trans); + new_trans->set_extension(ext); + + // send transaction in socket + tlm_phase phase = BEGIN_REQ; + sc_time delay = sc_time(REQ_INIT_DELAY, UNITS_DELAY); + initiator_cs->nb_transport_fw(*new_trans, phase, delay); } void NetworkInterfaceTlm::send_data_to_noc(){ @@ -300,6 +341,7 @@ void NetworkInterfaceTlm::receive_and_process_flit(tlm_gp& trans){ p->inTransmit.erase(position); p->transmitted.push_back(received_flit->id); + // log arrived flit if (received_flit->type==TAIL || received_flit->type==SINGLE){ stringstream ss; string flit_type = received_flit->type==SINGLE ? "Single":"Tail"; @@ -317,13 +359,21 @@ void NetworkInterfaceTlm::receive_and_process_flit(tlm_gp& trans){ packet_recv_queue.push(p); credit_counter++; - if(resp_in_progress) { - if(nxt_resp_pend){ - log_fatal("Attempt to have two pending responses in target"); - nxt_resp_pend = &trans; - } + // send configuration message to cs_router + if(check_cs_needed(link, trans)){ + send_cs_rout_conf_msg(trans); + } + + // send response if not type stream + if(p->dataType != TYPE_STREAM){ + if(resp_in_progress) { + if(nxt_resp_pend){ + log_fatal("Attempt to have two pending responses in target"); + nxt_resp_pend = &trans; + } + } + else{ send_response(trans); } } - else{ send_response(trans); } } @@ -375,7 +425,9 @@ tlm::tlm_sync_enum NetworkInterfaceTlm::send_end_req(tlm_gp& trans){ } // Queue internal event to mark beginning of response - delay = delay + sc_time(INTERN_PROC_DELAY, UNITS_DELAY); // Latency + delay = p->dataType != TYPE_STREAM ? + delay + sc_time(INTERN_PROC_DELAY, UNITS_DELAY) : + SC_ZERO_TIME; // no processing on stream target_peq.notify(trans, INTERNAL_PROC_PHASE, delay); return status; diff --git a/src/networkInterface/NetworkInterfaceTlm.h b/src/networkInterface/NetworkInterfaceTlm.h index be73d17..3bb23b9 100755 --- a/src/networkInterface/NetworkInterfaceTlm.h +++ b/src/networkInterface/NetworkInterfaceTlm.h @@ -70,6 +70,9 @@ public: Dir send_data_in_prog_dest; MemoryManager m_mm; uint8_t max_pos[3]; + // To Circuit Switching NoC + ni_init_socket initiator_cs; + ni_targ_socket target_cs; sc_event_or_list ev_msg_arrv; @@ -122,6 +125,22 @@ public: */ tlm_gp* build_transaction(Packet* p, Flit* f); + /** + * If message is init streaming, a router_cs needs to be + * configured + * + * @param trans TLM generic payload object + */ + bool check_cs_needed(tlm_gp& trans); + + /** + * Sends configuration message to router_cs + * + * @param trans TLM generic payload object + */ + bool send_cs_rout_conf_msg(tlm_gp& trans); + + /** * Generates flits when a packet arrives */ diff --git a/src/networkInterface/NetworkInterfaceTlmCS.h b/src/networkInterface/NetworkInterfaceTlmCS.h index 5b46756..83347f8 100755 --- a/src/networkInterface/NetworkInterfaceTlmCS.h +++ b/src/networkInterface/NetworkInterfaceTlmCS.h @@ -57,7 +57,7 @@ private: */ void receive_and_process_flit(tlm_gp& trans) override; - /** + /** * Send end request * * @param trans TLM generic payload object