Comment
Author: Admin | 2025-04-28
Local Watching Local watching allows you to specify exactly which section of the process is watching which signals, and where the event handlers are located. This functionality is specified with 4 macros that define the boundaries of each of the areas. Below is pseudo syntax of Local watching. W_BEGIN // put the watching declarations here watching(...); watching(...);W_DO // This is where the process functionality goes ...W_ESCAPE // This is where the handlers for the watched events go if (..) { ... }W_END The W_BEGIN macro marks the beginning of the local watching block. Between the W_BEGIN and W_DO macros are where all of the watching declarations are placed. These declarations look the same as the global watching events. Between the W_DO macro and the W_ESCAPE macro is where the process functionality is placed. This is the code that gets executed as long as none of the watching events occur. Between the W_ESCAPE and the W_END macros is where the event handlers reside. The event handlers will check to make sure that the relevant event has occurred and then perform the necessary action for that event. The W_END macro ends the local watching block. There are a few interesting things to note about local watching: All of the events in the declaration block have the same priority. If a different priority is needed then local watching blocks will need to be nested. Local watching only works in SC_CTHREAD processes. The signals in the watching expressions are sampled only on the active edges of the process. In an SC_CTHREAD process this means only when the clock that the process is sensitive to changes. Globally watched events have higher priority than locally watched events. Example Local Watching 1 //----------------------------------------------------- 2 // This is my second Systemc Example 3 // Design Name : first_counter 4 // File Name : first_counter.cpp 5 // Function : This is a 4 bit up-counter with 6 // Synchronous active high reset and 7 // with active high enable signal 8 //----------------------------------------------------- 9 #include "systemc.h" 10 11 SC_MODULE (first_counter) { 12 sc_in_clk clock ; // Clock input of the
Add Comment