Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5. SystemC 1.0 Main Purpose  Model RTL Instruments  Support diverse data type  Execute concurrently by using METHODs.

Similar presentations


Presentation on theme: "Chapter 5. SystemC 1.0 Main Purpose  Model RTL Instruments  Support diverse data type  Execute concurrently by using METHODs."— Presentation transcript:

1 Chapter 5

2 SystemC 1.0 Main Purpose  Model RTL Instruments  Support diverse data type  Execute concurrently by using METHODs

3 SystemC 2.0 High-level modeling Communication and synchronization  channel  interface  event

4 Event Notify – An event can be notified by calling the (non-const) notify() method my_event.notify(); // notify immediately my_event.notify( SC_ZERO_TIME ); // notify next delta cycle my_event.notify( 10, SC_NS ); // notify in 10 ns sc_time t( 10, SC_NS ); my_event.notify( t ); // same Wait for an event While(true) { Blah blah… Wait (my_event) }

5 Channel Contain functionality for communication Implements one or more interfaces May not be necessarily a point-to-point connection

6 Interface Abstract template  provides a set of method declarations, but provides no method implementations and no data fields Define how to access the channels  A port that is connected to a channel through an interface sees only those channel methods that are defined by the interface.

7 Simple FIFO Example Interface declaration  Inherit from sc_interface  Have not implemntation class write_if : virtual public sc_interface { public: virtual void write(char) = 0; virtual void reset() = 0; }; class read_if : virtual public sc_interface{ public: virtual void read(char &) = 0; virtual int num_available() = 0; };

8 Simple FIFO Example (cont.) Channel Implementation for write interface class fifo : public sc_channel, public write_if, public read_if { public: fifo(sc_module_name name) : sc_channel(name), num_elements(0), first(0) {} void write(char c) { if (num_elements == max) wait(read_event); data[(first + num_elements) % max] = c; ++ num_elements; write_event.notify(); } … }

9 Simple FIFO Example (cont.) Channel Implementation class fifo : public sc_channel, public write_if, public read_if { public: … void read(char &c){ if (num_elements == 0) wait(write_event); c = data[first]; -- num_elements; first = (first + 1) % max; read_event.notify(); } void reset() { num_elements = first = 0; } … }

10 Simple FIFO Example (cont.) Module Usage for producer class producer : public sc_module { public: sc_port out; … void main() { const char *str = "Visit www.systemc.org and see what SystemC can do for you today!\n"; while (*str) out->write(*str++); } };

11 Simple FIFO Example (cont.) Module Usage For Consumer sc_port in; void main() { char c; cout << endl << endl; while (true) { in->read(c); cout << c << flush; if (in->num_available() == 1) //cout " << flush; cout " << endl; if (in->num_available() == 9) //cout " << flush; cout " << endl; }

12 Native Channel of SystemC sc_signal sc_fifo sc_mutux sc_semaphore

13 Reference Function Specification for Systemc 2.0 src/comminication/


Download ppt "Chapter 5. SystemC 1.0 Main Purpose  Model RTL Instruments  Support diverse data type  Execute concurrently by using METHODs."

Similar presentations


Ads by Google