changes to naming of Network Interface

This commit is contained in:
HelenClaraGeorge 2024-11-27 22:06:03 +01:00
parent f047dfbf91
commit 64641338ae
18 changed files with 3260 additions and 10431 deletions

View file

@ -33,14 +33,14 @@ The log file is in out/report.log
# The current setup
• There are ROUTER_NO of routers.
• Multiple cores (CORE_NO) are connected to each router
• The cores transmit the data to each routers using non-blocking TLM
• The routers receive data from core in the input fifo
• Multiple PEs (CORE_NO) are connected to each router -Processing Elements and Network Interfaces
• The PEs transmit the data to each routers using non-blocking TLM
• The routers receive data from NI in the input fifo
• The data from the input fifo is processed to find destination router
• The sender router waits for the destination router's token (Semaphore)
• When the semaphore is available, the sender writes the data using non-blocking write to destination router's output fifo - this confirms whether space available in the fifo too
• At the destination router, the data from output fifo is processed to find the destination core
• The data is transmitted to the destination core using non-blocking TLM
• At the destination router, the data from output fifo is processed to find the destination NI
• The data is transmitted to the destination NI using non-blocking TLM
# Introduction to Corona
The Corona architecture is as follows;

View file

@ -0,0 +1,269 @@
<?xml version="1.0" ?>
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dataTypes>
<dataType id="0">
<name value="Packet"/>
</dataType>
</dataTypes>
<tasks>
<!-- Tasks 09 generate packets -->
<task id="0">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="1">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="2">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="3">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="4">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="5">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="6">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="7">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="8">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="9">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="100"/>
<interval min="100" max="100"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="10"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<!-- Task 10 receives packets -->
<task id="10">
<start max="0" min="0"/>
<duration max="-1" min="-1"/>
<repeat max="1" min="1"/>
<requires>
<requirement id="0">
<type value="0"/>
<source value="0"/>
<count max="10" min="10"/>
</requirement>
<!-- <requirement id="1">
<type value="0"/>
<source value="1"/>
<count max="1" min="1"/>
</requirement>
<requirement id="2">
<type value="0"/>
<source value="2"/>
<count max="1" min="1"/>
</requirement>
<requirement id="3">
<type value="0"/>
<source value="3"/>
<count max="1" min="1"/>
</requirement>
<requirement id="4">
<type value="0"/>
<source value="4"/>
<count max="1" min="1"/>
</requirement>
<requirement id="5">
<type value="0"/>
<source value="5"/>
<count max="1" min="1"/>
</requirement>
<requirement id="6">
<type value="0"/>
<source value="6"/>
<count max="1" min="1"/>
</requirement>
<requirement id="7">
<type value="0"/>
<source value="7"/>
<count max="1" min="1"/>
</requirement>
<requirement id="8">
<type value="0"/>
<source value="8"/>
<count max="1" min="1"/>
</requirement>
<requirement id="9">
<type value="0"/>
<source value="9"/>
<count max="1" min="1"/>
</requirement> -->
</requires>
</task>
</tasks>
</data>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" ?>
<map xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<bind>
<task value="0"/>
<node value="10"/>
</bind>
<bind>
<task value="1"/>
<node value="31"/>
</bind>
<bind>
<task value="2"/>
<node value="18"/>
</bind>
<bind>
<task value="3"/>
<node value="38"/>
</bind>
<bind>
<task value="4"/>
<node value="33"/>
</bind>
<bind>
<task value="5"/>
<node value="23"/>
</bind>
<bind>
<task value="6"/>
<node value="26"/>
</bind>
<bind>
<task value="7"/>
<node value="11"/>
</bind>
<bind>
<task value="8"/>
<node value="9"/>
</bind>
<bind>
<task value="9"/>
<node value="17"/>
</bind>
<bind>
<task value="10"/>
<node value="22"/>
</bind>
</map>

View file

