1 / 27

Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems. Processes in SystemC. Maziar Goudarzi. Today Program. Processes in SystemC Elements in defining processes in SystemC Some examples. Process. Module Basic unit of hierarchy (basic building block) in SystemC Process

igregory
Download Presentation

Design & Co-design of Embedded Systems

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. Design & Co-design of Embedded Systems Processes in SystemC Maziar Goudarzi

  2. Today Program • Processes in SystemC • Elements in defining processes in SystemC • Some examples Design & Co-design of Embedded Systems

  3. Process • Module • Basic unit of hierarchy (basic building block) in SystemC • Process • Basic unit of execution in SystemC • Processes are called to emulate the behavior of a target device or system Design & Co-design of Embedded Systems

  4. Process • Basics • Basic unit of execution within SystemC • Emulate the behavior of target device • Are triggered by clock edges and/or signal expressions • Processes are not hierarchical • A process does not call another process • C++ allows this. Avoid using that. • Processes communicate through signals Design & Co-design of Embedded Systems

  5. Process (cont’d) Module Input ports Process 1 IO port Process 2 Output ports Internal signal Design & Co-design of Embedded Systems

  6. Process (cont’d) • Each process has • Sensitivity list • Execution type • A series of statements • A process is specified in two parts • Process declaration • Registers the process with the SystemC simulation kernel • Process definition • Specifies the C++/SystemC statements that the process executes Design & Co-design of Embedded Systems

  7. Process (cont’d) • Process declaration • Sensitivity list + execution type • Must be given to SystemC simulation kernel to enable simulation • SystemC uses SC_MODULE constructor for this • Example: SC_CTOR(a_module) { SC_METHOD(a_process); sensitive<<a_port; } Design & Co-design of Embedded Systems

  8. Process (cont’d) • Process definition • The series of statements (operations) to be executed • Includes • reading/writing ports, signals, and variables • Any valid C++ statement (display messages, calculations, etc.) • SystemC uses SC_MODULE member functions for this • SystemC simulation kernel calls this member function when a corresponding event happens • Example: SC_MODULE(a_module) { void a_process(void) { ... } SC_CTOR(a_module) { SC_METHOD(a_process); } }; Design & Co-design of Embedded Systems

  9. Process (cont’d) • Communication between processes • SystemC (actually C++) allows to use SC_MODULE data members for this • Should we use that? Why? • Use signals (sc_signal<> type) to synchronize processes Design & Co-design of Embedded Systems

  10. Declaring a Process • Process sensitivity list • List of events that trigger this process • Three types of sensitivity • sensitive • Any change of value on the port/signal triggers the process • sensitive_pos • A positive edge on the port/signal triggers the process • sensitive_neg • A negative edge on the port/signal triggers the process • General syntax • sensitive << port_1 << signal_1 << ... << port_n • sensitive_pos << port_1 << signal_1; • sensitive_neg << port_1 << signal_1; Design & Co-design of Embedded Systems

  11. Declaring a Process (cont’d) • Process sensitivity list (cont’d) • The other syntax: • sensitive( port1 ); sensitive( signal1 ); • sensitive_pos( port1 ); sensitive_pos( sig1 ); • Sensitive_neg( port1 ); sensitive_neg( sig1 ); Design & Co-design of Embedded Systems

  12. Declaring a Process (cont’d) • Process execution types in SystemC • Defines the way that the process is executed • Process types • Method • Thread • Clocked Thread Design & Co-design of Embedded Systems

  13. Execution Types of Processes in SystemC • Three types of Process in SystemC • Methods • SC_METHOD process • Threads • SC_THREAD process • Clocked threads • SC_CTHREAD process Design & Co-design of Embedded Systems

  14. SC_METHOD Process • Is called once, when events occur on its sensitivity list • Cannot suspend execution (i.e. cannotwait()) • wait() is a function in SystemC kernel. • What happens if you put a wait() in a SC_METHOD process? • Returns control to the caller (SystemC Kernel) Design & Co-design of Embedded Systems

  15. Method Example:Packet Receiver void rcv::extract_id() { frame_type frame; frame = xin;if(frame.type==1) id = frame.ida;else id = frame.idb; } rcv id frame xin id #include “frame.h” SC_MODULE(rcv) { sc_in<frame_type> xin;sc_out<int> id; void extract_id(); SC_CTOR(rcv){ SC_METHOD(extract_id); sensitive(xin); }}; Design & Co-design of Embedded Systems

  16. SC_THREAD Process • Declaration to SystemC kernel is the same as SC_METHOD process • Can be suspended and re-activated • wait() system call • Process is re-activated when an event occurs on process sensitivity list • General syntax: void a_thread_process() { // some statements (initialization) while ( 1) { // some other statements wait(); } } Design & Co-design of Embedded Systems

  17. SC_THREAD Example:Traffic Light Controller SC_MODULE(traff) { sc_in<bool> roadsensor;sc_in<bool> clock; sc_out<bool> NSred;sc_out<bool> NSyellow;sc_out<bool> NSgreen;sc_out<bool> EWred;sc_out<bool> EWyellow;sc_out<bool> EWgreen; void control_lights(); Road Sensor SC_CTOR(traff){ SC_THREAD(control_lights); sensitive << roadsensor;sensitive_pos << clock; } }; Design & Co-design of Embedded Systems

  18. SC_THREAD Example:Traffic Light Controller (cont’d) void traff::control_lights() { NSred = NSyellow = false; NSgreen = true; EWred = true; EWyellow = EWgreen = false; while (true) { while (roadsensor == false)wait(); NSgreen = false; NSyellow = true; NSred = false; for (i=0; i<5; i++)wait(); NSgreen = NSyellow = false; NSred = true; EWgreen = true; EWyellow = EWred = false; for (i= 0; i<50; i++)wait(); NSgreen = NSyellow = false; NSred = true; EWgreen = false; EWyellow = true; EWred = false; for (i=0; i<5; i++) wait(); Design & Co-design of Embedded Systems

  19. SC_THREAD Example:Traffic Light Controller (cont’d) NSgreen = true; NSyellow = NSred = false; EWgreen = EWyellow = false; EWred = true; for (i=0; i<50; i++) wait(); } // while (true) } Design & Co-design of Embedded Systems

  20. SC_THREAD Process (cont’d) • The SC_THREADprocess is the most general one • Implementing traff module with SC_METHODprocess requires defining several states • Performance issue • SC_THREAD simulation is slower than SC_METHOD Design & Co-design of Embedded Systems

  21. SC_CTHREAD Process • The same as SC_THREAD, but is merely sensitive to edge of one clock • Results in better descriptions for synthesis • One major use: Implicit state machine • Implicit state machine vs. Explicit state machine • Additional waiting mechanisms • wait_until(<signal condition>) system call • Process is re-activated when the condition on the signals hold • timed wait, wait until condition with timeout (SystemC 2.0) Design & Co-design of Embedded Systems

  22. addr 32 newaddr start data 32 data8 ready datardy SC_CTHREAD Example:Bus Controller SC_MODULE(bus) { sc_in_clk clock; sc_in<bool> newaddr; sc_in<sc_uint<32> > addr; sc_in<bool> ready; sc_out<sc_uint<32> > data; sc_out<bool> start; sc_out<bool> datardy; sc_inout<sc_uint<8> > data8; sc_uint<32> tdata; sc_uint<32> taddr; void xfer(); Bus Cntrlr Mem Cntrlr SC_CTOR(bus) { SC_CTHREAD(xfer, clock.pos()); datardy.initialize(true); } }; Design & Co-design of Embedded Systems

  23. SC_CTHREAD Example:Bus Controller (cont’d) void bus::xfer() { while (true) { wait_until( newaddr.delayed() == true); taddr = addr.read(); datardy = false; data8 = taddr.range(7,0); start = true; wait(); data8 = taddr.range(15,8); start = false; wait(); data8 = taddr.range(23,16); wait(); data8 = taddr.range(31,24); wait(); wait_until(ready.delayed() == true); tdata.range(7,0)=data8; wait(); tdata.range(15,8)=data8; wait(); tdata.range(23,16)=data8; wait(); tdata.range(31,24)=data8; data = tdata; datardy = true; } } Design & Co-design of Embedded Systems

  24. What we learned today • Processes in SystemC • Various sensitivity styles • Various execution styles • SystemC ver. 2.0 User’s Guide • Most of Chapter 4 Design & Co-design of Embedded Systems

  25. Assignments • Today: Due date for Assignment 1 • Assignment 2: • Is put on the course web-page • Implement the traffic-light controller using only SC_METHOD • Model a file-server and its clients • Due date: • One week from now: Tuesday, Aban 3rd Design & Co-design of Embedded Systems

  26. Complementary Notes:SystemC_Win • http://www.geocities.com/systemc_win/ Design & Co-design of Embedded Systems

  27. Complementary Notes:SystemC_Win • http://www.geocities.com/systemc_win/ Design & Co-design of Embedded Systems

More Related