/******************************************************************************* * 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> neededFor; std::map, int> neededAmount; std::map> needs; std::map receivedData; std::map destToTask; std::map> taskToDest; std::map taskRepeatLeft; std::map taskStartTime; std::map taskTerminationTime; std::map countLeft; std::map 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(); };