| //Example of structural hierarchy and wiring between levels:
SC_MODULE(shiftreg) // Two-bit shift register
{ sc_in < bool > clk, reset, din;
sc_out < bool > dout;
sc_signal < bool > q1_s;
dff dff1, dff2; // Instantiate FFs
SC_CTOR(shiftreg) : dff1("dff1"), dff2("dff2")
{ dff1.clk(clk);
dff1.reset(reset);
dff1.d(din);
dff1.q(q1_s);
dff2.clk(clk);
dff2.reset(reset);
dff2.d(q1_s);
dff2.q(dout);
}
};
|
The sc_signal (extends sc_channel) should be used to obtain the compute/commit paradigm. Avoids non-determinacy from races on zero-delay flip-flops. » (See HERE.)
General SystemC channel provides general purpose interface between components.
Other SystemC channel types include FIFOs and semaphores.