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 sc_start

sc_start() is a key method in SystemC. This method starts the simulation phase, which consists of initialization and execution. sc_start() methods performs operations listed below.

   

space.gif

   

space.gif

  • Called First Time : sc_start starts the scheduler, which will run up to the simulation time passed as an argument (if an argument was passed).
  • When called on the second and subsequent occasions : sc_start will resume the scheduler from the time it had reached at the end of the previous call to sc_start. The scheduler will run for the time passed as an argument (if an argument was passed), relative to the current simulation time..
  • When a time is passed as an argument : the scheduler will execute up to and including the timed notification phase that advances simulation time to the end time (calculated by adding the time given as an argument to the simulation time when function sc_start is called).
  • Called without any arguments : the scheduler will run until it completes.
  • Called with a zero-valued time argument : the scheduler shall run for one delta cycle.
   

space.gif

Once started, the scheduler will run until either it completes, or the application calls the function sc_stop, or an exception occurs. Once the function sc_stop has been called, function sc_start shall not be called again. Function sc_start may be called from function sc_main, and only from function sc_main.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : sc_start()
   

space.gif


   1 #include <systemc.h>
   2 
   3 SC_MODULE (some_block) {
   4   sc_in<bool>   clock;
   5   sc_in<sc_bit> data;
   6   sc_in<sc_bit> reset;
   7   sc_in<sc_bit> inv;
   8   sc_out<sc_bit> out;
   9 
  10   void body () {
  11     if (reset.read() == 1) {
  12       out = sc_bit(0);
  13     } else if (inv.read() == 1) {
  14       out = ~out.read();
  15     } else {
  16       out.write(data.read());
  17     }
  18   }
  19    
  20   SC_CTOR(some_block) {
  21     SC_METHOD(body);
  22       sensitive << clock.pos();
  23   }
  24 };
  25 
  26 
  27 SC_MODULE (signal_bind) {
  28   sc_in<bool> clock;
  29 
  30   sc_signal<sc_bit> data;
  31   sc_signal<sc_bit> reset;
  32   sc_signal<sc_bit> inv;
  33   sc_signal<sc_bit> out;
  34   some_block *block;
  35 
  36   void do_test() {
  37     while (true) {
  38       wait();
  39       cout << "@" << sc_time_stamp() <<" Starting test"<<endl;
  40       wait();
  41       wait();
  42       inv = sc_bit('0');
  43       data = sc_bit('0');
  44       cout << "@" << sc_time_stamp() <<" Driving 0 all inputs"<<endl;
  45       // Assert reset
  46       reset = sc_bit('1');
  47       cout << "@" << sc_time_stamp() <<" Asserting reset"<<endl;
  48       // Deassert reset
  49       wait();
  50       wait();
  51       reset = sc_bit('0');
  52       cout << "@" << sc_time_stamp() <<" De-Asserting reset"<<endl;
  53       // Assert data
  54       wait();
  55       wait();
  56       cout << "@" << sc_time_stamp() <<" Asserting data"<<endl;
  57       data = sc_bit('1');
  58       wait();
  59       wait();
  60       cout << "@" << sc_time_stamp() <<" Asserting inv"<<endl;
  61       inv = sc_bit('1');
  62       wait();
  63       wait();
  64       cout << "@" << sc_time_stamp() <<" De-Asserting inv"<<endl;
  65       inv = sc_bit('0');
  66       wait();
  67       wait();
  68       cout<<"Terminating Simulation"<<endl;
  69       sc_stop(); // sc_stop triggers end of simulation
  70     }
  71   }
  72 
  73   void monitor() {
  74     cout << "@" << sc_time_stamp() << " data :" << data 
  75       << " reset :" << reset << " inv :" 
  76       << inv << " out :" << out <<endl;
  77   }
  78 
  79   SC_CTOR(signal_bind) {
  80     block = new some_block("SOME_BLOCK");
  81     block->clock       (clock)  ;
  82     block->data        (data)   ;
  83     block->reset       (reset)  ;
  84     block->inv         (inv)    ;
  85     block->out         (out)    ;
  86                            
  87     SC_CTHREAD(do_test,clock.pos());
  88     SC_METHOD(monitor);
  89       sensitive << data << reset << inv << out;
  90   }
  91 }; 
  92 
  93 int sc_main (int argc, char* argv[]) {
  94   sc_clock clock ("my_clock",1,0.5);
  95 
  96   signal_bind  object("SIGNAL_BIND");
  97     object.clock (clock.signal());
  98   sc_trace_file *wf = sc_create_vcd_trace_file("sc_start");
  99     sc_trace(wf, object.clock, "clock");
 100     sc_trace(wf, object.reset, "reset");
 101     sc_trace(wf, object.data, "data");
 102     sc_trace(wf, object.inv, "inv");
 103     sc_trace(wf, object.out, "out");
 104   sc_start(0); // First time called will init schedular
 105   sc_start(1); // Increment simulation by 1 time unit
 106   sc_start();  // Run the simulation till sc_stop is encountered
 107   // sc_start() is terminated and return to next startment after
 108   // encountering sc_stop()
 109   cout<<"Closing VCD File"<<endl;
 110   sc_close_vcd_trace_file(wf);
 111   return 0;// Terminate simulation
 112 }
You could download file sc_start.cpp here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output : sc_start
   

space.gif

 @0 s data :0 reset :0 inv :0 out :0
 WARNING: Default time step is used for VCD tracing.
 @1 ns Starting test
 @3 ns Driving 0 all inputs
 @3 ns Asserting reset
 @3 ns data :0 reset :1 inv :0 out :0
 @5 ns De-Asserting reset
 @5 ns data :0 reset :0 inv :0 out :0
 @7 ns Asserting data
 @7 ns data :1 reset :0 inv :0 out :0
 @8 ns data :1 reset :0 inv :0 out :1
 @9 ns Asserting inv
 @9 ns data :1 reset :0 inv :1 out :1
 @10 ns data :1 reset :0 inv :1 out :0
 @11 ns De-Asserting inv
 @11 ns data :1 reset :0 inv :0 out :1
 Terminating Simulation
 SystemC: simulation stopped by user.
 Closing VCD File
   

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