HOME       UP       PREV       FURTHER NOTES       NEXT (ESL Flow Model: Avoiding ISS/RTL overheads using native calls.)  
SystemC net-level coding styles were lectured in previous years but 15/16 onwards is non-examinable. But do try online practicals if you wish. »SystemC Get Started

Example (Counter)

In this example a C++ class is defined using the the SC_MODULE macro.

SC_MODULE(mycounter)
{
   sc_in  < bool       > clk, enable, reset;
   sc_out < sc_int<10> > sum;

   void m() // Behaviour 
   {
      if (reset) sum = 0;
      else if (enable) sum = sum.read()+1; // Use .read() since sc_out makes a signal.
   }

   SC_CTOR(mycounter) // constructor
     { SC_METHOD(m);
       sensitive << clk.pos();
     }
}

Modules inherit various attributes appropriate for an hierarchic hardware design including an instance name field and a channel binding capability.


3: (C) 2008-17, DJ Greaves, University of Cambridge, Computer Laboratory.