diff --git a/config/simple_2_layer_test/config.xml b/config/simple_2_layer_test/config.xml
new file mode 100755
index 0000000..c9fe69b
--- /dev/null
+++ b/config/simple_2_layer_test/config.xml
@@ -0,0 +1,55 @@
+
+
+
+
+ report
+
+
+ config/simple_test/net.xml
+
+
+
+
+
+ task
+ config/simple_2_layer_test/data.xml
+ config/simple_2_layer_test/map.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5 6 9 10
+
+
diff --git a/config/simple_2_layer_test/data.xml b/config/simple_2_layer_test/data.xml
new file mode 100644
index 0000000..8faccf1
--- /dev/null
+++ b/config/simple_2_layer_test/data.xml
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/simple_2_layer_test/map.xml b/config/simple_2_layer_test/map.xml
new file mode 100644
index 0000000..2973719
--- /dev/null
+++ b/config/simple_2_layer_test/map.xml
@@ -0,0 +1,19 @@
+
+
diff --git a/config/simple_2_layer_test/net.xml b/config/simple_2_layer_test/net.xml
new file mode 100644
index 0000000..7407f52
--- /dev/null
+++ b/config/simple_2_layer_test/net.xml
@@ -0,0 +1,879 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/simple_2_point_test/net.xml b/config/simple_2_point_test/net.xml
index 843b14b..7407f52 100644
--- a/config/simple_2_point_test/net.xml
+++ b/config/simple_2_point_test/net.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/config/simple_test/net.xml b/config/simple_test/net.xml
index 843b14b..7407f52 100644
--- a/config/simple_test/net.xml
+++ b/config/simple_test/net.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/config/simple_test/simple_data.xml b/config/simple_test/simple_data.xml
index aa5f49b..e01c948 100644
--- a/config/simple_test/simple_data.xml
+++ b/config/simple_test/simple_data.xml
@@ -21,7 +21,7 @@
-
+
@@ -34,7 +34,7 @@
-
+
diff --git a/config/config.xml b/config/synthetic_test/config.xml
similarity index 100%
rename from config/config.xml
rename to config/synthetic_test/config.xml
diff --git a/config/data_original.xml b/config/synthetic_test/data_original.xml
similarity index 94%
rename from config/data_original.xml
rename to config/synthetic_test/data_original.xml
index 76e1b2b..6e5a628 100755
--- a/config/data_original.xml
+++ b/config/synthetic_test/data_original.xml
@@ -29,7 +29,7 @@
-
+
@@ -49,7 +49,7 @@
-
+
@@ -64,7 +64,7 @@
-
+
@@ -78,7 +78,7 @@
-
+
@@ -107,7 +107,7 @@
-
+
@@ -122,7 +122,7 @@
-
+
diff --git a/config/map_original.xml b/config/synthetic_test/map_original.xml
similarity index 100%
rename from config/map_original.xml
rename to config/synthetic_test/map_original.xml
diff --git a/config/network.xml b/config/synthetic_test/net.xml
similarity index 99%
rename from config/network.xml
rename to config/synthetic_test/net.xml
index c21e274..f91ea32 100755
--- a/config/network.xml
+++ b/config/synthetic_test/net.xml
@@ -8,21 +8,21 @@
-
+
-
+
-
+
diff --git a/src/networkInterface/NetworkInterfaceTlm.cpp b/src/networkInterface/NetworkInterfaceTlm.cpp
index 66c5868..4d5baaf 100755
--- a/src/networkInterface/NetworkInterfaceTlm.cpp
+++ b/src/networkInterface/NetworkInterfaceTlm.cpp
@@ -31,8 +31,6 @@ using namespace std;
NetworkInterfaceTlm::NetworkInterfaceTlm(sc_module_name nm, Node& node,
uint8_t max_pos[3]) : NetworkInterface(nm, node),
credit_counter(NUM_CREDITS), ni_name(nm),
- initiator((string(nm)+"_initiator").c_str()),
- target((string(nm)+"_target").c_str()),
init_peq(this, &NetworkInterfaceTlm::init_peq_cb),
target_peq(this, &NetworkInterfaceTlm::target_peq_cb),
curr_req(0), resp_in_progress(false),
@@ -55,15 +53,17 @@ NetworkInterfaceTlm::NetworkInterfaceTlm(sc_module_name nm, Node& node,
SC_METHOD(receivePacketFromPE);
sensitive << packetPortContainer->portValidIn.pos();
- initiator.register_nb_transport_bw(this,
- &NetworkInterfaceTlm::nb_transport_bw_cb, 0);
- target.register_nb_transport_fw(this,
- &NetworkInterfaceTlm::nb_transport_fw_cb, 0);
+ for(uint lay=0; layregister_nb_transport_bw(this,
+ &NetworkInterfaceTlm::nb_transport_bw_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);
+ target[lay] = new ni_targ_socket((string(nm)+"_"+
+ to_string(lay)+"targ").c_str());
+ target[lay]->register_nb_transport_fw(this,
+ &NetworkInterfaceTlm::nb_transport_fw_cb, 0);
+ }
}
NetworkInterfaceTlm::~NetworkInterfaceTlm() {
@@ -134,6 +134,7 @@ tlm_gp* NetworkInterfaceTlm::build_transaction(Packet* p, Flit* f){
link_extension* ext = new link_extension();
ext->link = Direction::local;
ext->data_type = p->dataType;
+ ext->is_config_msg = false;
trans->set_extension(ext);
trans->set_command(tlm::TLM_WRITE_COMMAND);
@@ -161,12 +162,10 @@ 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;
- if(p->dataType == TYPE_STREAM){
- initiator_cs->nb_transport_fw(*trans, send_phase, delay);
- }
- else{
- initiator->nb_transport_fw(*trans, send_phase, delay);
- }
+ int lay = p->dataType == TYPE_STREAM ? 1:0;
+ log_info("Sending flit of type "+to_string(p->dataType)+
+ " to layer "+to_string(lay));
+ (*initiator[lay])->nb_transport_fw(*trans, send_phase, delay);
}
@@ -176,6 +175,12 @@ int NetworkInterfaceTlm::get_type_from_extension(tlm_gp& trans){
return extension->data_type;
}
+bool NetworkInterfaceTlm::get_is_cfg_from_extension(tlm_gp& trans){
+ link_extension* extension;
+ trans.get_extension(extension);
+ return extension->is_config_msg;
+}
+
bool NetworkInterfaceTlm::check_cs_needed(tlm_gp& trans){
int type = get_type_from_extension(trans);
@@ -198,12 +203,13 @@ void NetworkInterfaceTlm::send_cs_rout_conf_msg(tlm_gp& trans){
link_extension* ext = new link_extension();
ext->link = Dir::local; // set direction of connected router
ext->data_type = get_type_from_extension(trans);
+ ext->is_config_msg = get_is_cfg_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);
+ (*initiator[1])->nb_transport_fw(*new_trans, phase, delay);
}
void NetworkInterfaceTlm::send_data_to_noc(){
@@ -289,7 +295,7 @@ void NetworkInterfaceTlm::init_peq_cb(tlm_gp& trans, const tlm::tlm_phase& phase
// Send final phase transition to target
tlm::tlm_phase fw_phase = tlm::END_RESP;
sc_time delay = sc_time(RESP_END_DELAY, UNITS_DELAY);
- initiator->nb_transport_fw(trans, fw_phase, delay);
+ (*initiator[0])->nb_transport_fw(trans, fw_phase, delay);
}
}
@@ -336,49 +342,61 @@ tlm::tlm_sync_enum NetworkInterfaceTlm::nb_transport_fw_cb(int id,
void NetworkInterfaceTlm::receive_and_process_flit(tlm_gp& trans){
trans.set_response_status(tlm::TLM_OK_RESPONSE);
+ bool is_config_msg = get_is_cfg_from_extension(trans);
unsigned char* data_ptr = trans.get_data_ptr();
- Flit* received_flit = reinterpret_cast(data_ptr);
- Packet* p = received_flit->packet;
- double time = sc_time_stamp().to_double();
- auto position = find(p->inTransmit.begin(), p->inTransmit.end(), received_flit->id);
- if (position!=p->inTransmit.end())
- 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";
- ss << "Receive Flit " << flit_type << *received_flit;
- log_info(ss.str());
- }
- if (!p->toTransmit.empty() || !p->inTransmit.empty()) {
- stringstream ss;
- ss << "Received Tail Flit, but still missing flits! "
- << *received_flit;
- log_info(ss.str());
- }
- //globalReport.issueNoCOutputDataAmount(sc_time_stamp(),globalResources.bitWidth);
- if (p->toTransmit.empty() && p->inTransmit.empty())
- packet_recv_queue.push(p);
- credit_counter++;
-
- // send configuration message to cs_router
- if(check_cs_needed(trans)){
- send_cs_rout_conf_msg(trans);
- }
-
- // send response if not type stream
- if(p->dataType != TYPE_STREAM){
+ if(is_config_msg){
+ if(check_cs_needed(trans)){
+ log_info("Send router configuration message");
+ send_cs_rout_conf_msg(trans);
+ }
if(resp_in_progress) {
if(nxt_resp_pend){
- log_fatal("Attempt to have two pending responses in target");
- nxt_resp_pend = &trans;
+ log_fatal("Attempt to have two pending responses in target");
+ nxt_resp_pend = &trans;
}
}
else{ send_response(trans); }
}
+ else{
+ Flit* received_flit = reinterpret_cast(data_ptr);
+ Packet* p = received_flit->packet;
+ double time = sc_time_stamp().to_double();
+ auto position = find(p->inTransmit.begin(), p->inTransmit.end(), received_flit->id);
+ if (position!=p->inTransmit.end())
+ 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";
+ ss << "Receive Flit " << flit_type << *received_flit;
+ log_info(ss.str());
+ }
+ if (!p->toTransmit.empty() || !p->inTransmit.empty()) {
+ stringstream ss;
+ ss << "Received Tail Flit, but still missing flits! "
+ << *received_flit;
+ log_info(ss.str());
+ }
+ //globalReport.issueNoCOutputDataAmount(sc_time_stamp(),globalResources.bitWidth);
+ if (p->toTransmit.empty() && p->inTransmit.empty())
+ packet_recv_queue.push(p);
+ credit_counter++;
+
+ // 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); }
+ }
+ }
+
}
@@ -422,7 +440,7 @@ tlm::tlm_sync_enum NetworkInterfaceTlm::send_end_req(tlm_gp& trans){
tlm::tlm_phase bw_phase = tlm::END_REQ;
sc_time delay = sc_time(REQ_END_DELAY, UNITS_DELAY); // Accept delay
- tlm::tlm_sync_enum status = target->nb_transport_bw(trans,
+ tlm::tlm_sync_enum status = (*target[0])->nb_transport_bw(trans,
bw_phase, delay);
if (status == tlm::TLM_COMPLETED) {
trans.release();
@@ -445,7 +463,7 @@ void NetworkInterfaceTlm::send_response(tlm_gp& trans){
sc_time delay = SC_ZERO_TIME;
tlm::tlm_phase bw_phase = tlm::BEGIN_RESP;
- tlm::tlm_sync_enum status = target->nb_transport_bw(
+ tlm::tlm_sync_enum status = (*target[0])->nb_transport_bw(
trans, bw_phase, delay);
credit_counter--;
diff --git a/src/networkInterface/NetworkInterfaceTlm.h b/src/networkInterface/NetworkInterfaceTlm.h
index 5103142..1dad581 100755
--- a/src/networkInterface/NetworkInterfaceTlm.h
+++ b/src/networkInterface/NetworkInterfaceTlm.h
@@ -56,23 +56,23 @@ public:
sc_in clk;
PacketPortContainer* packetPortContainer;
// To NoC
- ni_init_socket initiator;
- ni_targ_socket target;
+ ni_init_socket* initiator[NUM_ACC_LAYERS];
+ ni_targ_socket* target[NUM_ACC_LAYERS];
tlm_utils::peq_with_cb_and_phase init_peq;
tlm_utils::peq_with_cb_and_phase target_peq;
tlm_gp* curr_req;
tlm_gp* end_req_pend;
tlm_gp* nxt_resp_pend;
tlm_gp* nxt_send_data_pend;
+
bool resp_in_progress;
bool send_data_in_progress;
int credit_counter;
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;
+ bool valid_socket[NUM_ACC_LAYERS] = {false};
+
sc_event_or_list ev_msg_arrv;
@@ -132,6 +132,13 @@ public:
*/
int get_type_from_extension(tlm_gp& trans);
+ /**
+ * Get variable is_cfg_msg from extension
+ *
+ * @param trans TLM generic payload object
+ */
+ bool get_is_cfg_from_extension(tlm_gp& trans);
+
/**
* If message is init streaming, a router_cs needs to be
* configured
diff --git a/src/networkManager/NetworkManager.cpp b/src/networkManager/NetworkManager.cpp
index 9d9bdcf..ca2b027 100755
--- a/src/networkManager/NetworkManager.cpp
+++ b/src/networkManager/NetworkManager.cpp
@@ -34,6 +34,7 @@ NetworkManager::NetworkManager(sc_module_name nm, std::string configFolder){
createClocks();
createNetworkParticipants();
createLinks();
+ connectUnboundedNi();
runNoC();
}
@@ -76,6 +77,7 @@ void NetworkManager::createNetworkParticipants() {
ni_name.c_str(), n, max_pos);
ni->clk(*clocks.at(n.type->id));
networkParticipants.at(n.id) = dynamic_cast(ni);
+ idNis.push_back(n.id);
std::string pe_name = "pe_" + std::to_string(n.id % numOfPEs);
ProcessingElementVC *pe = new ProcessingElementVC(pe_name.c_str(), n, tp.get());
@@ -106,23 +108,51 @@ void NetworkManager::createLinks() {
Node &node2 = globalResources.nodes.at(c.nodes.at(1));
bool is_node1_pe = node1.type->model == "ProcessingElement";
bool is_node2_pe = node2.type->model == "ProcessingElement";
+
if (is_node1_pe || is_node2_pe){
int ni_id = is_node1_pe ? node1.id : node2.id;
int rout_id = is_node1_pe ? node2.id : node1.id;
+ std::string rout_type = is_node1_pe ?
+ node2.type->model : node1.type->model;
+ uint8_t lay = rout_type=="Router" ? 0 : 1;
+
NetworkInterfaceTlm* ni =
dynamic_cast(
networkParticipants.at(ni_id));
TlmRouter* router = tlmNoc->getRouterNodeId(rout_id);
- ni->initiator.bind(*router->target_socket[DIR::Local]);
- router->init_socket[DIR::Local]->bind(ni->target);
+ ni->initiator[lay]->bind(*router->target_socket[DIR::Local]);
+ router->init_socket[DIR::Local]->bind(*ni->target[lay]);
+ ni->valid_socket[lay] = true;
+ link_id += 2;
}
- link_id += 2;
} else {
LOG(true,"Unsupported number of endpoints in connection "+to_string(c.id));
}
}
}
+void NetworkManager::connectUnboundedNi(){
+ // connecting unbounded network interfaces
+ for (uint8_t i=0; i < idNis.size(); i++){
+ for (uint8_t lay=0; lay < NUM_ACC_LAYERS; lay++){
+ NetworkInterfaceTlm* ni = dynamic_cast(
+ networkParticipants.at(idNis[i]));
+ if (!ni->valid_socket[lay]){
+ ni_init_socket* unbound_init = new ni_init_socket(
+ ("unb_ni_init_"+to_string(idNis[i])+"_"+to_string(lay)).c_str());
+ unbound_init->bind(*ni->target[lay]);
+ unbounded_initiators.push_back(unbound_init);
+
+ ni_targ_socket* unbound_targ = new ni_targ_socket(
+ ("unb_ni_targ_"+to_string(idNis[i])+"_"+to_string(lay)).c_str());
+ ni->initiator[lay]->bind(*unbound_targ);
+ unbounded_targets.push_back(unbound_targ);
+ }
+ }
+ }
+}
+
+
void NetworkManager::runNoC() {
for (auto &r : networkParticipants) {
if (r) {
diff --git a/src/networkManager/NetworkManager.h b/src/networkManager/NetworkManager.h
index 12f6ebc..a434b4e 100755
--- a/src/networkManager/NetworkManager.h
+++ b/src/networkManager/NetworkManager.h
@@ -38,8 +38,12 @@
using namespace tlm;
+typedef simple_initiator_socket_tagged ni_init_socket;
+typedef simple_target_socket_tagged ni_targ_socket;
+
class NetworkManager : public sc_module{
public:
+
SC_HAS_PROCESS(NetworkManager);
explicit NetworkManager(sc_module_name, std::string);
@@ -52,8 +56,12 @@ private:
std::unique_ptr tp;
TlmNoc* tlmNoc;
std::vector networkParticipants;
+ std::vector idNis;
std::vector> packetSignalContainers;
+ std::vector unbounded_initiators;
+ std::vector unbounded_targets;
+
/**
* Create clocks for Ratatoskr PEs
*/
@@ -75,6 +83,11 @@ private:
*/
void createLinks();
+ /**
+ * Connects all unbounded sockets in Network Interface
+ */
+ void connectUnboundedNi();
+
/**
* Initialize routers and starts traffic pool
*/
diff --git a/src/noc/noc.cpp b/src/noc/noc.cpp
index 049cddb..46d9378 100755
--- a/src/noc/noc.cpp
+++ b/src/noc/noc.cpp
@@ -60,7 +60,6 @@ void TlmNoc::initializeGlobalResources(string config_folder) {
void TlmNoc::initNoc() {
uint8_t max_pos[3];
get_max_pos(max_pos);
-
for (Node &n : globalResources.nodes) {
if (n.type->model == "Router" || n.type->model == "RouterCS"){
float float_rout_pos[3] = {n.pos.x, n.pos.y, n.pos.z};
@@ -70,31 +69,27 @@ void TlmNoc::initNoc() {
string msg = " initialized in position " +
to_string(rout_pos[0]) + "," + to_string(rout_pos[1])+
"," + to_string(rout_pos[2]);
- TlmRouter *r;
- string rout_name;
- if (n.type->model == "Router") {
- rout_name = "router_" + to_string(n.id);
- r = new TlmRouter(rout_name.c_str(), rout_pos, max_pos);
- }
- else {
- rout_name = "router_cs_" + to_string(n.id);
- r = new TlmRouterCS(rout_name.c_str(), rout_pos, max_pos);
- }
- log_info(rout_name + msg);
+ string rout_name = "router_" + to_string(n.id);
+ TlmRouter* r = new TlmRouter(rout_name.c_str(), rout_pos, max_pos);
routers.push_back(r);
- int id = routers.size()-1;
mapNodeRouter.insert(
pair(n.id, int(routers.size())-1));
+ log_info(rout_name + msg);
}
}
}
void TlmNoc::connectRouters(Node node1, Node node2, int link){
+ bool is_n1_router = node1.type->model=="Router";
+ bool is_n1_router_cs = node1.type->model=="RouterCS";
+ bool is_n2_router = node2.type->model=="Router";
+ bool is_n2_router_cs = node2.type->model=="RouterCS";
+
int n1_id = mapNodeRouter[node1.id];
int n2_id = mapNodeRouter[node2.id];
- if((node1.type->model=="Router" || node1.type->model=="RouterCS") &&
- (node2.type->model=="Router" || node1.type->model=="RouterCS")){
+
+ if((is_n1_router||is_n1_router_cs) && (is_n2_router||is_n2_router_cs)){
int connDir = node1.getDirOfCon(link);
int opposDir = DIR::getOppositeDir(connDir);
@@ -104,22 +99,22 @@ void TlmNoc::connectRouters(Node node1, Node node2, int link){
*routers[n1_id]->target_socket[connDir]);
routers[n1_id]->valid_links[connDir] = true;
routers[n2_id]->valid_links[opposDir] = true;
- log_conn(routers[n1_id]->router_name,routers[n2_id]->router_name,
+ log_conn(routers[n1_id]->router_name,
+ routers[n2_id]->router_name,
DIR::toString(connDir), DIR::toString(opposDir));
}
else{
- int r_id = (node1.type->model == "Router" ||
- node1.type->model == "RouterCS") ? n1_id:n2_id;
+ int r_id = (is_n1_router || is_n1_router_cs) ? n1_id:n2_id;
api_initiators.push_back(routers[r_id]->init_socket[DIR::Local]);
api_targets.push_back(routers[r_id]->target_socket[DIR::Local]);
routers[r_id]->valid_links[DIR::Local] = true;
log_conn(routers[r_id]->router_name, "noc interface",
DIR::toString(DIR::Local), "external");
}
-
}
+
void TlmNoc::connectUnbounded(){
// connecting unbounded routers
for (uint8_t id=0; id < routers.size(); id++){
@@ -141,7 +136,6 @@ void TlmNoc::connectUnbounded(){
}
}
}
-
}
diff --git a/src/router/router.cpp b/src/router/router.cpp
index aafb11e..8c8eb7d 100755
--- a/src/router/router.cpp
+++ b/src/router/router.cpp
@@ -63,6 +63,28 @@ void TlmRouter::initialize(){
}
/******************* COMMON FUNCTIONS ********************/
+tlm_gp* TlmRouter::build_transaction(tlm_gp& trans, int dest_link){
+ 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);
+ ext->is_config_msg = false;
+ new_trans->set_extension(ext);
+
+ return new_trans;
+}
+
void TlmRouter::send_begin_req(int link, tlm_gp& trans, int dest_link){
tlm_gp* new_trans = build_transaction(trans, dest_link);
@@ -95,6 +117,7 @@ bool TlmRouter::send_data(int link, int dest_link, tlm_gp& trans){
if (credit_counter[dest_link] > 0 && !curr_req[dest_link]){
send_begin_req(link, trans, dest_link);
if(check_cs_needed(link, dest_link, trans)){
+ log_info(link,"Send configuration message");
send_cs_rout_conf_msg(link, dest_link, trans);
}
return true;
@@ -108,8 +131,51 @@ bool TlmRouter::send_data(int link, int dest_link, tlm_gp& trans){
}
}
+void TlmRouter::check_transaction(int link, tlm_gp& trans) {
+ if(trans.is_response_error()) {
+ char txt[100];
+ sprintf(txt, "Transaction returned with error, response status = %s",
+ trans.get_response_string().c_str());
+ log_error(link, txt);
+ }
+
+ // Log completed routing
+ tlm_command cmd = trans.get_command();
+ sc_dt::uint64 adr = trans.get_address();
+ int* ptr = reinterpret_cast(trans.get_data_ptr());
+ std::stringstream stream;
+ stream << hex << adr << " check, cmd=" << (cmd ? 'W' : 'R')
+ << ", data=" << hex << *ptr;
+ log_info(link, stream.str());
+ // Allow the memory manager to free the transaction object
+ trans.release();
+}
+
+int TlmRouter::get_link_from_extension(tlm_gp& trans){
+ link_extension* extension;
+ trans.get_extension(extension);
+ return extension->link;
+}
+
+int TlmRouter::get_type_from_extension(tlm_gp& trans){
+ link_extension* extension;
+ trans.get_extension(extension);
+ return extension->data_type;
+}
+
+bool TlmRouter::get_is_cfg_from_extension(tlm_gp& trans){
+ link_extension* extension;
+ trans.get_extension(extension);
+ return extension->is_config_msg;
+}
/******************* CS CONFIG FUNCTIONS **********************/
+bool TlmRouter::check_cs_needed(int link, int destination, tlm_gp& trans){
+ int type = get_type_from_extension(trans);
+ return (link != Dir::local && destination != Dir::local) &&
+ (type == TYPE_INIT_STREAM || type == TYPE_END_STREAM);
+};
+
void TlmRouter::send_cs_rout_conf_msg(int link, int destination, tlm_gp& trans){
int dest_link = Dir::local;
unsigned char* data = new unsigned char(link | destination<<2);
@@ -130,6 +196,7 @@ void TlmRouter::send_cs_rout_conf_msg(int link, int destination, tlm_gp& trans){
link_extension* ext = new link_extension();
ext->link = dest_link; // set direction of connected router
ext->data_type = get_type_from_extension(trans);
+ ext->is_config_msg = true;
conf_trans->set_extension(ext);
// send transaction in socket
@@ -373,3 +440,25 @@ Dir TlmRouter::routing(int link, tlm_gp& trans){
uint8_t dest[3] = {dest_x, dest_y, dest_z};
return xyz_routing(link, dest);
}
+
+
+/******************* LOG FUNCTIONS ********************/
+void TlmRouter::log_info(uint8_t link, string msg){
+ string str_link = DIR::toString(link);
+ SC_REPORT_INFO(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
+}
+
+void TlmRouter::log_warn(uint8_t link, string msg){
+ string str_link = DIR::toString(link);
+ SC_REPORT_WARNING(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
+}
+
+void TlmRouter::log_error(uint8_t link, string msg){
+ string str_link = DIR::toString(link);
+ SC_REPORT_ERROR(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
+}
+
+void TlmRouter::log_fatal(uint8_t link, string msg){
+ string str_link = DIR::toString(link);
+ SC_REPORT_FATAL(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
+}
diff --git a/src/router/router.h b/src/router/router.h
index 2ec2873..1a8625b 100755
--- a/src/router/router.h
+++ b/src/router/router.h
@@ -32,7 +32,6 @@
#include "tlm_utils/simple_target_socket.h"
#include "tlm_utils/peq_with_cb_and_phase.h"
-#include "router/router_utils.h"
#include "utils/memory_manager.h"
#include "utils/configuration.h"
#include "utils/utils.h"
@@ -46,17 +45,21 @@ using namespace tlm_utils;
#define NUM_LINKS Direction::num_dirs
+DECLARE_EXTENDED_PHASE(INTERNAL_PROC_PHASE);
+
// Define an extension for the transactions
// link always point to initiator link of transaction
struct link_extension : tlm_extension {
int link;
int data_type;
+ bool is_config_msg;
virtual tlm_extension_base* clone() const {
return new link_extension(*this);
}
virtual void copy_from(const tlm_extension_base& ext) {
link = static_cast(ext).link;
data_type = static_cast(ext).data_type;
+ is_config_msg = static_cast(ext).is_config_msg;
}
};
@@ -95,6 +98,16 @@ class TlmRouter : public sc_module{
*/
void initialize();
+ /**
+ * Build the transaction tp send. Called by send flit
+ *
+ * @param trans TLM generic payload object
+ * @param dest_link destination link to send the data to
+ *
+ * @return created transaction
+ */
+ tlm_gp* build_transaction(tlm_gp& trans, int dest_link);
+
/**
* Send data
*
@@ -104,6 +117,26 @@ class TlmRouter : public sc_module{
*/
bool send_data(int link, int dest_link, tlm_gp& trans);
+ /**
+ * Checks transaction for errors, if no error found, log
+ * transaction and release transaction object. Called when
+ * transaction is completed
+ *
+ * @param link active link
+ * @param trans TLM generic payload object
+ */
+ void check_transaction(int link, tlm_gp& trans);
+
+ /**
+ * If message is init streaming, a router_cs needs to be
+ * configured
+ *
+ * @param link active link
+ * @param destination destination link to transmit transaction
+ * @param trans TLM generic payload object
+ */
+ bool check_cs_needed(int link, int destination, tlm_gp& trans);
+
/**
* Sends router_cs configuration message to local link
*
@@ -121,7 +154,7 @@ class TlmRouter : public sc_module{
* @param phase TLM current phase
* @param delay TLM expected delay
*/
- tlm_sync_enum nb_transport_bw_cb(int id, tlm_gp& trans,
+ virtual tlm_sync_enum nb_transport_bw_cb(int id, tlm_gp& trans,
tlm_phase& phase, sc_time& delay);
/**
@@ -217,4 +250,50 @@ class TlmRouter : public sc_module{
* @param trans TLM generic payload object
*/
Dir routing(int link, tlm_gp& trans);
+
+
+ /**
+ * Get link from extension
+ *
+ * @param trans TLM generic payload object
+ */
+ int get_link_from_extension(tlm_gp& trans);
+
+ /**
+ * Get type from extension
+ *
+ * @param trans TLM generic payload object
+ */
+ int get_type_from_extension(tlm_gp& trans);
+
+ /**
+ * Get variable is_cfg_msg from extension
+ *
+ * @param trans TLM generic payload object
+ */
+ bool get_is_cfg_from_extension(tlm_gp& trans);
+
+ /** Log info
+ * @param link active link
+ * @param msg log message
+ */
+ void log_info(uint8_t link, string msg);
+
+ /** Log warning
+ * @param link active link
+ * @param msg log message
+ */
+ void log_warn(uint8_t link, string msg);
+
+ /** Log error
+ * @param link active link
+ * @param msg log message
+ */
+ void log_error(uint8_t link, string msg);
+
+ /** Log fatal
+ * @param link active link
+ * @param msg log message
+ */
+ void log_fatal(uint8_t link, string msg);
};
\ No newline at end of file
diff --git a/src/router/router_cs.cpp b/src/router/router_cs.cpp
index 0cec005..0fb69ed 100755
--- a/src/router/router_cs.cpp
+++ b/src/router/router_cs.cpp
@@ -22,9 +22,6 @@
#include "router_cs.h"
#include "ratatoskrUtils/utils/Structures.h"
-typedef simple_initiator_socket_tagged rout_init_socket;
-typedef simple_target_socket_tagged rout_targ_socket;
-
TlmRouterCS::TlmRouterCS(sc_module_name name, uint8_t rout_pos[3],
uint8_t max_pos[3]):
TlmRouter(name, rout_pos, max_pos) {
@@ -34,23 +31,9 @@ TlmRouterCS::~TlmRouterCS(){
}
void TlmRouterCS::initialize(){
+ TlmRouter::initialize();
+ cout<<"Inherited function called";
for(int link=0; linknb_transport_fw(
+ status = (*init_socket[dest_link])->nb_transport_fw(
*new_trans, phase, delay);
curr_req[dest_link] = new_trans;
credit_counter[dest_link]--;
@@ -137,7 +120,7 @@ tlm_sync_enum TlmRouterCS::send_end_req(int link, tlm_gp& trans){
// Queue the acceptance and the response with the appropriate latency
sc_time delay = sc_time(REQ_END_DELAY, UNITS_DELAY);
tlm_phase phase = END_REQ;
- tlm_sync_enum status = (*target_socket_cs[link])->nb_transport_bw(
+ tlm_sync_enum status = (*target_socket[link])->nb_transport_bw(
trans, phase, delay);
if (status == TLM_COMPLETED) {
log_warn(link,"Request completed, no response to be send");
diff --git a/src/router/router_cs.h b/src/router/router_cs.h
index af92eb1..13c6d1a 100755
--- a/src/router/router_cs.h
+++ b/src/router/router_cs.h
@@ -43,18 +43,11 @@ DECLARE_EXTENDED_PHASE(CONF_ROUT_PHASE);
class TlmRouterCS : public TlmRouter{
public:
- typedef simple_initiator_socket_tagged routcs_init_socket;
- typedef simple_target_socket_tagged routcs_targ_socket;
-
SC_HAS_PROCESS(TlmRouterCS);
TlmRouterCS(sc_module_name name, uint8_t rout_pos[3],
uint8_t max_pos[3]);
~TlmRouterCS();
- routcs_init_socket* init_socket_cs[NUM_LINKS];
- routcs_targ_socket* target_socket_cs[NUM_LINKS];
-
-
/** Setter for auto_rout_map variable
* @param link auto_router_map index
* @param dir direction to route to
@@ -120,7 +113,7 @@ class TlmRouterCS : public TlmRouter{
* @param delay TLM expected delay
*/
tlm_sync_enum nb_transport_bw_cb(int id, tlm_gp& trans,
- tlm_phase& phase, sc_time& delay);
+ tlm_phase& phase, sc_time& delay) override;
/**
* Callback target Payload Event Queue (PEQ)
diff --git a/src/router/router_utils.cpp b/src/router/router_utils.cpp
deleted file mode 100644
index 041afa0..0000000
--- a/src/router/router_utils.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "router_utils.h"
-
-namespace RouterUtils{
- tlm_gp* build_transaction(tlm_gp& trans, int dest_link){
- 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);
-
- return new_trans;
- }
-
-
- void check_transaction(int link, tlm_gp& trans) {
- if(trans.is_response_error()) {
- char txt[100];
- sprintf(txt, "Transaction returned with error, response status = %s",
- trans.get_response_string().c_str());
- log_error(link, txt);
- }
-
- // Log completed routing
- tlm_command cmd = trans.get_command();
- sc_dt::uint64 adr = trans.get_address();
- int* ptr = reinterpret_cast(trans.get_data_ptr());
- std::stringstream stream;
- stream << hex << adr << " check, cmd=" << (cmd ? 'W' : 'R')
- << ", data=" << hex << *ptr;
- log_info(link, stream.str());
- // Allow the memory manager to free the transaction object
- trans.release();
- }
-
-
- int get_link_from_extension(tlm_gp& trans){
- link_extension* extension;
- trans.get_extension(extension);
- return extension->link;
- }
-
- int get_type_from_extension(tlm_gp& trans){
- link_extension* extension;
- trans.get_extension(extension);
- return extension->data_type;
- }
-
- bool check_cs_needed(int link, int destination, tlm_gp& trans){
- int type = get_type_from_extension(trans);
- return (link != Dir::local || destination != Dir::local) &&
- (type == TYPE_INIT_STREAM || type == TYPE_END_STREAM);
- }
-
- /******************* LOG FUNCTIONS ********************/
- void log_info(uint8_t link, string msg){
- string str_link = DIR::toString(link);
- SC_REPORT_INFO(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
- }
-
- void log_warn(uint8_t link, string msg){
- string str_link = DIR::toString(link);
- SC_REPORT_WARNING(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
- }
-
- void log_error(uint8_t link, string msg){
- string str_link = DIR::toString(link);
- SC_REPORT_ERROR(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
- }
-
- void log_fatal(uint8_t link, string msg){
- string str_link = DIR::toString(link);
- SC_REPORT_FATAL(R_LOG, (router_name+":"+str_link+":"+msg).c_str());
- }
-
-}
\ No newline at end of file
diff --git a/src/router/router_utils.h b/src/router/router_utils.h
deleted file mode 100644
index d96f397..0000000
--- a/src/router/router_utils.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2024 Juan Neyra
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- ******************************************************************************/
-#pragma once
-
-#ifndef SC_INCLUDE_DYNAMIC_PROCESSES
-#define SC_INCLUDE_DYNAMIC_PROCESSES
-#endif
-
-#include
-#include
-#include "tlm.h"
-
-#include "utils/memory_manager.h"
-#include "utils/configuration.h"
-#include "utils/utils.h"
-#include "utils/noc_logger.h"
-
-using namespace sc_core;
-using namespace sc_dt;
-using namespace std;
-using namespace tlm;
-using namespace tlm_utils;
-
-#define NUM_LINKS Direction::num_dirs
-
-DECLARE_EXTENDED_PHASE(INTERNAL_PROC_PHASE);
-
-
-// Define an extension for the transactions
-// link always point to initiator link of transaction
-struct link_extension : tlm_extension {
- int link;
- int data_type;
- virtual tlm_extension_base* clone() const {
- return new link_extension(*this);
- }
- virtual void copy_from(const tlm_extension_base& ext) {
- link = static_cast(ext).link;
- data_type = static_cast(ext).data_type;
- }
-};
-
-namespace RouterUtils{
- /**
- * Build the transaction tp send. Called by send flit
- *
- * @param trans TLM generic payload object
- * @param dest_link destination link to send the data to
- *
- * @return created transaction
- */
- tlm_gp* build_transaction(tlm_gp& trans, int dest_link);
-
-
- /**
- * Checks transaction for errors, if no error found, log
- * transaction and release transaction object. Called when
- * transaction is completed
- *
- * @param link active link
- * @param trans TLM generic payload object
- */
- void check_transaction(int link, tlm_gp& trans);
-
-
- /**
- * Get link from extension
- *
- * @param trans TLM generic payload object
- */
- int get_link_from_extension(tlm_gp& trans);
-
- /**
- * Get type from extension
- *
- * @param trans TLM generic payload object
- */
- int get_type_from_extension(tlm_gp& trans);
-
- /**
- * If message is init streaming, a router_cs needs to be
- * configured
- *
- * @param link active link
- * @param destination destination link to transmit transaction
- * @param trans TLM generic payload object
- */
- bool check_cs_needed(int link, int destination, tlm_gp& trans);
-
- /** Log info
- * @param link active link
- * @param msg log message
- */
- void log_info(uint8_t link, string msg);
-
- /** Log warning
- * @param link active link
- * @param msg log message
- */
- void log_warn(uint8_t link, string msg);
-
- /** Log error
- * @param link active link
- * @param msg log message
- */
- void log_error(uint8_t link, string msg);
-
- /** Log fatal
- * @param link active link
- * @param msg log message
- */
- void log_fatal(uint8_t link, string msg);
-}
diff --git a/src/utils/configuration.h b/src/utils/configuration.h
index a43f7fe..2f4c80e 100755
--- a/src/utils/configuration.h
+++ b/src/utils/configuration.h
@@ -27,6 +27,7 @@
#include
#include "tlm.h"
+#include "string.h"
using namespace sc_dt;
@@ -43,8 +44,11 @@ using namespace sc_dt;
typedef tlm::tlm_generic_payload tlm_gp;
// for circuit switching noc
+#define NUM_ACC_LAYERS 2
#define NUM_CREDITS_CS 1
#define TYPE_PACKET 0
#define TYPE_STREAM 1
-#define TYPE_INIT_STREAM 2
-#define TYPE_END_STREAM 3
+#define TYPE_ROUT_CONFIG 2
+
+const std::string STR_TYPES[5] = {"packet", "stream", "init stream",
+ "end stream", "acknowledge"};