commit a6b37bd0c1f290c20617e1713f3e9fef0190b742 Author: HelenClaraGeorge Date: Fri Oct 25 22:31:41 2024 +0200 Initial commit with project files for Corona implemented with TLM and FIFO diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..258b7e5 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +CXX = g++ +CXXFLAGS = -std=c++17 -g -I$(SYSTEMC_HOME)/include -I./include +LDFLAGS = -L$(SYSTEMC_HOME)/lib-linux64 -lsystemc +SRCDIR = src +INCDIR = include +OBJDIR = obj +OUTDIR = out + +SOURCES = $(wildcard $(SRCDIR)/*.cpp) +OBJECTS = $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o) +EXECUTABLE = $(OUTDIR)/noc_simulation + +all: directories $(EXECUTABLE) + +directories: + mkdir -p $(OBJDIR) $(OUTDIR) + +$(EXECUTABLE): $(OBJECTS) main.cpp + $(CXX) $(CXXFLAGS) $(OBJECTS) main.cpp -o $@ $(LDFLAGS) + +$(OBJDIR)/%.o: $(SRCDIR)/%.cpp + $(CXX) $(CXXFLAGS) -c $< -o $@ + +clean: + rm -rf $(OBJDIR) $(OUTDIR) + +.PHONY: all clean directories diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d8eba9 --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ +# Corona Optical Network on Chip (NoC) Simulation + +This project simulates the Corona all optical Network-on-Chip (NoC) architecture using SystemC TLM 2.0. + +## Project Structure + +Corona_NoC_Optical_230924/ +├── include/ +│ ├── configuration.h +│ ├── core.h +│ ├── router.h +├── src/ +│ ├── core.cpp +│ ├── router.cpp +├── main.cpp +├── Makefile +└── README.md + +## Prerequisites + +- SystemC (version 2.3.3 or later) +- C++ compiler supporting C++17 or later (e.g., GCC 7+ or Clang 5+) +- Make + +## Setup + +1. Install SystemC on your system. +2. Set the `SYSTEMC_HOME` environment variable to point to your SystemC installation directory: + + ```bash + export SYSTEMC_HOME=/path/to/your/systemc/installation + +## Compilation +make + +## Output + ./out/noc_simulation + + +# Log file +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 +• 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 + +# Introduction to Corona +The Corona architecture is as follows; + +1. Architectural Design: + +Corona is a 3D many-core architecture with 256 low-power multithreaded cores, organized into 64 clusters with each cluster having 4 cores and hub to facilitate communication. It uses nanophotonic communication for both inter-core and off-stack communication to memory or I/O devices. Each cluster has a channel associated with it. The channel starts at a cluster and passes through all other clusters and ends at the home cluster in a serpentine manner. Only the home cluster can read from the channel, but all other clusters can write into the channel. Each cluster has a token associated with it. The clusters can write into the channels of any other cluster by acquiring destination cluster’s token. + +The key components include: +• A photonic crossbar that fully interconnects the cores +• Dense wavelength division multiplexed (DWDM) optically connected memory modules +• An optical broadcast bus +• Memory controllers and network interfaces + +2. Communication Control: + +Communication in Corona is controlled through a distributed, all-optical, token-based arbitration scheme. This means: +• Each node participates in the token management process +• Optical tokens circulate continuously through the network +• Nodes must acquire a token to gain access to a communication channel + +3. Communication Decisions: + +The decision-making process for communication is as follows: +• When to communicate: A node initiates communication when it has data to send and has acquired the appropriate token. +• Who to communicate with: The destination is determined by the application needs. The photonic crossbar allows any node to communicate with any other node. +• When to stop: After completing its transmission, the node releases the token back into the network. + +4. Broadcast bus +• In addition, there is a broadcast bus waveguide, to which all clusters can read and write +• The clusters can write a common message into the broadcast bus by acquiring the broadcast token. + +The corona architecture has a global optical clock and the local optical clock is in phase synchronization with the global clock. + +In general, if we consider any particular cluster ‘n’, there will be a number of activities going on; +• Detecting token to transmit data +• Divert and acquire the token when it is detected +• Transmit data by modulating light on the desired channel +• Release the token once the data transmission is finished +• Detect broadcast token when it has a broadcast message to send +• Divert and acquire the broadcast token when it is detected +• Send broadcast message by modulating light on the broadcast channel +• Release broadcast token when broadcast message transmission is finished +• Detects for messages on home channel ‘n’ (Reading data) +• Detecting the broadcast channel for broadcast messages +• Acquire and renew the home token \ No newline at end of file diff --git a/include/configuration.h b/include/configuration.h new file mode 100644 index 0000000..839b71c --- /dev/null +++ b/include/configuration.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include +#include +#include + +using namespace sc_core; // For sc_time + +// Global parameters to generalize the design +#define ROUTER_NO 4 // 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 2 // Capacity of FIFO in router that receive data from other routers +#define LOG_NAME "MY_LOG" + +struct my_payload : public tlm::tlm_generic_payload { + unsigned int src_core; // Source core ID + unsigned int src_router; // Source router ID + unsigned int dst_core; // Destination core ID + unsigned int dst_router; // Destination router ID + int data; // Data value (random number) + sc_core::sc_time timestamp; // Timestamp field + + // Default constructor + my_payload() : src_core(0), src_router(0), dst_core(0), dst_router(0), data(0), timestamp(SC_ZERO_TIME) { + set_data_ptr(reinterpret_cast(&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, int 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(data) { + set_data_ptr(reinterpret_cast(&data)); + set_data_length(sizeof(data)); + set_streaming_width(sizeof(data)); + } + + // Function to update timestamp at any stage + void update_timestamp(sc_time new_time) { + timestamp = new_time; + } +}; + + +// Define the payload type +// struct my_payload : public tlm::tlm_generic_payload { +// unsigned int dst_core; +// unsigned int dst_router; +// int data; + +// my_payload() : dst_core(0), dst_router(0), data(0) { +// set_data_ptr(reinterpret_cast(&data)); +// set_data_length(sizeof(data)); +// set_streaming_width(sizeof(data)); +// } + +// my_payload(int d) : dst_core(0), dst_router(0), data(d) { +// set_data_ptr(reinterpret_cast(&data)); +// set_data_length(sizeof(data)); +// set_streaming_width(sizeof(data)); +// } + diff --git a/include/core.h b/include/core.h new file mode 100644 index 0000000..a40554e --- /dev/null +++ b/include/core.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // For rand() +#include // For time() + +#include "configuration.h" + + +// Initiator module (processor core) +SC_MODULE(core) { + tlm_utils::simple_initiator_socket socket; + tlm_utils::simple_target_socket target_socket; + unsigned int source_router_id; // Source router ID for this core + unsigned int source_core_id; + + SC_CTOR(core); + + // Thread for sending data + void thread(); + + /// Forwarding function for receiving data from router + tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& trans, tlm::tlm_phase& phase, sc_time& delay); + + void log_info(std::string msg); + void log_error(std::string msg); +}; diff --git a/include/router.h b/include/router.h new file mode 100644 index 0000000..6c357ca --- /dev/null +++ b/include/router.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // For rand() +#include // For time() + +#include "configuration.h" +#include "semaphore_manager.h" + +using namespace sc_core; + +// Router module with FIFOs, semaphores, and capacity control for receive FIFO +SC_MODULE(router) { + tlm_utils::simple_target_socket sockets[CORE_NO]; // Sockets to receive data from cores + tlm_utils::simple_initiator_socket core_sockets[CORE_NO]; // Sockets to send data to cores + sc_core::sc_fifo in_fifo; // FIFO for incoming transactions from cores + sc_core::sc_fifo out_fifo; // FIFO for transactions to be processed by the router + + + unsigned int current_router_id; + + // Declare the semaphore for access control + sc_core::sc_semaphore sem; + int router_id; + const int D = 10; // Base delay for each router communication (in ns) + + + // Pointers to other routers' FIFOs and semaphores for inter-router communication + std::vector*> other_out_fifos; + std::vector other_sems; + + // Add a pointer to the semaphore manager + semaphore_manager* sem_mgr; + + SC_CTOR(router); + + // Function to handle incoming transactions + 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(); + + // Thread to process router_receive_fifo and forward transactions to cores + void process_router_receive_fifo(); + + void log_info(std::string msg); + void log_error(std::string msg); + + // Method to set the semaphore manager instance after creation + void set_semaphore_manager(semaphore_manager* manager) { + sem_mgr = manager; + } +}; + diff --git a/include/semaphore_manager.h b/include/semaphore_manager.h new file mode 100644 index 0000000..d30b67f --- /dev/null +++ b/include/semaphore_manager.h @@ -0,0 +1,123 @@ +// semaphore_manager.h +#ifndef SEMAPHORE_MANAGER_H +#define SEMAPHORE_MANAGER_H + +#include +#include +#include +#include +#include +#include +#include "configuration.h" + +using namespace sc_core; + +class semaphore_manager : public sc_module { +public: + SC_HAS_PROCESS(semaphore_manager); + + semaphore_manager(sc_module_name name) : sc_module(name) { + semaphore_owners.resize(ROUTER_NO, 0); // Start with all tokens at router 0 + request_queues.resize(ROUTER_NO); // Initialize a queue for each semaphore + queue_entries.resize(ROUTER_NO); // Set for each semaphore to track queued routers + semaphore_status.resize(ROUTER_NO, false); // All semaphores are initially free + std::fill_n(last_router_owner, ROUTER_NO, -1); // Initialize all last owners to -1 + SC_THREAD(update_semaphores); // Start automatic ownership update thread + sc_report_handler::set_log_file_name("out/report.log"); + sc_report_handler::set_actions(LOG_NAME, SC_INFO, SC_LOG|SC_DISPLAY); + } + + // Request a token for a semaphore with round-robin and priority ordering + bool request_token(int router_id, int semaphore_id) { + //wait(SC_ZERO_TIME); + std::lock_guard lock(mutex); // Ensure atomic access + if (semaphore_id >= 0 && semaphore_id < ROUTER_NO) { + + wait(SC_ZERO_TIME); + // Give priority if the request follows round-robin order from the last owner + if (semaphore_owners[semaphore_id] == router_id || semaphore_owners[semaphore_id] == -1 || (!semaphore_status[semaphore_id] && request_queues[semaphore_id].empty())) + { + log_info("Token for destination router " + std::to_string(semaphore_id) + " granted to Router " + std::to_string(router_id)); + semaphore_owners[semaphore_id] = router_id; + semaphore_status[semaphore_id] = true; // Mark semaphore as in use + last_router_owner[semaphore_id] = router_id; // Update the last owner + return true; + } else { + if (queue_entries[semaphore_id].find(router_id) == queue_entries[semaphore_id].end()) { + request_queues[semaphore_id].push(router_id); + queue_entries[semaphore_id].insert(router_id); // Track in the set + log_info("Router " + std::to_string(router_id) + " added to queue for semaphore " + std::to_string(semaphore_id)); + } + + } + } + return false; + } + + // Release the token and pass it to the next in the round-robin or queue order + bool release_token(int router_id, int semaphore_id) { + std::lock_guard lock(mutex); // Ensure atomic access + if (semaphore_id >= 0 && semaphore_id < ROUTER_NO) { + if (semaphore_owners[semaphore_id] == router_id) { + log_info("Router " + std::to_string(router_id) + " released token for destination router " + std::to_string(semaphore_id)); + semaphore_status[semaphore_id] = false; // Mark semaphore as free + + //wait(0, SC_NS); + + if (!request_queues[semaphore_id].empty()) { + int next_router = request_queues[semaphore_id].front(); + request_queues[semaphore_id].pop(); + queue_entries[semaphore_id].erase(next_router); // Remove from set when dequeued + semaphore_owners[semaphore_id] = next_router; + //semaphore_status[semaphore_id] = true; // Mark semaphore as in use + log_info("Token for destination router " + std::to_string(semaphore_id) + " passed to Router " + std::to_string(next_router)); + request_token(next_router, semaphore_id); + + } else { + semaphore_owners[semaphore_id] = -1; + // Assign to next router in round-robin if idle + // semaphore_owners[semaphore_id] = (semaphore_owners[semaphore_id] + 1) % ROUTER_NO; + // log_info("Token for destination router " + std::to_string(semaphore_id) + " passed to Router " + std::to_string(semaphore_owners[semaphore_id])); + } + return true; + } + } + return false; + } + + // Periodic update function to rotate token ownership in round-robin if tokens are idle + void update_semaphores() { + while (true) { + wait(20, SC_NS); + for (int i = 0; i < ROUTER_NO; ++i) { + std::lock_guard lock(mutex); // Ensure atomic update + if (semaphore_owners[i] == -1 && request_queues[i].empty()) { + semaphore_owners[i] = (last_router_owner[i] + 1) % ROUTER_NO; + log_info("Updated owner of semaphore " + std::to_string(i) + " to Router " + std::to_string(semaphore_owners[i])); + + } + } + } + } + + +private: + std::vector semaphore_owners; // Tracks router ownership (-1 means no owner) + std::vector> request_queues; // Queue of pending requests per semaphore + std::vector semaphore_status; // Semaphore availability + sc_mutex mutex; // Mutex to ensure atomic operations + std::vector> queue_entries; // Track entries in each queue to prevent duplicates + int last_router_owner[ROUTER_NO]; // Array to track last owner for round-robin assignment + + //print log messages + void log_info(std::string msg){ + SC_REPORT_INFO(LOG_NAME, msg.c_str()); + } + + void log_error(std::string msg){ + SC_REPORT_ERROR(LOG_NAME, msg.c_str()); + } + +}; + +#endif // SEMAPHORE_MANAGER_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..4041bbf --- /dev/null +++ b/main.cpp @@ -0,0 +1,82 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // For rand() +#include // For time() + +#include "configuration.h" +#include "router.h" +#include "core.h" +#include "semaphore_manager.h" + +int sc_main(int argc, char* argv[]) { + + // Create a semaphore manager instance + semaphore_manager sem_mgr("SemaphoreManager"); + // Instantiate ROUTER_NO routers + router* routers[ROUTER_NO]; + std::vector router_sems; + std::vector*> router_out_fifos; + for (int i = 0; i < ROUTER_NO; ++i) { + std::string router_name = "router" + std::to_string(i); + routers[i] = new router(router_name.c_str()); + + // Assign the router ID + routers[i]-> router_id = i; + + // Store semaphores and out_fifos in vectors + router_sems.push_back(&routers[i]->sem); + router_out_fifos.push_back(&routers[i]->out_fifo); + + routers[i]->set_semaphore_manager(&sem_mgr); // Pass semaphore manager to each router + } + + // Set up pointers to other routers' semaphores and out_fifos for each router + for (int i = 0; i < ROUTER_NO; i++) { + routers[i]->other_sems = router_sems; + routers[i]->other_out_fifos = router_out_fifos; + } + + // Instantiate ROUTER_NO*CORE_NO cores (CORE_NO per router) + core* cores[ROUTER_NO][CORE_NO]; // ROUTER_NO routers, each with CORE_NO cores + for (int i = 0; i < ROUTER_NO; ++i) { // Router index + for (int j = 0; j < CORE_NO; ++j) { // Core index within each router + std::string core_name = "core" + std::to_string(i) + "_" + std::to_string(j); + cores[i][j] = new core(core_name.c_str()); + cores[i][j]->source_router_id = i; // Set source router ID + cores[i][j]->source_core_id = j; // Set source router ID + } + } + + // Bind cores to their respective routers + for (int i = 0; i < ROUTER_NO; ++i) { // Router index + for (int j = 0; j < CORE_NO; ++j) { // Core index within each router + cores[i][j]->socket.bind(routers[i]->sockets[j]); // Core's socket to router's target socket + routers[i]->core_sockets[j].bind(cores[i][j]->target_socket); // Router's initiator socket to core's target socket + routers[i]->current_router_id= i; + } + } + + // Start the simulation + sc_core::sc_start(400, SC_NS); + //sc_start(); + + // 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 + } + + delete routers[i]; // Delete each router + + } + + return 0; +} + diff --git a/obj/core.o b/obj/core.o new file mode 100644 index 0000000..fbff322 Binary files /dev/null and b/obj/core.o differ diff --git a/obj/router.o b/obj/router.o new file mode 100644 index 0000000..285edee Binary files /dev/null and b/obj/router.o differ diff --git a/out/noc_simulation b/out/noc_simulation new file mode 100644 index 0000000..36396d2 Binary files /dev/null and b/out/noc_simulation differ diff --git a/out/report.log b/out/report.log new file mode 100644 index 0000000..7c15d31 --- /dev/null +++ b/out/report.log @@ -0,0 +1,745 @@ +0 s: Info: MY_LOG: Core 0 of Source Router: 0: Processing data 2 for router 1 and core 3 at time: 0 s +0 s: Info: MY_LOG: Router router0: Received transaction with data: 2 at time: 0 s +0 s: Info: MY_LOG: Core core0_0: Transaction successful, data sent: 2 at time: 0 s +0 s: Info: MY_LOG: Core 1 of Source Router: 0: Processing data 20 for router 2 and core 3 at time: 0 s +0 s: Info: MY_LOG: Router router0: Received transaction with data: 20 at time: 0 s +0 s: Info: MY_LOG: Core core0_1: Transaction successful, data sent: 20 at time: 0 s +0 s: Info: MY_LOG: Core 2 of Source Router: 0: Processing data 31 for router 1 and core 3 at time: 0 s +0 s: Info: MY_LOG: Router router0: Received transaction with data: 31 at time: 0 s +0 s: Info: MY_LOG: Core core0_2: Transaction successful, data sent: 31 at time: 0 s +0 s: Info: MY_LOG: Core 3 of Source Router: 0: Processing data 84 for router 3 and core 0 at time: 0 s +0 s: Info: MY_LOG: Router router0: Received transaction with data: 84 at time: 0 s +0 s: Info: MY_LOG: Core core0_3: Transaction successful, data sent: 84 at time: 0 s +0 s: Info: MY_LOG: Core 0 of Source Router: 1: Processing data 13 for router 0 and core 3 at time: 0 s +0 s: Info: MY_LOG: Router router1: Received transaction with data: 13 at time: 0 s +0 s: Info: MY_LOG: Core core1_0: Transaction successful, data sent: 13 at time: 0 s +0 s: Info: MY_LOG: Core 1 of Source Router: 1: Processing data 48 for router 0 and core 1 at time: 0 s +0 s: Info: MY_LOG: Router router1: Received transaction with data: 48 at time: 0 s +0 s: Info: MY_LOG: Core core1_1: Transaction successful, data sent: 48 at time: 0 s +0 s: Info: MY_LOG: Core 2 of Source Router: 1: Processing data 65 for router 3 and core 1 at time: 0 s +0 s: Info: MY_LOG: Router router1: Received transaction with data: 65 at time: 0 s +0 s: Info: MY_LOG: Core core1_2: Transaction successful, data sent: 65 at time: 0 s +0 s: Info: MY_LOG: Core 3 of Source Router: 1: Processing data 18 for router 2 and core 0 at time: 0 s +0 s: Info: MY_LOG: Router router1: Received transaction with data: 18 at time: 0 s +0 s: Info: MY_LOG: Core core1_3: Transaction successful, data sent: 18 at time: 0 s +0 s: Info: MY_LOG: Core 0 of Source Router: 2: Processing data 89 for router 0 and core 1 at time: 0 s +0 s: Info: MY_LOG: Router router2: Received transaction with data: 89 at time: 0 s +0 s: Info: MY_LOG: Core core2_0: Transaction successful, data sent: 89 at time: 0 s +0 s: Info: MY_LOG: Core 1 of Source Router: 2: Processing data 50 for router 1 and core 0 at time: 0 s +0 s: Info: MY_LOG: Router router2: Received transaction with data: 50 at time: 0 s +0 s: Info: MY_LOG: Core core2_1: Transaction successful, data sent: 50 at time: 0 s +0 s: Info: MY_LOG: Core 2 of Source Router: 2: Processing data 71 for router 0 and core 3 at time: 0 s +0 s: Info: MY_LOG: Router router2: Received transaction with data: 71 at time: 0 s +0 s: Info: MY_LOG: Core core2_2: Transaction successful, data sent: 71 at time: 0 s +0 s: Info: MY_LOG: Core 3 of Source Router: 2: Processing data 1 for router 0 and core 3 at time: 0 s +0 s: Info: MY_LOG: Router router2: Received transaction with data: 1 at time: 0 s +0 s: Info: MY_LOG: Core core2_3: Transaction successful, data sent: 1 at time: 0 s +0 s: Info: MY_LOG: Core 0 of Source Router: 3: Processing data 2 for router 0 and core 1 at time: 0 s +0 s: Info: MY_LOG: Router router3: Received transaction with data: 2 at time: 0 s +0 s: Info: MY_LOG: Core core3_0: Transaction successful, data sent: 2 at time: 0 s +0 s: Info: MY_LOG: Core 1 of Source Router: 3: Processing data 3 for router 0 and core 1 at time: 0 s +0 s: Info: MY_LOG: Router router3: Received transaction with data: 3 at time: 0 s +0 s: Info: MY_LOG: Core core3_1: Transaction successful, data sent: 3 at time: 0 s +0 s: Info: MY_LOG: Core 2 of Source Router: 3: Processing data 46 for router 1 and core 0 at time: 0 s +0 s: Info: MY_LOG: Router router3: Received transaction with data: 46 at time: 0 s +0 s: Info: MY_LOG: Core core3_2: Transaction successful, data sent: 46 at time: 0 s +0 s: Info: MY_LOG: Core 3 of Source Router: 3: Processing data 71 for router 0 and core 1 at time: 0 s +0 s: Info: MY_LOG: Router router3: Received transaction with data: 71 at time: 0 s +0 s: Info: MY_LOG: Core core3_3: Transaction successful, data sent: 71 at time: 0 s +0 s: Info: MY_LOG: Token for destination router 1 granted to Router 0 +0 s: Info: MY_LOG: router0 forwarded data: 2 to Router_1 +0 s: Info: MY_LOG: Token for destination router 0 granted to Router 1 +0 s: Info: MY_LOG: router1 forwarded data: 13 to Router_0 +0 s: Info: MY_LOG: Router 3 added to queue for semaphore 0 +0 s: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:2 +0 s: Info: MY_LOG: Router 2 added to queue for semaphore 0 +0 s: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +5 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:2 +5 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +10 ns: Info: MY_LOG: Router 0 released token for destination router 1 +10 ns: Info: MY_LOG: Router 1: Received transaction with data: 2 from Router 0 after a delay of:10 ns +10 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 2 to core 3 +10 ns: Info: MY_LOG: Core 3 of parent Router: 1: Processing transaction and received data: 2 +10 ns: Info: MY_LOG: Router router1: Core 3 completed transaction, data: 2 +10 ns: Info: MY_LOG: Token for destination router 2 granted to Router 0 +10 ns: Info: MY_LOG: router0 forwarded data: 20 to Router_2 +10 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:2 +10 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +15 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:2 +15 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +20 ns: Info: MY_LOG: Updated owner of semaphore 1 to Router 1 +20 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:2 +20 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +25 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:2 +25 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +30 ns: Info: MY_LOG: Router 1 released token for destination router 0 +30 ns: Info: MY_LOG: Token for destination router 0 passed to Router 3 +30 ns: Info: MY_LOG: Router 0: Received transaction with data: 13 from Router 1 after a delay of:30 ns +30 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 13 to core 3 +30 ns: Info: MY_LOG: Core 3 of parent Router: 0: Processing transaction and received data: 13 +30 ns: Info: MY_LOG: Router router0: Core 3 completed transaction, data: 13 +30 ns: Info: MY_LOG: Router 2: Received transaction with data: 20 from Router 0 after a delay of:20 ns +30 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 20 to core 3 +30 ns: Info: MY_LOG: Core 3 of parent Router: 2: Processing transaction and received data: 20 +30 ns: Info: MY_LOG: Router router2: Core 3 completed transaction, data: 20 +30 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +30 ns: Info: MY_LOG: Router 1 added to queue for semaphore 0 +30 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +30 ns: Info: MY_LOG: Router 0 released token for destination router 2 +30 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +30 ns: Info: MY_LOG: router0 forwarded data: 31 to Router_1 +30 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +30 ns: Info: MY_LOG: router3 forwarded data: 2 to Router_0 +30 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +35 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +35 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +40 ns: Info: MY_LOG: Router 0 released token for destination router 1 +40 ns: Info: MY_LOG: Router 1: Received transaction with data: 31 from Router 0 after a delay of:10 ns +40 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 31 to core 3 +40 ns: Info: MY_LOG: Core 3 of parent Router: 1: Processing transaction and received data: 31 +40 ns: Info: MY_LOG: Router router1: Core 3 completed transaction, data: 31 +40 ns: Info: MY_LOG: Router 0: Received transaction with data: 2 from Router 3 after a delay of:10 ns +40 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 2 to core 1 +40 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 2 +40 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 2 +40 ns: Info: MY_LOG: Token for destination router 3 granted to Router 0 +40 ns: Info: MY_LOG: router0 forwarded data: 84 to Router_3 +40 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:89 +40 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +40 ns: Info: MY_LOG: Updated owner of semaphore 1 to Router 1 +40 ns: Info: MY_LOG: Updated owner of semaphore 2 to Router 1 +40 ns: Info: MY_LOG: Router 3 released token for destination router 0 +40 ns: Info: MY_LOG: Token for destination router 0 passed to Router 2 +40 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +40 ns: Info: MY_LOG: Router 3 added to queue for semaphore 0 +40 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +45 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +45 ns: Info: MY_LOG: router2 forwarded data: 89 to Router_0 +45 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +45 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +50 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +50 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +55 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +55 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +60 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:48 +60 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +65 ns: Info: MY_LOG: Router 2 released token for destination router 0 +65 ns: Info: MY_LOG: Token for destination router 0 passed to Router 1 +65 ns: Info: MY_LOG: Router 0: Received transaction with data: 89 from Router 2 after a delay of:20 ns +65 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 89 to core 1 +65 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 89 +65 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 89 +65 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +65 ns: Info: MY_LOG: Token for destination router 1 granted to Router 2 +65 ns: Info: MY_LOG: router2 forwarded data: 50 to Router_1 +65 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +65 ns: Info: MY_LOG: router1 forwarded data: 48 to Router_0 +65 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +70 ns: Info: MY_LOG: Router 0 released token for destination router 3 +70 ns: Info: MY_LOG: Router 3: Received transaction with data: 84 from Router 0 after a delay of:30 ns +70 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 84 to core 0 +70 ns: Info: MY_LOG: Core 0 of parent Router: 3: Processing transaction and received data: 84 +70 ns: Info: MY_LOG: Router router3: Core 0 completed transaction, data: 84 +70 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +75 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +80 ns: Info: MY_LOG: Updated owner of semaphore 3 to Router 1 +80 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +85 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +90 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:3 +95 ns: Info: MY_LOG: Router 1 released token for destination router 0 +95 ns: Info: MY_LOG: Token for destination router 0 passed to Router 3 +95 ns: Info: MY_LOG: Router 0: Received transaction with data: 48 from Router 1 after a delay of:30 ns +95 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 48 to core 1 +95 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 48 +95 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 48 +95 ns: Info: MY_LOG: Router 1: Received transaction with data: 50 from Router 2 after a delay of:30 ns +95 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 50 to core 0 +95 ns: Info: MY_LOG: Core 0 of parent Router: 1: Processing transaction and received data: 50 +95 ns: Info: MY_LOG: Router router1: Core 0 completed transaction, data: 50 +95 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +95 ns: Info: MY_LOG: Token for destination router 3 granted to Router 1 +95 ns: Info: MY_LOG: router1 forwarded data: 65 to Router_3 +95 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +95 ns: Info: MY_LOG: router3 forwarded data: 3 to Router_0 +95 ns: Info: MY_LOG: Router 2 released token for destination router 1 +95 ns: Info: MY_LOG: Router 2 added to queue for semaphore 0 +95 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:71 +100 ns: Info: MY_LOG: Core 0 of Source Router: 1: Processing data 97 for router 2 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router1: Received transaction with data: 97 at time: 100 ns +100 ns: Info: MY_LOG: Core core1_0: Transaction successful, data sent: 97 at time: 100 ns +100 ns: Info: MY_LOG: Core 0 of Source Router: 3: Processing data 52 for router 2 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router3: Received transaction with data: 52 at time: 100 ns +100 ns: Info: MY_LOG: Core core3_0: Transaction successful, data sent: 52 at time: 100 ns +100 ns: Info: MY_LOG: Core 0 of Source Router: 2: Processing data 0 for router 0 and core 1 at time: 100 ns +100 ns: Info: MY_LOG: Router router2: Received transaction with data: 0 at time: 100 ns +100 ns: Info: MY_LOG: Core core2_0: Transaction successful, data sent: 0 at time: 100 ns +100 ns: Info: MY_LOG: Core 2 of Source Router: 1: Processing data 94 for router 0 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router1: Received transaction with data: 94 at time: 100 ns +100 ns: Info: MY_LOG: Core core1_2: Transaction successful, data sent: 94 at time: 100 ns +100 ns: Info: MY_LOG: Core 0 of Source Router: 0: Processing data 71 for router 1 and core 0 at time: 100 ns +100 ns: Info: MY_LOG: Router router0: Received transaction with data: 71 at time: 100 ns +100 ns: Info: MY_LOG: Core core0_0: Transaction successful, data sent: 71 at time: 100 ns +100 ns: Info: MY_LOG: Core 3 of Source Router: 3: Processing data 56 for router 1 and core 0 at time: 100 ns +100 ns: Info: MY_LOG: Router router3: Received transaction with data: 56 at time: 100 ns +100 ns: Info: MY_LOG: Core core3_3: Transaction successful, data sent: 56 at time: 100 ns +100 ns: Info: MY_LOG: Core 3 of Source Router: 0: Processing data 33 for router 1 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router0: Received transaction with data: 33 at time: 100 ns +100 ns: Info: MY_LOG: Core core0_3: Transaction successful, data sent: 33 at time: 100 ns +100 ns: Info: MY_LOG: Core 1 of Source Router: 2: Processing data 72 for router 0 and core 3 at time: 100 ns +100 ns: Info: MY_LOG: Router router2: Received transaction with data: 72 at time: 100 ns +100 ns: Info: MY_LOG: Core core2_1: Transaction successful, data sent: 72 at time: 100 ns +100 ns: Info: MY_LOG: Core 2 of Source Router: 2: Processing data 67 for router 1 and core 3 at time: 100 ns +100 ns: Info: MY_LOG: Router router2: Received transaction with data: 67 at time: 100 ns +100 ns: Info: MY_LOG: Core core2_2: Transaction successful, data sent: 67 at time: 100 ns +100 ns: Info: MY_LOG: Core 3 of Source Router: 2: Processing data 71 for router 0 and core 1 at time: 100 ns +100 ns: Info: MY_LOG: Router router2: Received transaction with data: 71 at time: 100 ns +100 ns: Info: MY_LOG: Core core2_3: Transaction successful, data sent: 71 at time: 100 ns +100 ns: Info: MY_LOG: Core 2 of Source Router: 0: Processing data 59 for router 2 and core 0 at time: 100 ns +100 ns: Info: MY_LOG: Router router0: Received transaction with data: 59 at time: 100 ns +100 ns: Info: MY_LOG: Core core0_2: Transaction successful, data sent: 59 at time: 100 ns +100 ns: Info: MY_LOG: Core 1 of Source Router: 1: Processing data 36 for router 2 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router1: Received transaction with data: 36 at time: 100 ns +100 ns: Info: MY_LOG: Core core1_1: Transaction successful, data sent: 36 at time: 100 ns +100 ns: Info: MY_LOG: Core 1 of Source Router: 3: Processing data 22 for router 2 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router3: Received transaction with data: 22 at time: 100 ns +100 ns: Info: MY_LOG: Core core3_1: Transaction successful, data sent: 22 at time: 100 ns +100 ns: Info: MY_LOG: Core 2 of Source Router: 3: Processing data 87 for router 2 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router3: Received transaction with data: 87 at time: 100 ns +100 ns: Info: MY_LOG: Core core3_2: Transaction successful, data sent: 87 at time: 100 ns +100 ns: Info: MY_LOG: Core 3 of Source Router: 1: Processing data 41 for router 3 and core 2 at time: 100 ns +100 ns: Info: MY_LOG: Router router1: Received transaction with data: 41 at time: 100 ns +100 ns: Info: MY_LOG: Core core1_3: Transaction successful, data sent: 41 at time: 100 ns +100 ns: Info: MY_LOG: Core 1 of Source Router: 0: Processing data 64 for router 3 and core 3 at time: 100 ns +100 ns: Info: MY_LOG: Router router0: Received transaction with data: 64 at time: 100 ns +100 ns: Info: MY_LOG: Core core0_1: Transaction successful, data sent: 64 at time: 100 ns +100 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:71 +100 ns: Info: MY_LOG: Updated owner of semaphore 1 to Router 3 +100 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +100 ns: Info: MY_LOG: router0 forwarded data: 71 to Router_1 +105 ns: Info: MY_LOG: Router 3 released token for destination router 0 +105 ns: Info: MY_LOG: Token for destination router 0 passed to Router 2 +105 ns: Info: MY_LOG: Router 0: Received transaction with data: 3 from Router 3 after a delay of:10 ns +105 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 3 to core 1 +105 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 3 +105 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 3 +105 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +105 ns: Info: MY_LOG: Router 3 added to queue for semaphore 1 +105 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:46 +105 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +105 ns: Info: MY_LOG: router2 forwarded data: 71 to Router_0 +110 ns: Info: MY_LOG: Router 0 released token for destination router 1 +110 ns: Info: MY_LOG: Token for destination router 1 passed to Router 3 +110 ns: Info: MY_LOG: Router 1: Received transaction with data: 71 from Router 0 after a delay of:10 ns +110 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 71 to core 0 +110 ns: Info: MY_LOG: Core 0 of parent Router: 1: Processing transaction and received data: 71 +110 ns: Info: MY_LOG: Router router1: Core 0 completed transaction, data: 71 +110 ns: Info: MY_LOG: Token for destination router 1 granted to Router 3 +110 ns: Info: MY_LOG: Router 0 added to queue for semaphore 1 +110 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:33 +110 ns: Info: MY_LOG: Token for destination router 1 granted to Router 3 +110 ns: Info: MY_LOG: router3 forwarded data: 46 to Router_1 +115 ns: Info: MY_LOG: Router 1 released token for destination router 3 +115 ns: Info: MY_LOG: Router 3: Received transaction with data: 65 from Router 1 after a delay of:20 ns +115 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 65 to core 1 +115 ns: Info: MY_LOG: Core 1 of parent Router: 3: Processing transaction and received data: 65 +115 ns: Info: MY_LOG: Router router3: Core 1 completed transaction, data: 65 +115 ns: Info: MY_LOG: Token for destination router 2 granted to Router 1 +115 ns: Info: MY_LOG: router1 forwarded data: 18 to Router_2 +115 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:33 +120 ns: Info: MY_LOG: Updated owner of semaphore 3 to Router 2 +120 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:33 +125 ns: Info: MY_LOG: Router 2 released token for destination router 0 +125 ns: Info: MY_LOG: Router 0: Received transaction with data: 71 from Router 2 after a delay of:20 ns +125 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 71 to core 3 +125 ns: Info: MY_LOG: Core 3 of parent Router: 0: Processing transaction and received data: 71 +125 ns: Info: MY_LOG: Router router0: Core 3 completed transaction, data: 71 +125 ns: Info: MY_LOG: Router 2: Received transaction with data: 18 from Router 1 after a delay of:10 ns +125 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 18 to core 0 +125 ns: Info: MY_LOG: Core 0 of parent Router: 2: Processing transaction and received data: 18 +125 ns: Info: MY_LOG: Router router2: Core 0 completed transaction, data: 18 +125 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +125 ns: Info: MY_LOG: router2 forwarded data: 1 to Router_0 +125 ns: Info: MY_LOG: Router 1 released token for destination router 2 +125 ns: Info: MY_LOG: Token for destination router 2 granted to Router 1 +125 ns: Info: MY_LOG: router1 forwarded data: 97 to Router_2 +125 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:33 +130 ns: Info: MY_LOG: Router 3 released token for destination router 1 +130 ns: Info: MY_LOG: Token for destination router 1 passed to Router 0 +130 ns: Info: MY_LOG: Router 1: Received transaction with data: 46 from Router 3 after a delay of:20 ns +130 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 46 to core 0 +130 ns: Info: MY_LOG: Core 0 of parent Router: 1: Processing transaction and received data: 46 +130 ns: Info: MY_LOG: Router router1: Core 0 completed transaction, data: 46 +130 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +130 ns: Info: MY_LOG: Router 3 added to queue for semaphore 0 +130 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:71 +130 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +130 ns: Info: MY_LOG: router0 forwarded data: 33 to Router_1 +135 ns: Info: MY_LOG: Router 1 released token for destination router 2 +135 ns: Info: MY_LOG: Router 2: Received transaction with data: 97 from Router 1 after a delay of:10 ns +135 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 97 to core 2 +135 ns: Info: MY_LOG: Core 2 of parent Router: 2: Processing transaction and received data: 97 +135 ns: Info: MY_LOG: Router router2: Core 2 completed transaction, data: 97 +135 ns: Info: MY_LOG: Router 1 added to queue for semaphore 0 +135 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:94 +135 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:71 +140 ns: Info: MY_LOG: Updated owner of semaphore 2 to Router 2 +140 ns: Info: MY_LOG: Router 0 released token for destination router 1 +140 ns: Info: MY_LOG: Router 1: Received transaction with data: 33 from Router 0 after a delay of:10 ns +140 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 33 to core 2 +140 ns: Info: MY_LOG: Core 2 of parent Router: 1: Processing transaction and received data: 33 +140 ns: Info: MY_LOG: Router router1: Core 2 completed transaction, data: 33 +140 ns: Info: MY_LOG: Token for destination router 2 granted to Router 0 +140 ns: Info: MY_LOG: router0 forwarded data: 59 to Router_2 +140 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:94 +140 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:71 +145 ns: Info: MY_LOG: Router 2 released token for destination router 0 +145 ns: Info: MY_LOG: Token for destination router 0 passed to Router 3 +145 ns: Info: MY_LOG: Router 0: Received transaction with data: 1 from Router 2 after a delay of:20 ns +145 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 1 to core 3 +145 ns: Info: MY_LOG: Core 3 of parent Router: 0: Processing transaction and received data: 1 +145 ns: Info: MY_LOG: Router router0: Core 3 completed transaction, data: 1 +145 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +145 ns: Info: MY_LOG: Router 2 added to queue for semaphore 0 +145 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +145 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:94 +145 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +145 ns: Info: MY_LOG: router3 forwarded data: 71 to Router_0 +150 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +150 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:94 +155 ns: Info: MY_LOG: Router 3 released token for destination router 0 +155 ns: Info: MY_LOG: Token for destination router 0 passed to Router 1 +155 ns: Info: MY_LOG: Router 0: Received transaction with data: 71 from Router 3 after a delay of:10 ns +155 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 71 to core 1 +155 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 71 +155 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 71 +155 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +155 ns: Info: MY_LOG: Router 3 added to queue for semaphore 2 +155 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:52 +155 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +155 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +155 ns: Info: MY_LOG: router1 forwarded data: 94 to Router_0 +160 ns: Info: MY_LOG: Router 0 released token for destination router 2 +160 ns: Info: MY_LOG: Token for destination router 2 passed to Router 3 +160 ns: Info: MY_LOG: Router 2: Received transaction with data: 59 from Router 0 after a delay of:20 ns +160 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 59 to core 0 +160 ns: Info: MY_LOG: Core 0 of parent Router: 2: Processing transaction and received data: 59 +160 ns: Info: MY_LOG: Router router2: Core 0 completed transaction, data: 59 +160 ns: Info: MY_LOG: Token for destination router 2 granted to Router 3 +160 ns: Info: MY_LOG: Token for destination router 3 granted to Router 0 +160 ns: Info: MY_LOG: router0 forwarded data: 64 to Router_3 +160 ns: Info: MY_LOG: Updated owner of semaphore 1 to Router 1 +160 ns: Info: MY_LOG: Token for destination router 2 granted to Router 3 +160 ns: Info: MY_LOG: router3 forwarded data: 52 to Router_2 +160 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +165 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +170 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +175 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +180 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:0 +185 ns: Info: MY_LOG: Router 1 released token for destination router 0 +185 ns: Info: MY_LOG: Token for destination router 0 passed to Router 2 +185 ns: Info: MY_LOG: Router 0: Received transaction with data: 94 from Router 1 after a delay of:30 ns +185 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 94 to core 2 +185 ns: Info: MY_LOG: Core 2 of parent Router: 0: Processing transaction and received data: 94 +185 ns: Info: MY_LOG: Router router0: Core 2 completed transaction, data: 94 +185 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +185 ns: Info: MY_LOG: Router 1 added to queue for semaphore 2 +185 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:36 +185 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +185 ns: Info: MY_LOG: router2 forwarded data: 0 to Router_0 +190 ns: Info: MY_LOG: Router 3: Received transaction with data: 64 from Router 0 after a delay of:30 ns +190 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 64 to core 3 +190 ns: Info: MY_LOG: Core 3 of parent Router: 3: Processing transaction and received data: 64 +190 ns: Info: MY_LOG: Router router3: Core 3 completed transaction, data: 64 +190 ns: Info: MY_LOG: Router 2: Received transaction with data: 52 from Router 3 after a delay of:30 ns +190 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 52 to core 2 +190 ns: Info: MY_LOG: Core 2 of parent Router: 2: Processing transaction and received data: 52 +190 ns: Info: MY_LOG: Router router2: Core 2 completed transaction, data: 52 +190 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:36 +190 ns: Info: MY_LOG: Router 0 released token for destination router 3 +190 ns: Info: MY_LOG: Router 3 released token for destination router 2 +190 ns: Info: MY_LOG: Token for destination router 2 passed to Router 1 +190 ns: Info: MY_LOG: Token for destination router 2 granted to Router 1 +190 ns: Info: MY_LOG: Token for destination router 1 granted to Router 3 +190 ns: Info: MY_LOG: router3 forwarded data: 56 to Router_1 +195 ns: Info: MY_LOG: Token for destination router 2 granted to Router 1 +195 ns: Info: MY_LOG: router1 forwarded data: 36 to Router_2 +200 ns: Info: MY_LOG: Updated owner of semaphore 3 to Router 1 +200 ns: Info: MY_LOG: Core 1 of Source Router: 2: Processing data 90 for router 0 and core 1 at time: 200 ns +200 ns: Info: MY_LOG: Router router2: Received transaction with data: 90 at time: 200 ns +200 ns: Info: MY_LOG: Core core2_1: Transaction successful, data sent: 90 at time: 200 ns +200 ns: Info: MY_LOG: Core 1 of Source Router: 1: Processing data 62 for router 0 and core 1 at time: 200 ns +200 ns: Info: MY_LOG: Router router1: Received transaction with data: 62 at time: 200 ns +200 ns: Info: MY_LOG: Core core1_1: Transaction successful, data sent: 62 at time: 200 ns +200 ns: Info: MY_LOG: Core 0 of Source Router: 1: Processing data 35 for router 3 and core 3 at time: 200 ns +200 ns: Info: MY_LOG: Router router1: Received transaction with data: 35 at time: 200 ns +200 ns: Info: MY_LOG: Core core1_0: Transaction successful, data sent: 35 at time: 200 ns +200 ns: Info: MY_LOG: Core 0 of Source Router: 0: Processing data 33 for router 1 and core 2 at time: 200 ns +200 ns: Info: MY_LOG: Router router0: Received transaction with data: 33 at time: 200 ns +200 ns: Info: MY_LOG: Core core0_0: Transaction successful, data sent: 33 at time: 200 ns +200 ns: Info: MY_LOG: Core 2 of Source Router: 1: Processing data 84 for router 0 and core 2 at time: 200 ns +200 ns: Info: MY_LOG: Router router1: Received transaction with data: 84 at time: 200 ns +200 ns: Info: MY_LOG: Core core1_2: Transaction successful, data sent: 84 at time: 200 ns +200 ns: Info: MY_LOG: Core 1 of Source Router: 0: Processing data 42 for router 2 and core 2 at time: 200 ns +200 ns: Info: MY_LOG: Router router0: Received transaction with data: 42 at time: 200 ns +200 ns: Info: MY_LOG: Core core0_1: Transaction successful, data sent: 42 at time: 200 ns +200 ns: Info: MY_LOG: Core 3 of Source Router: 1: Processing data 35 for router 0 and core 0 at time: 200 ns +200 ns: Info: MY_LOG: Router router1: Received transaction with data: 35 at time: 200 ns +200 ns: Info: MY_LOG: Core core1_3: Transaction successful, data sent: 35 at time: 200 ns +200 ns: Info: MY_LOG: Core 3 of Source Router: 0: Processing data 64 for router 3 and core 3 at time: 200 ns +200 ns: Info: MY_LOG: Router router0: Received transaction with data: 64 at time: 200 ns +200 ns: Info: MY_LOG: Core core0_3: Transaction successful, data sent: 64 at time: 200 ns +200 ns: Info: MY_LOG: Core 2 of Source Router: 2: Processing data 42 for router 3 and core 3 at time: 200 ns +200 ns: Info: MY_LOG: Router router2: Received transaction with data: 42 at time: 200 ns +200 ns: Info: MY_LOG: Core core2_2: Transaction successful, data sent: 42 at time: 200 ns +200 ns: Info: MY_LOG: Core 3 of Source Router: 2: Processing data 53 for router 3 and core 3 at time: 200 ns +200 ns: Info: MY_LOG: Router router2: Received transaction with data: 53 at time: 200 ns +200 ns: Info: MY_LOG: Core core2_3: Transaction successful, data sent: 53 at time: 200 ns +200 ns: Info: MY_LOG: Core 2 of Source Router: 0: Processing data 53 for router 1 and core 2 at time: 200 ns +200 ns: Info: MY_LOG: Router router0: Received transaction with data: 53 at time: 200 ns +200 ns: Info: MY_LOG: Core core0_2: Transaction successful, data sent: 53 at time: 200 ns +200 ns: Info: MY_LOG: Core 1 of Source Router: 3: Processing data 64 for router 1 and core 1 at time: 200 ns +200 ns: Info: MY_LOG: Router router3: Received transaction with data: 64 at time: 200 ns +200 ns: Info: MY_LOG: Core core3_1: Transaction successful, data sent: 64 at time: 200 ns +200 ns: Info: MY_LOG: Core 0 of Source Router: 2: Processing data 98 for router 3 and core 1 at time: 200 ns +200 ns: Info: MY_LOG: Router router2: Received transaction with data: 98 at time: 200 ns +200 ns: Info: MY_LOG: Core core2_0: Transaction successful, data sent: 98 at time: 200 ns +200 ns: Info: MY_LOG: Core 2 of Source Router: 3: Processing data 82 for router 0 and core 0 at time: 200 ns +200 ns: Info: MY_LOG: Router router3: Received transaction with data: 82 at time: 200 ns +200 ns: Info: MY_LOG: Core core3_2: Transaction successful, data sent: 82 at time: 200 ns +200 ns: Info: MY_LOG: Core 3 of Source Router: 3: Processing data 90 for router 2 and core 2 at time: 200 ns +200 ns: Info: MY_LOG: Router router3: Received transaction with data: 90 at time: 200 ns +200 ns: Info: MY_LOG: Core core3_3: Transaction successful, data sent: 90 at time: 200 ns +200 ns: Info: MY_LOG: Core 0 of Source Router: 3: Processing data 91 for router 2 and core 1 at time: 200 ns +200 ns: Info: MY_LOG: Router router3: Received transaction with data: 91 at time: 200 ns +200 ns: Info: MY_LOG: Core core3_0: Transaction successful, data sent: 91 at time: 200 ns +200 ns: Info: MY_LOG: Router 0 added to queue for semaphore 1 +200 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:33 +205 ns: Info: MY_LOG: Router 2 released token for destination router 0 +205 ns: Info: MY_LOG: Router 0: Received transaction with data: 0 from Router 2 after a delay of:20 ns +205 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 0 to core 1 +205 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 0 +205 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 0 +205 ns: Info: MY_LOG: Router 2: Received transaction with data: 36 from Router 1 after a delay of:10 ns +205 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 36 to core 2 +205 ns: Info: MY_LOG: Core 2 of parent Router: 2: Processing transaction and received data: 36 +205 ns: Info: MY_LOG: Router router2: Core 2 completed transaction, data: 36 +205 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +205 ns: Info: MY_LOG: router2 forwarded data: 72 to Router_0 +205 ns: Info: MY_LOG: Router 1 released token for destination router 2 +205 ns: Info: MY_LOG: Token for destination router 3 granted to Router 1 +205 ns: Info: MY_LOG: router1 forwarded data: 41 to Router_3 +205 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:33 +210 ns: Info: MY_LOG: Router 3 released token for destination router 1 +210 ns: Info: MY_LOG: Token for destination router 1 passed to Router 0 +210 ns: Info: MY_LOG: Router 1: Received transaction with data: 56 from Router 3 after a delay of:20 ns +210 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 56 to core 0 +210 ns: Info: MY_LOG: Core 0 of parent Router: 1: Processing transaction and received data: 56 +210 ns: Info: MY_LOG: Router router1: Core 0 completed transaction, data: 56 +210 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +210 ns: Info: MY_LOG: Token for destination router 2 granted to Router 3 +210 ns: Info: MY_LOG: router3 forwarded data: 22 to Router_2 +210 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +210 ns: Info: MY_LOG: router0 forwarded data: 33 to Router_1 +220 ns: Info: MY_LOG: Router 0 released token for destination router 1 +220 ns: Info: MY_LOG: Router 1: Received transaction with data: 33 from Router 0 after a delay of:10 ns +220 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 33 to core 2 +220 ns: Info: MY_LOG: Core 2 of parent Router: 1: Processing transaction and received data: 33 +220 ns: Info: MY_LOG: Router router1: Core 2 completed transaction, data: 33 +220 ns: Info: MY_LOG: Router 0 added to queue for semaphore 2 +220 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:42 +225 ns: Info: MY_LOG: Router 2 released token for destination router 0 +225 ns: Info: MY_LOG: Router 0: Received transaction with data: 72 from Router 2 after a delay of:20 ns +225 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 72 to core 3 +225 ns: Info: MY_LOG: Core 3 of parent Router: 0: Processing transaction and received data: 72 +225 ns: Info: MY_LOG: Router router0: Core 3 completed transaction, data: 72 +225 ns: Info: MY_LOG: Router 3: Received transaction with data: 41 from Router 1 after a delay of:20 ns +225 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 41 to core 2 +225 ns: Info: MY_LOG: Core 2 of parent Router: 3: Processing transaction and received data: 41 +225 ns: Info: MY_LOG: Router router3: Core 2 completed transaction, data: 41 +225 ns: Info: MY_LOG: Token for destination router 1 granted to Router 2 +225 ns: Info: MY_LOG: router2 forwarded data: 67 to Router_1 +225 ns: Info: MY_LOG: Router 1 released token for destination router 3 +225 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +225 ns: Info: MY_LOG: router1 forwarded data: 62 to Router_0 +225 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:42 +230 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:42 +235 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:42 +240 ns: Info: MY_LOG: Updated owner of semaphore 3 to Router 2 +240 ns: Info: MY_LOG: Router 3 released token for destination router 2 +240 ns: Info: MY_LOG: Token for destination router 2 passed to Router 0 +240 ns: Info: MY_LOG: Router 2: Received transaction with data: 22 from Router 3 after a delay of:30 ns +240 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 22 to core 2 +240 ns: Info: MY_LOG: Core 2 of parent Router: 2: Processing transaction and received data: 22 +240 ns: Info: MY_LOG: Router router2: Core 2 completed transaction, data: 22 +240 ns: Info: MY_LOG: Token for destination router 2 granted to Router 0 +240 ns: Info: MY_LOG: Router 3 added to queue for semaphore 2 +240 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:87 +240 ns: Info: MY_LOG: Token for destination router 2 granted to Router 0 +240 ns: Info: MY_LOG: router0 forwarded data: 42 to Router_2 +245 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:87 +250 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:87 +255 ns: Info: MY_LOG: Router 2 released token for destination router 1 +255 ns: Info: MY_LOG: Router 1: Received transaction with data: 67 from Router 2 after a delay of:30 ns +255 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 67 to core 3 +255 ns: Info: MY_LOG: Core 3 of parent Router: 1: Processing transaction and received data: 67 +255 ns: Info: MY_LOG: Router router1: Core 3 completed transaction, data: 67 +255 ns: Info: MY_LOG: Router 0: Received transaction with data: 62 from Router 1 after a delay of:30 ns +255 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 62 to core 1 +255 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 62 +255 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 62 +255 ns: Info: MY_LOG: Router 2 added to queue for semaphore 0 +255 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:71 +255 ns: Info: MY_LOG: Router 1 released token for destination router 0 +255 ns: Info: MY_LOG: Token for destination router 0 passed to Router 2 +255 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +255 ns: Info: MY_LOG: Token for destination router 3 granted to Router 1 +255 ns: Info: MY_LOG: router1 forwarded data: 35 to Router_3 +255 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:87 +260 ns: Info: MY_LOG: Updated owner of semaphore 1 to Router 3 +260 ns: Info: MY_LOG: Router 0 released token for destination router 2 +260 ns: Info: MY_LOG: Token for destination router 2 passed to Router 3 +260 ns: Info: MY_LOG: Router 2: Received transaction with data: 42 from Router 0 after a delay of:20 ns +260 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 42 to core 2 +260 ns: Info: MY_LOG: Core 2 of parent Router: 2: Processing transaction and received data: 42 +260 ns: Info: MY_LOG: Router router2: Core 2 completed transaction, data: 42 +260 ns: Info: MY_LOG: Token for destination router 2 granted to Router 3 +260 ns: Info: MY_LOG: Router 0 added to queue for semaphore 3 +260 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:64 +260 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +260 ns: Info: MY_LOG: router2 forwarded data: 71 to Router_0 +260 ns: Info: MY_LOG: Token for destination router 2 granted to Router 3 +260 ns: Info: MY_LOG: router3 forwarded data: 87 to Router_2 +265 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:64 +270 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:64 +275 ns: Info: MY_LOG: Router 1 released token for destination router 3 +275 ns: Info: MY_LOG: Token for destination router 3 passed to Router 0 +275 ns: Info: MY_LOG: Router 3: Received transaction with data: 35 from Router 1 after a delay of:20 ns +275 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 35 to core 3 +275 ns: Info: MY_LOG: Core 3 of parent Router: 3: Processing transaction and received data: 35 +275 ns: Info: MY_LOG: Router router3: Core 3 completed transaction, data: 35 +275 ns: Info: MY_LOG: Token for destination router 3 granted to Router 0 +275 ns: Info: MY_LOG: Router 1 added to queue for semaphore 0 +275 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:84 +275 ns: Info: MY_LOG: Token for destination router 3 granted to Router 0 +275 ns: Info: MY_LOG: router0 forwarded data: 64 to Router_3 +280 ns: Info: MY_LOG: Router 2 released token for destination router 0 +280 ns: Info: MY_LOG: Token for destination router 0 passed to Router 1 +280 ns: Info: MY_LOG: Router 0: Received transaction with data: 71 from Router 2 after a delay of:20 ns +280 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 71 to core 1 +280 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 71 +280 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 71 +280 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +280 ns: Info: MY_LOG: Router 2 added to queue for semaphore 0 +280 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:90 +280 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +280 ns: Info: MY_LOG: router1 forwarded data: 84 to Router_0 +285 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:90 +290 ns: Info: MY_LOG: Router 2: Received transaction with data: 87 from Router 3 after a delay of:30 ns +290 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 87 to core 2 +290 ns: Info: MY_LOG: Core 2 of parent Router: 2: Processing transaction and received data: 87 +290 ns: Info: MY_LOG: Router router2: Core 2 completed transaction, data: 87 +290 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:90 +290 ns: Info: MY_LOG: Router 3 released token for destination router 2 +290 ns: Info: MY_LOG: Token for destination router 1 granted to Router 3 +290 ns: Info: MY_LOG: router3 forwarded data: 64 to Router_1 +295 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:90 +300 ns: Info: MY_LOG: Updated owner of semaphore 2 to Router 0 +300 ns: Info: MY_LOG: Core 2 of Source Router: 0: Processing data 37 for router 1 and core 0 at time: 300 ns +300 ns: Info: MY_LOG: Router router0: Received transaction with data: 37 at time: 300 ns +300 ns: Info: MY_LOG: Core core0_2: Transaction successful, data sent: 37 at time: 300 ns +300 ns: Info: MY_LOG: Core 3 of Source Router: 3: Processing data 79 for router 0 and core 3 at time: 300 ns +300 ns: Info: MY_LOG: Router router3: Received transaction with data: 79 at time: 300 ns +300 ns: Info: MY_LOG: Core core3_3: Transaction successful, data sent: 79 at time: 300 ns +300 ns: Info: MY_LOG: Core 1 of Source Router: 1: Processing data 99 for router 3 and core 3 at time: 300 ns +300 ns: Info: MY_LOG: Router router1: Received transaction with data: 99 at time: 300 ns +300 ns: Info: MY_LOG: Core core1_1: Transaction successful, data sent: 99 at time: 300 ns +300 ns: Info: MY_LOG: Core 1 of Source Router: 3: Processing data 51 for router 0 and core 3 at time: 300 ns +300 ns: Info: MY_LOG: Router router3: Received transaction with data: 51 at time: 300 ns +300 ns: Info: MY_LOG: Core core3_1: Transaction successful, data sent: 51 at time: 300 ns +300 ns: Info: MY_LOG: Core 2 of Source Router: 3: Processing data 31 for router 2 and core 2 at time: 300 ns +300 ns: Info: MY_LOG: Router router3: Received transaction with data: 31 at time: 300 ns +300 ns: Info: MY_LOG: Core core3_2: Transaction successful, data sent: 31 at time: 300 ns +300 ns: Info: MY_LOG: Core 0 of Source Router: 3: Processing data 67 for router 2 and core 0 at time: 300 ns +300 ns: Info: MY_LOG: Router router3: Received transaction with data: 67 at time: 300 ns +300 ns: Info: MY_LOG: Core core3_0: Transaction successful, data sent: 67 at time: 300 ns +300 ns: Info: MY_LOG: Core 3 of Source Router: 1: Processing data 53 for router 2 and core 0 at time: 300 ns +300 ns: Info: MY_LOG: Router router1: Received transaction with data: 53 at time: 300 ns +300 ns: Info: MY_LOG: Core core1_3: Transaction successful, data sent: 53 at time: 300 ns +300 ns: Info: MY_LOG: Core 3 of Source Router: 0: Processing data 42 for router 1 and core 2 at time: 300 ns +300 ns: Info: MY_LOG: Router router0: Received transaction with data: 42 at time: 300 ns +300 ns: Info: MY_LOG: Core core0_3: Transaction successful, data sent: 42 at time: 300 ns +300 ns: Info: MY_LOG: Core 0 of Source Router: 1: Processing data 33 for router 0 and core 0 at time: 300 ns +300 ns: Info: MY_LOG: Router router1: Received transaction with data: 33 at time: 300 ns +300 ns: Info: MY_LOG: Core core1_0: Transaction successful, data sent: 33 at time: 300 ns +300 ns: Info: MY_LOG: Core 3 of Source Router: 2: Processing data 54 for router 3 and core 1 at time: 300 ns +300 ns: Info: MY_LOG: Router router2: Received transaction with data: 54 at time: 300 ns +300 ns: Info: MY_LOG: Core core2_3: Transaction successful, data sent: 54 at time: 300 ns +300 ns: Info: MY_LOG: Core 1 of Source Router: 0: Processing data 38 for router 1 and core 2 at time: 300 ns +300 ns: Info: MY_LOG: Router router0: Received transaction with data: 38 at time: 300 ns +300 ns: Info: MY_LOG: Core core0_1: Transaction successful, data sent: 38 at time: 300 ns +300 ns: Info: MY_LOG: Core 0 of Source Router: 2: Processing data 27 for router 1 and core 1 at time: 300 ns +300 ns: Info: MY_LOG: Router router2: Received transaction with data: 27 at time: 300 ns +300 ns: Info: MY_LOG: Core core2_0: Transaction successful, data sent: 27 at time: 300 ns +300 ns: Info: MY_LOG: Core 1 of Source Router: 2: Processing data 44 for router 1 and core 0 at time: 300 ns +300 ns: Info: MY_LOG: Router router2: Received transaction with data: 44 at time: 300 ns +300 ns: Info: MY_LOG: Core core2_1: Transaction successful, data sent: 44 at time: 300 ns +300 ns: Info: MY_LOG: Core 2 of Source Router: 1: Processing data 75 for router 3 and core 2 at time: 300 ns +300 ns: Info: MY_LOG: Router router1: Received transaction with data: 75 at time: 300 ns +300 ns: Info: MY_LOG: Core core1_2: Transaction successful, data sent: 75 at time: 300 ns +300 ns: Info: MY_LOG: Core 2 of Source Router: 2: Processing data 41 for router 1 and core 3 at time: 300 ns +300 ns: Info: MY_LOG: Router router2: Received transaction with data: 41 at time: 300 ns +300 ns: Info: MY_LOG: Core core2_2: Transaction successful, data sent: 41 at time: 300 ns +300 ns: Info: MY_LOG: Core 0 of Source Router: 0: Processing data 5 for router 2 and core 1 at time: 300 ns +300 ns: Info: MY_LOG: Router router0: Received transaction with data: 5 at time: 300 ns +300 ns: Info: MY_LOG: Core core0_0: Transaction successful, data sent: 5 at time: 300 ns +300 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:90 +305 ns: Info: MY_LOG: Router 0 released token for destination router 3 +305 ns: Info: MY_LOG: Router 3: Received transaction with data: 64 from Router 0 after a delay of:30 ns +305 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 64 to core 3 +305 ns: Info: MY_LOG: Core 3 of parent Router: 3: Processing transaction and received data: 64 +305 ns: Info: MY_LOG: Router router3: Core 3 completed transaction, data: 64 +305 ns: Info: MY_LOG: Router 0 added to queue for semaphore 1 +305 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:53 +305 ns: Info: MY_LOG: Router router2: Semaphore unavailable. Retrying with data:90 +310 ns: Info: MY_LOG: Router 1 released token for destination router 0 +310 ns: Info: MY_LOG: Token for destination router 0 passed to Router 2 +310 ns: Info: MY_LOG: Router 0: Received transaction with data: 84 from Router 1 after a delay of:30 ns +310 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 84 to core 2 +310 ns: Info: MY_LOG: Core 2 of parent Router: 0: Processing transaction and received data: 84 +310 ns: Info: MY_LOG: Router router0: Core 2 completed transaction, data: 84 +310 ns: Info: MY_LOG: Router 1: Received transaction with data: 64 from Router 3 after a delay of:20 ns +310 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 64 to core 1 +310 ns: Info: MY_LOG: Core 1 of parent Router: 1: Processing transaction and received data: 64 +310 ns: Info: MY_LOG: Router router1: Core 1 completed transaction, data: 64 +310 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +310 ns: Info: MY_LOG: Router 1 added to queue for semaphore 0 +310 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:35 +310 ns: Info: MY_LOG: Router router0: Semaphore unavailable. Retrying with data:53 +310 ns: Info: MY_LOG: Token for destination router 0 granted to Router 2 +310 ns: Info: MY_LOG: router2 forwarded data: 90 to Router_0 +310 ns: Info: MY_LOG: Router 3 released token for destination router 1 +310 ns: Info: MY_LOG: Token for destination router 1 passed to Router 0 +310 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +310 ns: Info: MY_LOG: Router 3 added to queue for semaphore 0 +310 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +315 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:35 +315 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +315 ns: Info: MY_LOG: router0 forwarded data: 53 to Router_1 +315 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +320 ns: Info: MY_LOG: Updated owner of semaphore 3 to Router 1 +320 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:35 +320 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +325 ns: Info: MY_LOG: Router 0 released token for destination router 1 +325 ns: Info: MY_LOG: Router 1: Received transaction with data: 53 from Router 0 after a delay of:10 ns +325 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 53 to core 2 +325 ns: Info: MY_LOG: Core 2 of parent Router: 1: Processing transaction and received data: 53 +325 ns: Info: MY_LOG: Router router1: Core 2 completed transaction, data: 53 +325 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +325 ns: Info: MY_LOG: router0 forwarded data: 37 to Router_1 +325 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:35 +325 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +330 ns: Info: MY_LOG: Router 2 released token for destination router 0 +330 ns: Info: MY_LOG: Token for destination router 0 passed to Router 1 +330 ns: Info: MY_LOG: Router 0: Received transaction with data: 90 from Router 2 after a delay of:20 ns +330 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 90 to core 1 +330 ns: Info: MY_LOG: Core 1 of parent Router: 0: Processing transaction and received data: 90 +330 ns: Info: MY_LOG: Router router0: Core 1 completed transaction, data: 90 +330 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +330 ns: Info: MY_LOG: Token for destination router 3 granted to Router 2 +330 ns: Info: MY_LOG: router2 forwarded data: 42 to Router_3 +330 ns: Info: MY_LOG: Token for destination router 0 granted to Router 1 +330 ns: Info: MY_LOG: router1 forwarded data: 35 to Router_0 +330 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +335 ns: Info: MY_LOG: Router 0 released token for destination router 1 +335 ns: Info: MY_LOG: Router 1: Received transaction with data: 37 from Router 0 after a delay of:10 ns +335 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 37 to core 0 +335 ns: Info: MY_LOG: Core 0 of parent Router: 1: Processing transaction and received data: 37 +335 ns: Info: MY_LOG: Router router1: Core 0 completed transaction, data: 37 +335 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +335 ns: Info: MY_LOG: router0 forwarded data: 42 to Router_1 +335 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +340 ns: Info: MY_LOG: Router 2 released token for destination router 3 +340 ns: Info: MY_LOG: Router 3: Received transaction with data: 42 from Router 2 after a delay of:10 ns +340 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 42 to core 3 +340 ns: Info: MY_LOG: Core 3 of parent Router: 3: Processing transaction and received data: 42 +340 ns: Info: MY_LOG: Router router3: Core 3 completed transaction, data: 42 +340 ns: Info: MY_LOG: Token for destination router 3 granted to Router 2 +340 ns: Info: MY_LOG: router2 forwarded data: 53 to Router_3 +340 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +345 ns: Info: MY_LOG: Router 0 released token for destination router 1 +345 ns: Info: MY_LOG: Router 1: Received transaction with data: 42 from Router 0 after a delay of:10 ns +345 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 42 to core 2 +345 ns: Info: MY_LOG: Core 2 of parent Router: 1: Processing transaction and received data: 42 +345 ns: Info: MY_LOG: Router router1: Core 2 completed transaction, data: 42 +345 ns: Info: MY_LOG: Token for destination router 1 granted to Router 0 +345 ns: Info: MY_LOG: router0 forwarded data: 38 to Router_1 +345 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +350 ns: Info: MY_LOG: Router 2 released token for destination router 3 +350 ns: Info: MY_LOG: Router 3: Received transaction with data: 53 from Router 2 after a delay of:10 ns +350 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 53 to core 3 +350 ns: Info: MY_LOG: Core 3 of parent Router: 3: Processing transaction and received data: 53 +350 ns: Info: MY_LOG: Router router3: Core 3 completed transaction, data: 53 +350 ns: Info: MY_LOG: Token for destination router 3 granted to Router 2 +350 ns: Info: MY_LOG: router2 forwarded data: 98 to Router_3 +350 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +355 ns: Info: MY_LOG: Router 0 released token for destination router 1 +355 ns: Info: MY_LOG: Router 1: Received transaction with data: 38 from Router 0 after a delay of:10 ns +355 ns: Info: MY_LOG: Router router1: Forwarding transaction with data: 38 to core 2 +355 ns: Info: MY_LOG: Core 2 of parent Router: 1: Processing transaction and received data: 38 +355 ns: Info: MY_LOG: Router router1: Core 2 completed transaction, data: 38 +355 ns: Info: MY_LOG: Token for destination router 2 granted to Router 0 +355 ns: Info: MY_LOG: router0 forwarded data: 5 to Router_2 +355 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +360 ns: Info: MY_LOG: Router 2 released token for destination router 3 +360 ns: Info: MY_LOG: Router 3: Received transaction with data: 98 from Router 2 after a delay of:10 ns +360 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 98 to core 1 +360 ns: Info: MY_LOG: Core 1 of parent Router: 3: Processing transaction and received data: 98 +360 ns: Info: MY_LOG: Router router3: Core 1 completed transaction, data: 98 +360 ns: Info: MY_LOG: Router 0: Received transaction with data: 35 from Router 1 after a delay of:30 ns +360 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 35 to core 0 +360 ns: Info: MY_LOG: Core 0 of parent Router: 0: Processing transaction and received data: 35 +360 ns: Info: MY_LOG: Router router0: Core 0 completed transaction, data: 35 +360 ns: Info: MY_LOG: Token for destination router 3 granted to Router 2 +360 ns: Info: MY_LOG: router2 forwarded data: 54 to Router_3 +360 ns: Info: MY_LOG: Updated owner of semaphore 1 to Router 1 +360 ns: Info: MY_LOG: Router router3: Semaphore unavailable. Retrying with data:82 +360 ns: Info: MY_LOG: Router 1 released token for destination router 0 +360 ns: Info: MY_LOG: Token for destination router 0 passed to Router 3 +360 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +360 ns: Info: MY_LOG: Router 1 added to queue for semaphore 3 +360 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:99 +365 ns: Info: MY_LOG: Token for destination router 0 granted to Router 3 +365 ns: Info: MY_LOG: router3 forwarded data: 82 to Router_0 +365 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:99 +370 ns: Info: MY_LOG: Router 2 released token for destination router 3 +370 ns: Info: MY_LOG: Token for destination router 3 passed to Router 1 +370 ns: Info: MY_LOG: Router 3: Received transaction with data: 54 from Router 2 after a delay of:10 ns +370 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 54 to core 1 +370 ns: Info: MY_LOG: Core 1 of parent Router: 3: Processing transaction and received data: 54 +370 ns: Info: MY_LOG: Router router3: Core 1 completed transaction, data: 54 +370 ns: Info: MY_LOG: Token for destination router 3 granted to Router 1 +370 ns: Info: MY_LOG: Token for destination router 1 granted to Router 2 +370 ns: Info: MY_LOG: router2 forwarded data: 27 to Router_1 +370 ns: Info: MY_LOG: Token for destination router 3 granted to Router 1 +370 ns: Info: MY_LOG: router1 forwarded data: 99 to Router_3 +375 ns: Info: MY_LOG: Router 0 released token for destination router 2 +375 ns: Info: MY_LOG: Router 3 released token for destination router 0 +375 ns: Info: MY_LOG: Router 2: Received transaction with data: 5 from Router 0 after a delay of:20 ns +375 ns: Info: MY_LOG: Router router2: Forwarding transaction with data: 5 to core 1 +375 ns: Info: MY_LOG: Core 1 of parent Router: 2: Processing transaction and received data: 5 +375 ns: Info: MY_LOG: Router router2: Core 1 completed transaction, data: 5 +375 ns: Info: MY_LOG: Router 0: Received transaction with data: 82 from Router 3 after a delay of:10 ns +375 ns: Info: MY_LOG: Router router0: Forwarding transaction with data: 82 to core 0 +375 ns: Info: MY_LOG: Core 0 of parent Router: 0: Processing transaction and received data: 82 +375 ns: Info: MY_LOG: Router router0: Core 0 completed transaction, data: 82 +375 ns: Info: MY_LOG: Token for destination router 2 granted to Router 3 +375 ns: Info: MY_LOG: router3 forwarded data: 90 to Router_2 +380 ns: Info: MY_LOG: Updated owner of semaphore 0 to Router 0 +390 ns: Info: MY_LOG: Router 1 released token for destination router 3 +390 ns: Info: MY_LOG: Router 3: Received transaction with data: 99 from Router 1 after a delay of:20 ns +390 ns: Info: MY_LOG: Router router3: Forwarding transaction with data: 99 to core 3 +390 ns: Info: MY_LOG: Core 3 of parent Router: 3: Processing transaction and received data: 99 +390 ns: Info: MY_LOG: Router router3: Core 3 completed transaction, data: 99 +390 ns: Info: MY_LOG: Router 1 added to queue for semaphore 2 +390 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:53 +395 ns: Info: MY_LOG: Router router1: Semaphore unavailable. Retrying with data:53 diff --git a/src/core.cpp b/src/core.cpp new file mode 100644 index 0000000..e19ff2f --- /dev/null +++ b/src/core.cpp @@ -0,0 +1,125 @@ +#include "core.h" + +// Initiator module (processor core) +core::core(sc_module_name name) { + sc_report_handler::set_log_file_name("out/report.log"); + sc_report_handler::set_actions(LOG_NAME, SC_INFO, SC_LOG|SC_DISPLAY); + SC_THREAD(thread); + target_socket.register_nb_transport_fw(this, &core::nb_transport_fw); +} + +// Thread for sending data +void core::thread() { + + // Initialize random seed (only once per run, for all cores) + static bool seeded = false; + if (!seeded) { + srand(time(0)); // Seed the random number generator + seeded = true; + } + + // Infinite loop for sending data + while (true) { + my_payload* trans = nullptr; + // Core ID and source router ID from main logic + unsigned int source_core = source_core_id; + unsigned int src_router_id = source_router_id; // Source router from the main logic + + sc_time delay = SC_ZERO_TIME; // Start with zero delay + sc_time inter_transaction_delay = sc_time(90, SC_NS); // Delay between transactions + // Loop to retry the same transaction + bool retry = false; + do { + if (!retry) { + // Generate random data between 0 and 100 + int data = rand() % 101; + + // Random destination router (ensuring it's different from source router) + unsigned int destination_router_id; + do { + destination_router_id = rand() % ROUTER_NO; // Random router ID between 0 and ROUTER_NO-1 + } while (destination_router_id == src_router_id); // Ensure it's not the same as source router + + // Destination core ID (random between 0 and CORE_NO-1) + unsigned int dst_core_id = rand() % CORE_NO; + + // Create payload with generated values + trans = new my_payload(source_core, src_router_id, dst_core_id, destination_router_id, data); + trans->update_timestamp(sc_time_stamp()); // Set the current simulation time + + // Construct the address (calculation based on router/core IDs) + unsigned int offset = 0x20; // offset + unsigned int address = (destination_router_id << 12) | (dst_core_id << 8) | offset; + trans->set_address(address); + + // Print which core is currently sending the data + log_info( "Core " + std::to_string(source_core) + " of Source Router: " + std::to_string(source_router_id) + + ": Processing data " + std::to_string(trans->data) + " for router " + std::to_string(destination_router_id) + + " and core " + std::to_string(dst_core_id) + " at time: " + trans->timestamp.to_string()); + } + + // Set up the rest of the transaction + trans->set_byte_enable_ptr(nullptr); + trans->set_dmi_allowed(false); + trans->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); + + + tlm::tlm_phase phase = tlm::BEGIN_REQ; // Transaction phase + tlm::tlm_sync_enum status = socket->nb_transport_fw(*trans, phase, delay); // Non-blocking transport + + if (status == tlm::TLM_COMPLETED || phase == tlm::END_REQ) { + log_info("Core " + std::string(name()) + ": Transaction successful, data sent: " + std::to_string(trans->data) + " at time: " + sc_time_stamp().to_string()); + delete trans; // Clean up the transaction + retry = false; // Move on to the next transaction + wait(inter_transaction_delay); + } else if (status == tlm::TLM_ACCEPTED) { + log_info("Core " + std::string(name()) + ": Transaction accepted, waiting for completion."); + wait(delay); // Wait for response + retry = false; // No need to retry, accepted transaction will continue + } else if (status == tlm::TLM_UPDATED && phase == tlm::BEGIN_REQ) { + log_info("Core " + std::string(name()) + ": FIFO full, retrying..."); + //wait(delay); // Wait for some time before retrying + // --i; // Retry the same transaction + wait(delay + sc_time(20, SC_NS)); // Add some delay before retrying + // wait(router->core_fifo_event); + retry = true; // Retry the same transaction + } + + } while (retry); + + + wait(delay); + } +} + +/// Forwarding function for receiving data from router +tlm::tlm_sync_enum core::nb_transport_fw(tlm::tlm_generic_payload& trans, tlm::tlm_phase& phase, sc_time& delay) { + if (phase == tlm::BEGIN_REQ) { + my_payload* my_trans = dynamic_cast(&trans); + + // Print which core is processing the received data + log_info("Core " + std::to_string(source_core_id) + " of parent Router: " + std::to_string(source_router_id) + + ": Processing transaction " + "and received data: " + std::to_string(my_trans->data)); + + // log_info("Core " + std::string(name()) + ": Received transaction, data: " + std::to_string(my_trans->data)); + + + // Send acknowledgment or status back + trans.set_response_status(tlm::TLM_OK_RESPONSE); + + // Log the received data and remove the payload + delete my_trans; + return tlm::TLM_COMPLETED; + } + return tlm::TLM_ACCEPTED; +} + + + +void core::log_info(std::string msg){ + SC_REPORT_INFO(LOG_NAME, msg.c_str()); +} + +void core::log_error(std::string msg){ + SC_REPORT_ERROR(LOG_NAME, msg.c_str()); +} \ No newline at end of file diff --git a/src/router.cpp b/src/router.cpp new file mode 100644 index 0000000..029e48d --- /dev/null +++ b/src/router.cpp @@ -0,0 +1,209 @@ +#include "router.h" + +// Router module with FIFOs, semaphores, and capacity control for receive FIFO +router::router(sc_module_name name) +: in_fifo(CORE_FIFO_CAPACITY), out_fifo(ROUTER_RECEIVE_FIFO_CAPACITY), sem(1), router_id(-1) // default router id +{ + sc_report_handler::set_log_file_name("out/report.log"); + sc_report_handler::set_actions(LOG_NAME, SC_INFO, SC_LOG|SC_DISPLAY); + for (int i = 0; i < CORE_NO; ++i) { + 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 + } + + 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 +} + +// Function to handle incoming transactions +tlm::tlm_sync_enum router::nb_transport_fw(tlm::tlm_generic_payload& trans, tlm::tlm_phase& phase, sc_time& delay) { + if (phase == tlm::BEGIN_REQ) { + if (in_fifo.num_free() == 0) { + log_info("Router "+std::string(name())+": Input FIFO full, cannot accept transaction with data: "+std::to_string(dynamic_cast(&trans)->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(&trans); + my_payload* my_trans = new my_payload(); + // Log the time when the core sent the transaction + sc_time sent_time = orig_trans->timestamp; + my_trans->dst_core = orig_trans->dst_core; + 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; + my_trans->update_timestamp(current_time); // Update the timestamp in the payload + + my_trans->set_address(orig_trans->get_address()); + my_trans->set_command(orig_trans->get_command()); + my_trans->set_data_ptr(reinterpret_cast(&my_trans->data)); + my_trans->set_data_length(orig_trans->get_data_length()); + my_trans->set_streaming_width(orig_trans->get_streaming_width()); + my_trans->set_byte_enable_ptr(orig_trans->get_byte_enable_ptr()); + my_trans->set_dmi_allowed(orig_trans->is_dmi_allowed()); + 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: " + std::to_string(my_trans->data) + + " at time: " + current_time.to_string()); + + phase = tlm::END_REQ; // Mark the end of the request phase + delay = sc_time(10, SC_NS); // Add some delay + return tlm::TLM_UPDATED; + } + return tlm::TLM_ACCEPTED; +} + + + +// Thread to process in_fifo +void router::process_core_fifo() { + + my_payload* payload; + while (true) { + // log_info(std::string(name()) + " has: " + std::to_string(in_fifo.num_free()) + // + " remaining space in the input fifo" ); + + + + unsigned int current_router = current_router_id; + + // Wait for data in the input FIFO + payload = in_fifo.read(); // Blocking read + + //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 + //blocking write to destination router + + // Retry mechanism + bool success = false; + while (!success) { + + //wait(SC_ZERO_TIME); + if (sem_mgr->request_token(router_id, destination_router_id)) { + + if (other_out_fifos[destination_router_id]->num_free() > 0) { + other_sems[destination_router_id]-> wait(); + + int dest_fifo_space = other_out_fifos[destination_router_id]->num_free(); + // If there's space and the semaphore is available, send the payload + log_info(std::string(name()) + " forwarded data: " + std::to_string(payload->data) + + " to Router_" + std::to_string(destination_router_id)); + sc_core::sc_time delay_T = sc_core::sc_time((destination_router_id -current_router + ROUTER_NO) % ROUTER_NO * 10, SC_NS); + sc_core::sc_time recv_time = sc_time_stamp() + delay_T; + payload->update_timestamp(recv_time); + wait(delay_T); + other_out_fifos[destination_router_id]->write(payload); // Blocking write to the destination router's FIFO + success = true; // Successfully sent the payload, exit the loop + other_sems[destination_router_id]->post(); // Release the semaphore + // Release the semaphore after forwarding + sem_mgr->release_token(router_id, destination_router_id); + + } else { + log_info("Router " + std::string(name()) + ": Destination router's out_fifo full. Retrying with data:" + std::to_string(payload->data)); + other_sems[destination_router_id]->post(); // Release the semaphore + sem_mgr->release_token(router_id, destination_router_id); // Release and retry + wait(sc_time(5, SC_NS)); // Wait before retrying + } + + } else { + + + log_info("Router " + std::string(name()) + ": Semaphore unavailable. Retrying with data:" + std::to_string(payload->data)); + wait(sc_time(5, SC_NS)); // Wait before retrying + } + } + + } +} + + +// Thread to process router_receive_fifo and forward transactions to cores +void router::process_router_receive_fifo() { + + my_payload* payload; + int prev_src_id = -1; + sc_core::sc_time prev_timestamp = sc_time(0.1, SC_NS); + while (true) { + + + // log_info(std::string(name()) + " has: " + std::to_string(out_fifo.num_free()) + // + " remaining space in the output fifo" ); + + // Wait for data in the output FIFO + payload = out_fifo.read(); // Blocking read + + // 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 + unsigned int src_router = payload->src_router; + sc_core::sc_time timestamp = payload->timestamp; + + 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){ + // log_info("Router " + std::to_string(dest_router_id)+ ": Received transaction with data: " + std::to_string(payload->data) + // + " from Router " + std::to_string(payload->src_router) + " after a delay of:" + std::to_string(delay_T) + " ns" ); + // prev_src_id = src_router; + // prev_timestamp = timestamp; + // } else { + + // 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) + + " from Router " + std::to_string(payload->src_router) + " after a delay of:" + std::to_string(delay_T) + " ns" ); + + prev_src_id = src_router; + prev_timestamp = timestamp; + //} + + + + log_info("Router " + std::string(name())+ ": Forwarding transaction with data: " + std::to_string(payload->data) + + " to core " + std::to_string(destination_core_id)); + + // Send the payload to the corresponding core 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]->nb_transport_fw(*payload, phase, delay); + + if (status == tlm::TLM_COMPLETED) { + log_info("Router " + std::string(name()) + ": Core " + std::to_string(destination_core_id) + + " completed transaction, data: " + std::to_string(payload->data)); + + //// other_sems[dest_router_id]->post(); + + } else if (status == tlm::TLM_ACCEPTED) { + log_info("Router " + std::string(name()) + ": Core " + std::to_string(destination_core_id) + + " accepted transaction, waiting for completion."); + } else if (status == tlm::TLM_UPDATED) { + log_info("Router " + std::string(name()) + ": Core " + std::to_string(destination_core_id) + + " updated transaction, waiting for completion."); + } else { + log_error("Router " + std::string(name()) + ": Unexpected response from core " + std::to_string(destination_core_id)); + delete payload; + } + + } +} + +//print log messages +void router::log_info(std::string msg){ + SC_REPORT_INFO(LOG_NAME, msg.c_str()); +} + +void router::log_error(std::string msg){ + SC_REPORT_ERROR(LOG_NAME, msg.c_str()); +} \ No newline at end of file