quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif 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.

   

space.gif

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
   

space.gif

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.

   

space.gif

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.
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example Local Watching
   

space.gif


  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 design
 13   sc_in<bool>   reset ;      // active high, synchronous Reset input
 14   sc_in<bool>   enable;      // Active high enable signal for counter
 15   sc_out<sc_uint<4> > counter_out; // 4 bit vector output of the counter
 16 
 17   //------------Local Variables Here---------------------
 18   sc_uint<4>	count;
 19 
 20   //------------Code Starts Here-------------------------
 21   // Below function implements actual counter logic
 22   void incr_count () {
 23     while (true) { 
 24       wait();
 25       // If enable is active, then we increment the counter
 26       if (enable.read() == 1) {
 27         count = count + 1;
 28         counter_out.write(count);
 29       }
 30       W_BEGIN
 31         watching(reset.delayed());
 32       W_DO
 33         wait();
 34         if (enable.read() == 1) {
 35           count = count + 1;
 36           counter_out.write(count);
 37         }
 38       W_ESCAPE
 39         if (reset.read() == 1) {
 40           count =  0;
 41           counter_out.write(count);
 42           cout<<"@" << sc_time_stamp() <<
 43             " :: Local Watching reset is activated"<<endl;
 44         }
 45       W_END
 46     }
 47   } // End of function incr_count
 48 
 49   // Below functions prints value of count when ever it changes
 50   void print_count () {
 51     while (true) {
 52       wait();
 53       cout<<"@" << sc_time_stamp() <<
 54         " :: Counter Value "<<counter_out.read()<<endl;
 55     }
 56   }
 57 
 58   // Constructor for the counter
 59   // Since this counter is a positive edge trigged one,
 60   // We trigger the below block with respect to positive
 61   // edge of the clock
 62   SC_CTOR(first_counter) {
 63     // cthreads require to have thread name and triggering 
 64     // event to passed as clock object
 65     SC_CTHREAD(incr_count, clock.pos());
 66     // Level Sensitive to change in counter output
 67     SC_THREAD(print_count);
 68       sensitive << counter_out;
 69   } // End of Constructor
 70 
 71 }; // End of Module counter
You could download file counter_local_watching.cpp here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output : Local Watching
   

space.gif

              SystemC 2.0.1 --- Oct  6 2006 19:17:37
         Copyright (c) 1996-2002 by all Contributors
                     ALL RIGHTS RESERVED
 @0 s Asserting reset
 
 WARNING: Default time step is used for VCD tracing.
 @10 ns De-Asserting reset
 
 @11 ns :: Local Watching reset is activated
 @13 ns :: Local Watching reset is activated
 @15 ns :: Local Watching reset is activated
 @17 ns :: Local Watching reset is activated
 @19 ns :: Local Watching reset is activated
 @21 ns :: Local Watching reset is activated
 @23 ns :: Local Watching reset is activated
 @25 ns :: Local Watching reset is activated
 @27 ns :: Local Watching reset is activated
 @29 ns :: Local Watching reset is activated
 @40 ns Asserting Enable
 
 @41 ns :: Counter Value 1
 @43 ns :: Counter Value 2
 @45 ns :: Counter Value 3
 @47 ns :: Counter Value 4
 @49 ns :: Counter Value 5
 @51 ns :: Counter Value 6
 @53 ns :: Counter Value 7
 @55 ns :: Counter Value 8
 @57 ns :: Counter Value 9
 @59 ns :: Counter Value 10
 @61 ns :: Counter Value 11
 @63 ns :: Counter Value 12
 @65 ns :: Counter Value 13
 @67 ns :: Counter Value 14
 @69 ns :: Counter Value 15
 @71 ns :: Counter Value 0
 @73 ns :: Counter Value 1
 @75 ns :: Counter Value 2
 @77 ns :: Counter Value 3
 @79 ns :: Counter Value 4
 @80 ns De-Asserting Enable
 
 @80 ns Terminating simulation
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com