diff --git a/simulators/c++2/src_simulator/Bus.cpp b/simulators/c++2/src_simulator/Bus.cpp index 613c49134ddc8309d9e68c552c6c24c10c1b3bc2..7830250d4bbf6b955026d619d6770f3bbd21fa67 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 0000000000000000000000000000000000000000..d81a422801bd448c32bb7457521c969ff93ac11a --- /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 b683468b85e5c0ee25725098bedae6ca7d7fc365..0de4926992c52e35fcba2cb48035c523e9a39fd8 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 0000000000000000000000000000000000000000..0ab07100089394907953dc2c586a9fe5ae6a6985 --- /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 ff23b09477318d0817e69e66960cea5f4cd0ab7c..494ef6e4524cdfaa5991a67367d8e4d59dd46924 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 ea7f7bd38d17b7a33d9ae008d11f3e482a90d426..60daccf75813dbd8cc78d682da99166eb9b2f3b7 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 4f90fcdce2bf8d12c9de0eae60cfbc11f27f96b9..d4a23cad95b2dde61328f4a0b8e9694562040f55 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 0000000000000000000000000000000000000000..31f842a2cdd2c5cc9bab134738979057e7267b83 --- /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 0000000000000000000000000000000000000000..9cd93f67d09662b09cfe7610e05c8d8182d04fc1 --- /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 7fb8c58c9083b83c0e99c55b77b610dad1219c4d..1fb07de9bdd17a5ff7d405a57dc906216d224f4a 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 31571fdd6371a8f0926de89b1b260632c0c60935..02637ba7926ff6ed5ce44ac84823ab1d06f55615 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 0048403ec97a4aca3ddc10eee0842e7c388412ee..24a086f51b4c586364d0fe37689be092f467221e 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 3c3930c3a077ec0f551504d2583ec8959a28fc9f..5c5af3c7be7ce9514eb400e7d2992e280216a3f6 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 17036b8d63a869500f22ef3d642d604635877135..f30a80ccd59ed37af6f16dad58419490e65e60ed 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 c7c5445ad5abaf3162b1eefee2a8eb457d4c682a..3c20367a2c479fd243421ca9af4addc2f4e6f078 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 af1c46c516d3edf3d7b2c1d74e0d110ef35ebfdd..40f02646cbba053483f3982d5ad024b6df267551 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 c02fcd65b503284ebe69a887a26e480433e9f20e..c766a1c1a7e21b9448a20b7f566c669a62851ee8 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 3da6799d8c5b2f7c7c064c0f0d4c86fb9c705f79..3b52beea3c4b6e346701dda250a400a1bee6475d 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 bd7ddced890e64ac516b8e722fe0506dcdc93a56..d90172791564ddd429fa56962117eea94427a10a 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 d51139cb45be4fb7d53841fabf0bcbd433e97156..0dc15c2be3b1086d7d4d1cbadf5add140c003ec7 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 b6124fb5f758c6f0890578bc1b40f28c6556fc0b..2891b46d4e90015a54632fd34e1036779d150551 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 fc6d64fe031cecb029300697400ca105cd81252d..d1896fe6afa816aabd1f342de675e0a647bf3945 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 c39a1136ce48494bd1d9a516baca28811361f637..6f7ec45f37a853f3b579f97797da505a039c53a9 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 6c4e4375eb94d0c758973641bae9eebd4e9a9358..e1c95306e3919b8d33dbcca87a1352df199dfb02 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 26f307a8d3888245a7fcfdc7d607786b9d96e83a..0d7343c652f84e8371194006ffa3bdad53c48423 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 880a8ad57a8c7cbdc4d39c49448505dcdc458c73..6025a370d96e4661fda8020e4be2739d60c85e43 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 92a6bc876c1d6c1f274e7624b4838077edee4382..f2576bae6eb163212df207c46cf7a7d5c2ac60ec 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 5b613a9864dfd02919a4c9d51d2d69a75b04df02..80c36ad16b882ffa50b5d5cca178a2c863e63a04 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 4f363cf65777f23417bd7a82827c7066aae7e69a..5f945df3e4167c24521ee45313619d6ea7b91853 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 3952b9458cc65704d23c822dacc66979189d2c88..6f25a0c987ffc78b49d3111fb275ffad1da0cf3d 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 0000000000000000000000000000000000000000..d0105132f2f2ee95b71af3364606abc924b4aad2 --- /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 0000000000000000000000000000000000000000..edf782cbfd7834de1a7e7bd67cd73042f413f960 --- /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 73251dc54c73849763dc46d3d6c41be03c9f5216..aebf63168103f62e8b5ca2f79b5a3250f0a26675 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: