tlm_noc_sim/src/router/router_cs.h

91 lines
3 KiB
C++
Executable file

/*******************************************************************************
* Copyright (C) 2024 Juan Neyra
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
#pragma once
#ifndef SC_INCLUDE_DYNAMIC_PROCESSES
#define SC_INCLUDE_DYNAMIC_PROCESSES
#endif
#include <systemc>
#include <string>
#include "tlm.h"
using namespace sc_core;
using namespace sc_dt;
using namespace std;
using namespace tlm;
using namespace tlm_utils;
DECLARE_EXTENDED_PHASE(CONF_ROUT_PHASE);
class TlmRouterCS : public sc_module, TlmRouter{
public:
SC_HAS_PROCESS(TlmRouterCS);
TlmRouterCS(sc_module_name name, uint8_t rout_pos[3],
uint8_t max_pos[3]);
~TlmRouterCS();
void set_auto_router_map(int link, Dir dir);
Dir get_auto_router_map(int link);
private:
Dir auto_rout_map[NUM_LINKS] = {0};
/**
* Configure sockets and set initial values of variables
*/
void initialize() override;
/**
* Routing
*
* @param link active link
* @param trans TLM generic payload object
*/
Dir TlmRouterCS::routing(int link, tlm_gp& trans) override;
/**
* Process arrived data: finds destination link and transmit it
*
* @param link active link
* @param trans TLM generic payload object
*/
void switching(int link, tlm_gp& trans);
/**
* Send end request
*
* @param link active link
* @param trans TLM generic payload object
*/
tlm::tlm_sync_enum send_end_req(int link, tlm_gp& trans) override;
/**
* Callback target Payload Event Queue (PEQ)
*
* @param trans TLM generic payload object
* @param phase TLM current phase
*/
void target_peq_cb(tlm_gp& trans, const tlm_phase& phase) override;
};