Пример #1
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();
  }
Пример #2
0
  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();
  }
Пример #3
0
  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 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);
 }
 void target1()
 {
   sc_assert(count == 0);
   ch2 = sc_spawn(sc_bind(&Top::child2, this));
   ch3 = sc_spawn(sc_bind(&Top::child3, this));
   wait(ch2.terminated_event() & ch3.terminated_event());
   f5 = 1;
 }
Пример #6
0
 void ctrl()
 {
   ts3.resume();
   
   wait(10, SC_NS);
   ts1.resume();
   ev.notify();
   
   wait(10, SC_NS);
   ts2.resume();
   tr2.sync_reset_off();
   tr4.sync_reset_off();
   
   wait(10, SC_NS);
   td2.enable();
   
   wait(10, SC_NS);
   ev.notify();
   
   wait(10, SC_NS);
   ev.notify();
   td2.disable();
   
   wait(10, SC_NS);
   td4.enable();
   ts4.resume();
   ev.notify();
 }
Пример #7
0
 void target3() // Target for throw_it from target2()
 {
   try {
     wait(1, SC_US);
   }
   catch (std::exception ex) {
     sc_assert( t3.valid() );
     sc_assert( !t3.terminated() );
     f6 = 1;
   }
 }
Пример #8
0
 void target()
 {
   cout << "Target called at " << sc_time_stamp() << endl;
   if (suspend_target)
     t.suspend();
   if (resume_target)
   {
     t.resume();
     suspend_target = false;
   }
 }
Пример #9
0
 void start_of_simulation()
 {
   try {
     t1.throw_it(ex);
   }
   catch (std::exception ex) {
     f1 = 1;
     sc_assert( t1.valid() );
     sc_assert( !t1.terminated() );
   }
 }
 void child8()
 {
   gch10 = sc_spawn(sc_bind(&Top::grandchild10, this));
   gch11 = sc_spawn(sc_bind(&Top::grandchild11, this));
   try {
     wait(20, SC_NS);
   }
   catch (std::exception e) {
     f13 = 1;
     sc_assert( sc_time_stamp() == sc_time(210, SC_NS) );
   }
   wait(gch10.terminated_event() & gch11.terminated_event());
 }
 void child9()
 {
   gch12 = sc_spawn(sc_bind(&Top::grandchild12, this));
   gch13 = sc_spawn(sc_bind(&Top::grandchild13, this));
   try {
     wait(20, SC_NS);
   }
   catch (std::exception e) {
     f14 = 1;
     sc_assert( sc_time_stamp() == sc_time(210, SC_NS) );
   }
   wait(gch12.terminated_event() & gch13.terminated_event());
 }
Пример #12
0
 void target2()
 {
   wait(100, SC_NS);
   try {
     t2.throw_it(ex);  // Process throws an exception to itself
     sc_assert( false );
   }
   catch (std::exception ex) {
     sc_assert( t2.valid() );
     sc_assert( !t2.terminated() );
     f5 = 1;
     t3.throw_it(ex);
   }
 }
Пример #13
0
  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 target7()
 {
   wait(200, SC_NS);
   count = 11;
   ch8 = sc_spawn(sc_bind(&Top::child8, this));
   ch9 = sc_spawn(sc_bind(&Top::child9, this));
   try {
     wait(20, SC_NS);
   }
   catch (std::exception e) {
     sc_assert( sc_time_stamp() == sc_time(210, SC_NS) );
   }
   wait(ch8.terminated_event() & ch9.terminated_event());
   sc_assert( sc_time_stamp() == sc_time(214, SC_NS) );
   f12 = 1;
 }
Пример #15
0
 void target()
 {
   cout << "Target called/reset at " << sc_time_stamp() << endl;
   count = 0;
   for (;;)
   {
     try {
       wait(ev);
       cout << "Target awoke at " << sc_time_stamp() << endl;
       ++count;
     }
     catch (const sc_unwind_exception& ex) {
       cout << "sc_unwind_exception caught by target" << endl;
       if (count == 2)
         sc_assert( ex.is_reset() );
       else if (count == 1)
       {
         sc_assert( !ex.is_reset() );
         sc_assert( !killing_over );
         k.kill();
       }
       else
         sc_assert( false );
       throw ex;
     }
   }
 }
