diff --git a/README.md b/README.md
index ec533c2..7e6a9e5 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,3 @@
-# Defines
-
-`cmake -DDEFINE_ENABLE_NETRACE=ON`
-
-enables netrace mode
-
-`cmake -DDEFINE_ENABLE_GUI=ON`
-
-enables GUI mode
# Corona Optical Network on Chip (NoC) Simulation with Ratatoskr
@@ -29,9 +20,11 @@ This project simulates the Corona all optical Network-on-Chip (NoC) architecture
## Compilation
./build.sh
-## Output simple test
- ./sim --configFolder .
-
+## Output simple test - 1 Task
+ ./sim --configFolder simple_test
+
+## Output - 2 Task
+ ./sim --configFolder simple_2_point_test
# Log file
diff --git a/config/net.xml b/config/net.xml
index fc66cae..5d47d14 100644
--- a/config/net.xml
+++ b/config/net.xml
@@ -48,166 +48,295 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
diff --git a/config/simple_test/simple_map.xml b/config/simple_test/simple_map.xml
index bee1db8..1053b30 100644
--- a/config/simple_test/simple_map.xml
+++ b/config/simple_test/simple_map.xml
@@ -2,10 +2,10 @@
diff --git a/out/report.log b/out/report.log
index 66e8ec9..829c981 100644
--- a/out/report.log
+++ b/out/report.log
@@ -1,12 +1,12 @@
-59 ns: INFO: MY_LOG: Flits generated for packet of id 0 to be sent to 0.000000,0.667000,0.000000 from 0.000000,0.000000,0.000000
-59 ns: INFO: MY_LOG: Network Interface 0 of Source Router: 0: Processing packet flit with ID: 1 for router 3 and Network Interface 12 at time: 59 ns
+59 ns: INFO: MY_LOG: Flits generated for packet of id 0 to be sent to 0.000000,1.000000,0.000000 from 0.000000,0.000000,0.000000
+59 ns: INFO: MY_LOG: Network Interface 10 of Source Router: 0: Processing packet flit with ID: 1 for router 3 and Network Interface 21 at time: 59 ns
59 ns: INFO: MY_LOG: Router Layer.NocTlm.router0: Received transaction with data at time: 59 ns
-59 ns: INFO: MY_LOG: Network Interface core0_0: Transaction successful, flit sent ID: 1 at time: 59 ns
+59 ns: INFO: MY_LOG: Network Interface core0_2: Transaction successful, flit sent ID: 1 at time: 59 ns
59 ns: INFO: MY_LOG: router id: 0, dest Router id: 3
59 ns: INFO: MY_LOG: Token for destination router 3 granted to Router 0
59 ns: INFO: MY_LOG: Router: 0 forwarded data with ID: 1 to Router_3
89 ns: INFO: MY_LOG: Router 0 released token for destination router 3
89 ns: INFO: MY_LOG: Router 3: Received transaction with data: 1 from Router 0 after a delay of:30 ns
-89 ns: INFO: MY_LOG: Router 3: Forwarding transaction with data: 1 to Processing Element 12
-89 ns: INFO: MY_LOG: Network Interface 12 of parent Router: 3: Processing transaction and received flit ID: 1
-89 ns: INFO: MY_LOG: Router 3: Network Interface 12 completed transaction, data ID: 1
+89 ns: INFO: MY_LOG: Router 3: Forwarding transaction with data: 1 to Processing Element 21
+89 ns: INFO: MY_LOG: Network Interface 21 of parent Router: 3: Processing transaction and received flit ID: 1
+89 ns: INFO: MY_LOG: Router 3: Network Interface 21 completed transaction, data ID: 1
diff --git a/src/main.cpp b/src/main.cpp
index 42692f6..e86baeb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,22 +34,26 @@ namespace po = boost::program_options;
int sc_main(int arg_num, char *arg_vec[])
{
+
po::variables_map vm;
po::options_description desc("Allowed Options");
desc.add_options()("configFolder", po::value()->default_value(""), "Input path for config.xml and net.xml");
try {
+
po::store(po::parse_command_line(arg_num, arg_vec, desc), vm);
po::notify(vm);
}
catch (po::error &e) {
+
cerr << "ERROR: " << e.what() << endl << endl << desc << endl;
return 1;
}
std::string configFolder = vm["configFolder"].as();
-
+
// start simulation
std::unique_ptr networkManager =
std::make_unique("Layer", configFolder);
+
GlobalResources& globalResources = GlobalResources::getInstance();
cout << "Random seed " << globalResources.rd_seed << endl;
cout << endl
diff --git a/src/networkInterface/NetworkInterfaceTlm.cpp b/src/networkInterface/NetworkInterfaceTlm.cpp
index df574cc..f9531e8 100644
--- a/src/networkInterface/NetworkInterfaceTlm.cpp
+++ b/src/networkInterface/NetworkInterfaceTlm.cpp
@@ -139,15 +139,18 @@ void NetworkInterfaceTlm::send_packet_to_router() {
my_payload* trans = nullptr;
unsigned int src_core_id = p->src.id;
- unsigned int src_router_id = src_core_id/CORE_NO;
+ int src_router_id = ((src_core_id - CORE_OFFSET) / CORE_NO);
+ std::cout<<"source router id is: "<< src_router_id << std::endl;
unsigned int dst_core_id = p->dst.id;
- unsigned int destination_router_id = dst_core_id/CORE_NO;
+ int destination_router_id = ((dst_core_id - CORE_OFFSET) /CORE_NO);
+ std::cout<<"destination router id is: "<< destination_router_id << std::endl;
sc_time delay = sc_time(0, SC_NS);
-
+ std::cout<<"source PE ID: "<src.id<<" destination PE ID: "<dst.id<set_address(address);
log_info( "Network Interface " + std::to_string(src_core_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)
diff --git a/src/networkManager/NetworkManager.cpp b/src/networkManager/NetworkManager.cpp
index 6800351..042509b 100644
--- a/src/networkManager/NetworkManager.cpp
+++ b/src/networkManager/NetworkManager.cpp
@@ -37,6 +37,7 @@ NetworkManager::NetworkManager(sc_module_name nm, std::string configFolder){
}
void NetworkManager::createClocks() {
+
clocks.resize(globalResources.nodeTypes.size());
for (const auto &nodeType : globalResources.nodeTypes) {
clocks.at(nodeType->id) = std::make_unique(
@@ -47,16 +48,19 @@ void NetworkManager::createClocks() {
void NetworkManager::createTrafficPool() {
+
unsigned long numOfPEs = CORE_NO * globalResources.nodes.size() / 2;
-#ifndef ENABLE_NETRACE
- if (globalResources.benchmark == "task") {
- tp = std::make_unique();
- } else if (globalResources.benchmark == "synthetic") {
- tp = std::make_unique();
- } else {
- FATAL("Please specify correct benchmark type");
- }
-#endif
+ #ifndef ENABLE_NETRACE
+ if (globalResources.benchmark == "task") {
+
+ tp = std::make_unique();
+ } else if (globalResources.benchmark == "synthetic") {
+
+ tp = std::make_unique();
+ } else {
+ FATAL("Please specify correct benchmark type");
+ }
+ #endif
// #ifdef ENABLE_NETRACE
// tp = std::make_unique("NetracePool");
// #endif
@@ -64,36 +68,39 @@ 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 (Node &n : globalResources.nodes) {
- if (n.type->model == "Router") {
- int id = n.id;
+ if (n.type->model == "ProcessingElement") {
+ int id = (n.id-CORE_OFFSET)/CORE_NO;
+ int j = (n.id-CORE_OFFSET)%CORE_NO;
- for (int j = 0; j < CORE_NO; ++j) {
- int index = tlmNoc->cores[id][j]->source_core_id % numOfPEs;
+ int index = tlmNoc->cores[id][j]->source_core_id % numOfPEs;
- NetworkInterfaceTlm* ni = tlmNoc->cores[id][j];
- if (!ni) continue; // Ensure ni is valid
+ NetworkInterfaceTlm* ni = tlmNoc->cores[id][j];
+ if (!ni) continue; // Ensure ni is valid
- std::string pe_name = "pe_" + std::to_string(n.id) + "_" + std::to_string(j);
- ProcessingElementVC *pe = new ProcessingElementVC(pe_name.c_str(), n, tp.get(), index);
+ std::string pe_name = "pe_" + std::to_string(n.id) + "_" + std::to_string(j);
+ ProcessingElementVC *pe = new ProcessingElementVC(pe_name.c_str(), n, tp.get(), index);
- auto sig1 = std::make_unique(
- ("packetSigCon1_" + std::to_string(n.id) + "_" + std::to_string(j)).c_str());
- auto sig2 = std::make_unique(
- ("packetSigCon2_" + std::to_string(n.id) + "_" + std::to_string(j)).c_str());
+ auto sig1 = std::make_unique(
+ ("packetSigCon1_" + std::to_string(n.id) + "_" + std::to_string(j)).c_str());
+ auto sig2 = std::make_unique(
+ ("packetSigCon2_" + std::to_string(n.id) + "_" + std::to_string(j)).c_str());
- ni->bind(nullptr, sig1.get(), sig2.get());
- pe->bind(nullptr, sig2.get(), sig1.get());
- ni->clk(*clocks.at(n.type->id));
+ ni->bind(nullptr, sig1.get(), sig2.get());
+ pe->bind(nullptr, sig2.get(), sig1.get());
+ ni->clk(*clocks.at(n.type->id));
- networkParticipants.push_back(dynamic_cast(pe));
- packetSignalContainers.push_back(move(sig1));
- packetSignalContainers.push_back(move(sig2));
+ networkParticipants.push_back(dynamic_cast(pe));
+ packetSignalContainers.push_back(move(sig1));
+ packetSignalContainers.push_back(move(sig2));
- if (index < tp->processingElements.size()) {
- tp->processingElements[index] = pe;
- }
+ if (index < tp->processingElements.size()) {
+ tp->processingElements[index] = pe;
}
}
}
diff --git a/src/networkManager/NetworkManager.h b/src/networkManager/NetworkManager.h
index 6024fe9..a594bf5 100644
--- a/src/networkManager/NetworkManager.h
+++ b/src/networkManager/NetworkManager.h
@@ -65,7 +65,7 @@ private:
std::unique_ptr tp;
NocTlm* tlmNoc;
std::vector networkParticipants;
- std::vector idNis;
+ std::vector idNis;
std::vector> packetSignalContainers;
//std::vector> links; ////
diff --git a/src/noc/noc.cpp b/src/noc/noc.cpp
index 556cbdc..5e851d3 100644
--- a/src/noc/noc.cpp
+++ b/src/noc/noc.cpp
@@ -99,7 +99,7 @@ void NocTlm::setup_routers_and_cores() {
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; // Set source core ID
+ cores[id][j]->source_core_id = CORE_NO*id + j + CORE_OFFSET; // Set source core ID
}
}
}
diff --git a/src/router/router.cpp b/src/router/router.cpp
index daefb88..9a72f1b 100644
--- a/src/router/router.cpp
+++ b/src/router/router.cpp
@@ -98,8 +98,9 @@ void router::process_core_fifo() {
//std::cout<get_address();
- unsigned int destination_router_id = (address >> 12) & 0xF; // Extract router ID from address
- unsigned int destination_core_id = (address >> 8) & 0xF; // Extract core ID from 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<request_token(current_router_id, destination_router_id)) {
if (other_out_fifos[destination_router_id]->num_free() > 0) {
@@ -163,10 +164,12 @@ void router::process_router_receive_fifo() {
// Extract destination core ID from the address
unsigned int address = payload->get_address();
- unsigned int destination_core_id = (address >> 8) & 0xF; // Core ID
- unsigned int dest_router_id = (address >> 12) & 0xF; // Extract router ID from address
+ std::cout<<"address "<> 8) & 0xFF; // Core 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<= CORE_NO) {
// log_error("Router " + std::string(name()) + ": Invalid destination core ID: " + std::to_string(destination_core_id));
@@ -185,7 +188,7 @@ void router::process_router_receive_fifo() {
// wait(delay_T, SC_NS); // Simulate delay for receiving the data
log_info("Router " + std::to_string(dest_router_id)+ ": Received transaction with data: " + std::to_string(payload->data->id)
- + " from Router " + std::to_string(payload->src_router) + " after a delay of:" + std::to_string(delay_T) + " ns" );
+ + " from Router " + std::to_string(src_router) + " after a delay of:" + std::to_string(delay_T) + " ns" );
prev_src_id = src_router;
prev_timestamp = timestamp;
diff --git a/src/utils/configuration.h b/src/utils/configuration.h
index 46a3ee2..8ca2d68 100644
--- a/src/utils/configuration.h
+++ b/src/utils/configuration.h
@@ -33,12 +33,13 @@
using namespace sc_core; // For sc_time
// Global parameters to generalize the design
-#define ROUTER_NO 4 // Number of routers
+#define ROUTER_NO 8 // Number of routers
#define CORE_NO 4 // Number of cores per router
#define CORE_FIFO_CAPACITY 8 // Capacity of FIFO in router that receive data from cores
#define ROUTER_RECEIVE_FIFO_CAPACITY 4 // 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"
-#define NI_LOG "TLM_NI"
+#define NI_LOG "TLM_NI"
struct my_payload : public tlm::tlm_generic_payload {