Reputation: 892
Is it possible to use a wait statement with an input signal in a thread, i.e.
void Thread::myThread(){
while(1){
wait(mySignal);
if(mySignal == 1){
//do stuff
}
}
}
where mySignal
is sc_in<int> mySignal;
I tried to run a similar variation, but i get the following error when i try to step over the wait statement.
From what I've been able to read about waits
, it seems they take time, events, and some other combinations, but not directly a signal.
Assuming i cannot use the signal directly inside the wait, could i achieve the same result by making the thread sensitive in the constructor, i.e.
SC_MODULE(myModule){
sc_in<bool> mySignal;
void myThread();
SC_CTOR(myModule){
SC_THREAD(myThread)
sensitive << mySignal;
}
}
void myModule::myThread(){
while(1){
wait(); //Wait for mySignal
if(mySignal == 1){
//do stuff
}
}
}
Upvotes: 0
Views: 1159
Reputation: 1034
There are slight inconsistencies in your code. Try changing your code to this:
SC_MODULE(myModule){
sc_in<bool> mySignal;
void myThread();
SC_CTOR(myModule){
SC_THREAD(myThread); //<< SC_THREAD is a macro.
sensitive << mySignal;
}
}
void myModule::myThread(){ //<< Did you mean this instead of Thread class
while(1){
wait(); //Wait for mySignal
if(mySignal == 1){
//do stuff
}
}
}
Upvotes: 1