Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo

Similar presentations


Presentation on theme: "Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo"— Presentation transcript:

1 Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo
SystemC (Week 3) Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo 19 September 2018 Embedded Computing Lab

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

3 Chap. 2 Execution Semantics
19 September 2018 Embedded Computing Lab

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

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

6 Embedded Computing Lab
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. Invocation: 激發 19 September 2018 Embedded Computing Lab

7 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

8 Embedded Computing Lab
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 Facilitated: 使…容易 19 September 2018 Embedded Computing Lab

9 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

10 Embedded Computing Lab
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) 19 September 2018 Embedded Computing Lab

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

12 Embedded Computing Lab
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 notion:想法 19 September 2018 Embedded Computing Lab

13 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

14 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

15 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

16 Embedded Computing Lab
Scheduler Steps Repeat step 2 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. 19 September 2018 Embedded Computing Lab

17 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

18 Embedded Computing Lab
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 ) sc_simulation_time() (Chapter ). 19 September 2018 Embedded Computing Lab

19 Embedded Computing Lab
Event 19 September 2018 Embedded Computing Lab

20 Embedded Computing Lab
Event Occurrence 19 September 2018 Embedded Computing Lab

21 Embedded Computing Lab
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 19 September 2018 Embedded Computing Lab

22 Embedded Computing Lab
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 19 September 2018 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 19 September 2018 Embedded Computing Lab

24 Embedded Computing Lab
Process 19 September 2018 Embedded Computing Lab

25 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

26 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

27 Embedded Computing Lab
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). 19 September 2018 Embedded Computing Lab

28 Embedded Computing Lab
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. 19 September 2018 Embedded Computing Lab

29 Embedded Computing Lab
Dynamic Sensitivity Set the sensitivity list in runtime for next trigger condition. Method process => next_trigger() Thread process => wait() 19 September 2018 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. 19 September 2018 Embedded Computing Lab

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

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


Download ppt "Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo"

Similar presentations


Ads by Google