From ac735a647fe23a78ad19e301b1ee8738dbd7ab15 Mon Sep 17 00:00:00 2001 From: Daniel Knorreck <daniel.knorreck@telecom-paristech.fr> Date: Wed, 22 Jul 2009 16:39:30 +0000 Subject: [PATCH] Listener concept reviewed --- simulators/c++2/src_simulator/Bus.cpp | 5 +- simulators/c++2/src_simulator/BusAbstr.h | 80 ++++++++++++++++ simulators/c++2/src_simulator/CPU.cpp | 3 +- simulators/c++2/src_simulator/CPUAbstr.h | 72 ++++++++++++++ simulators/c++2/src_simulator/CPUPB.cpp | 2 +- simulators/c++2/src_simulator/CPUPBL.cpp | 2 +- simulators/c++2/src_simulator/CPURR.cpp | 2 +- simulators/c++2/src_simulator/ChannelAbstr.h | 95 +++++++++++++++++++ simulators/c++2/src_simulator/CommandAbstr.h | 88 +++++++++++++++++ .../c++2/src_simulator/CommandListener.h | 5 +- .../c++2/src_simulator/ListenerSubject.h | 3 + .../c++2/src_simulator/ListenersSimCmd.cpp | 54 ++++++++++- .../c++2/src_simulator/ListenersSimCmd.h | 55 ++++++++++- .../c++2/src_simulator/SchedulableDevice.h | 2 +- simulators/c++2/src_simulator/Simulator.cpp | 14 +-- simulators/c++2/src_simulator/Slave.h | 5 +- .../c++2/src_simulator/TMLActionCommand.cpp | 5 +- simulators/c++2/src_simulator/TMLChannel.h | 2 +- .../c++2/src_simulator/TMLChoiceCommand.cpp | 5 +- simulators/c++2/src_simulator/TMLCommand.cpp | 9 +- simulators/c++2/src_simulator/TMLCommand.h | 2 +- .../c++2/src_simulator/TMLEventBChannel.cpp | 6 +- .../c++2/src_simulator/TMLEventFBChannel.cpp | 6 +- .../c++2/src_simulator/TMLEventFChannel.cpp | 6 +- simulators/c++2/src_simulator/TMLTask.cpp | 3 +- simulators/c++2/src_simulator/TMLTask.h | 4 +- .../c++2/src_simulator/TMLTransaction.h | 2 - .../c++2/src_simulator/TMLbrbwChannel.cpp | 6 +- .../c++2/src_simulator/TMLbrnbwChannel.cpp | 6 +- .../c++2/src_simulator/TMLnbrnbwChannel.cpp | 6 +- simulators/c++2/src_simulator/TaskAbstr.h | 83 ++++++++++++++++ .../c++2/src_simulator/TransactionAbstr.h | 88 +++++++++++++++++ .../c++2/src_simulator/TransactionListener.h | 19 ++-- 33 files changed, 685 insertions(+), 60 deletions(-) create mode 100644 simulators/c++2/src_simulator/BusAbstr.h create mode 100644 simulators/c++2/src_simulator/CPUAbstr.h create mode 100644 simulators/c++2/src_simulator/ChannelAbstr.h create mode 100644 simulators/c++2/src_simulator/CommandAbstr.h create mode 100644 simulators/c++2/src_simulator/TaskAbstr.h create mode 100644 simulators/c++2/src_simulator/TransactionAbstr.h diff --git a/simulators/c++2/src_simulator/Bus.cpp b/simulators/c++2/src_simulator/Bus.cpp index 613c49134d..7830250d4b 100644 --- a/simulators/c++2/src_simulator/Bus.cpp +++ b/simulators/c++2/src_simulator/Bus.cpp @@ -94,7 +94,7 @@ void Bus::schedule(){ if (aTransToExecute!=_transactionHash.end()){ _nextTransaction=aTransToExecute; calcStartTimeLength(); - FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction->second); + //FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction->second); } _schedulingNeeded=false; #ifdef DEBUG_BUS @@ -138,7 +138,8 @@ bool Bus::addTransaction(){ std::cout << i->second->toString() << "\n"; }*/ _schedulingNeeded=true; - FOR_EACH_TRANSLISTENER (*i)->transExecuted(aNextTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(aNextTrans); + NOTIFY_TRANS_EXECUTED(aNextTrans); return true; } diff --git a/simulators/c++2/src_simulator/BusAbstr.h b/simulators/c++2/src_simulator/BusAbstr.h new file mode 100644 index 0000000000..d81a422801 --- /dev/null +++ b/simulators/c++2/src_simulator/BusAbstr.h @@ -0,0 +1,80 @@ +/*Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Daniel Knorreck, +Ludovic Apvrille, Renaud Pacalet + * + * ludovic.apvrille AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + */ + +#ifndef BusAbstrH +#define BusAbstrH +#include <Bus.h> + +class BusAbstr{ +public: + ///Constructor + /** + \param iID ID of the bus + */ + BusAbstr(Bus* iBus):_bus(iBus){ + } + ///Destructor + ~BusAbstr(){ + } + ///Returns the size of an atomic bus transaction + /** + \return Burst size + */ + inline TMLLength getBurstSize() const{ + return _bus->getBurstSize(); + } + ///Returns a string representation of the Bus + /** + \return Detailed string representation + */ + inline std::string getName() const{ + return _bus->toString(); + } + ///Returns the unique ID of the bus + /** + \return Unique ID + */ + inline unsigned int getID() const{ + return _bus->getID(); + } +private: + Bus* _bus; +}; +#endif diff --git a/simulators/c++2/src_simulator/CPU.cpp b/simulators/c++2/src_simulator/CPU.cpp index b683468b85..0de4926992 100644 --- a/simulators/c++2/src_simulator/CPU.cpp +++ b/simulators/c++2/src_simulator/CPU.cpp @@ -254,7 +254,8 @@ bool CPU::addTransaction(){ #endif _busyCycles+=_nextTransaction->getOverallLength(); //std::cout << "busyCycles: " << _busyCycles << std::endl; - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_nextTransaction); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_nextTransaction); + NOTIFY_TRANS_EXECUTED(_nextTransaction); _nextTransaction=0; return true; }else return false; diff --git a/simulators/c++2/src_simulator/CPUAbstr.h b/simulators/c++2/src_simulator/CPUAbstr.h new file mode 100644 index 0000000000..0ab0710008 --- /dev/null +++ b/simulators/c++2/src_simulator/CPUAbstr.h @@ -0,0 +1,72 @@ +/*Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Daniel Knorreck, +Ludovic Apvrille, Renaud Pacalet + * + * ludovic.apvrille AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + */ + +#ifndef CPUAbstrH +#define CPUAbstrH +#include <CPU.h> +class CPUAbstr{ +public: + ///Constructor + /** + \param iTask Pointer to CPU object which shall be encapsulated + */ + CPUAbstr(CPU* iCPU):_cpu(iCPU){ + } + ///Destructor + ~CPUAbstr(){ + } + ///Returns the name of the CPU + /** + \return Name of the CPU + */ + inline std::string getName() const{ + return _cpu->toString(); + } + ///Returns the unique ID of the CPU + /** + \return Unique ID + */ + inline unsigned int getID() const{ + return _cpu->getID(); + } +private: + CPU* _cpu; +}; +#endif diff --git a/simulators/c++2/src_simulator/CPUPB.cpp b/simulators/c++2/src_simulator/CPUPB.cpp index ff23b09477..494ef6e452 100644 --- a/simulators/c++2/src_simulator/CPUPB.cpp +++ b/simulators/c++2/src_simulator/CPUPB.cpp @@ -100,7 +100,7 @@ void CPUPB::schedule(){ if (aOldTransaction!=0 && aOldTransaction!=_nextTransaction && _busNextTransaction!=0) _busNextTransaction->registerTransaction(0,this); if (_nextTransaction!=0){ calcStartTimeLength(); - FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction); + //FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction); } } diff --git a/simulators/c++2/src_simulator/CPUPBL.cpp b/simulators/c++2/src_simulator/CPUPBL.cpp index ea7f7bd38d..60daccf758 100644 --- a/simulators/c++2/src_simulator/CPUPBL.cpp +++ b/simulators/c++2/src_simulator/CPUPBL.cpp @@ -60,7 +60,7 @@ void CPUPBL::schedule(){ } if (_nextTransaction!=0){ calcStartTimeLength(); - FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction); + //FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction); } } diff --git a/simulators/c++2/src_simulator/CPURR.cpp b/simulators/c++2/src_simulator/CPURR.cpp index 4f90fcdce2..d4a23cad95 100644 --- a/simulators/c++2/src_simulator/CPURR.cpp +++ b/simulators/c++2/src_simulator/CPURR.cpp @@ -70,7 +70,7 @@ void CPURR::schedule(){ calcStartTimeLength(); if (_taskChanged) _taskStartTime = _nextTransaction->getStartTime() + _nextTransaction->getIdlePenalty() + _nextTransaction->getTaskSwitchingPenalty(); if (_busNextTransaction==0 && _nextTransaction->getEndTime() > _taskStartTime + _timeQuantum) truncateNextTransAt(_taskStartTime + _timeQuantum); - FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction); + //FOR_EACH_TRANSLISTENER (*i)->transScheduled(_nextTransaction); } } diff --git a/simulators/c++2/src_simulator/ChannelAbstr.h b/simulators/c++2/src_simulator/ChannelAbstr.h new file mode 100644 index 0000000000..31f842a2cd --- /dev/null +++ b/simulators/c++2/src_simulator/ChannelAbstr.h @@ -0,0 +1,95 @@ +/*Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Daniel Knorreck, +Ludovic Apvrille, Renaud Pacalet + * + * ludovic.apvrille AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + */ + +#ifndef ChnanelAbstrH +#define ChnanelAbstrH +#include <TMLChannel.h> + +class ChannelAbstr{ +public: + ///Constructor + /** + \param iTask Pointer to CPU object which shall be encapsulated + */ + ChannelAbstr(TMLChannel* iChannel):_channel(iChannel){ + } + ///Destructor + ~ChannelAbstr(){ + } + ///Returns the name of the channel + /** + \return Name of the channel + */ + inline std::string getName() const{ + return _channel->toString(); + } + ///Returns the unique ID of the device + /** + \return Unique ID + */ + inline unsigned int getID() const{ + return _channel->getID(); + } + ///Returns a flag indicating if a channel overflow has been encoutered + /** + \return Channel overflow flag + */ + inline bool getOverflow(){ + return _channel->getOverflow(); + } + ///Returns a flag indicating if a channel underflow has been encoutered + /** + \return Channel underflow flag + */ + inline bool getUnderflow(){ + return _channel->getUnderflow(); + } + ///Returns the number of samples stored in the channel + /** + \return Content of the channel + */ + inline TMLLength getContent(){ + return _channel->getContent(); + } +private: + TMLChannel* _channel; +}; +#endif + diff --git a/simulators/c++2/src_simulator/CommandAbstr.h b/simulators/c++2/src_simulator/CommandAbstr.h new file mode 100644 index 0000000000..9cd93f67d0 --- /dev/null +++ b/simulators/c++2/src_simulator/CommandAbstr.h @@ -0,0 +1,88 @@ +/*Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Daniel Knorreck, +Ludovic Apvrille, Renaud Pacalet + * + * ludovic.apvrille AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + */ + +#ifndef CommandAbstrH +#define CommandAbstrH +#include <TMLCommand.h> + +class CommandAbstr{ +public: + ///Constructor + /** + \param iCmd Pointer to Command object which shall be encapsulated + */ + CommandAbstr(TMLCommand* iCmd):_cmd(iCmd){ + } + ///Destructor + ~CommandAbstr(){ + } + ///Returns a short string representation of the command type + /** + \return Short string representation of command type + */ + inline std::string getCommandStr() const{ + return _cmd->getCommandStr(); + } + ///Returns the unique ID of the command + /** + \return Unique ID + */ + inline unsigned int getID() const{ + return _cmd->getID(); + } + ///Returns the progress of the command + /** + \return Progress of the command + */ + inline TMLLength getProgress() const{ + return _cmd->getProgress(); + } + ///Returns the length of the command + /** + \return Length of the command + */ + inline TMLLength getLength() const{ + //_cmd->getLength(); + return 0; + } +protected: + TMLCommand* _cmd; +}; +#endif diff --git a/simulators/c++2/src_simulator/CommandListener.h b/simulators/c++2/src_simulator/CommandListener.h index 7fb8c58c90..1fb07de9bd 100644 --- a/simulators/c++2/src_simulator/CommandListener.h +++ b/simulators/c++2/src_simulator/CommandListener.h @@ -40,7 +40,10 @@ Ludovic Apvrille, Renaud Pacalet #ifndef CommandListenerH #define CommandListenerH -#define FOR_EACH_CMDLISTENER for(std::list<CommandListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) +//#define FOR_EACH_CMDLISTENER for(std::list<CommandListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) +#define NOTIFY_CMD_ENTERED(iComm) for(std::list<CommandListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) (*i)->commandEntered(iComm) +#define NOTIFY_CMD_EXECUTED(iComm) for(std::list<CommandListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) (*i)->commandExecuted(iComm) +#define NOTIFY_CMD_FINISHED(iComm) for(std::list<CommandListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) (*i)->commandFinished(iComm) ///Encapsulates events associated with commands class CommandListener{ diff --git a/simulators/c++2/src_simulator/ListenerSubject.h b/simulators/c++2/src_simulator/ListenerSubject.h index 31571fdd63..02637ba792 100644 --- a/simulators/c++2/src_simulator/ListenerSubject.h +++ b/simulators/c++2/src_simulator/ListenerSubject.h @@ -49,6 +49,8 @@ public: \param iListener Pointer to the listener */ void registerListener(T* iListener){ + //void registerListener(void* iListener){ + _listeners.push_back(iListener); } ///Removes a listener from the internal list @@ -56,6 +58,7 @@ public: \param iListener Pointer to the listener */ void removeListener(T* iListener){ + //void removeListener(void* iListener){ _listeners.remove(iListener); } ///Destructor diff --git a/simulators/c++2/src_simulator/ListenersSimCmd.cpp b/simulators/c++2/src_simulator/ListenersSimCmd.cpp index 0048403ec9..24a086f51b 100644 --- a/simulators/c++2/src_simulator/ListenersSimCmd.cpp +++ b/simulators/c++2/src_simulator/ListenersSimCmd.cpp @@ -47,6 +47,8 @@ Ludovic Apvrille, Renaud Pacalet #include <TMLNotifiedCommand.h> #include <TMLWaitCommand.h> #include <TMLTask.h> +#define COND_SOURCE_FILE_NAME "newlib.c" +#define COND_OBJ_FILE_NAME "newlib.o" unsigned int CondBreakpoint::_freeID=0; bool Breakpoint::_enabled=true; @@ -96,10 +98,10 @@ void Breakpoint::setEnabled(bool iEnabled){ //************************************************************************ -CondBreakpoint::CondBreakpoint(SimComponents* iSimComp, std::string iCond, TMLTask* iTask):_simComp(iSimComp), _condText(iCond), _condFunc(0), _dlHandle(0), _task(iTask){ +CondBreakpoint::CondBreakpoint(SimComponents* iSimComp, std::string iCond, TMLTask* iTask):_simComp(iSimComp), _condText(iCond), _condFunc(0), _dlHandle(0), _task(iTask), _cSourceFileCreated(false), _objectFileCreated(false), _libFileCreated(false){ _ID=_freeID++; FILE* in; - std::ofstream myfile ("newlib.c"); + std::ofstream myfile (COND_SOURCE_FILE_NAME); char aExeName[256]; int len = getexename(aExeName, sizeof(aExeName)); if (len==-1) return; @@ -107,6 +109,7 @@ CondBreakpoint::CondBreakpoint(SimComponents* iSimComp, std::string iCond, TMLTa //strcat(aExeName, "/src_simulator"); std::cout << "ExeName: " << aExeName << std::endl; if (myfile.is_open()){ + _cSourceFileCreated=true; std::ostringstream aCmd; myfile << "#include <" << iTask->toString() << ".h>\n"; for(VariableLookUpTableName::const_iterator i=iTask->getVariableIteratorName(false); i !=iTask->getVariableIteratorName(true); ++i){ @@ -118,21 +121,23 @@ CondBreakpoint::CondBreakpoint(SimComponents* iSimComp, std::string iCond, TMLTa myfile << " return (" << iCond << ");\n"; myfile << "}\n"; myfile.close(); - aCmd << "g++ -c -fPIC -Wall newlib.c -I" << aExeName << " -I" << aExeName << "/src_simulator"; + aCmd << "g++ -c -fPIC -Wall " << COND_SOURCE_FILE_NAME << " -I" << aExeName << " -I" << aExeName << "/src_simulator"; //in = popen("g++ -c -fPIC -Wall newlib.c -I. -I./src_simulator", "r"); in = popen(aCmd.str().c_str(), "r"); if (pclose(in)!=0){ std::cout << "Compiler error!\n"; return; } + _objectFileCreated=true; aCmd.str(""); - aCmd << "g++ -shared -Wl,-soname," << "lib" << _ID << ".so.1" << " -o " << "lib" << _ID << ".so.1.0.1" << " newlib.o"; + aCmd << "g++ -shared -Wl,-soname," << "lib" << _ID << ".so.1" << " -o " << "lib" << _ID << ".so.1.0.1 " << COND_OBJ_FILE_NAME; //in = popen("g++ -shared -Wl,-soname,l.so.1 -o l.so.1.0.1 newlib.o", "r"); in = popen(aCmd.str().c_str(), "r"); if (pclose(in)!=0){ std::cout << "Compiler error!\n"; return; } + _libFileCreated=true; }else{ std::cout << "Error when creating C condition source file.\n"; return; @@ -181,6 +186,13 @@ bool CondBreakpoint::conditionValid() const{ CondBreakpoint::~CondBreakpoint(){ TMLCommand::removeGlobalListener(this); if (_dlHandle!=0) dlclose(_dlHandle); + if (_cSourceFileCreated) remove(COND_SOURCE_FILE_NAME); + if (_objectFileCreated) remove(COND_OBJ_FILE_NAME); + if (_libFileCreated){ + std::ostringstream aFileName; + aFileName << "lib" << _ID << ".so.1.0.1"; + remove(aFileName.str().c_str()); + } } @@ -256,7 +268,7 @@ void RunXTimeUnits::setEndTime(TMLTime iEndTime){ //************************************************************************ -RunTillTransOnDevice::RunTillTransOnDevice(SimComponents* iSimComp, ListenerSubject<TransactionListener>* iSubject):_simComp(iSimComp), _subject(iSubject) { +RunTillTransOnDevice::RunTillTransOnDevice(SimComponents* iSimComp, ListenerSubject <TransactionListener> * iSubject):_simComp(iSimComp), _subject(iSubject) { _subject->registerListener(this); } RunTillTransOnDevice::~RunTillTransOnDevice(){ @@ -268,3 +280,35 @@ bool RunTillTransOnDevice::transExecuted(TMLTransaction* iTrans){ _simComp->setStopFlag(true, MSG_TRANSONDEVICE); return true; } + + +//************************************************************************ +RunTillTransOnTask::RunTillTransOnTask(SimComponents* iSimComp, ListenerSubject<TaskListener>* iSubject):_simComp(iSimComp), _subject(iSubject) { + _subject->registerListener(this); +} + +RunTillTransOnTask::~RunTillTransOnTask(){ + _subject->removeListener(this); +} + +bool RunTillTransOnTask::transExecuted(TMLTransaction* iTrans){ + //_simComp->setStopFlag(true); + _simComp->setStopFlag(true, MSG_TRANSONDEVICE); + return true; +} + + +//************************************************************************ +ConstraintBlock::ConstraintBlock(SimComponents* iSimComp):_simComp(iSimComp){ +} + +ConstraintBlock::~ConstraintBlock(){ +} + +bool ConstraintBlock::transExecuted(TMLTransaction* iTrans){ + if (constraintFunc(TransactionAbstr(iTrans), CommandAbstr(iTrans->getCommand()), TaskAbstr(iTrans->getCommand()->getTask()), CPUAbstr(iTrans->getCommand()->getTask()->getCPU()), ChannelAbstr(iTrans->getChannel()))){ + _simComp->setStopFlag(true, MSG_CONSTRAINTBLOCK); + return true; + } + return false; +} diff --git a/simulators/c++2/src_simulator/ListenersSimCmd.h b/simulators/c++2/src_simulator/ListenersSimCmd.h index 3c3930c3a0..5c5af3c7be 100644 --- a/simulators/c++2/src_simulator/ListenersSimCmd.h +++ b/simulators/c++2/src_simulator/ListenersSimCmd.h @@ -44,6 +44,12 @@ Ludovic Apvrille, Renaud Pacalet #include <TransactionListener.h> #include <CommandListener.h> #include <ListenerSubject.h> +#include <TransactionAbstr.h> +#include <CommandAbstr.h> +#include <TaskAbstr.h> +#include <CPUAbstr.h> +#include <ChannelAbstr.h> + #define MSG_RUNXTRANSACTIONS "Transactions executed" #define MSG_BREAKPOINT "Breakpoint reached" #define MSG_CONDBREAKPOINT "Conditional breakpoint reached" @@ -51,6 +57,7 @@ Ludovic Apvrille, Renaud Pacalet #define MSG_RUNXCOMMANDS "Commands executed" #define MSG_RUNXTIMEUNITS "Time units elapsed" #define MSG_TRANSONDEVICE "Transaction on device encountered" +#define MSG_CONSTRAINTBLOCK "Constraint not fulfilled" class SimComponents; @@ -84,7 +91,7 @@ protected: //************************************************************************ ///Listener establishing a breakpoint -class Breakpoint: public CommandListener, public TransactionListener{ +class Breakpoint: public CommandListener{ public: ///Constructor /** @@ -107,7 +114,7 @@ protected: //************************************************************************ ///Breakpoint based on a condition -class CondBreakpoint: public CommandListener, public TransactionListener{ +class CondBreakpoint: public CommandListener{ public: ///Constructor /** @@ -146,12 +153,18 @@ protected: TMLTask* _task; ///Keeps track of the IDs already in use static unsigned int _freeID; + ///Flag indicating that the C source file has been created + bool _cSourceFileCreated; + ///Flag indicating that the object file has been created + bool _objectFileCreated; + ///Flag indicating that the library file has been created + bool _libFileCreated; }; //************************************************************************ ///Listener which stops the simulation as soon as a random choice command is encountered -class RunTillNextRandomChoice: public CommandListener, public TransactionListener{ +class RunTillNextRandomChoice: public CommandListener{ public: ///Constructor /** @@ -174,7 +187,7 @@ protected: //************************************************************************ ///Listener which stops the simulation after a given number of commands -class RunXCommands: public CommandListener, public TransactionListener{ +class RunXCommands: public CommandListener{ public: ///Constructor /** @@ -245,6 +258,38 @@ protected: ///Pointer to a SimComponents object SimComponents* _simComp; ///Device to listen on - ListenerSubject<TransactionListener>* _subject; + ListenerSubject <TransactionListener> * _subject; +}; + + +//************************************************************************ +///Listener which stops the simulation as soon as a given task executes a transaction +class RunTillTransOnTask: public TaskListener{ +public: + ///Constructor + /** + \param iSimComp Pointer to a SimComponents object + \param iSubject Task to listen on + */ + RunTillTransOnTask(SimComponents* iSimComp, ListenerSubject<TaskListener>* iSubject); + ///Destructor + virtual ~RunTillTransOnTask(); + bool transExecuted(TMLTransaction* iTrans); +protected: + ///Pointer to a SimComponents object + SimComponents* _simComp; + ///Task to listen on + ListenerSubject <TaskListener> * _subject; +}; + + +//************************************************************************ +class ConstraintBlock: public TransactionListener{ + ConstraintBlock(SimComponents* iSimComp); + ~ConstraintBlock(); + bool transExecuted(TMLTransaction* iTrans); + virtual bool constraintFunc(TransactionAbstr iTrans, CommandAbstr iCmd, TaskAbstr iTask, CPUAbstr iCPU, ChannelAbstr iChan) =0; +private: + SimComponents* _simComp; }; #endif diff --git a/simulators/c++2/src_simulator/SchedulableDevice.h b/simulators/c++2/src_simulator/SchedulableDevice.h index 17036b8d63..f30a80ccd5 100644 --- a/simulators/c++2/src_simulator/SchedulableDevice.h +++ b/simulators/c++2/src_simulator/SchedulableDevice.h @@ -51,7 +51,7 @@ class TransactionListener; class TransactionListener; ///Base class for devices which perform a scheduling -class SchedulableDevice: public Serializable, public ListenerSubject<TransactionListener>{ +class SchedulableDevice: public Serializable, public ListenerSubject <TransactionListener> { public: ///Constructor /** diff --git a/simulators/c++2/src_simulator/Simulator.cpp b/simulators/c++2/src_simulator/Simulator.cpp index c7c5445ad5..3c20367a2c 100644 --- a/simulators/c++2/src_simulator/Simulator.cpp +++ b/simulators/c++2/src_simulator/Simulator.cpp @@ -998,7 +998,7 @@ bool Simulator::runXTimeUnits(unsigned int iTime, TMLTransaction*& oLastTrans){ } bool Simulator::runToBusTrans(SchedulableCommDevice* iBus, TMLTransaction*& oLastTrans){ - ListenerSubject<TransactionListener>* aSubject= static_cast<ListenerSubject<TransactionListener>* > (iBus); + ListenerSubject <TransactionListener>* aSubject= static_cast<ListenerSubject<TransactionListener>* > (iBus); RunTillTransOnDevice aListener(_simComp, aSubject); return simulate(oLastTrans); } @@ -1010,8 +1010,8 @@ bool Simulator::runToCPUTrans(SchedulableDevice* iCPU, TMLTransaction*& oLastTra } bool Simulator::runToTaskTrans(TMLTask* iTask, TMLTransaction*& oLastTrans){ - ListenerSubject<TransactionListener>* aSubject= static_cast<ListenerSubject<TransactionListener>* > (iTask); - RunTillTransOnDevice aListener(_simComp, aSubject); + ListenerSubject<TaskListener>* aSubject= static_cast<ListenerSubject<TaskListener>* > (iTask); + RunTillTransOnTask aListener(_simComp, aSubject); return simulate(oLastTrans); } @@ -1174,9 +1174,11 @@ void Simulator::writeSimState(std::ostream& ioMessage){ if (_busy){ ioMessage << SIM_BUSY << TAG_STATUSc; }else{ - if (_simTerm) + if (_simTerm){ ioMessage << SIM_TERM << TAG_STATUSc << TAG_REASONo << MSG_SIMENDED << TAG_REASONc; - else - ioMessage << SIM_READY << TAG_STATUSc << TAG_REASONo << _simComp->getStopReason() << TAG_REASONc; + }else{ + ioMessage << SIM_READY << TAG_STATUSc; + if (_simComp->getStopReason()!="") ioMessage << TAG_REASONo << _simComp->getStopReason() << TAG_REASONc; + } } } diff --git a/simulators/c++2/src_simulator/Slave.h b/simulators/c++2/src_simulator/Slave.h index af1c46c516..40f02646cb 100644 --- a/simulators/c++2/src_simulator/Slave.h +++ b/simulators/c++2/src_simulator/Slave.h @@ -49,7 +49,7 @@ class Master; class TMLTransaction; ///Base class for Bus slaves -class Slave: public ListenerSubject<TransactionListener> { +class Slave: public ListenerSubject <TransactionListener> { public: ///Constructor Slave(unsigned int iID, std::string iName):_name(iName), _ID(iID) {} @@ -68,7 +68,8 @@ public: std::string toString() {return _name;} ///Adds the transaction determined by the scheduling algorithm to the internal list of scheduled transactions virtual void addTransaction(TMLTransaction* iTrans){ - FOR_EACH_TRANSLISTENER (*i)->transExecuted(iTrans); + //FOR_EACH_TRANSLISTENER (static_cast<TransactionListener*>(*i))->transExecuted(iTrans); + NOTIFY_TRANS_EXECUTED(iTrans); } ///Returns the unique ID of the Slave /** diff --git a/simulators/c++2/src_simulator/TMLActionCommand.cpp b/simulators/c++2/src_simulator/TMLActionCommand.cpp index c02fcd65b5..c766a1c1a7 100644 --- a/simulators/c++2/src_simulator/TMLActionCommand.cpp +++ b/simulators/c++2/src_simulator/TMLActionCommand.cpp @@ -51,7 +51,7 @@ void TMLActionCommand::execute(){ TMLCommand* TMLActionCommand::prepareNextTransaction(){ if (_simComp->getStopFlag()){ - std::cout << "aSimStopped=true " << std::endl; + //std::cout << "aSimStopped=true " << std::endl; _task->setCurrCommand(this); return this; //for command which generates transactions this is returned anyway by prepareTransaction } @@ -59,7 +59,8 @@ TMLCommand* TMLActionCommand::prepareNextTransaction(){ //std::cout << "Action func CALLED length: " << *_pLength << " progress:" << _progress << std::endl; (_task->*_actionFunc)(); _task->setCurrCommand(aNextCommand); - FOR_EACH_CMDLISTENER (*i)->commandFinished(this); + //FOR_EACH_CMDLISTENER (*i)->commandFinished(this); + NOTIFY_CMD_FINISHED(this); if (aNextCommand!=0) return aNextCommand->prepare(false); return 0; } diff --git a/simulators/c++2/src_simulator/TMLChannel.h b/simulators/c++2/src_simulator/TMLChannel.h index 3da6799d8c..3b52beea3c 100644 --- a/simulators/c++2/src_simulator/TMLChannel.h +++ b/simulators/c++2/src_simulator/TMLChannel.h @@ -54,7 +54,7 @@ class TMLTask; class Bus; ///This class defines the basic interfaces and functionalites of a TML channel. All specific channels are derived from this base class. A channel is able to convey data and events. -class TMLChannel: public Serializable, public ListenerSubject<TransactionListener>{ +class TMLChannel: public Serializable, public ListenerSubject <TransactionListener> { public: ///Constructor /** diff --git a/simulators/c++2/src_simulator/TMLChoiceCommand.cpp b/simulators/c++2/src_simulator/TMLChoiceCommand.cpp index bd7ddced89..d901727915 100644 --- a/simulators/c++2/src_simulator/TMLChoiceCommand.cpp +++ b/simulators/c++2/src_simulator/TMLChoiceCommand.cpp @@ -63,7 +63,7 @@ TMLCommand* TMLChoiceCommand::getNextCommand() const{ TMLCommand* TMLChoiceCommand::prepareNextTransaction(){ if (_simComp->getStopFlag()){ - std::cout << "aSimStopped=true " << std::endl; + //std::cout << "aSimStopped=true " << std::endl; _task->setCurrCommand(this); return this; //for command which generates transactions this is returned anyway by prepareTransaction } @@ -72,7 +72,8 @@ TMLCommand* TMLChoiceCommand::prepareNextTransaction(){ _indexNextCommand=(_task->*_condFunc)(); TMLCommand* aNextCommand=getNextCommand(); _task->setCurrCommand(aNextCommand); - FOR_EACH_CMDLISTENER (*i)->commandFinished(this); + //FOR_EACH_CMDLISTENER (*i)->commandFinished(this); + NOTIFY_CMD_FINISHED(this); if (aNextCommand!=0) return aNextCommand->prepare(false); return 0; } diff --git a/simulators/c++2/src_simulator/TMLCommand.cpp b/simulators/c++2/src_simulator/TMLCommand.cpp index d51139cb45..0dc15c2be3 100644 --- a/simulators/c++2/src_simulator/TMLCommand.cpp +++ b/simulators/c++2/src_simulator/TMLCommand.cpp @@ -72,7 +72,8 @@ TMLCommand* TMLCommand::prepare(bool iInit){ if(_length==_progress){ TMLCommand* aNextCommand; //std::cout << "COMMAND FINISHED!!n"; - FOR_EACH_CMDLISTENER (*i)->commandFinished(this); + //FOR_EACH_CMDLISTENER (*i)->commandFinished(this); + NOTIFY_CMD_FINISHED(this); _progress=0; //std::cout << "Prepare command, get next command" << std::endl; aNextCommand=getNextCommand(); @@ -94,10 +95,12 @@ TMLCommand* TMLCommand::prepare(bool iInit){ //_simStopped=false; if (_progress==0) //FOR_EACH_CMDLISTENER _simStopped|= (*i)->commandEntered(this); - FOR_EACH_CMDLISTENER (*i)->commandEntered(this); + //FOR_EACH_CMDLISTENER (*i)->commandEntered(this); + NOTIFY_CMD_ENTERED(this); else //FOR_EACH_CMDLISTENER _simStopped|= (*i)->commandExecuted(this); - FOR_EACH_CMDLISTENER (*i)->commandExecuted(this); + //FOR_EACH_CMDLISTENER (*i)->commandExecuted(this); + NOTIFY_CMD_EXECUTED(this); //std::cout << "Prepare next transaction" << std::endl; //if (_simStopped){ //if (_simComp->getStopFlag()){ diff --git a/simulators/c++2/src_simulator/TMLCommand.h b/simulators/c++2/src_simulator/TMLCommand.h index b6124fb5f7..2891b46d4e 100644 --- a/simulators/c++2/src_simulator/TMLCommand.h +++ b/simulators/c++2/src_simulator/TMLCommand.h @@ -53,7 +53,7 @@ class Comment; class SimComponents; ///This class defines the basic interfaces and functionalites of a TML command. All specific commands are derived from this base class. -class TMLCommand: public Serializable, public ListenerSubject<CommandListener>{ +class TMLCommand: public Serializable, public ListenerSubject <CommandListener> { public: ///Constructor /** diff --git a/simulators/c++2/src_simulator/TMLEventBChannel.cpp b/simulators/c++2/src_simulator/TMLEventBChannel.cpp index fc6d64fe03..d1896fe6af 100644 --- a/simulators/c++2/src_simulator/TMLEventBChannel.cpp +++ b/simulators/c++2/src_simulator/TMLEventBChannel.cpp @@ -102,7 +102,8 @@ void TMLEventBChannel::write(TMLTransaction* iTrans){ _readTrans->setRunnableTime(iTrans->getEndTime()); _readTrans->setVirtualLength(WAIT_SEND_VLEN); } - FOR_EACH_TRANSLISTENER (*i)->transExecuted(iTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(iTrans); + NOTIFY_WRITE_TRANS_EXECUTED(iTrans); } bool TMLEventBChannel::read(){ @@ -121,7 +122,8 @@ bool TMLEventBChannel::read(){ _paramQueue.pop_front(); //NEW //} //std::cout << "after if" << std::endl; - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + NOTIFY_READ_TRANS_EXECUTED(_readTrans); _readTrans=0; return true; } diff --git a/simulators/c++2/src_simulator/TMLEventFBChannel.cpp b/simulators/c++2/src_simulator/TMLEventFBChannel.cpp index c39a1136ce..6f7ec45f37 100644 --- a/simulators/c++2/src_simulator/TMLEventFBChannel.cpp +++ b/simulators/c++2/src_simulator/TMLEventFBChannel.cpp @@ -66,7 +66,8 @@ void TMLEventFBChannel::write(){ _readTrans->setRunnableTime(_writeTrans->getEndTime()); _readTrans->setVirtualLength(WAIT_SEND_VLEN); } - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + NOTIFY_WRITE_TRANS_EXECUTED(_writeTrans); _writeTrans=0; } @@ -83,7 +84,8 @@ bool TMLEventFBChannel::read(){ _writeTrans->setRunnableTime(_readTrans->getEndTime()); _writeTrans->setVirtualLength(WAIT_SEND_VLEN); } - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + NOTIFY_READ_TRANS_EXECUTED(_readTrans); _readTrans=0; return true; } diff --git a/simulators/c++2/src_simulator/TMLEventFChannel.cpp b/simulators/c++2/src_simulator/TMLEventFChannel.cpp index 6c4e4375eb..e1c95306e3 100644 --- a/simulators/c++2/src_simulator/TMLEventFChannel.cpp +++ b/simulators/c++2/src_simulator/TMLEventFChannel.cpp @@ -68,7 +68,8 @@ void TMLEventFChannel::write(){ _readTrans->setVirtualLength(WAIT_SEND_VLEN); } } - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + NOTIFY_WRITE_TRANS_EXECUTED(_writeTrans); _writeTrans=0; } @@ -81,7 +82,8 @@ bool TMLEventFChannel::read(){ if (_readTrans->getCommand()->getParamFuncPointer()!=0) (_readTask->*(_readTrans->getCommand()->getParamFuncPointer()))(_paramQueue.front()); //NEW _paramQueue.pop_front(); //NEW //} - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + NOTIFY_READ_TRANS_EXECUTED(_readTrans); _readTrans=0; return true; } diff --git a/simulators/c++2/src_simulator/TMLTask.cpp b/simulators/c++2/src_simulator/TMLTask.cpp index 26f307a8d3..0d7343c652 100644 --- a/simulators/c++2/src_simulator/TMLTask.cpp +++ b/simulators/c++2/src_simulator/TMLTask.cpp @@ -119,7 +119,8 @@ void TMLTask::addTransaction(TMLTransaction* iTrans){ _transactList.push_back(iTrans); _endLastTransaction=iTrans->getEndTime(); _busyCycles+=iTrans->getOperationLength(); - FOR_EACH_TRANSLISTENER (*i)->transExecuted(iTrans); + //FOR_EACH_TASKLISTENER (*i)->transExecuted(iTrans); + NOTIFY_TASK_TRANS_EXECUTED(iTrans); if(iTrans->getChannel()==0){ _noCPUTransactions++; _CPUContentionDelay+=iTrans->getStartTime()-iTrans->getRunnableTime(); diff --git a/simulators/c++2/src_simulator/TMLTask.h b/simulators/c++2/src_simulator/TMLTask.h index 880a8ad57a..6025a370d9 100644 --- a/simulators/c++2/src_simulator/TMLTask.h +++ b/simulators/c++2/src_simulator/TMLTask.h @@ -48,7 +48,7 @@ Ludovic Apvrille, Renaud Pacalet #include <Comment.h> #include <MemPool.h> #include <ListenerSubject.h> -#include <TransactionListener.h> +#include <TaskListener.h> class TMLCommand; class CPU; @@ -61,7 +61,7 @@ enum vcdTaskVisState START_TRANS }; -class TMLTask: public TraceableDevice, public Serializable, public ListenerSubject<TransactionListener>{ +class TMLTask: public TraceableDevice, public Serializable, public ListenerSubject <TaskListener>{ public: ///Constructor /** diff --git a/simulators/c++2/src_simulator/TMLTransaction.h b/simulators/c++2/src_simulator/TMLTransaction.h index 92a6bc876c..f2576bae6e 100644 --- a/simulators/c++2/src_simulator/TMLTransaction.h +++ b/simulators/c++2/src_simulator/TMLTransaction.h @@ -198,8 +198,6 @@ protected: ///Branching penalty unsigned int _branchingPenalty; #endif - /////Task terminated flag - //bool _terminated; ///Channel on which data was conveyed TMLChannel* _channel; ///Memory pool for transactions diff --git a/simulators/c++2/src_simulator/TMLbrbwChannel.cpp b/simulators/c++2/src_simulator/TMLbrbwChannel.cpp index 5b613a9864..80c36ad16b 100644 --- a/simulators/c++2/src_simulator/TMLbrbwChannel.cpp +++ b/simulators/c++2/src_simulator/TMLbrbwChannel.cpp @@ -64,7 +64,8 @@ void TMLbrbwChannel::write(){ _content+=_writeTrans->getVirtualLength(); _nbToWrite=0; if (_readTrans!=0 && _readTrans->getVirtualLength()==0) _readTrans->setRunnableTime(_writeTrans->getEndTime()); - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + NOTIFY_WRITE_TRANS_EXECUTED(_writeTrans); _writeTrans=0; setTransactionLength(); } @@ -76,7 +77,8 @@ bool TMLbrbwChannel::read(){ _content-=_readTrans->getVirtualLength(); _nbToRead=0; if (_writeTrans!=0 && _writeTrans->getVirtualLength()==0) _writeTrans->setRunnableTime(_readTrans->getEndTime()); - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + NOTIFY_READ_TRANS_EXECUTED(_readTrans); _readTrans=0; setTransactionLength(); return true; diff --git a/simulators/c++2/src_simulator/TMLbrnbwChannel.cpp b/simulators/c++2/src_simulator/TMLbrnbwChannel.cpp index 4f363cf657..5f945df3e4 100644 --- a/simulators/c++2/src_simulator/TMLbrnbwChannel.cpp +++ b/simulators/c++2/src_simulator/TMLbrnbwChannel.cpp @@ -62,7 +62,8 @@ void TMLbrnbwChannel::write(){ _content+=_writeTrans->getVirtualLength(); _nbToWrite=0; if (_readTrans!=0 && _readTrans->getVirtualLength()==0) _readTrans->setRunnableTime(_writeTrans->getEndTime()); - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + NOTIFY_WRITE_TRANS_EXECUTED(_writeTrans); _writeTrans=0; setTransactionLength(); } @@ -73,7 +74,8 @@ bool TMLbrnbwChannel::read(){ }else{ _content-=_readTrans->getVirtualLength(); _nbToRead=0; - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + NOTIFY_READ_TRANS_EXECUTED(_readTrans); _readTrans=0; setTransactionLength(); return true; diff --git a/simulators/c++2/src_simulator/TMLnbrnbwChannel.cpp b/simulators/c++2/src_simulator/TMLnbrnbwChannel.cpp index 3952b9458c..6f25a0c987 100644 --- a/simulators/c++2/src_simulator/TMLnbrnbwChannel.cpp +++ b/simulators/c++2/src_simulator/TMLnbrnbwChannel.cpp @@ -55,12 +55,14 @@ void TMLnbrnbwChannel::testRead(TMLTransaction* iTrans){ } void TMLnbrnbwChannel::write(){ - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_writeTrans); + NOTIFY_WRITE_TRANS_EXECUTED(_writeTrans); _writeTrans=0; } bool TMLnbrnbwChannel::read(){ - FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + //FOR_EACH_TRANSLISTENER (*i)->transExecuted(_readTrans); + NOTIFY_READ_TRANS_EXECUTED(_readTrans); _readTrans=0; return true; } diff --git a/simulators/c++2/src_simulator/TaskAbstr.h b/simulators/c++2/src_simulator/TaskAbstr.h new file mode 100644 index 0000000000..d0105132f2 --- /dev/null +++ b/simulators/c++2/src_simulator/TaskAbstr.h @@ -0,0 +1,83 @@ +/*Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Daniel Knorreck, +Ludovic Apvrille, Renaud Pacalet + * + * ludovic.apvrille AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + */ + +#ifndef TaskAbstrH +#define TaskAbstrH +#include <TMLTask.h> + +class TaskAbstr{ +public: + ///Constructor + /** + \param iTask Pointer to Task object which shall be encapsulated + */ + TaskAbstr(TMLTask* iTask):_task(iTask) { + } + ///Destructor + ~TaskAbstr(){ + } + ///Returns the priority of the task + /** + \return Priority + */ + inline unsigned int getPriority() const{ + return _task->getPriority(); + } + + ///Returns the name of the task + /** + \return Name of the task + */ + inline std::string getName() const{ + return _task->toString(); + } + ///Returns the unique ID of the task + /** + \return Unique ID + */ + inline unsigned int getID() const{ + return _task->getID(); + } + //getExecTime() + //getAvContDelay() +private: + TMLTask* _task; +}; +#endif diff --git a/simulators/c++2/src_simulator/TransactionAbstr.h b/simulators/c++2/src_simulator/TransactionAbstr.h new file mode 100644 index 0000000000..edf782cbfd --- /dev/null +++ b/simulators/c++2/src_simulator/TransactionAbstr.h @@ -0,0 +1,88 @@ +/*Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Daniel Knorreck, +Ludovic Apvrille, Renaud Pacalet + * + * ludovic.apvrille AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + */ + +#ifndef TransactionAbstrH +#define TransactionAbstrH +#include<TMLTransaction.h> + +class TransactionAbstr{ +public: + ///Constructor + /** + \param iTrans Pointer to Transaction object which shall be encapsulated + */ + TransactionAbstr(TMLTransaction* iTrans): _trans(iTrans){ + } + ///Destructor + ~TransactionAbstr(){ + } + ///Returns the time when the transaction became runnable + /** + \return Runnable time + */ + inline TMLTime getRunnableTime() const{ + return _trans->getRunnableTime(); + } + ///Returns the start time of the transaction + /** + \return Start time + */ + inline TMLTime getStartTime() const{ + return _trans->getStartTime(); + } + ///Returns the length of the operation and penalties + /** + \return Overall transaction length + */ + inline TMLTime getLength() const{ + return _trans->getOverallLength(); + } + ///Returns the virtual length of the transaction (number of execution units already carried out by previous transactions) + /** + \return Virtual length + */ + inline TMLLength getVirtualLength() const{ + return _trans->getVirtualLength(); + } +private: + TMLTransaction* _trans; + +}; +#endif diff --git a/simulators/c++2/src_simulator/TransactionListener.h b/simulators/c++2/src_simulator/TransactionListener.h index 73251dc54c..aebf631681 100644 --- a/simulators/c++2/src_simulator/TransactionListener.h +++ b/simulators/c++2/src_simulator/TransactionListener.h @@ -40,7 +40,10 @@ Ludovic Apvrille, Renaud Pacalet #ifndef TransactionListenerH #define TransactionListenerH -#define FOR_EACH_TRANSLISTENER for(std::list<TransactionListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) +//#define FOR_EACH_TRANSLISTENER for(std::list<TransactionListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) +#define NOTIFY_TRANS_EXECUTED(iTrans) for(std::list<TransactionListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) (*i)->transExecuted(iTrans) +#define NOTIFY_WRITE_TRANS_EXECUTED(iTrans) for(std::list<TransactionListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) (*i)->transExecuted(iTrans) +#define NOTIFY_READ_TRANS_EXECUTED(iTrans) for(std::list<TransactionListener*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) (*i)->transExecuted(iTrans) ///Encapsulates events associated with transactions class TransactionListener{ @@ -50,13 +53,13 @@ public: \param iTrans Pointer to the transaction \return true if simulation is stopped */ - virtual bool transExecuted(TMLTransaction* iTrans){return false;}; - ///Gets called when a transaction is scheduled - /** - \param iTrans Pointer to the transaction - \return true if simulation is stopped - */ - virtual bool transScheduled(TMLTransaction* iTrans){return false;}; + virtual bool transExecuted(TMLTransaction* iTrans){return false;} + /////Gets called when a transaction is scheduled + ////** + //\param iTrans Pointer to the transaction + //\return true if simulation is stopped + //*/ + //virtual bool transScheduled(TMLTransaction* iTrans){return false;} ///Destructor virtual ~TransactionListener(){} protected: -- GitLab