64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <systemc.h>
|
|
#include <tlm.h>
|
|
#include <tlm_utils/simple_initiator_socket.h>
|
|
#include <tlm_utils/simple_target_socket.h>
|
|
|
|
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<unsigned char*>(&data));
|
|
set_data_length(sizeof(data));
|
|
set_streaming_width(sizeof(data));
|
|
}
|
|
|
|
// Constructor with random data
|
|
my_payload(unsigned int source_core, unsigned int src_router_id, unsigned int dst_core_id, unsigned int destination_router_id, 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<unsigned char*>(&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<unsigned char*>(&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<unsigned char*>(&data));
|
|
// set_data_length(sizeof(data));
|
|
// set_streaming_width(sizeof(data));
|
|
// }
|
|
|