1 / 13

Chapter 5

Chapter 5. SystemC 1.0. Main Purpose Model RTL Instruments Support diverse data type Execute concurrently by using METHOD s. SystemC 2.0. High-level modeling Communication and synchronization channel interface event. Event.

wworden
Télécharger la présentation

Chapter 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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<write_if> 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<read_if> in; void main() { char c; cout << endl << endl; while (true) { in->read(c); cout << c << flush; if (in->num_available() == 1) //cout << "<1>" << flush; cout << "<1>" << endl; if (in->num_available() == 9) //cout << "<9>" << flush; cout << "<9>" << endl; } }

  12. Native Channel of SystemC • sc_signal<T> • sc_fifo<T> • sc_mutux<T> • sc_semaphore<t>

  13. Reference • Function Specification for Systemc 2.0 • src/comminication/

More Related