78 lines
3 KiB
C++
78 lines
3 KiB
C++
/*******************************************************************************
|
|
* Copyright (C) 2024
|
|
*
|
|
* 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
|
|
|
|
#include "ratatoskrUtils/processingElement/ProcessingElementVC.h"
|
|
#include "utils/PacketFactoryCS.h"
|
|
#include "utils/GlobalResourcesCS.h"
|
|
|
|
class ProcessingElementCS : public ProcessingElementVC {
|
|
public:
|
|
// Almost same functionality as ProcessingElementVC but uses TaskCS
|
|
std::map<dataTypeID_t, std::set<TaskCS>> neededFor;
|
|
std::map<std::pair<TaskCS, dataTypeID_t>, int> neededAmount;
|
|
std::map<TaskCS, std::set<dataTypeID_t>> needs;
|
|
std::map<dataTypeID_t, int> receivedData;
|
|
std::map<DataDestinationCS, TaskCS> destToTask;
|
|
std::map<TaskCS, std::set<DataDestinationCS>> taskToDest;
|
|
std::map<TaskCS, int> taskRepeatLeft;
|
|
std::map<TaskCS, int> taskStartTime;
|
|
std::map<TaskCS, int> taskTerminationTime;
|
|
std::map<DataDestinationCS, int> countLeft;
|
|
std::map<DataDestinationCS, int> destWait;
|
|
|
|
GlobalResourcesCS& globalResources = GlobalResourcesCS::getInstance();
|
|
|
|
PacketFactoryCS& packetFactoryCS = PacketFactoryCS::getInstance();
|
|
|
|
ProcessingElementCS(sc_module_name mn, Node& node, TrafficPool* tp):
|
|
ProcessingElementVC(mn, node, tp) {};
|
|
|
|
/**
|
|
* On every clock cycle, checks if task needs to begin and starts it
|
|
*/
|
|
void thread() override;
|
|
|
|
/**
|
|
* Updates requirements and sends messages at the right time
|
|
*
|
|
* @param taskcs Circuit switching task to execute
|
|
*/
|
|
void execute(TaskCS&);
|
|
|
|
/**
|
|
* Receives packet and processes it
|
|
*/
|
|
void receive() override;
|
|
|
|
/**
|
|
* Sends message with a random delay
|
|
*
|
|
* @param taskcs Circuit switching task from which to send a message
|
|
*/
|
|
void startSending(TaskCS&);
|
|
|
|
/**
|
|
* Checks if requirements are fullfilled
|
|
*/
|
|
void checkNeed();
|
|
};
|