c++systemc

Prevent SC_METHOD from executing without event/trigger


My method fsm1 executes once even without event and therefore id1_cmd.read() and id1_value.read() contain 0 and not the correct values.

//------------------------------------------------------------------
//  Method:  control::fsm1() 
//  Parameter: None
//  @Sensitivity: ID_1_cmd (unsigned int)
//------------------------------------------------------------------
void control::fsm1() {
   cout << id1_cmd.read() << endl;
   cout << id1_value.read() << endl;

}

//------------------------------------------------------------------
//  Method: Constructor
//------------------------------------------------------------------
SC_CTOR(control) {
    SC_METHOD(fsm1);
    sensitive << id1_cmd;
}

Exists there a way to prevent it from executing once or do i have to handle that case always in my methods?


Solution

  • Use the dont_initialize method see the Language Reference Manual

    SC_CTOR(control) {
        SC_METHOD(fsm1);
        sensitive << id1_cmd;
        dont_initialize();
    }