@ -0,0 +1,55 @@
<?xml version="1.0" ?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<general>
<simulationTime value="1500"/>
<outputToFile value="true">report</outputToFile>
</general>
<noc>
<nocFile>config/Test_10_task/net.xml</nocFile>
<flitsPerPacket value="1"/>
<bitWidth value="32"/>
<Vdd value="5"/>
</noc>
<application>
<benchmark>task</benchmark>
<dataFile>config/Test_10_task/10pt_data.xml</dataFile>
<mapFile>config/Test_10_task/10pt_map.xml</mapFile>
</application>
<verbose>
<processingElements>
<function_calls value="false"/>
<send_flit value="false"/>
<send_head_flit value="true"/>
<receive_flit value="false"/>
<receive_tail_flit value="true"/>
<throttle value="false"/>
<reset value="false"/>
</processingElements>
<router>
<function_calls value="false"/>
<send_flit value="false"/>
<send_head_flit value="false"/>
<receive_flit value="false"/>
<receive_tail_flit value="false"/>
<throttle value="false"/>
<reset value="false"/>
<assign_channel value="false"/>
<buffer_overflow value="true"/>
</router>
<netrace>
<inject value="true"/>
<eject value="true"/>
<router_receive value="true"/>
</netrace>
<tasks>
<function_calls value="true"/>
<xml_parse value="false"/>
<data_receive value="true"/>
<data_send value="true"/>
<source_execute value="false"/>
</tasks>
</verbose>
<report>
<bufferReportRouters>5 6 9 10</bufferReportRouters>
</report>
</configuration>

1136
config/Test_10_task/net.xml Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,245 @@
<?xml version="1.0" ?>
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dataTypes>
<dataType id="0">
<name value="Packet"/>
</dataType>
<dataType id="1">
<name value="Stream"/>
</dataType>
</dataTypes>
<tasks>
<task id="0">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="5"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="1">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="5"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="2">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="5"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="3">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="5"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="4">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="5"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<!-- <task id="5">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="11"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="6">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="11"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="7">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="11"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="8">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="11"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="9">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="11"/>
</destination>
</destinations>
</possibility>
</generates>
</task>
<task id="10">
<start min="0" max="0"/>
<duration min="-1" max="-1"/>
<repeat min="1" max="1"/>
<generates>
<possibility id="0">
<probability value="1"/>
<destinations>
<destination id="0">
<delay min="0" max="10"/>
<interval min="5" max="5"/>
<count min="1" max="1"/>
<type value="0"/>
<task value="11"/>
</destination>
</destinations>
</possibility>
</generates>
</task> -->
<task id="5">
<start max="0" min="0"/>
<duration max="-1" min="-1"/>
<repeat max="1" min="1"/>
<requires>
<requirement id="0">
<type value="0"/>
<source value="0"/>
<count max="5" min="5"/>
</requirement>
</requires>
</task>
</tasks>
</data>

View file

@ -0,0 +1,51 @@
<?xml version="1.0" ?>
<map xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<bind>
<task value="0"/>
<node value="10"/>
</bind>
<bind>
<task value="1"/>
<node value="31"/>
</bind>
<bind>
<task value="2"/>
<node value="18"/>
</bind>
<bind>
<task value="3"/>
<node value="38"/>
</bind>
<bind>
<task value="4"/>
<node value="33"/>
</bind>
<!-- <bind>
<task value="5"/>
<node value="23"/>
</bind>
<bind>
<task value="6"/>
<node value="26"/>
</bind>
<bind>
<task value="7"/>
<node value="11"/>
</bind>
<bind>
<task value="8"/>
<node value="9"/>
</bind>
<bind>
<task value="9"/>
<node value="17"/>
</bind>
<bind>
<task value="10"/>
<node value="22"/>
</bind> -->
<bind>
<task value="5"/>
<node value="15"/>
</bind>
</map>

View file

