void target()
  {
    switch (count)
    {
      case 0:
        f0 = 1;
        count = 1;
        next_trigger(10, SC_NS);
        break;

      case 1:
        f1 = 1;
        count = 2;
        target_handle.reset();
        break;

      case 2:
        f2 = 1;
        count = 3;
        target_handle.reset();
        break;

      case 3:
        f3 = 1;
        count = 4;
        break;
    }
  }
  void control()
  {
    wait(SC_ZERO_TIME);
    
    count = 1;
    ev.notify();
    wait(10, SC_NS);
    
    count = 2;
    ev.notify();
    t.disable();
    wait(SC_ZERO_TIME);
    
    count = 3;
    ev.notify();
    wait(SC_ZERO_TIME);
    
    count = 4;
    t.enable();
    ev.notify();
    wait(10, SC_NS);

    count = 5;
    t.disable();
    t.reset();
    wait(10, SC_NS);
    
    count = 6;
    t.reset();
    wait(10, SC_NS);
   
    sc_stop();
  }
 void ctrl()
 {
   count = 1;
   ph = sc_spawn(sc_bind(&Top::parent_proc, this));
   wait(10, SC_NS);
   
   count = 2;
   ph.reset(SC_INCLUDE_DESCENDANTS);
   wait(10, SC_NS);
   
   count = 3;
   ev.notify();
   wait(10, SC_NS);
   
   count = 4;
   ph.suspend(SC_INCLUDE_DESCENDANTS);
   wait(10, SC_NS);
   
   count = 5;
   ev.notify();
   wait(10, SC_NS);
   
   count = 6;
   ph.resume(SC_INCLUDE_DESCENDANTS);
   wait(10, SC_NS);
   
   count = 7;
   ph.kill(SC_INCLUDE_DESCENDANTS);
   wait(10, SC_NS);
 }
Exemple #4
0
  void T1()
  {
    wait(25, SC_NS);
    cout << "suspend at " << sc_time_stamp() << endl;
    h2.suspend();
    wait(20, SC_NS);
    cout << "resume at " << sc_time_stamp() << endl;
    h2.resume();
    wait(20, SC_NS);

    cout << "disable at " << sc_time_stamp() << endl;
    h2.disable();
    wait(20, SC_NS);
    cout << "enable at " << sc_time_stamp() << endl;
    h2.enable();
    wait(20, SC_NS);
    
    h2.reset();
    wait(20, SC_NS);
    
    h2.kill();
    wait(20, SC_NS);

    sc_pause();
    wait(50, SC_NS);
    sc_stop();
    end_of_T1 = true;
  }
Exemple #5
0
  void calling()
  {
    wait(15, SC_NS);
    // Target runs at time 10 NS due to notification
    sc_assert( count == 1 );

    wait(10, SC_NS);
    // Target runs again at time 20 NS due to notification
    sc_assert( count == 2 );

    t.reset();
    // Target reset immediately at time 25 NS
    sc_assert( count == 0 );

    wait(10, SC_NS);
    // Target runs again at time 30 NS due to notification
    sc_assert( count == 1 );

    t.kill();
    sc_assert( !killing_over );
    killing_over = true;

    // Target killed immediately at time 35 NS
    sc_assert( t.terminated() ); 
    sc_assert( k.terminated() );

    sc_stop();
  }
  void control()
  {
    wait(SC_ZERO_TIME);
    
    count = 1;
    ev.notify();
    wait(10, SC_NS);
    
    count = 2;
    ev.notify();
    t.disable();
    wait(SC_ZERO_TIME);
    
    count = 3;
    ev.notify();
    wait(SC_ZERO_TIME);
    
    count = 4;
    t.enable();
    ev.notify();
    wait(10, SC_NS);

    count = 5;
    t.disable();
    t.reset();
    wait(10, SC_NS);
    
    count = 6;
    t.reset();
    wait(10, SC_NS);
   
    if (!strcmp (name(), "top0"))
    {
        wait(20, SC_NS);
        sc_stop();
    }
  }
  void calling()
  {
    wait(15, SC_NS);

    t.sync_reset_on();
    wait(10, SC_NS);

    t.sync_reset_off();
    wait(10, SC_NS);

    t.reset();
    wait(SC_ZERO_TIME);
    
    sc_stop();
  }
  void calling()
  {
    wait(SC_ZERO_TIME);

    count = 1;
    t1.suspend(SC_INCLUDE_DESCENDANTS);
    ev.notify(5, SC_NS);
    wait(10, SC_NS);
    
    count = 2;
    t1.resume(SC_INCLUDE_DESCENDANTS);
    wait(10, SC_NS);
    
    count = 3;
    t1.disable(SC_INCLUDE_DESCENDANTS);
    ev.notify(5, SC_NS);
    wait(10, SC_NS);
    
    count = 4;
    t1.enable(SC_INCLUDE_DESCENDANTS);
    wait(10, SC_NS);
    
    count = 5;
    ev.notify();
    wait(10, SC_NS);
    
    count = 6;
    t1.sync_reset_on(SC_INCLUDE_DESCENDANTS);
    wait(10, SC_NS);
    
    count = 7;
    ev.notify();
    wait(10, SC_NS);

    count = 8;
    t1.sync_reset_off(SC_INCLUDE_DESCENDANTS);
    wait(sc_time(110, SC_NS) - sc_time_stamp());
    
    count = 10;
    t4.reset(SC_INCLUDE_DESCENDANTS);
    wait(sc_time(210, SC_NS) - sc_time_stamp());
    
    t7.throw_it(ex, SC_INCLUDE_DESCENDANTS);
  }
