SC_MODULE(mycounter) { sc_in < bool > clk, enable, reset; sc_out < sc_int<10> > sum; void m() { if (reset) sum = 0; else if (enable) sum = sum.read()+1; // Use .read() since channel contains a signal. } SC_CTOR(mycounter) { SC_METHOD(m); sensitive << clk.pos(); } }
SystemC enables a user class to be defined using the the SC_MODULE macro.
Modules inherit various attributes appropriate for an hierarchic hardware design including an instance name, a type name and channel binding capability..