@ -0,0 +1,55 @@
<?xml version="1.0" ?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<general>
<simulationTime value="1500"/>
<outputToFile value="true">report</outputToFile>
</general>
<noc>
<nocFile>config/Test_5_task/net.xml</nocFile>
<flitsPerPacket value="1"/>
<bitWidth value="32"/>
<Vdd value="5"/>
</noc>
<application>
<benchmark>task</benchmark>
<dataFile>config/Test_5_task/5t_data.xml</dataFile>
<mapFile>config/Test_5_task/5t_map.xml</mapFile>
</application>
<verbose>
<processingElements>
<function_calls value="false"/>
<send_flit value="false"/>
<send_head_flit value="true"/>
<receive_flit value="false"/>
<receive_tail_flit value="true"/>
<throttle value="false"/>
<reset value="false"/>
</processingElements>
<router>
<function_calls value="false"/>
<send_flit value="false"/>
<send_head_flit value="false"/>
<receive_flit value="false"/>
<receive_tail_flit value="false"/>
<throttle value="false"/>
<reset value="false"/>
<assign_channel value="false"/>
<buffer_overflow value="true"/>
</router>
<netrace>
<inject value="true"/>
<eject value="true"/>
<router_receive value="true"/>
</netrace>
<tasks>
<function_calls value="true"/>
<xml_parse value="false"/>
<data_receive value="true"/>
<data_send value="true"/>
<source_execute value="false"/>
</tasks>
</verbose>
<report>
<bufferReportRouters>5 6 9 10</bufferReportRouters>
</report>
</configuration>