Exemple #9
0
 void bystander() // Gets reset by victim
 {
   for (;;)
   {
     try {
       wait(ev);
     }
     catch (const sc_unwind_exception& ex) {
       cout << "sc_unwind_exception caught by bystander" << endl;
       sc_assert( sc_time_stamp() == sc_time(35, SC_NS) );
       sc_assert( ex.is_reset() == true );
       sc_assert( !killing_over );
       sc_assert( v.is_unwinding() ); // sic
       sc_assert( sc_is_unwinding() );
       
       b2.reset();
       throw ex;
     }
   }
 }
Exemple #10
0
 void victim()
 {
   try {
     while (true)
     {
       wait(1, SC_NS);
       sc_assert( !sc_is_unwinding() );
     }
   }
   catch (const sc_unwind_exception& ex)
   {
     cout << "sc_unwind_exception caught by victim" << endl;
     sc_assert( sc_time_stamp() == sc_time(35, SC_NS) );
     sc_assert( ex.is_reset() == false );
     sc_assert( !killing_over );
     sc_assert( v.is_unwinding() );
     sc_assert( sc_is_unwinding() );
     
     b.reset();
     throw ex;
   }
 }
Exemple #11
0
  void calling()
  {
    wait(15, SC_NS);
    // Target runs at time 10 NS due to notification
    sc_assert( count == 1 );
    // The victim awakes every 1ns
    sc_assert( sc_time_to_pending_activity() <= sc_time(1, SC_NS) );
 
    wait(10, SC_NS);
    // Target runs again at time 20 NS due to notification
    sc_assert( count == 2 );
    
    t.reset();
    // Target reset immediately at time 25 NS
    sc_assert( count == 0 );
 
    wait(10, SC_NS);
    // Target runs again at time 30 NS due to notification
    sc_assert( count == 1 );
    
    t.kill();
    sc_assert( !killing_over );
    killing_over = true;
    
    // Target killed immediately at time 35 NS
    if (t.valid())
      sc_assert( t.terminated() );
    if (k.valid())
      sc_assert( k.terminated() );
    if (v.valid())
      sc_assert( v.terminated() );
    sc_assert( b.valid() && !b.terminated() );
    sc_assert( b2.valid() && !b2.terminated() );
    if (b3.valid())
      sc_assert( b3.terminated() );
      
    sc_stop();
  }
