diff --git a/simulators/c++2/Makefile b/simulators/c++2/Makefile index e0127f50cbe9af4aac3239dd038f32b3bda32870..ebac9443b080f53d6639131b90ff62a4ab4ff794 100755 --- a/simulators/c++2/Makefile +++ b/simulators/c++2/Makefile @@ -12,9 +12,9 @@ LOPT = -O1 -pthread -ldl DEBUG = -g OTHER = -Wall TRY = -Wno-deprecated -CFLAGS = $(OPT) $(OTHER) $(TRY) +#CFLAGS = $(OPT) $(OTHER) $(TRY) LFLAGS = $(LOPT) $(OTHER) $(TRY) -#CFLAGS = $(DEBUG) $(OTHER) +CFLAGS = $(DEBUG) $(OTHER) OBJDIR = lib MODULE = run diff --git a/simulators/c++2/src_simulator/TEPE/AliasConstraint.cpp b/simulators/c++2/src_simulator/TEPE/AliasConstraint.cpp index 7d0a520ffb9156a59201867fe341f20337a23f74..85662ead74f1ffa3df4ab7fd094be2215d27c1d3 100644 --- a/simulators/c++2/src_simulator/TEPE/AliasConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/AliasConstraint.cpp @@ -47,9 +47,11 @@ void AliasConstraint::evalInput(){ //if (_rightConstr==0) std::cout << "Not connected\n"; //if (_s1Notified==UNDEF) std::cout << "s1 undef\n"; //if (_s2Notified==UNDEF) std::cout << "s2 undef\n"; - if (!( _s1Notified==UNDEF || _s2Notified==UNDEF || _rightConstr==0)){ + //if (!( _s1Notified==UNDEF || _s2Notified==UNDEF || _rightConstr==0)){ + if (!( _s1Notified==UNDEF || _s2Notified==UNDEF)){ //std::cout << "Allright\n"; - (_rightConstr->*_ntfFuncSigOut)(_s1Notified==TRUE || _s2Notified==TRUE); + //(_rightConstr->*_ntfFuncSigOut)(_s1Notified==TRUE || _s2Notified==TRUE); + notifyRightConstraints(_s1Notified==TRUE || _s2Notified==TRUE); notifiedReset(); }//else //std::cout << "Something is wrong\n"; diff --git a/simulators/c++2/src_simulator/TEPE/EqConstraint.cpp b/simulators/c++2/src_simulator/TEPE/EqConstraint.cpp index 6519f01c46753e0a6cf9881807b8dd5b8ae6de01..95047a290ebbef0c0cb1b421489504cb0516f905 100644 --- a/simulators/c++2/src_simulator/TEPE/EqConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/EqConstraint.cpp @@ -73,41 +73,31 @@ std::istream& EqConstraint::readObject(std::istream& s){ void EqConstraint::evalInput(){ if (!(_enabledNotified==UNDEF || _s1Notified==UNDEF)){ - if(_enabledNotified==TRUE && _includeBounds){ //early enable - - //std::cout << "Enabled\n"; - _constrEnabled=true; + if(_enabledNotified==TRUE){ //early enable + _constrEnabled = (_disabledNotified==FALSE); _propReported = false; //why do we need that? --> failure may otherwise not be reported if _eqResult==true } - if (_disabledNotified==TRUE && !_includeBounds) _constrEnabled=false; //early disable - + bool aRelevantEqResult=_eqResult; if (_s1Notified==TRUE){ //sigout and enable/disable notifications for connected operators if (_eqResult){ _eqResult=false; - //if (_aboveConstr!=0) _aboveConstr[0]->notifyEnable(1); - if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(false); + notifyRightConstraints(false); }else{ _eqResult=true; - //if (_aboveConstr!=0) _aboveConstr[0]->notifyEnable(2); - if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(true); + notifyRightConstraints(true); } }else{ - //if (_aboveConstr!=0) _aboveConstr[0]->notifyEnable(0); - if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(false); + notifyRightConstraints(false); } + if (_includeBounds ) aRelevantEqResult=_eqResult; - if (_constrEnabled && (!_eqResult) && (!_propReported)){ //report failure + std::cout << "Enabled: " << _constrEnabled << " eqresult: " << _eqResult << " reported: " << _propReported <<"\n"; + if (_constrEnabled && (!aRelevantEqResult) && (!_propReported)){ //report failure reportPropOccurrence(false); - //std::cout << "Report occurrence of Eq: 0\n"; + std::cout << "Report occurrence of Eq: 0\n"; _propReported = true; } - - _constrEnabled |= (_enabledNotified==TRUE); - /*if (!_constrEnabled && _enabledNotified==TRUE && _disabledNotified==FALSE){ //enable - //_constrEnabled = true; - //_propReported = false; - }*/ if (_disabledNotified==TRUE){ //disable, report success //std::cout << " DIsable*********************************************\n"; if (!_propReported){ @@ -119,5 +109,4 @@ void EqConstraint::evalInput(){ } notifiedReset(); } - //if (_disabledNotified==TRUE) std::cout << "Blooooooooocked!!!!\n"; } diff --git a/simulators/c++2/src_simulator/TEPE/FSMConstraint.cpp b/simulators/c++2/src_simulator/TEPE/FSMConstraint.cpp index 4c1a3a6fe70035a40c5c784b59432042930726fd..aa9e0f0ee35d6b58dd09d40817719e5ffce2ad32 100644 --- a/simulators/c++2/src_simulator/TEPE/FSMConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/FSMConstraint.cpp @@ -94,7 +94,8 @@ void FSMConstraint::evalInput(){ } notifiedReset(); if (_aboveConstr!=0) _aboveConstr[0]->notifyEnable(aEnableFlag); - if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(aSigOutFlag); + //if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(aSigOutFlag); + notifyRightConstraints(aSigOutFlag); //if (aSigOutFlag || !aPropResult) reportPropOccurrence(aPropResult); if (aSigOutFlag || ((aEnableFlag & 1)!=0 && !aPropResult) ){ //if (aSigOutFlag || (aEnableFlag & 1)!=0){ diff --git a/simulators/c++2/src_simulator/TEPE/PropLabConstraint.cpp b/simulators/c++2/src_simulator/TEPE/PropLabConstraint.cpp index 17b05d164c05fd1365614026daa74cfef372db8a..dc7e1178a0f0b838fbc36529facf9c3dc397abc5 100644 --- a/simulators/c++2/src_simulator/TEPE/PropLabConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/PropLabConstraint.cpp @@ -70,16 +70,16 @@ void PropLabConstraint::notifyEnable(unsigned int iSigState){ } std::ostream& PropLabConstraint::writeObject(std::ostream& s){ - unsigned char aTmp = (_property)?1:0; - WRITE_STREAM(s, aTmp); + //unsigned char aTmp = (_property)?1:0; + //WRITE_STREAM(s, aTmp); _aboveConstr[0]->writeObject(s); return s; } std::istream& PropLabConstraint::readObject(std::istream& s){ - unsigned char aTmp; - READ_STREAM(s, aTmp); - _property = (aTmp ==1); + //unsigned char aTmp; + //READ_STREAM(s, aTmp); + //_property = (aTmp ==1); _aboveConstr[0]->readObject(s); return s; } diff --git a/simulators/c++2/src_simulator/TEPE/PropRelConstraint.cpp b/simulators/c++2/src_simulator/TEPE/PropRelConstraint.cpp index 7b5ecae16d79e452cf8fe03cd13b97de7847cec6..4b3740fb1ce430d560fda5681ee578d854af2d68 100644 --- a/simulators/c++2/src_simulator/TEPE/PropRelConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/PropRelConstraint.cpp @@ -75,3 +75,6 @@ std::ostream& PropRelConstraint::writeObject(std::ostream& s){ std::istream& PropRelConstraint::readObject(std::istream& s){ return s; } + +void PropRelConstraint::reset(){ +} \ No newline at end of file diff --git a/simulators/c++2/src_simulator/TEPE/PropRelConstraint.h b/simulators/c++2/src_simulator/TEPE/PropRelConstraint.h index 19c355d6c50094368bed487c0eb275227d19163d..edc55a82154311a4d0411db807be8c525861959a 100644 --- a/simulators/c++2/src_simulator/TEPE/PropRelConstraint.h +++ b/simulators/c++2/src_simulator/TEPE/PropRelConstraint.h @@ -52,6 +52,7 @@ public: void notifyEnable(unsigned int iSigState); std::ostream& writeObject(std::ostream& s); std::istream& readObject(std::istream& s); + void reset(); protected: PropRelType _type; }; diff --git a/simulators/c++2/src_simulator/TEPE/PropertyConstraint.cpp b/simulators/c++2/src_simulator/TEPE/PropertyConstraint.cpp index c11ee3977a56bcdb09303b8258c9ca33af41e9c5..791574c7ab8b000e09cea27c2854002aa012b840 100644 --- a/simulators/c++2/src_simulator/TEPE/PropertyConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/PropertyConstraint.cpp @@ -43,7 +43,11 @@ PropertyConstraint::PropertyConstraint():_aboveConstr(0), _noAboveConstr(0){ } PropertyConstraint::~PropertyConstraint(){ - if (_aboveConstr!=0) delete [] _aboveConstr; + if (_aboveConstr!=0){ + for (unsigned int i=0; i<_noAboveConstr; i++) + delete _aboveConstr[i]; + delete [] _aboveConstr; + } } std::ostream& PropertyConstraint::writeObject(std::ostream& s){ diff --git a/simulators/c++2/src_simulator/TEPE/PropertyStateConstraint.cpp b/simulators/c++2/src_simulator/TEPE/PropertyStateConstraint.cpp index 039899f0bd18f69c5aa3c979357a40c976cd24bc..9b93bed5e8448de977aa4d1e3712a26dbd241578 100644 --- a/simulators/c++2/src_simulator/TEPE/PropertyStateConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/PropertyStateConstraint.cpp @@ -39,6 +39,7 @@ Ludovic Apvrille, Renaud Pacalet */ #include <PropertyStateConstraint.h> +#include <SignalConstraint.h> PropertyStateConstraint::PropertyStateConstraint(PropType iType): _type(iType), _constrEnabled(false), _enabledNotified(UNDEF), _disabledNotified(UNDEF), _property(_type==GENERAL || _type == NFINALLY){ } @@ -53,6 +54,21 @@ bool PropertyStateConstraint::evalProp(){ void PropertyStateConstraint::notifyEnable(unsigned int iSigState){ _disabledNotified = ((iSigState & 1)==0)? FALSE:TRUE; _enabledNotified = ((iSigState & 2)==0)? FALSE:TRUE; + SignalConstraint* testSig= dynamic_cast<SignalConstraint*>(this); + if (testSig!=0){ + switch (iSigState){ + case 1: + std::cout << testSig->getID() << ": -d\n"; + break; + case 2: + std::cout << testSig->getID() << ": e-\n"; + break; + case 3: + std::cout << testSig->getID() << ": ed\n"; + break; + default: ; + } + } evalInput(); } @@ -67,6 +83,8 @@ void PropertyStateConstraint::reset(){ void PropertyStateConstraint::forceDisable(){ _constrEnabled=false; + if (_aboveConstr!=0) _aboveConstr[0]->forceDisable(); + } std::ostream& PropertyStateConstraint::writeObject(std::ostream& s){ diff --git a/simulators/c++2/src_simulator/TEPE/SignalConstraint.cpp b/simulators/c++2/src_simulator/TEPE/SignalConstraint.cpp index f661f90e733b2156806bdb38323d6d4307e8c9a3..ccdcad96d8b9fa253c913192b2229677b600c7ab 100644 --- a/simulators/c++2/src_simulator/TEPE/SignalConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/SignalConstraint.cpp @@ -39,8 +39,19 @@ Ludovic Apvrille, Renaud Pacalet */ #include <SignalConstraint.h> +#include <PropertyConstraint.h> -SignalConstraint::SignalConstraint(ID iID, bool iIncludeBounds): _ID(iID), _s1Notified(UNDEF), _ntfFuncSigOut(0), _rightConstr(0), _includeBounds(iIncludeBounds){ +SignalConstraint::SignalConstraint(ID iID, bool iIncludeBounds): _ID(iID), _s1Notified(UNDEF), /*_ntfFuncSigOut(0), _rightConstr(0),*/ _includeBounds(iIncludeBounds){ +} + +SignalConstraint::~SignalConstraint(){ + /*std::cout << "SignalConstraint Destructor\n"; + for(SignalNotificationList::const_iterator i=_rightConstraints.begin(); i != _rightConstraints.end(); ++i){ + if (dynamic_cast<PropertyConstraint*>(i->first)==0){ + delete i->first; + std::cout << "Delete done\n"; + } + }*/ } void SignalConstraint::notifyS1(bool iSigState){ @@ -59,8 +70,9 @@ void SignalConstraint::notifyS2(bool iSigState){} void SignalConstraint::notifySf(bool iSigState){} void SignalConstraint::connectSigOut(SignalConstraint* iRightConstr, NtfSigFuncPointer iNotFunc){ - _ntfFuncSigOut = iNotFunc; - _rightConstr = iRightConstr; + //_ntfFuncSigOut = iNotFunc; + //_rightConstr = iRightConstr; + _rightConstraints.push_back(std::pair<SignalConstraint*, NtfSigFuncPointer>(iRightConstr, iNotFunc)); } void SignalConstraint::notifiedReset(){ @@ -68,6 +80,16 @@ void SignalConstraint::notifiedReset(){ _s1Notified = UNDEF; } +void SignalConstraint::notifyRightConstraints(bool iSigState){ + for(SignalNotificationList::const_iterator i=_rightConstraints.begin(); i != _rightConstraints.end(); ++i){ + ((i->first)->*(i->second))(iSigState); + } +} + +ID SignalConstraint::getID(){ + return _ID; +} + //void SignalConstraint::setSimTime(TMLTime iSimTime){ // _simTime = iSimTime; //} diff --git a/simulators/c++2/src_simulator/TEPE/SignalConstraint.h b/simulators/c++2/src_simulator/TEPE/SignalConstraint.h index 947a7575fda0c3030cf20bab64c0d525d47965ee..89c030a128fba3c5f6fcddfc786c4ece0de93cd2 100644 --- a/simulators/c++2/src_simulator/TEPE/SignalConstraint.h +++ b/simulators/c++2/src_simulator/TEPE/SignalConstraint.h @@ -44,23 +44,26 @@ Ludovic Apvrille, Renaud Pacalet #include <definitions.h> class SignalConstraint; -typedef void (SignalConstraint::*NtfSigFuncPointer) (bool iSigState); class SignalConstraint{ public: SignalConstraint(ID iID, bool iIncludeBounds); + virtual ~SignalConstraint(); void notifyS1(bool iSigState); virtual void notifyS2(bool iSigState); virtual void notifySf(bool iSigState); void connectSigOut(SignalConstraint* iRightConstr, NtfSigFuncPointer iNotFunc); virtual void notifiedReset(); + ID getID(); //static void setSimTime(TMLTime iSimTime); protected: virtual void evalInput()=0; + void notifyRightConstraints(bool iSigState); ID _ID; Tristate _s1Notified; - NtfSigFuncPointer _ntfFuncSigOut; - SignalConstraint *_rightConstr; + //NtfSigFuncPointer _ntfFuncSigOut; + //SignalConstraint *_rightConstr; + SignalNotificationList _rightConstraints; bool _includeBounds; static TMLTime _simTime; }; diff --git a/simulators/c++2/src_simulator/TEPE/TimeMMConstraint.cpp b/simulators/c++2/src_simulator/TEPE/TimeMMConstraint.cpp index 5b5a341207865f9750661e7bf17aaa5e85b8d55e..251a5b1ade7ef2c6dbaf847ebd3477e4b94722b8 100644 --- a/simulators/c++2/src_simulator/TEPE/TimeMMConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/TimeMMConstraint.cpp @@ -109,6 +109,7 @@ void TimeMMConstraint::evalInput(){ } notifiedReset(); if (_aboveConstr!=0) _aboveConstr[0]->notifyEnable(aEnaFlag); - if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(aSigOut); + //if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(aSigOut); + notifyRightConstraints(aSigOut); } } diff --git a/simulators/c++2/src_simulator/TEPE/TimeTConstraint.cpp b/simulators/c++2/src_simulator/TEPE/TimeTConstraint.cpp index b7281d558ccfb0fb7aef2cc32b247c61c53c2db2..45afea1d6bfeabd5b26862ed16a872b82ee5276f 100644 --- a/simulators/c++2/src_simulator/TEPE/TimeTConstraint.cpp +++ b/simulators/c++2/src_simulator/TEPE/TimeTConstraint.cpp @@ -99,7 +99,7 @@ void TimeTConstraint::evalInput(){ } notifiedReset(); if (_aboveConstr!=0) _aboveConstr[0]->notifyEnable(aEnaFlag); - if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(aSigOut); - + //if (_rightConstr!=0) (_rightConstr->*_ntfFuncSigOut)(aSigOut); + notifyRightConstraints(aSigOut); } } diff --git a/simulators/c++2/src_simulator/definitions.h b/simulators/c++2/src_simulator/definitions.h index 2e364520f6e79fcdb000eff62cf0f132d723008f..0eb63b9853d0b9bea362b812a3cc053ea65c5502 100644 --- a/simulators/c++2/src_simulator/definitions.h +++ b/simulators/c++2/src_simulator/definitions.h @@ -85,7 +85,7 @@ using std::max; #define STATE_HASH_ENABLED #define LISTENERS_ENABLED #undef EBRDD_ENABLED -#define DOT_GRAPH_ENABLED +//#define DOT_GRAPH_ENABLED #define CLOCK_INC 20 #define BLOCK_SIZE 500000 @@ -199,8 +199,10 @@ class Slave; class Comment; class WorkloadSource; class BusMaster; +class GeneralListener; class EBRDD; class EBRDDCommand; +class SignalConstraint; ///Datatype used for time measurements typedef unsigned long long TMLTime; @@ -226,6 +228,12 @@ typedef std::list<Serializable*> SerializableList; typedef std::list<Slave*> SlaveList; ///Datatype used in SimComponents to store channel objects typedef std::list<TMLChannel*> ChannelList; +///Datatype used in SimComponents to store TEPE listeners +typedef std::list<GeneralListener*> TEPEListenerList; +///Datatype used in TEPEs to Point to a function to be notified upon a signal occurrence +typedef void (SignalConstraint::*NtfSigFuncPointer) (bool iSigState); +///Datatype used in TEPE SignalConstraints to store a list of right constraints to be notified upon a signal occurrence +typedef std::list<std::pair<SignalConstraint*, NtfSigFuncPointer> > SignalNotificationList; ///Type of a TMLCommand typedef enum {NONE=(1), EXE=(1<<1), RD=(1<<2), WR=(1<<3), SEL=(1<<4), SND=(1<<5), REQ=(1<<6), WAIT=(1<<7), NOTIF=(1<<8), ACT=(1<<9), CHO=(1<<10), RND=(1<<11), STP=(1<<12)} CommandType; @@ -250,7 +258,9 @@ typedef void (TMLTask::*ActionFuncPointer) (); ///Type of member function pointer used to indicate a function encapsulating a condition (for TMLChoiceCommand) typedef TMLTime (TMLTask::*LengthFuncPointer) (); ///Type of pointer to indicate a function encapsulating a TEPE condition -typedef bool (*EqFuncPointer)(ParamType**); +typedef bool (*EqFuncPointer)(ParamType**); +///Type of pointer to indicate a function encapsulating a TEPE setting +typedef ParamType (*SettingFuncPointer)(ParamType**); ///Type of pointer to indicate a function returning the random rage of a command typedef unsigned int (TMLTask::*RangeFuncPointer) (ParamType& oMin, ParamType& oMax); ///Type of member function pointer used to indicate a function encapsulating parameter manipulation (for TMLWaitCommand, TMLSendCommand) diff --git a/simulators/c++2/src_simulator/evt/ListenerSubject.h b/simulators/c++2/src_simulator/evt/ListenerSubject.h index b083d405f832e042efdaaac52b66b92a8ee19177..a13f02fef93a1070afcb785d3b0fbb1adee976eb 100644 --- a/simulators/c++2/src_simulator/evt/ListenerSubject.h +++ b/simulators/c++2/src_simulator/evt/ListenerSubject.h @@ -86,7 +86,12 @@ public: } ///Destructor - virtual ~ListenerSubject(){} + virtual ~ListenerSubject(){ + //listenersUnLock(); + //for(typename std::list<T*>::iterator i=_listeners.begin(); i != _listeners.end(); ++i) { + // delete (*i); + //} + } protected: ///List of listeners std::list<T*> _listeners; diff --git a/simulators/c++2/src_simulator/evt/ListenersSimCmd.cpp b/simulators/c++2/src_simulator/evt/ListenersSimCmd.cpp index a884e17ef4765f52de2f6903b5576a33e7fbe2c4..dce6ad3e06a7d008adff2a1fd7371b0d789938aa 100644 --- a/simulators/c++2/src_simulator/evt/ListenersSimCmd.cpp +++ b/simulators/c++2/src_simulator/evt/ListenersSimCmd.cpp @@ -332,18 +332,23 @@ TEPESigListener::TEPESigListener(ID* iSubjectIDs, unsigned int iNbOfSubjectIDs, } TEPESigListener::~TEPESigListener(){ - /*for (unsigned int i=0; i< nbOfSubjectIDs; i++){ - ListenerSubject <GeneralListener>* aSubject = iSimComp->getListenerByID(iSubjectIDs[i]); - if (aSubject!=0) aSubject->removeListener(this); - }*/ + std::cerr << "Delete Sig\n"; for (unsigned int i=0; i< _nbOfSubjectIDs; i++){ ListenerSubject <GeneralListener>* aSubject = _simComp->getListenerByID(_subjectIDs[i]); if (aSubject!=0) aSubject->removeListener(this); } + /*for (unsigned int i=0; i<_nbOfSignals; i++){ + std::cout << "loop\n"; + if (dynamic_cast<PropertyConstraint*>(_notifConstr[i])==0){ + delete _notifConstr[i]; + std::cout << "Delete done II\n"; + } + }*/ _simulator->removeListener(this); delete [] _subjectIDs; delete [] _notifConstr; delete [] _notifFunc; + std::cerr << "End Delete Sig\n"; } void TEPESigListener::simulationStarted(){ @@ -428,12 +433,18 @@ TEPEFloatingSigListener::TEPEFloatingSigListener(ListenerSubject<GeneralListener } TEPEFloatingSigListener::~TEPEFloatingSigListener(){ + std::cerr << "Delete Floating\n"; _simulator->removeListener(this); + for (unsigned int i=0; i<_nbOfStartNodes; i++){ + delete _startNodes[i]; + } delete [] _notifConstr; delete [] _notifFunc; delete [] _startNodes; + std::cerr << "End Delete Floating\n"; } void TEPEFloatingSigListener::timeAdvances(TMLTime iCurrTime){ + std::cout << "New simulation time: " << iCurrTime << "\n"; for (unsigned int i=0; i<_nbOfSignals; i++){ (_notifConstr[i]->*_notifFunc[i])(false); } @@ -462,17 +473,32 @@ void TEPEFloatingSigListener::simulationStopped(){ std::cout << "Eval Prop " << i << ": " << _startNodes[i]->evalProp() << "\n"; } +std::ostream& TEPEFloatingSigListener::writeObject(std::ostream& s){ + for (unsigned int i=0; i<_nbOfStartNodes; i++){ + _startNodes[i]->writeObject(s); + } +} + +std::istream& TEPEFloatingSigListener::readObject(std::istream& s){ + for (unsigned int i=0; i<_nbOfStartNodes; i++){ + _startNodes[i]->readObject(s); + } +} + +void TEPEFloatingSigListener::reset(){ + for (unsigned int i=0; i<_nbOfStartNodes; i++){ + _startNodes[i]->reset(); + } +} + + //*********************************************************************** -//bool EquationFunc(TMLTask** iTasks){ -//return iTasks[1]->a + iTasks[1]->b = iTasks[1]->c + iTasks[3]->e; -//} is friend of each Task in iTasks TEPEEquationListener::TEPEEquationListener(ID* iSubjectIDs, unsigned int iNbOfSubjectIDs, ParamType** iVar, EqFuncPointer iEqFunc, SignalConstraint* iNotifConstr, NtfSigFuncPointer iNotifFunc, SimComponents* iSimComp, ListenerSubject<GeneralListener>* iSimulator) : _subjectIDs(iSubjectIDs), _nbOfSubjectIDs(iNbOfSubjectIDs), _var(iVar), _eqFunc(iEqFunc), _eqResult(true), _notifConstr(iNotifConstr), _notifFunc(iNotifFunc), _sigNotified(false), _simComp(iSimComp), _simulator(iSimulator){ - std::cerr << "before func\n"; - //_eqResult = _eqFunc(_var); - std::cerr << "before loop\n"; + //std::cerr << "before func\n"; + //std::cerr << "before loop\n"; for (unsigned int i=0; i< _nbOfSubjectIDs; i++){ - std::cerr << "next id: " << _subjectIDs[i] << "\n"; + //std::cerr << "next id: " << _subjectIDs[i] << "\n"; ListenerSubject <GeneralListener>* aSubject = _simComp->getListenerByID(_subjectIDs[i]); if (aSubject!=0) aSubject->registerListener(this); } @@ -480,6 +506,7 @@ TEPEEquationListener::TEPEEquationListener(ID* iSubjectIDs, unsigned int iNbOfSu } TEPEEquationListener::~TEPEEquationListener(){ + std::cerr << "Delete Eq\n"; for (unsigned int i=0; i< _nbOfSubjectIDs; i++){ ListenerSubject <GeneralListener>* aSubject = _simComp->getListenerByID(_subjectIDs[i]); if (aSubject!=0) aSubject->removeListener(this); @@ -487,37 +514,99 @@ TEPEEquationListener::~TEPEEquationListener(){ _simulator->removeListener(this); delete [] _subjectIDs; delete [] _var; + std::cerr << "End Delete Eq\n"; } void TEPEEquationListener::commandFinished(TMLCommand* iComm, ID iID){ - /*if (_eqResult != _eqFunc(_var)){ - _eqResult = !_eqResult; - (_notifConstr->*_notifFunc)(true); - _sigNotified=true; - }*/ - //if several alternations of variables at the same time only last one is taken into account - _sigNotified = (_eqResult != _eqFunc(_var)); + //if several alternations of variables arise at the same time only last value is taken into account + //_sigNotified = (_eqResult != _eqFunc(_var)); + _sigNotified = true; std::cout << "Check equation result: " << _sigNotified << "\n"; } void TEPEEquationListener::timeAdvances(TMLTime iCurrTime){ if(_sigNotified){ _sigNotified=false; - (_notifConstr->*_notifFunc)(true); - _eqResult = !_eqResult; + bool aNewEqResult = _eqFunc(_var); + (_notifConstr->*_notifFunc)(_eqResult != aNewEqResult); + _eqResult = aNewEqResult; }else{ (_notifConstr->*_notifFunc)(false); } } void TEPEEquationListener::simulationStarted(){ - (_notifConstr->*_notifFunc)(false); + //(_notifConstr->*_notifFunc)(false); + bool aNewEqResult = _eqFunc(_var); + (_notifConstr->*_notifFunc)(_eqResult !=aNewEqResult); + _eqResult = aNewEqResult; } void TEPEEquationListener::simulationStopped(){ (_notifConstr->*_notifFunc)(false); } - + + +//*********************************************************************** +TEPESettingListener::TEPESettingListener(ID* iSubjectIDs, unsigned int iNbOfSubjectIDs, ParamType** iVar, SettingFuncPointer iSetFunc, unsigned int inbOfSignals, SignalConstraint** iNotifConstr, NtfSigFuncPointer* iNotifFunc, SimComponents* iSimComp, ListenerSubject<GeneralListener>* iSimulator): _subjectIDs(iSubjectIDs), _nbOfSubjectIDs(iNbOfSubjectIDs), _var(iVar), _setFunc(iSetFunc), _nbOfSignals(inbOfSignals), _setResult( _setFunc(_var)), _notifConstr(iNotifConstr), _notifFunc(iNotifFunc), _sigNotified(false), _simComp(iSimComp), _simulator(iSimulator){ + for (unsigned int i=0; i< _nbOfSubjectIDs; i++){ + //std::cerr << "next id: " << _subjectIDs[i] << "\n"; + ListenerSubject <GeneralListener>* aSubject = _simComp->getListenerByID(_subjectIDs[i]); + if (aSubject!=0) aSubject->registerListener(this); + } + _simulator->registerListener(this); +} + +TEPESettingListener::~TEPESettingListener(){ + std::cerr << "Delete Setting\n"; + for (unsigned int i=0; i< _nbOfSubjectIDs; i++){ + ListenerSubject <GeneralListener>* aSubject = _simComp->getListenerByID(_subjectIDs[i]); + if (aSubject!=0) aSubject->removeListener(this); + } + _simulator->removeListener(this); + delete [] _subjectIDs; + delete [] _var; + delete [] _notifConstr; + delete [] _notifFunc; + std::cerr << "End Delete Setting\n"; +} + +void TEPESettingListener::commandFinished(TMLCommand* iComm, ID iID){ + /*if (_eqResult != _eqFunc(_var)){ + _eqResult = !_eqResult; + (_notifConstr->*_notifFunc)(true); + _sigNotified=true; + }*/ + //if several alternations of variables at the same time only last one is taken into account + _sigNotified=true; + //std::cout << "Check setting result: " << _setNewResult << "\n"; +} + +void TEPESettingListener::timeAdvances(TMLTime iCurrTime){ + bool aSigNotification; + if (_sigNotified){ + ParamType aNewSetResult = _setFunc(_var); + _sigNotified=false; + aSigNotification = (_setResult != aNewSetResult); + _setResult = aNewSetResult; + }else{ + aSigNotification=false; + } + for (unsigned int i=0; i<_nbOfSignals; i++) + (_notifConstr[i]->*_notifFunc[i])(aSigNotification); +} + +void TEPESettingListener::simulationStarted(){ + for (unsigned int i=0; i<_nbOfSignals; i++) + (_notifConstr[i]->*_notifFunc[i])(false); +} + +void TEPESettingListener::simulationStopped(){ + for (unsigned int i=0; i<_nbOfSignals; i++) + (_notifConstr[i]->*_notifFunc[i])(false); +} + + //************************************************************************ /*TestListener::TestListener(SimComponents* iSimComp):_simComp(iSimComp){ } diff --git a/simulators/c++2/src_simulator/evt/ListenersSimCmd.h b/simulators/c++2/src_simulator/evt/ListenersSimCmd.h index 23daab5f3078edac7711435143a1e738c826f959..5aa79641f37e4332826c1141d6dccd045b814b2d 100644 --- a/simulators/c++2/src_simulator/evt/ListenersSimCmd.h +++ b/simulators/c++2/src_simulator/evt/ListenersSimCmd.h @@ -357,13 +357,16 @@ protected: }; //************************************************************************ -class TEPEFloatingSigListener: public GeneralListener{ +class TEPEFloatingSigListener: public GeneralListener, public Serializable{ public: TEPEFloatingSigListener(ListenerSubject<GeneralListener>* iSimulator, unsigned int inbOfSignals, SignalConstraint** iNotifConstr, NtfSigFuncPointer* iNotifFunc, unsigned int iNbOfStartNodes, PropertyConstraint** iStartNodes); ~TEPEFloatingSigListener(); void timeAdvances(TMLTime iCurrTime); void simulationStarted(); void simulationStopped(); + std::ostream& writeObject(std::ostream& s); + std::istream& readObject(std::istream& s); + void reset(); protected: ListenerSubject<GeneralListener>* _simulator; unsigned int _nbOfSignals; @@ -375,9 +378,6 @@ protected: //************************************************************************ class TEPEEquationListener: public GeneralListener{ - //bool EquationFunc(TMLTask** iTasks){ - //return iTasks[1]->a + iTasks[1]->b = iTasks[1]->c + iTasks[3]->e; - //} is friend of each Task in iTasks public: TEPEEquationListener(ID* iSubjectIDs, unsigned int iNbOfSubjectIDs, ParamType** iVar, EqFuncPointer iEqFunc, SignalConstraint* iNotifConstr, NtfSigFuncPointer iNotifFunc, SimComponents* iSimComp, ListenerSubject<GeneralListener>* iSimulator); ~TEPEEquationListener(); @@ -397,6 +397,29 @@ protected: SimComponents* _simComp; ListenerSubject<GeneralListener>* _simulator; }; + +//************************************************************************ +class TEPESettingListener: public GeneralListener{ +public: + TEPESettingListener(ID* iSubjectIDs, unsigned int iNbOfSubjectIDs, ParamType** iVar, SettingFuncPointer iSetFunc, unsigned int inbOfSignals, SignalConstraint** iNotifConstr, NtfSigFuncPointer* iNotifFunc, SimComponents* iSimComp, ListenerSubject<GeneralListener>* iSimulator); + ~TEPESettingListener(); + void commandFinished(TMLCommand* iComm, ID iID); + void timeAdvances(TMLTime iCurrTime); + void simulationStarted(); + void simulationStopped(); +protected: + ID* _subjectIDs; + unsigned int _nbOfSubjectIDs; + ParamType** _var; + SettingFuncPointer _setFunc; + unsigned int _nbOfSignals; + ParamType _setResult; + SignalConstraint** _notifConstr; + NtfSigFuncPointer* _notifFunc; + bool _sigNotified; + SimComponents* _simComp; + ListenerSubject<GeneralListener>* _simulator; +}; //************************************************************************ /*class TestListener: public TaskListener, public ChannelListener, public CommandListener{ diff --git a/simulators/c++2/src_simulator/sim/SimComponents.cpp b/simulators/c++2/src_simulator/sim/SimComponents.cpp index 51c60793e719e19730aac7e0bf7487e7adb8bb2e..4b86d30399623e9911d65e49cbbb98c6f4c0bf10 100644 --- a/simulators/c++2/src_simulator/sim/SimComponents.cpp +++ b/simulators/c++2/src_simulator/sim/SimComponents.cpp @@ -59,6 +59,13 @@ SimComponents::SimComponents(int iHashValue /*, Simulator* iSimulator*/): _simul } SimComponents::~SimComponents(){ + //std::cerr << "b1\n"; + for(TEPEListenerList::iterator i=_tepeListenerList.begin(); i != _tepeListenerList.end(); ++i){ + //std::cerr << "b...\n"; + delete (*i); + //std::cerr << "after b...\n"; + } + //std::cerr << "b2\n"; for(SerializableList::iterator i=_serList.begin(); i != _serList.end(); ++i){ delete (*i); } @@ -125,10 +132,14 @@ void SimComponents::addEBRDD(EBRDD* iEBRDD){ } #endif -void SimComponents::addTEPEConstraint(PropertyConstraint* iPropConstr){ - std::cout << "before add\n"; - _serList.push_back(dynamic_cast<Serializable*>(iPropConstr)); - std::cout << "after add\n"; +void SimComponents::addTEPEListener(GeneralListener* iTEPEListener){ + //std::cout << "before add\n"; + _tepeListenerList.push_back(iTEPEListener); + //std::cout << "after add\n"; +} + +void SimComponents::setTEPEEntryPoint(TEPEFloatingSigListener* iTEPEEntryPoint){ + _serList.push_back(dynamic_cast<Serializable*>(iTEPEEntryPoint)); } void SimComponents::streamBenchmarks(std::ostream& s) const{ @@ -251,14 +262,14 @@ TMLChannel* SimComponents::getChannelByName(const std::string& iChannel) const{ } SchedulableDevice* SimComponents::getCPUByID(ID iID) const{ - std::cerr << "getCPUByID " << iID << "\n"; - CPUList::const_iterator i=_cpuList.begin(); - std::cerr << "getCPUByID after i=_cpuList.begin()" << iID << "\n"; - for(/*CPUList::const_iterator i=_cpuList.begin()*/; i != _cpuList.end(); ++i){ - std::cout << "CPU x\n"; + //std::cerr << "getCPUByID " << iID << "\n"; + //CPUList::const_iterator i=_cpuList.begin(); + //std::cerr << "getCPUByID after i=_cpuList.begin()" << iID << "\n"; + for(CPUList::const_iterator i=_cpuList.begin(); i != _cpuList.end(); ++i){ + //std::cout << "CPU x\n"; if ((*i)->getID()==iID) return (*i); } - std::cout << "End CPU\n"; + //std::cout << "End CPU\n"; return NULL; } @@ -326,22 +337,22 @@ std::string SimComponents::getCmpNameByID(ID iID){ //ListenerSubject <TransactionListener>* SimComponents::getListenerByID(ID iID){ ListenerSubject <GeneralListener>* SimComponents::getListenerByID(ID iID){ - std::cerr << "Hello 1\n"; + //std::cerr << "Hello 1\n"; ListenerSubject <GeneralListener>* aListener = getCPUByID(iID); if (aListener!=0) return aListener; - std::cerr << "Hello 2\n"; + //std::cerr << "Hello 2\n"; aListener = TMLCommand::getCommandByID(iID); if (aListener!=0) return aListener; - std::cerr << "Hello 3\n"; + //std::cerr << "Hello 3\n"; aListener = getTaskByID(iID); if (aListener!=0) return aListener; - std::cerr << "Hello 4\n"; + //std::cerr << "Hello 4\n"; aListener = getBusByID(iID); if (aListener!=0) return aListener; - std::cerr << "Hello 5\n"; + //std::cerr << "Hello 5\n"; aListener = getSlaveByID(iID); if (aListener!=0) return aListener; - std::cerr << "Hello 6\n"; + //std::cerr << "Hello 6\n"; return getChannelByID(iID); } diff --git a/simulators/c++2/src_simulator/sim/SimComponents.h b/simulators/c++2/src_simulator/sim/SimComponents.h index fb9e2be72ca3e3bfa92a042235dd38133973d656..d42e1bb7b442bc9b2b4e6df48e3c98605bdb332c 100644 --- a/simulators/c++2/src_simulator/sim/SimComponents.h +++ b/simulators/c++2/src_simulator/sim/SimComponents.h @@ -54,6 +54,7 @@ class Simulator; class IndeterminismSource; class GeneralListener; class PropertyConstraint; +class TEPEFloatingSigListener; #ifdef EBRDD_ENABLED class EBRDD; #endif @@ -119,7 +120,8 @@ public: /** \param iPropConstr TEPE Constraint */ - void addTEPEConstraint(PropertyConstraint* iPropConstr); + void addTEPEListener(GeneralListener* iTEPEListener); + void setTEPEEntryPoint(TEPEFloatingSigListener* iTEPEEntryPoint); ///Calls streamBenchmarks of all traceable devices contained in vcdList /** param s Reference to output stream object @@ -302,6 +304,8 @@ protected: TaskList _taskList; ///List holding channels ChannelList _channelList; + ///TEPE listener listener + TEPEListenerList _tepeListenerList; #ifdef EBRDD_ENABLED ///List holding EBRDDs EBRDDList _ebrddList; diff --git a/simulators/c++2/src_simulator/sim/Simulator.cpp b/simulators/c++2/src_simulator/sim/Simulator.cpp index f6597b7b25f8efba615685cf7164fc97c63a2c65..f6467007f29fec94050ba04a74c80830f40a6d4f 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.cpp +++ b/simulators/c++2/src_simulator/sim/Simulator.cpp @@ -59,7 +59,7 @@ Ludovic Apvrille, Renaud Pacalet #endif -Simulator::Simulator(SimServSyncInfo* iSyncInfo):_syncInfo(iSyncInfo), _simComp(_syncInfo->_simComponents),/*_simComp(0),*/ _busy(false), _simTerm(false), _leafsID(0), /*_randChoiceBreak(0),*/ _randChoiceBreak(_syncInfo->_simComponents){ +Simulator::Simulator(SimServSyncInfo* iSyncInfo):_syncInfo(iSyncInfo), _simComp(_syncInfo->_simComponents), _busy(false), _simTerm(false), _randChoiceBreak(_syncInfo->_simComponents), _wasReset(true){ } Simulator::~Simulator(){ @@ -148,7 +148,7 @@ TMLTransaction* Simulator::getTransLowestEndTime(SchedulableDevice*& oResultDevi std::cout << "The Graph output took " << getTimeDiff(aBegin,aEnd) << "usec. File: " << iTraceFileName << std::endl; }*/ -ID Simulator::schedule2GraphDOT(std::ostream& iFile, ID iStartState, unsigned int& oTransCounter) const{ +ID Simulator::schedule2GraphDOT(std::ostream& iDOTFile, std::ostream& iAUTFile, ID iStartState, unsigned int& oTransCounter) const{ CPUList::iterator i; GraphTransactionQueue aQueue; TMLTransaction* aTrans, *aTopElement; @@ -171,20 +171,20 @@ ID Simulator::schedule2GraphDOT(std::ostream& iFile, ID iStartState, unsigned in } //13 -> 17 [label = "i(CPU0__test1__TMLTask_1__wro__test1__ch<4 ,4>)"]; oTransCounter++; -#ifdef DOT_GRAPH_ENABLED - iFile << aStartState << " -> " << aEndState << " [label = \"i(" << aCPU->toString() << "__" << aTopElement->getCommand()->getTask()->toString() << "__" << aTopElement->getCommand()->getCommandStr(); +//#ifdef DOT_GRAPH_ENABLED + iDOTFile << aStartState << " -> " << aEndState << " [label = \"i(" << aCPU->toString() << "__" << aTopElement->getCommand()->getTask()->toString() << "__" << aTopElement->getCommand()->getCommandStr(); if (aTopElement->getChannel()!=0){ - iFile << "__" << aTopElement->getChannel()->toShortString(); + iDOTFile << "__" << aTopElement->getChannel()->toShortString(); } - iFile << "<" << aTopElement->getVirtualLength() << ">)\"]\n"; -#else + iDOTFile << "<" << aTopElement->getVirtualLength() << ">)\"]\n"; +//#else //(20,"i(CPU0__test1__TMLTask_1__wr__test1__ch<4 ,4>)", 24) - iFile << "(" << aStartState << "," << "\"i(" << aCPU->toString() << "__" << aTopElement->getCommand()->getTask()->toString() << "__" << aTopElement->getCommand()->getCommandStr(); + iAUTFile << "(" << aStartState << "," << "\"i(" << aCPU->toString() << "__" << aTopElement->getCommand()->getTask()->toString() << "__" << aTopElement->getCommand()->getCommandStr(); if (aTopElement->getChannel()!=0){ - iFile << "__" << aTopElement->getChannel()->toShortString(); + iAUTFile << "__" << aTopElement->getChannel()->toShortString(); } - iFile << "<" << aTopElement->getVirtualLength() << ">)\"," << aEndState <<")\n"; -#endif + iAUTFile << "<" << aTopElement->getVirtualLength() << ">)\"," << aEndState <<")\n"; +//#endif aStartState = aEndState; //aOutp << aTempStr.str() << ++aTransitionNo << ")\n"; //} @@ -390,7 +390,8 @@ bool Simulator::simulate(TMLTransaction*& oLastTrans){ transLET=getTransLowestEndTime(cpuLET); //std::cout << "after getTLET" << std::endl; #ifdef LISTENERS_ENABLED - NOTIFY_SIM_STARTED(); + if (_wasReset) NOTIFY_SIM_STARTED(); + _wasReset=false; #endif while (transLET!=0 && !_simComp->getStopFlag()){ #ifdef DEBUG_KERNEL @@ -506,11 +507,12 @@ bool Simulator::simulate(TMLTransaction*& oLastTrans){ //sleep(1); } #ifdef LISTENERS_ENABLED - NOTIFY_SIM_STOPPED(); + bool aSimCompleted = (transLET==0 && !_simComp->getStoppedOnAction()); + if (aSimCompleted) NOTIFY_SIM_STOPPED(); #endif gettimeofday(&aEnd,NULL); //std::cout << "The simulation took " << getTimeDiff(aBegin,aEnd) << "usec.\n"; - return (transLET==0 && !_simComp->getStoppedOnAction()); + return (aSimCompleted); } const std::string Simulator::getArgs(const std::string& iComp, const std::string& iDefault, int iLen, char** iArgs){ @@ -659,30 +661,30 @@ void Simulator::decodeCommand(std::string iCmd){ case 7: {//Explore Tree //for (int i=0; i<RECUR_DEPTH; i++) leafsForLevel[i]=0; std::cout << "Explore tree." << std::endl; - _leafsID=0; - std::ofstream myfile ("tree"); + std::ofstream myDOTfile ("tree.dot"); + std::ofstream myAUTfile ("tree.aut.tmp"); //std::ofstream myfile2 ("tree.txt"); - if (myfile.is_open() /*&& myfile2.is_open()*/){ -#ifdef DOT_GRAPH_ENABLED - myfile << "digraph BCG {\nsize = \"7, 10.5\";\ncenter = TRUE;\nnode [shape = circle];\n0 [peripheries = 2];\n"; -#endif + if (myDOTfile.is_open() && myAUTfile.is_open()){ +//#ifdef DOT_GRAPH_ENABLED + myDOTfile << "digraph BCG {\nsize = \"7, 10.5\";\ncenter = TRUE;\nnode [shape = circle];\n0 [peripheries = 2];\n"; +//#endif unsigned int aTransCounter=0; - exploreTree(0, 0, myfile, aTransCounter); -#ifdef DOT_GRAPH_ENABLED - myfile << "}\n"; - system ("mv tree tree.dot"); - myfile.close(); -#else - myfile.close(); - std::ofstream myfile3 ("header"); - if (myfile3.is_open()){ + exploreTree(0, 0, myDOTfile, myAUTfile, aTransCounter); +//#ifdef DOT_GRAPH_ENABLED + myDOTfile << "}\n"; + //system ("mv tree tree.dot"); + myDOTfile.close(); +//#else + myAUTfile.close(); + std::ofstream myTMPfile ("header"); + if (myTMPfile.is_open()){ //des (0, 29, 27) - myfile3 << "des(0," << aTransCounter << "," << TMLTransaction::getID() << ")\n"; - myfile3.close(); - system ("cat header tree > tree.aut"); - system ("rm header tree"); + myTMPfile << "des(0," << aTransCounter << "," << TMLTransaction::getID() << ")\n"; + myTMPfile.close(); + system ("cat header tree.aut.tmp > tree.aut"); + system ("rm header tree.aut.tmp"); } -#endif +//#endif //myfile2.close(); } aGlobMsg << TAG_MSGo << "Tree was explored" << TAG_MSGc << std::endl; @@ -817,6 +819,7 @@ void Simulator::decodeCommand(std::string iCmd){ } case 2: //reset std::cout << "Simulator reset." << std::endl; + _wasReset=true; _simComp->reset(); _simComp->resetStateHash(); _simTerm=false; @@ -1267,7 +1270,7 @@ bool Simulator::runUntilCondition(std::string& iCond, TMLTask* iTask, TMLTransac if (oSuccess) return simulate(oLastTrans); else return false; } -void Simulator::exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iFile, unsigned int& oTransCounter){ +void Simulator::exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iDOTFile, std::ofstream& iAUTFile, unsigned int& oTransCounter){ TMLTransaction* aLastTrans; //if (iDepth<RECUR_DEPTH){ ID aLastID; @@ -1277,17 +1280,17 @@ void Simulator::exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iFil aSimTerminated=runToNextRandomCommand(aLastTrans); aRandomCmd = _simComp->getCurrentRandomCmd(); }while (!aSimTerminated && aRandomCmd==0 && _simComp->wasKnownStateReached()==0); - aLastID = schedule2GraphDOT(iFile,iPrevID,oTransCounter); + aLastID = schedule2GraphDOT(iDOTFile, iAUTFile, iPrevID,oTransCounter); //if (_simComp->wasKnownStateReached()==0){ //if(aRandomCmd==0){ if(aSimTerminated){ oTransCounter++; -#ifdef DOT_GRAPH_ENABLED - iFile << aLastID << " -> " << TMLTransaction::getID() << " [label = \"i(allCPUsTerminated<" << SchedulableDevice::getSimulatedTime() << ">)\"]\n"; -#else +//#ifdef DOT_GRAPH_ENABLED + iDOTFile << aLastID << " -> " << TMLTransaction::getID() << " [label = \"i(allCPUsTerminated<" << SchedulableDevice::getSimulatedTime() << ">)\"]\n"; +//#else //(21,"i(allCPUsTerminated)", 25) - iFile << "(" << aLastID << "," << "\"i(allCPUsTerminated<" << SchedulableDevice::getSimulatedTime() << ">)\"," << TMLTransaction::getID() << ")\n"; -#endif + iAUTFile << "(" << aLastID << "," << "\"i(allCPUsTerminated<" << SchedulableDevice::getSimulatedTime() << ">)\"," << TMLTransaction::getID() << ")\n"; +//#endif TMLTransaction::incID(); //}else{ }else if (_simComp->wasKnownStateReached()==0){ @@ -1308,7 +1311,7 @@ void Simulator::exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iFil aStreamBuffer.str(aStringBuffer); _simComp->readObject(aStreamBuffer); aRandomCmd->setRandomValue(aBranch); - exploreTree(iDepth+1, aLastID, iFile, oTransCounter); + exploreTree(iDepth+1, aLastID, iDOTFile, iAUTFile, oTransCounter); } }else{ unsigned int aBranch=0; @@ -1319,7 +1322,7 @@ void Simulator::exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iFil aStreamBuffer.str(aStringBuffer); _simComp->readObject(aStreamBuffer); aRandomCmd->setRandomValue(aBranch); - exploreTree(iDepth+1, aLastID, iFile, oTransCounter); + exploreTree(iDepth+1, aLastID, iDOTFile, iAUTFile, oTransCounter); } aBranch++; aNbNextCmds >>=1; } diff --git a/simulators/c++2/src_simulator/sim/Simulator.h b/simulators/c++2/src_simulator/sim/Simulator.h index fc0b3b50c092f11c99130013d957a2c58352b112..db319a337976ae066c68dc38f3542fb190e5fb8e 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.h +++ b/simulators/c++2/src_simulator/sim/Simulator.h @@ -212,7 +212,7 @@ public: \param iPrevID ID of the parent leaf \param iFile Reference to the output file */ - void exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iFile, unsigned int& oTransCounter); + void exploreTree(unsigned int iDepth, ID iPrevID, std::ofstream& iDOTFile, std::ofstream& iAUTFile, unsigned int& oTransCounter); ///Writes a HTML representation of the schedule of CPUs and buses to an output file void schedule2HTML(std::string& iTraceFileName) const; ///Writes simulation traces in VCD format to an output file @@ -226,7 +226,7 @@ public: */ void schedule2Graph(std::string& iTraceFileName) const; //ID schedule2Graph(std::ostream& iFile, ID iStartState) const; - ID schedule2GraphDOT(std::ostream& iFile, ID iStartState, unsigned int& oTransCounter) const; + ID schedule2GraphDOT(std::ostream& iDOTFile, std::ostream& iAUTFile, ID iStartState, unsigned int& oTransCounter) const; ///Writes a plain text representation of the schedule of CPUs to an output file /** \param iTraceFileName Name of the output trace file @@ -301,11 +301,11 @@ protected: bool _busy; ///Simulation terminated flag bool _simTerm; - ///Counts the leafs of the tree made up by explored control flow branches - unsigned int _leafsID; ///Keeps track of all breakpoints set during the simulation BreakpointSet _breakpoints; ///Random choice breakpoint RunTillNextRandomChoice _randChoiceBreak; + ///Flag indicating if the simulator has previously been reset + bool _wasReset; }; #endif