Yes you can use it both at the same time because sc_in_clk
is merely a typedef of sc_in<bool>
. That means it doesn't matter whether you use sc_in_clk
or sc_in<bool>
with SC_CTHREAD
.
From the documentation:
typedef sc_in<bool> sc_in_clk;
The typedef sc_in_clk is provided for convenience when adding clock inputs to a module and for backward compatibility with earlier versions of SystemC. An application may use sc_in_clk or sc_in< bool > interchangeably.
I tried to reproduce your problem in my own environment (SystemC 2.3.2). Based on the snippet you posted, I created this small SystemC program:
#include <systemc.h>
SC_MODULE(my_module)
{
sc_in_clk clk;
void foo();
SC_CTOR(my_module)
{
SC_CTHREAD(foo, clk.pos());
}
};
void my_module::foo()
{
while(1)
{
cout << sc_time_stamp() << endl;
wait();
}
}
my_module *DUT;
int sc_main(int argc, char** argv){
sc_clock clk("clk", 10, SC_NS);
DUT = new my_module("my_module");
DUT->clk(clk);
sc_start(50, SC_NS);
return 0;
}
This code works as expected and the output is:
0 s
10 ns
20 ns
30 ns
40 ns
You can try to match the structure of your code to the structure of the program above to find potential other bugs in your code.
What is the structure of your void foo()
? Does it contain any form of the wait function, other than void wait();
or void wait(int);
? Because a clocked thread process may only call these two forms of wait.