Exemple #12
0
  void calling()
  {
    wait(SC_ZERO_TIME);

    count = 1;
    ev.notify(5, SC_NS);
    wait(10, SC_NS);

    count = 2;
    t1.throw_it(ex);
    sc_assert( t1.valid() );
    sc_assert( !t1.terminated() );
    sc_assert(f4); 
    wait(10, SC_NS);

    count = 3;
    t4.throw_it(ex); // Throw exception in method process
    sc_assert( t4.valid() );
    sc_assert( !t4.terminated() );
    wait(sc_time(200, SC_NS) - sc_time_stamp());
    
    count = 4;
    t1.suspend();
    ev.notify(5, SC_NS);
    wait(10, SC_NS);
    
    count = 5;
    t1.throw_it(ex);
    wait(10, SC_NS);
    
    count = 6;
    t1.throw_it(ex);
    sc_assert( t1.valid() );
    sc_assert( !t1.terminated() );
    wait(10, SC_NS);
    
    count = 7;
    t1.resume();
    wait(sc_time(300, SC_NS) - sc_time_stamp());
    
    count = 8;
    t1.disable();
    ev.notify(5, SC_NS);
    wait(10, SC_NS);
    
    count = 9;
    t1.throw_it(ex);
    wait(10, SC_NS);
    
    count = 10;
    t1.throw_it(ex);
    wait(10, SC_NS);
    
    count = 11;
    t1.enable();
    wait(sc_time(400, SC_NS) - sc_time_stamp());
    
    count = 12;
    t1.sync_reset_on();
    ev.notify(5, SC_NS);
    wait(10, SC_NS);
    wait(sc_time(400, SC_NS) - sc_time_stamp());
    
    count = 13;
    t1.throw_it(ex);
    wait(10, SC_NS);
    
    count = 14;
    t1.throw_it(ex);
    wait(10, SC_NS);
    
    count = 15;
    t1.sync_reset_off();
    wait(sc_time(500, SC_NS) - sc_time_stamp());
    
    count = 16;
    ev.notify();
    t1.throw_it(ex);
    wait(10, SC_NS);
    
    count = 17;
    t1.reset();
    wait(sc_time(600, SC_NS) - sc_time_stamp());
    
    count = 18;
    t1.disable();
    t5.enable();
    areset.write(false);
    wait(10, SC_NS);
    
    count = 19;
    ev.notify();
    wait(10, SC_NS);

    count = 20;
    ev.notify();
    wait(10, SC_NS);

    count = 21;
    areset.write(true);
    wait(10, SC_NS);

    count = 22;
    t5.throw_it(ex);
    wait(10, SC_NS);

    count = 23;
    ev.notify();
    wait(10, SC_NS);

    count = 24;
    t5.throw_it(ex);
    wait(10, SC_NS);

    count = 25;
    areset.write(false);
    wait(sc_time(700, SC_NS) - sc_time_stamp());

    count = 26;
    ev.notify();
    wait(10, SC_NS);
    // async_reset_signal_is ?    
  }
  void ctrl()
  {
    wait(SC_ZERO_TIME);
    sc_assert( sc_delta_count() == 1 );
    
    count = 1;
    ev.notify();
    wait(target_awoke_event);
    
    count = 2;
    ev.notify();
    t.suspend();
    yield();
    
    count = 2;
    t.resume();
    wait(target_awoke_event);

    count = 3;
    ev.notify();
    t.disable();
    wait(target_awoke_event);
    
    count = 4;
    ev.notify();
    yield();

    count = 5;
    t.enable();
    yield();

    count = 6;
    ev.notify();
    wait(target_awoke_event);
    
    count = 7;
    t.suspend();
    ev.notify();
    yield();
    
    count = 8;
    t.resume();
    wait(target_awoke_event);
    
    count = 9;
    reset_count = 9;
    t.sync_reset_on();
    ev.notify();
    wait(target_awoke_event);
    
    count = 10;
    reset_count = 10;
    ev.notify();
    wait(target_awoke_event);

    count = 11;
    t.sync_reset_off();
    ev.notify();
    wait(target_awoke_event);
    
    count = 12;
    t.resume();
    t.enable();
    t.sync_reset_off();
    yield();
    
    count = 13;
    ev.notify();
    wait(target_awoke_event);
     
    count = 14;
    reset_count = 14;
    t.reset();
    
    count = 15;
    ev.notify();
    wait(target_awoke_event);
    
    count = 16;
    reset_count = 16;
    t.reset();
    
    count = 17;
    t.throw_it(ex);

    count = 18;
    t.kill();
    yield();
    
    count = 19;
    m.enable();
    ev.notify();
    wait(target_awoke_event);
        
    count = 20;
    ev.notify();
    m.suspend();
    yield();
    
    count = 21;
    m.resume();
    wait(target_awoke_event);
        
    count = 22;
    m.suspend();
    ev.notify();
    yield();
    
    count = 23;
    m.resume();
    wait(target_awoke_event);

    count = 24;
    m.suspend();
    ev.notify();
    
    count = 25;
    m.resume();
    wait(target_awoke_event);

    count = 26;
    reset_count = 26;
    m.sync_reset_on();
    ev.notify();
    wait(target_awoke_event);
    
    count = 27;
    m.disable();
    ev.notify();
    yield();
    
    count = 28;
    reset_count = 28;
    m.enable();
    ev.notify();
    wait(target_awoke_event);
    
    count = 29;
    m.sync_reset_off();
    m.enable();
    m.resume();
    yield();
    
    count = 30;
    reset_count = 30;
    m.reset();
    
    count = 31;
    m.kill();
    yield();
    
    sc_assert( sc_delta_count() == 1 );
    f27 = 1;
  }