1 / 32

SystemC (Week 3)

SystemC (Week 3). Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo. Today’s Articles. Chap. 2 Execution Semantics Chap. 4 Events Chap. 9 Processes. Chap. 2 Execution Semantics. Execution Semantics. Start at time = 0 Move forward only

vdubose
Download Presentation

SystemC (Week 3)

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. SystemC (Week 3) Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo Embedded Computing Lab

  2. Today’s Articles • Chap. 2 Execution Semantics • Chap. 4 Events • Chap. 9 Processes Embedded Computing Lab

  3. Chap. 2 Execution Semantics Embedded Computing Lab

  4. Execution Semantics • Start at time = 0 • Move forward only • Time increment are base on the default time unit and time resolution. Embedded Computing Lab

  5. main() and sc_main() • main() • It is a part of SystemC library. • It calls the function sc_main(). Embedded Computing Lab

  6. Elaboration • Elaboration is defined as the execution of sc_main() function from the start if sc_main() to the first invocation of sc_start(). • Includes the construction of instances of modules and channels to connect them, sc_object and sc_time variables. Embedded Computing Lab

  7. Elaboration • sc_set_default_time_unit() • Changing default time unit. • sc_set_time_resolution() • Changing time resolution. • If the 2 functions are called, must called during elaboration. • The 2 functions must also be called before any sc_time objects are constructed. Embedded Computing Lab

  8. Elaboration • During elaboration, the structural elements of the system are created and connected throughout the system hierarchy. • Facilitated by C++ class object constructor behavior. • There are no constraints on the order in which port to channel binding occurs during elaboration. • a port must be bound to some channel, then the port must be bound by the time elaboration completes Embedded Computing Lab

  9. Elaboration • Finally, the top level modules are connected via channels in the sc_main() function. • SystemC does not support the dynamic creation of modules. • The structure of the system is created during elaboration time and does not change during simulation. Embedded Computing Lab

  10. Initialization • Initialization is the first step in the SystemC scheduler. • dont_initialize() • To turn off the initialization of a process, this function can be called after SC_METHOD or SC_THREAD process declaration inside the module constructor Macro (ref chap. 9) Embedded Computing Lab

  11. Initialization • Different versions or a different simulator may yield a different result if care is not taken when writing models. Embedded Computing Lab

  12. Simulation Semantics • The SystemC scheduler: • Controls the timing of process execution • supports the notion of delta-cycles • A delta-cycle consists of the execution of an evaluate and update phase. • There may be a variable number of delta-cycles for every simulation time Embedded Computing Lab

  13. Simulation Semantics • SystemC processes are non-preemptive. • The scheduler is invoked by sc_start(). • Once scheduler is returned, simulation may continue from the time the scheduler last stopped by invoking the sc_start() function. Embedded Computing Lab

  14. Simulation Semantics • Once started the scheduler continues until • there are no more events • a process explicitly stops it (by calling the sc_stop() function) • an exception condition occurs. Embedded Computing Lab

  15. Scheduler Steps • Initialize phase (chap. 2.3) • Evaluate phase • From the set of processes that are ready to run, select a process and resume its execution. • The order is unspecified • The execution of a process may include calls to the request_update() function which schedules pending calls to update()function in the update phase. • The request_update() function may only be called inside member functions of a primitive channel. Embedded Computing Lab

  16. Scheduler Steps • Repeat step2 for any other process ready to run. • Update phase • Execute any pending calls to update() from calls to the request_update() function executed in the evaluate phase. • If there are pending delta-delay notifications, determine which processes are ready to run and go to step 2. Embedded Computing Lab

  17. Scheduler Steps • If there are no more timed event notifications, the simulation is finished. • Else, advance the current simulation time to the time of the earliest (next) pending timed event notification. • Determine which processes become ready to run due to the events that have pending notifications at the current time. Go to step 2. Embedded Computing Lab

  18. Simulation functions • sc_start() • Called in sc_main() to start the scheduler. • sc_stop() • Called in sc_main() to stop the scheduler. • Process can not be continued anymore • Two functions are provided for the user to obtain the current simulation time. • sc_time_stamp() (Chapter 12.20 ) • sc_simulation_time() (Chapter 12.16 ). Embedded Computing Lab

  19. Event Embedded Computing Lab

  20. Event Occurrence Embedded Computing Lab

  21. Notification • Immediate notification. • Event occurs in the same evaluate phase within a delta-cycle • Delta-delay notification. • Event occurs in the evaluate phase within the next delta-cycle • Non-zero delay notification (timed notification). • Event occurs delayed by the time value Embedded Computing Lab

  22. Example • Process C will be triggered only in this delta cycle. • Example Code • sc_event my_event ; // event declaration • sc_time t (10, SC_NS) // declaration of a 10 ns time interval • my_event.notify(); // immediate notification • my_event.notify (SC_ZERO_TIME); // delta-delay notification • my_event.notify (t); // notification in 10 ns Embedded Computing Lab

  23. Canceling event notifications • Define event and const value • sc_event a, b, c; • sc_time t(10, SC_MS); • Notify an event • a.notify(); // current delta-cycle • notify(SC_ZERO_TIME, b); // next delta-cycle • notify(t, c); // 10 ms delay • Cancel an event notification • a.cancel(); // Error! Can't cancel immediate notification • b.cancel(); // cancel notification on event b • c.cancel(); // cancel notification on event c Embedded Computing Lab

  24. Process Embedded Computing Lab

  25. Basic Concept • Target • A member function of a module class. • Be invoked by events (sensitivity list). • Static Sensitivity , Dynamic Sensitivity • Not hierarchical. • Type • Method , Thread , Clocked Thread. Embedded Computing Lab

  26. Method Process • When completion, it returns control to the SystemC kernel (simulator scheduler). • Never write infinite loop. • Never call wait() to suspend process. • Has no internal state. • Code example 1. Embedded Computing Lab

  27. Thread Process • Be invoked only once (during simulation initialization). • Be implemented with an infinite loop. • When calling wait(), the process is suspended and internal state (local variables) is saved. • The process is resumed by sensitivity list (state is restored). Embedded Computing Lab

  28. Static Sensitivity • Be declared in the module constructor for that process. • Both the () and the << operators are overloaded in sc_sensitive class. • Code example 2. Embedded Computing Lab

  29. Dynamic Sensitivity • Set the sensitivity list in runtime for next trigger condition. • Method process => next_trigger() • Thread process => wait() Embedded Computing Lab

  30. Dynamic Sensitivity - next_trigger • Execution of a next_trigger() statement sets the sensitivity for the next trigger for the method process. • If multiple next_trigger() statements are executed, the last one wins. Embedded Computing Lab

  31. Dynamic Sensitivity - wait • wait() specifies the condition for resuming the thread process. Embedded Computing Lab

  32. Dynamic Sensitivity - Argument • There are several different function prototypes for dynamic sensitivity. • Code example 3. Embedded Computing Lab

More Related