HOME       UP       PREV       FURTHER NOTES       NEXT (ESL TLM in SystemC: TLM 2.0)  

TLM 1.0 - First Standard Continued

A suitable coding style for sending calls `along the nets' (prior to the TLM 2.0 standard):
//Define the interfaces:
class write_if: public sc_interface
{ public:
  virtual void write(char) = 0;
  virtual void reset() = 0;
};

class read_if: public sc_interface
{ public:
  virtual char read() = 0;
};

//Define a component that inherits:
class fifo_dev: sc_module("fifo_dev"), 
public write_if, public read_if, ... 
{
  void write(char) { ... }
  void reset() { ... }

  ...
}
SC_MODULE("fifo_writer") 
{
  sc_port outputport;
  sc_in  clk;
  void writer()
  {
    outputport.write(random());
  }

  SC_CTOR(fifo_writer} {
     SC_METHOD(writer);
     sensitive << clk.pos();
  }
}

//Top level instances:
fifo_dev myfifo("myfifo");
fifo_writer mywriter("mywriter");
// Port binding:
mywriter.outputport(myfifo);

Here a thread passes between modules, but modules are plumbed in Hardware/EDS netlist structural style.


15: (C) 2008-11, DJ Greaves, University of Cambridge, Computer Laboratory.