1136
config/Test_5_task/net.xml Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -34,13 +34,13 @@ NetworkInterfaceTlm::NetworkInterfaceTlm(sc_module_name nm, Node& node) :
NetworkInterface(nm, node), lastReceivedCreditID(-1), credit_counter(0), ni_name(nm), resp_in_progress(false)
{
//change the sending tlm function name to different one for identification from receiving function
target_socket.register_nb_transport_fw(this, &NetworkInterfaceTlm::nb_transport_fw); ////from core
target_socket.register_nb_transport_fw(this, &NetworkInterfaceTlm::nb_transport_fw);
//sc_report_handler::set_actions(NI_LOG, SC_INFO, SC_LOG|SC_DISPLAY);
sc_report_handler::set_log_file_name("out/report.log"); //from core
sc_report_handler::set_actions(LOG_NAME, SC_INFO, SC_LOG|SC_DISPLAY); //from core
sc_report_handler::set_log_file_name("out/report.log");
sc_report_handler::set_actions(LOG_NAME, SC_INFO, SC_LOG|SC_DISPLAY);
try {
this->id = source_core_id;
this->id = source_ni_id;
this->dbid = rep.registerElement("ProcessingElement", this->id);
this->node = node;
this->packetPortContainer = new PacketPortContainer(
@ -118,9 +118,7 @@ void NetworkInterfaceTlm::generateFlitsForPacket(Packet* p) {
void NetworkInterfaceTlm::send_packet_to_router() {
my_payload* trans = nullptr;
//unsigned int source_core = source_core_id;
//unsigned int src_router_id = source_router_id;
sc_time delay = sc_time(0, SC_NS);
bool retry = false;
do {
@ -147,23 +145,24 @@ void NetworkInterfaceTlm::send_packet_to_router() {
unsigned int src_core_id = p->src.id;
int src_router_id = ((src_core_id - CORE_OFFSET) / CORE_NO);
unsigned int src_ni_id = p->src.id;
int src_router_id = ((src_ni_id - CORE_OFFSET) / CORE_NO);
unsigned int dst_core_id = p->dst.id;
int destination_router_id = ((dst_core_id - CORE_OFFSET) /CORE_NO);
unsigned int dst_ni_id = p->dst.id;
int destination_router_id = ((dst_ni_id - CORE_OFFSET) /CORE_NO);
std::cout<<"source router id is: "<< src_router_id<<"destination router id is: "<< destination_router_id << std::endl;
std::cout<<"source PE ID: "<<p->src.id<<" destination PE ID: "<<p->dst.id<<std::endl;
trans = new my_payload(src_core_id, src_router_id, dst_core_id, destination_router_id, current_flit, sc_time_stamp());
// Construct the address (calculation based on router/core IDs)
trans = new my_payload(src_ni_id, src_router_id, dst_ni_id, destination_router_id, current_flit, sc_time_stamp());
// Construct the address (calculation based on router/ni IDs)
unsigned int offset = 0x20; // Offset remains the same
unsigned int address = (destination_router_id << 16) | (dst_core_id << 8) | offset;
unsigned int address = (destination_router_id << 16) | (dst_ni_id << 8) | offset;
trans->set_address(address);
log_info( "Network Interface " + std::to_string(src_core_id) + " of Source Router: " + std::to_string(source_router_id)
log_info( "Network Interface " + std::to_string(src_ni_id) + " of Source Router: " + std::to_string(source_router_id)
+ ": Processing packet flit with ID: " + std::to_string(trans->data->id) + " for router " + std::to_string(destination_router_id)
+ " and Network Interface " + std::to_string(dst_core_id) + " at time: " + trans->timestamp.to_string());
+ " and Network Interface " + std::to_string(dst_ni_id) + " at time: " + trans->timestamp.to_string());
// Set up the rest of the transaction
trans->set_data_length(p->size);
@ -238,8 +237,8 @@ tlm::tlm_sync_enum NetworkInterfaceTlm::nb_transport_fw(tlm::tlm_generic_payload
if (phase == tlm::BEGIN_REQ) {
my_payload* my_trans = dynamic_cast<my_payload*>(&trans);
// Print which core is processing the received data
log_info("Network Interface " + std::to_string(source_core_id) + " of parent Router: " + std::to_string(source_router_id)
// Print which ni is processing the received data
log_info("Network Interface " + std::to_string(source_ni_id) + " of parent Router: " + std::to_string(source_router_id)
+ ": Processing transaction " + "and received flit ID: " + std::to_string(my_trans->data->id));
// Send acknowledgment or status back

View file

@ -56,10 +56,10 @@ It manages the sending and receiving of data packets and the flow control betwee
class NetworkInterfaceTlm : public NetworkInterface {
public:
tlm_utils::simple_initiator_socket<NetworkInterfaceTlm> socket; //from core
tlm_utils::simple_target_socket<NetworkInterfaceTlm> target_socket; //from core
unsigned int source_router_id; //from core
unsigned int source_core_id; //from core
tlm_utils::simple_initiator_socket<NetworkInterfaceTlm> socket;
tlm_utils::simple_target_socket<NetworkInterfaceTlm> target_socket;
unsigned int source_router_id;
unsigned int source_ni_id;
//typedef simple_initiator_socket_tagged<NetworkInterfaceTlm> ni_init_socket;
//typedef simple_target_socket_tagged<NetworkInterfaceTlm> ni_targ_socket;

View file

@ -70,7 +70,7 @@ void NetworkManager::createTrafficPool() {
void NetworkManager::createNetworkParticipants() {
int numOfPEs = tp->processingElements.size();
for (int j = 0; j < ROUTER_NO; ++j) { // Core index within each router
for (int j = 0; j < ROUTER_NO; ++j) { // NI index within each router
}
for (Node &n : globalResources.nodes) {
@ -78,9 +78,9 @@ void NetworkManager::createNetworkParticipants() {
int id = (n.id-CORE_OFFSET)/CORE_NO;
int j = (n.id-CORE_OFFSET)%CORE_NO;
int index = tlmNoc->cores[id][j]->source_core_id % numOfPEs;
int index = tlmNoc->nis[id][j]->source_ni_id % numOfPEs;
NetworkInterfaceTlm* ni = tlmNoc->cores[id][j];
NetworkInterfaceTlm* ni = tlmNoc->nis[id][j];
if (!ni) continue; // Ensure ni is valid
std::string pe_name = "pe_" + std::to_string(n.id) + "_" + std::to_string(j);
@ -107,63 +107,7 @@ void NetworkManager::createNetworkParticipants() {
}
// void NetworkManager::createNetworkParticipants() {
// int numOfPEs = tp->processingElements.size();
// for (Node &n : globalResources.nodes) {
// if (n.type->model == "RouterVC") {
// int id = n.id;
// for (int j = 0; j < CORE_NO; ++j) { // Core index within each router
// NetworkInterfaceTlm* ni = tlmNoc->cores[id][j];
// std::string pe_name = "pe_" + std::to_string(n.id);
// ProcessingElementVC *pe = new ProcessingElementVC(pe_name.c_str(), n, tp.get());
// std::unique_ptr<PacketSignalContainer> sig1 =
// std::make_unique<PacketSignalContainer>(
// ("packetSigCon1_" + std::to_string(n.id)).c_str());
// std::unique_ptr<PacketSignalContainer> sig2 =
// std::make_unique<PacketSignalContainer>(
// ("packetSigCon2_" + std::to_string(n.id)).c_str());
// ni->bind(nullptr, sig1.get(), sig2.get());
// pe->bind(nullptr, sig2.get(), sig1.get());
// networkParticipants.push_back(dynamic_cast<NetworkParticipant *>(pe));
// packetSignalContainers.push_back(move(sig1));
// packetSignalContainers.push_back(move(sig2));
// tp->processingElements.at(cores[id][j]->source_core_id % numOfPEs) = pe;
// }
// }
// }
// }
/*
void NetworkManager::createLinks() {
int link_id = 0;
for (auto &c : globalResources.connections) {
int connNodesSize = c.nodes.size();
if (connNodesSize == 2) { //might extend to bus architecture
// gets nodes for connections
Node &node1 = globalResources.nodes.at(c.nodes.at(0));
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;
NetworkInterfaceTlm* ni =
dynamic_cast<NetworkInterfaceTlm *>(
networkParticipants.at(ni_id));
MyRouter* router = tlmNoc->getRouterNodeId(rout_id);
ni->initiator.bind(*router->target_socket[DIR::Local]);
router->init_socket[DIR::Local]->bind(ni->target);
}
link_id += 2;
} else {
LOG(true,"Unsupported number of endpoints in connection "+to_string(c.id));
}
}
}
*/
void NetworkManager::runNoC() {
for (auto &r : networkParticipants) {
if (r) {

View file

@ -30,7 +30,7 @@ NocTlm::NocTlm(sc_module_name nm, std::string config_folder): sc_module(nm) {
// Create a semaphore manager instance
sem_mgr = new semaphore_manager("SemaphoreManager");
initializeGlobalResources(config_folder);
setup_routers_and_cores();
setup_routers_and_nis();
sc_report_handler::set_actions(N_LOG, SC_INFO, SC_LOG|SC_DISPLAY);
}
@ -39,7 +39,7 @@ NocTlm::~NocTlm() {
// Clean up memory to avoid leaks
for (int i = 0; i < ROUTER_NO; ++i) {
for (int j = 0; j < CORE_NO; ++j) {
delete cores[i][j]; // Delete each core (NI)
delete nis[i][j]; // Delete each NI
}
delete routers[i]; // Delete each router
}
@ -66,7 +66,7 @@ void NocTlm::initializeGlobalResources(std::string config_folder) {
globalResources.outputDirectory = "out";
}
void NocTlm::setup_routers_and_cores() {
void NocTlm::setup_routers_and_nis() {
// Instantiate ROUTER_NO routers
//globalResources.nodes.size()
for (Node &n : globalResources.nodes) {
@ -91,26 +91,26 @@ void NocTlm::setup_routers_and_cores() {
}
}
// Instantiate ROUTER_NO * CORE_NO cores (CORE_NO per router)
// Instantiate ROUTER_NO * CORE_NO nis (CORE_NO per router)
for (Node &n : globalResources.nodes) {
if (n.type->model == "Router"){
int id = n.id;
for (int j = 0; j < CORE_NO; ++j) { // Core index within each router
std::string core_name = "core" + std::to_string(id) + "_" + std::to_string(j);
cores[id][j] = new NetworkInterfaceTlm(core_name.c_str(), n);
cores[id][j]->source_router_id = id; // Set source router ID
cores[id][j]->source_core_id = CORE_NO*id + j + CORE_OFFSET; // Set source core ID
for (int j = 0; j < CORE_NO; ++j) { // NI index within each router
std::string ni_name = "ni" + std::to_string(id) + "_" + std::to_string(j);
nis[id][j] = new NetworkInterfaceTlm(ni_name.c_str(), n);
nis[id][j]->source_router_id = id; // Set source router ID
nis[id][j]->source_ni_id = CORE_NO*id + j + CORE_OFFSET; // Set source NI ID
}
}
}
// Bind cores to their respective routers
// Bind NIs to their respective routers
for (Node &n : globalResources.nodes) {
if (n.type->model == "Router"){
int id = n.id;
for (int j = 0; j < CORE_NO; ++j) { // Core index within each router
cores[id][j]->socket.bind(routers[id]->sockets[j]); // Core's socket to router's target socket
routers[id]->core_sockets[j].bind(cores[id][j]->target_socket); // Router's initiator socket to core's target socket
for (int j = 0; j < CORE_NO; ++j) { // NI index within each router
nis[id][j]->socket.bind(routers[id]->sockets[j]); // NI's socket to router's target socket
routers[id]->core_sockets[j].bind(nis[id][j]->target_socket); // Router's initiator socket to ni's target socket
routers[id]->current_router_id = id;
}
}

View file

@ -65,13 +65,13 @@ public:
GlobalResources& globalResources = GlobalResources::getInstance();
router* routers[ROUTER_NO];
NetworkInterfaceTlm* cores[ROUTER_NO][CORE_NO];
NetworkInterfaceTlm* nis[ROUTER_NO][CORE_NO];
std::vector<sc_core::sc_semaphore*> router_sems;
std::vector<sc_core::sc_fifo<my_payload*>*> router_out_fifos;
semaphore_manager* sem_mgr;
// Method to initialize the routers and cores
void setup_routers_and_cores();
// Method to initialize the routers and nis
void setup_routers_and_nis();
void log_info(std::string msg);

View file

@ -29,11 +29,11 @@ router::router(sc_module_name name)
sc_report_handler::set_actions(LOG_NAME, SC_INFO, SC_LOG|SC_DISPLAY);
for (int i = 0; i < CORE_NO; ++i) {
//changed name to match receiving function
sockets[i].register_nb_transport_fw(this, &router::nb_transport_fw); //register the nb_transport fun to each target socket to receive data from core
sockets[i].register_nb_transport_fw(this, &router::nb_transport_fw); //register the nb_transport fun to each target socket to receive data from ni
}
SC_THREAD(process_core_fifo); //process to handle data in the input fifo where data from core has been saved and send them destination router
SC_THREAD(process_router_receive_fifo); //process to send the data available in output fifo to destination core
SC_THREAD(process_in_fifo); //process to handle data in the input fifo where data from ni has been saved and send them destination router
SC_THREAD(process_out_fifo); //process to send the data available in output fifo to destination ni
}
// Function to handle incoming transactions, changed function name
@ -42,20 +42,21 @@ tlm::tlm_sync_enum router::nb_transport_fw(tlm::tlm_generic_payload& trans, tlm:
if (in_fifo.num_free() == 0) {
log_info("Router "+ std::string(name()) +": Input FIFO full, cannot accept transaction with data: ");
delay = sc_time(5, SC_NS); // Delay before retry
//wait(core_fifo_event);
return tlm::TLM_UPDATED; // Indicate to retry later
}
sc_time current_time = sc_time_stamp();
//manually copy the transaction payload for future use
my_payload* orig_trans = dynamic_cast<my_payload*>(&trans);
my_payload* my_trans = new my_payload();
// Log the time when the core sent the transaction
// Log the time when the ni sent the transaction
sc_time sent_time = orig_trans->timestamp;
my_trans->dst_core = orig_trans->dst_core;
my_trans->dst_ni = orig_trans->dst_ni;
my_trans->dst_router = orig_trans->dst_router;
my_trans->data = orig_trans->data;
my_trans->src_router = orig_trans->src_router;
my_trans->src_core = orig_trans->src_core;
int src_router_id = orig_trans->src_router;
my_trans->src_ni = orig_trans->src_ni;
my_trans->update_timestamp(current_time); // Update the timestamp in the payload
my_trans->set_address(orig_trans->get_address());
@ -68,8 +69,8 @@ tlm::tlm_sync_enum router::nb_transport_fw(tlm::tlm_generic_payload& trans, tlm:
my_trans->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE);
// Push the transaction into the input FIFO by blocking write
in_fifo.write(my_trans);
//in_fifo_event.notify(sc_core::SC_ZERO_TIME);
log_info("Router " + std::string(name()) + ": Received transaction with data "
log_info("Router " + std::to_string(src_router_id) + ": Received transaction with data "
+ " at time: " + current_time.to_string());
phase = tlm::END_REQ; // Mark the end of the request phase
@ -82,7 +83,7 @@ tlm::tlm_sync_enum router::nb_transport_fw(tlm::tlm_generic_payload& trans, tlm:
// Thread to process in_fifo
void router::process_core_fifo() {
void router::process_in_fifo() {
my_payload* payload;
while (true) {
@ -97,11 +98,11 @@ void router::process_core_fifo() {
payload = in_fifo.read(); // Blocking read
//std::cout<<in_fifo.num_free()<<std::endl;
// Decode the address to determine the destination router and core
// Decode the address to determine the destination router and ni
unsigned int address = payload->get_address();
unsigned int destination_router_id = (address >> 16) & 0xF; // Extract router ID from address
unsigned int destination_core_id = (address >> 8) & 0xFF; // Extract core ID from address
std::cout<<"destination core id from address at source router:"<< destination_core_id<<std::endl;
unsigned int destination_ni_id = (address >> 8) & 0xFF; // Extract ni ID from address
std::cout<<"destination NI id from address at source router:"<< destination_ni_id<<std::endl;
//blocking write to destination router
if(sem_mgr->peek_token(current_router_id, destination_router_id)) {
log_info("Router " + std::to_string(current_router) + " : Token for destination Router: " + std::to_string(destination_router_id) + " is currently available to acquire" );
@ -153,8 +154,8 @@ void router::process_core_fifo() {
}
// Thread to process router_receive_fifo and forward transactions to cores
void router::process_router_receive_fifo() {
// Thread to process router_receive_fifo and forward transactions to NIs
void router::process_out_fifo() {
my_payload* payload;
int prev_src_id = -1;
@ -168,19 +169,15 @@ void router::process_router_receive_fifo() {
// Wait for data in the output FIFO
payload = out_fifo.read(); // Blocking read
// Extract destination core ID from the address
// Extract destination NI ID from the address
unsigned int address = payload->get_address();
unsigned int destination_core_id = (address >> 8) & 0xFF; // Core ID
unsigned int destination_ni_id = (address >> 8) & 0xFF; // NI ID
unsigned int dest_router_id = (address >> 16) & 0xF; // Extract router ID from address
unsigned int src_router = payload->src_router;
sc_core::sc_time timestamp = payload->timestamp;
std::cout<<"destination core id from address at destination router:"<< destination_core_id<<std::endl;
//std::cout<<"destination NI id from address at destination router:"<< destination_ni_id<<std::endl;
// if (destination_core_id >= CORE_NO) {
// log_error("Router " + std::string(name()) + ": Invalid destination core ID: " + std::to_string(destination_core_id));
// delete payload;
// continue;
// }
int delay_T = (dest_router_id -src_router + ROUTER_NO) % ROUTER_NO * D;
// if(timestamp==prev_timestamp){
@ -202,27 +199,27 @@ void router::process_router_receive_fifo() {
log_info("Router " + std::to_string(current_router_id) + ": Forwarding transaction with data: " + std::to_string(payload->data->id)
+ " to Processing Element " + std::to_string(destination_core_id));
+ " to Processing Element " + std::to_string(destination_ni_id));
// Send the payload to the corresponding core using non-blocking TLM
// Send the payload to the corresponding NI using non-blocking TLM
tlm::tlm_phase phase = tlm::BEGIN_REQ;
sc_time delay = SC_ZERO_TIME;
tlm::tlm_sync_enum status = core_sockets[destination_core_id % CORE_NO]->nb_transport_fw(*payload, phase, delay);
tlm::tlm_sync_enum status = core_sockets[destination_ni_id % CORE_NO]->nb_transport_fw(*payload, phase, delay);
if (status == tlm::TLM_COMPLETED) {
log_info("Router " + std::to_string(current_router_id) + ": Network Interface " + std::to_string(destination_core_id)
log_info("Router " + std::to_string(current_router_id) + ": Network Interface " + std::to_string(destination_ni_id)
+ " completed transaction, data ID: " + std::to_string(payload->data->id));
//// other_sems[dest_router_id]->post();
} else if (status == tlm::TLM_ACCEPTED) {
log_info("Router " + std::to_string(current_router_id) + ": Network Interface " + std::to_string(destination_core_id)
log_info("Router " + std::to_string(current_router_id) + ": Network Interface " + std::to_string(destination_ni_id)
+ " accepted transaction, waiting for completion.");
} else if (status == tlm::TLM_UPDATED) {
log_info("Router " + std::to_string(current_router_id) + ": Network Interface " + std::to_string(destination_core_id)
log_info("Router " + std::to_string(current_router_id) + ": Network Interface " + std::to_string(destination_ni_id)
+ " updated transaction, waiting for completion.");
} else {
log_error("Router " + std::to_string(current_router_id) + ": Unexpected response from Network Interface " + std::to_string(destination_core_id));
log_error("Router " + std::to_string(current_router_id) + ": Unexpected response from Network Interface " + std::to_string(destination_ni_id));
delete payload;
}

View file

@ -41,9 +41,9 @@ using namespace sc_core;
// Router module with FIFOs, semaphores, and capacity control for receive FIFO
SC_MODULE(router) {
tlm_utils::simple_target_socket<router> sockets[CORE_NO]; // Sockets to receive data from cores
tlm_utils::simple_initiator_socket<router> core_sockets[CORE_NO]; // Sockets to send data to cores
sc_core::sc_fifo<my_payload*> in_fifo; // FIFO for incoming transactions from cores
tlm_utils::simple_target_socket<router> sockets[CORE_NO]; // Sockets to receive data from nis
tlm_utils::simple_initiator_socket<router> core_sockets[CORE_NO]; // Sockets to send data to nis
sc_core::sc_fifo<my_payload*> in_fifo; // FIFO for incoming transactions from nis
sc_core::sc_fifo<my_payload*> out_fifo; // FIFO for transactions to be processed by the router
@ -68,10 +68,10 @@ SC_MODULE(router) {
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& trans, tlm::tlm_phase& phase, sc_time& delay);
// Thread to process core_fifo
void process_core_fifo();
void process_in_fifo();
// Thread to process router_receive_fifo and forward transactions to cores
void process_router_receive_fifo();
// Thread to process router_receive_fifo and forward transactions to nis
void process_out_fifo();
void log_info(std::string msg);
void log_error(std::string msg);

View file

@ -34,8 +34,8 @@ using namespace sc_core; // For sc_time
// Global parameters to generalize the design
#define ROUTER_NO 8 // Number of routers
#define CORE_NO 4 // Number of cores per router
#define CORE_FIFO_CAPACITY 20 // Capacity of FIFO in router that receive data from cores
#define CORE_NO 4 // Number of NIs per router
#define CORE_FIFO_CAPACITY 20 // Capacity of FIFO in router that receive data from nis
#define ROUTER_RECEIVE_FIFO_CAPACITY 20 // Capacity of FIFO in router that receive data from other routers
#define CORE_OFFSET 8 // To find the Router number, it is same as ROUTER_NO
#define LOG_NAME "MY_LOG"
@ -43,23 +43,23 @@ using namespace sc_core; // For sc_time
struct my_payload : public tlm::tlm_generic_payload {
unsigned int src_core; // Source core ID
unsigned int src_ni; // Source ni ID
unsigned int src_router; // Source router ID
unsigned int dst_core; // Destination core ID
unsigned int dst_ni; // Destination ni ID
unsigned int dst_router; // Destination router ID
Flit* data; // Data value
sc_core::sc_time timestamp; // Timestamp field
// Default constructor
my_payload() : src_core(0), src_router(0), dst_core(0), dst_router(0), data(nullptr), timestamp(SC_ZERO_TIME) {
my_payload() : src_ni(0), src_router(0), dst_ni(0), dst_router(0), data(nullptr), timestamp(SC_ZERO_TIME) {
set_data_ptr(reinterpret_cast<unsigned char*>(&data));
set_data_length(sizeof(data));
set_streaming_width(sizeof(data));
}
// Constructor with random data
my_payload(unsigned int source_core, unsigned int src_router_id, unsigned int dst_core_id, unsigned int destination_router_id, Flit* flit_data, sc_time time = SC_ZERO_TIME)
: src_core(source_core), src_router(src_router_id), dst_core(dst_core_id), dst_router(destination_router_id), data(flit_data), timestamp(time) {
my_payload(unsigned int source_ni, unsigned int src_router_id, unsigned int dst_ni_id, unsigned int destination_router_id, Flit* flit_data, sc_time time = SC_ZERO_TIME)
: src_ni(source_ni), src_router(src_router_id), dst_ni(dst_ni_id), dst_router(destination_router_id), data(flit_data), timestamp(time) {
set_data_ptr(reinterpret_cast<unsigned char*>(&data));
set_data_length(sizeof(data));
set_streaming_width(sizeof(data));