Пример #16
0
  void calling()
  {
    wait(15, SC_NS);
    // Target runs at 10 NS
    
    suspend_target = true;
    wait(10, SC_NS);
    // Target runs at 20 NS and suspends itself
    
    wait(10, SC_NS);
    // Target does not run at 30 NS
    
    suspend_target = false;
    t.resume();
    // Target runs at 35 NS
    
    wait(10, SC_NS);
    // Target runs at 40 NS  

    suspend_target = true;
    resume_target = true;
    wait(10, SC_NS);
    // Target runs at 50 NS  
    
    sc_stop();
  }
 void target4()
 {
   if (count == 0)
   {
     wait(100, SC_NS);
     count = 9;
     ch5 = sc_spawn(sc_bind(&Top::child5, this));
     ch6 = sc_spawn(sc_bind(&Top::child6, this));
   }
   else // Hard reset
   {
     sc_assert( sc_time_stamp() == sc_time(110, SC_NS) );
     f11 = 1;
   }
   wait(ch5.terminated_event() & ch6.terminated_event());
   f6 = 1;
 }
Пример #18
0
  void T1()
  {
    wait(25, SC_NS);
    cout << "suspend: time = " << sc_time_stamp() << endl;
    h2.suspend();
    wait(20, SC_NS);
    cout << "resume: time = " << sc_time_stamp() << endl;
    h2.resume();
    wait(20, SC_NS);

    cout << "disable: time = " << sc_time_stamp() << endl;
    h2.disable();
    wait(20, SC_NS);
    cout << "enable: time = " << sc_time_stamp() << endl;
    h2.enable();
    wait(20, SC_NS);
    sc_stop();
  }
Пример #19
0
  void target()
  {
    bomb local_obj(target_handle);

    wait(10, SC_NS);
    
    f0 = 1;
    target_handle.kill();
  }
Пример #20
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;
     }
   }
 }
Пример #21
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;
  }
Пример #22
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;
   }
 }
Пример #23
0
  void third_bystander() // Gets killed by second bystander
  {
    for (;;)
    {
      try {
        wait(ev);
      }
      catch (const sc_unwind_exception& ex) {
        cout << "sc_unwind_exception caught by third_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( b.is_unwinding() ); // sic
        sc_assert( b2.is_unwinding() ); // sic
        sc_assert( sc_is_unwinding() );

        third_bystander_knocked_over = true;
        throw ex;
      }
    }
  }
Пример #24
0
 void calling()
 {
   wait(15, SC_NS);
   // Target runs at time 10 NS due to notification
   
   t.sync_reset_on();
   // Target does not run at time 15 NS 
   
   wait(10, SC_NS);
   // Target is reset at time 20 NS due to notification 
   
   wait(10, SC_NS);
   // Target is reset again at time 30 NS due to notification 
   
   t.sync_reset_off();
   // Target does not run at time 35 NS 
   
   wait(10, SC_NS);
   // Target runs at time 40 NS due to notification
   
   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();
    }
  }
Пример #26
0
 void ticker()
 {
   for (;;)
   {
     try {
       wait(10, SC_NS);
       ev.notify();
       sc_assert( !sc_is_unwinding() );
     }
     catch (const sc_unwind_exception& ex)
     {
       // ticker process killed by target
       cout << "sc_unwind_exception caught by ticker" << endl;
       sc_assert( !ex.is_reset() );
       sc_assert( count == 1 );
       sc_assert( !killing_over );
       sc_assert( t.is_unwinding() );
       sc_assert( sc_is_unwinding() );
      
       v.kill();
       throw ex;
     }
   }
 }
  void T1()
  {
    wait(1, SC_NS);
    t2a = sc_spawn(sc_bind(&Top::T2, this));
    t2b = sc_spawn(sc_bind(&Top::T2, this));
    wait(1, SC_NS);
    sc_assert( t2a.valid() );
    sc_assert( t2b.valid() );
    
    std::vector<sc_object*> children = t1.get_child_objects();
    sc_assert( children.size() == 2);
    
    sc_event_and_list and_list = t2a.terminated_event() & t2b.terminated_event();
    wait( and_list );

    sc_assert( t2a.valid() );
    sc_assert( t2a.terminated() );
    sc_assert( t2b.valid() );
    sc_assert( t2b.terminated() );
    sc_assert( sc_time_stamp() == sc_time(3, SC_NS) );
  }
  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);
  }
Пример #29
0
  void target()
  {
    cout << "Target called/reset at " << sc_time_stamp() << endl;

    for (;;)
    {
      try {
        wait(ev);
        cout << "Target awoke at " << sc_time_stamp() << endl;
      }
      catch (const sc_unwind_exception& ex) {
        cout << "Unwinding at " << sc_time_stamp() << endl;
        sc_assert( t.is_unwinding() );
        sc_assert( sc_is_unwinding() );
        throw ex;
      }
    }
  }
Пример #30
0
 ~bomb()
 {
   h.kill();  // Aborts !!!!!!
 }