Ejemplo n.º 1
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();
  }
 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);
 }
Ejemplo n.º 3
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();
 }
//------------------------------------------------------------------------------
//"sc_process_b::add_static_event"
//
// This method adds an event to the list of static events, and sets the
// event up to call back this process when it fires.
//------------------------------------------------------------------------------
void sc_process_b::add_static_event( const sc_event& e )
{
    sc_method_handle method_h; // This process as a method.
    sc_thread_handle thread_h; // This process as a thread.


    // CHECK TO SEE IF WE ARE ALREADY REGISTERED WITH THE EVENT:

    for( int i = m_static_events.size() - 1; i >= 0; -- i ) {
        if( &e == m_static_events[i] ) {
            return;
        }
    }

    // REMEMBER THE EVENT AND THEN REGISTER OUR OBJECT INSTANCE WITH IT:

    m_static_events.push_back( &e );

    switch ( m_process_kind )
    {
    case SC_THREAD_PROC_:
    case SC_CTHREAD_PROC_:
        thread_h = SCAST<sc_thread_handle>( this );
        e.add_static( thread_h );
        break;
    case SC_METHOD_PROC_:
        method_h = SCAST<sc_method_handle>( this );
        e.add_static( method_h );
        break;
    default:
        assert( false );
        break;
    }
}
Ejemplo n.º 5
0
 void schedule_events_while_paused()
 {
   sig4.write(4);
   immed_event.notify();
   delta_event.notify(SC_ZERO_TIME);
   
   // Should be able to instantiate an sc_object while paused
   mut = new sc_mutex("mut");
   sem = new sc_semaphore("sem", 1);
 }
Ejemplo n.º 6
0
  void f()
  {
    while(true)
    {
      e2.notify(sc_time(1,sc_ns));
      wait(e2);

      e3.notify(sc_time(10,sc_ns));

      wait(e3);
    }
  }
Ejemplo n.º 7
0
 void getmsg() {
   if (m<max) {
     wait(msg_event);
     msg = (++m) * 11 + 5;
     msg_event.notify();
   }
 }
Ejemplo n.º 8
0
Archivo: main.cpp Proyecto: Yonka/sc
 virtual void write(sc_uint<8> data)
 {
     if (data == 255)
         eop.notify(0, SC_MS);
     else
         write_buf.write(data);
 }
Ejemplo n.º 9
0
  void topEntry() {
    while(true) {
      x = x*2;

      if (x>5){
				
	wait(1, SC_NS);
					
      }
      v++;
      wait(1, SC_NS);
      w++;
      y = y + 1;
      for (int i = 0; i<10; i++) {
	x++;
	if (x>3){
	  x = y-2;
	  wait(1, SC_NS);
	}
      }
      x = x *2;			
      oev.notify(1, SC_NS);
      wait(ev);
      y = x-2;
      f(x, y);
      out_port.write(y);
      wait(4, SC_NS);
    }	
  }
Ejemplo n.º 10
0
	void f3() {
		while(true) {
			global = 4;
			wait(15, SC_NS);
   e1.notify();
		}
	}
Ejemplo n.º 11
0
Archivo: main.cpp Proyecto: Yonka/sc
    void send_byte()
    {
        out_port->write(x);
        send.notify(5, SC_NS);
        wait();
//		cout << "send " << x << '\n';
    }
Ejemplo n.º 12
0
 void gen()
 {
   for (;;)
   {
     wait(10, SC_NS);
     ev.notify();
   }
 }
Ejemplo n.º 13
0
 void ticker()
 {
   for (;;)
   {
     wait(10, SC_NS);
     ev.notify();
   }
 }
Ejemplo n.º 14
0
 void before_end_of_elaboration()
 {
   cout << "sc_get_status() == " << hex << sc_get_status() << " before_end_of_elaboration in " << name() << endl;
   sc_assert( sc_get_status() == SC_BEFORE_END_OF_ELABORATION );
   sc_assert( sc_is_running() == false );
   sig1.write(1);
   timed_event.notify(1234, SC_NS);
   sc_pause();  // Should be ignored
 }
  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);
  }
Ejemplo n.º 16
0
  void f()
  {
    while(true)
    {
      e1.notify(sc_time(5,sc_ns));
      wait(e1);

      wait(2,sc_ns);
    }
  }
Ejemplo n.º 17
0
    int round_robin(const char *str, sc_event& receive, sc_event& send, int cnt)
    {
        while (--cnt >= 0)
        {
            wait(receive);
            cout << "Round robin thread " << str <<
                 " at time " << sc_time_stamp() << endl;
            wait(10, SC_NS);
            send.notify();
        }

        return 0;
    }
Ejemplo n.º 18
0
 void T() {
   if(m>0 && max > 0)
     wait(20,SC_NS);
   if (m<max+1) {    
     msg_event.notify();
     wait(msg_event);
     h = hash(msg);
     while (table[h] != 0) {
       h = (h+1) % size;
     }
     table[h] = msg;
   }
 }
  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();
    }
  }
Ejemplo n.º 20
0
 void target_method()
 {
   switch (count)
   {
     case 19: f20=1; break;
     case 21: f21=1; break;
     case 23: f22=1; break;
     case 25: f23=1; break;
     case 26: f24=1; break;
     case 28: f25=1; break;
     case 30: f26=1; break;
     default: sc_assert(false); break;
   }
   target_awoke_event.notify();
 }
Ejemplo n.º 21
0
	void f1() {
		while(true) { 
			wait(SC_ZERO_TIME);
			cout<<"TimeStamp: " <<sc_time_stamp();
			for (int i = 0 ; i<10; i++) {
				x[i] = i;
			}
			wait(1, SC_NS);
			cout<<"\nTimeStamp wait(1, SC_NS): " <<sc_time_stamp();
			e1.notify();
			cout<<"\nTimeStamp e1.notify(): " <<sc_time_stamp();
			wait(e3);
			cout<<"\nTimeStamp wait(e3): " <<sc_time_stamp();
			sc_stop();
		}
	}
Ejemplo n.º 22
0
 void target_thread()
 {
   switch (count)
   {
     case  0: f0=1; break;
     case  9: f7=1; break;
     case 10: f9=1; break;
     case 14: f13=1; break;
     case 16: f16=1; break;
     default: sc_assert(false); break;
   }
   while (true)
   {
     try {
       target_awoke_event.notify();
       wait(ev);
      }
     catch (const std::exception& e) {
       switch (count)
       {
         case  9: sc_assert(sc_is_unwinding()); f6=1; break;
         case 10: sc_assert(sc_is_unwinding()); f8=1; break;
         case 14: sc_assert(sc_is_unwinding()); f12=1; break;
         case 16: sc_assert(sc_is_unwinding()); f15=1; break;
         case 17: sc_assert( !sc_is_unwinding() ); f17=1; break;
         case 18: sc_assert(sc_is_unwinding()); f19=1; break;
         default: sc_assert(false); break;
       }
       if ( sc_is_unwinding() )
         throw dynamic_cast<const sc_unwind_exception&>(e);
     }
     switch (count)
     {
       case  1: f1=1; break;
       case  2: f2=1; break;
       case  3: f3=1; break;
       case  6: f4=1; break;
       case  8: f5=1; break;
       case 11: f10=1; break;
       case 13: f11=1; break;
       case 15: f14=1; break;
       case 17: f18=1; break;
       default: sc_assert(false); break;
     }
   }
 }
Ejemplo n.º 23
0
  void ticker()
  {
    for (;;)
    {
      try {
        wait(10, SC_NS);
        ev.notify();
      }
      catch (const sc_unwind_exception& ex) {
        // ticker process killed by target
        cout << "sc_unwind_exception caught by ticker" << endl;
	sc_assert( sc_is_unwinding() ); 
        sc_assert( !ex.is_reset() );
        sc_assert( count == 1 );
        sc_assert( !killing_over );
        throw ex;
      }
    }
  }
Ejemplo n.º 24
0
	void latency_measurement_poc() {
		last_time_stamp = sc_time_stamp();
		max_latency = SC_ZERO_TIME;
		while(true) {
			wait(end1|end2|end3);
			if(!end1_pending && !end2_pending && !end3_pending ) {
				cur_latency = sc_time_stamp()-last_time_stamp;
				last_time_stamp = sc_time_stamp();
				if( cur_latency > max_latency) {
					max_latency = cur_latency;
				}
				cout << "\t ------------------->  LATENCY : " << cur_latency << endl;
				end1_pending= true;
				end2_pending= true;
				end3_pending= true;
				send_other_input_vector.notify(SC_ZERO_TIME);
			}
		}
	}
Ejemplo n.º 25
0
 void yield()
 {
   yield_event_1.notify();
   wait(yield_event_2);
 }
Ejemplo n.º 26
0
 void yield_helper_method()
 {
   yield_event_2.notify();
 }
Ejemplo n.º 27
0
//int ldecod(/*int argc, char **argv*/)
//int ldecod(char * cfg_file)
//int ldecod(char * cfg_file, unsigned char * bitstream)
//int ldecod(char * cfg_file, unsigned char * bitstream, unsigned int length)
int ldecod(unsigned char * bitstream, unsigned int length)
#endif
{
  // allocate memory for the structures
if (Frame_cnt == 0)
{
  if ((input =  (struct inp_par *)calloc(1, sizeof(struct inp_par)))==NULL) no_mem_exit("main: input");
  if ((snr =  (struct snr_par *)calloc(1, sizeof(struct snr_par)))==NULL) no_mem_exit("main: snr");
  if ((img =  (struct img_par *)calloc(1, sizeof(struct img_par)))==NULL) no_mem_exit("main: img");
}
  // Read Configuration File
/*
  if (argc != 2)
  {
    snprintf(errortext, ET_SIZE, "Usage: %s <config.dat> \n\t<config.dat> defines decoder parameters",argv[0]);
    error(errortext, 300);
  }
*/
  Bitstream_leng = length;
 //init_conf(input, cfg_file);// read cfg & init
  init_conf2(input);// read cfg & init

  g_new_frame=1;

  switch (input->FileFormat)
  {
  case 0:
    //OpenBitstreamFile (input->infile);//Load bitsteam: master_read()
    OpenBitstreamFile2 (bitstream);//Load bitsteam: master_read()
    break;
  case 1:
    OpenRTPFile (input->infile);
    break;
  default:
    printf ("Unsupported file format %d, exit\n", input->FileFormat);
  }

  // Allocate Slice data struct
  malloc_slice(input,img);

  init(img);

  dec_picture = NULL;

  dpb.init_done = 0;

  //  init_dpb(input);
  init_out_buffer();

  img->idr_psnr_number=0;
  img->psnr_number=0;

  img->number=0;
  img->type = I_SLICE;
  img->tr_old = -1; // WYK: Oct. 8, 2001, for detection of a new frame
  img->dec_ref_pic_marking_buffer = NULL;

  // B pictures
  Bframe_ctr=0;

  // time for total decoding session
  tot_time = 0;
#ifdef ESLSC
  tb_hls_cavld_p = (tb_hls_cavld*)tb;
#endif
  // one clock cycle for one frame
  //printf("[%d]",Frame_cnt);
  //cout<< "-->start_time:"<<sc_time_stamp() << endl;
  while (decode_one_frame(img, input, snr) != EOS)
  {
    //flush_one_dpb();//cylin  
    
    num_pending_frame++;
    if(!flag_start_dump_frame){             
      //cout<< sc_time_stamp() <<"\t"<<" ldecode().event_dump_one_frame_req.notify"<<endl;
      flag_start_dump_frame = 1;
      event_dump_one_frame_req.notify(5*CLK_CYCLES, CLK_UNIT);//CYLin:define in "global.h"
    }
    
  }
  //if(flag_start_dump_frame && num_pending_frame >= FRAME_BUFFER_SIZE)
  if(num_pending_frame >= FRAME_BUFFER_SIZE)
    wait(event_dump_one_frame_end);//CYLin:waiting pre-frame

  __report(input, img, snr);

if(Frame_cnt == 60)
{
  //if(flag_start_dump_frame)
  while(num_pending_frame){
      wait(event_dump_one_frame_end);//CYLin:waiting pre-frame
  }
  free_slice(input,img);
  FmoFinit();
  free_global_buffers(input, img);
  //printf("********  flush_dpb()  ***********\n");//cylin.debug
  flush_dpb();

  //CloseBitstreamFile();
  CloseBitstreamFile2();

//  fclose(p_out);
//  fclose(p_out2);
  if (p_ref)
    fclose(p_ref);
#if TRACE
  fclose(p_trace);
#endif

  ercClose(erc_errorVar);

  free_dpb();

  uninit_out_buffer();

  free (input);
  free (snr);
  free (img);
}  
  //while( !kbhit() ); 
  return 0;
}
Ejemplo n.º 28
0
  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;
  }
Ejemplo n.º 29
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 ?    
  }
Ejemplo n.º 30
0
 void T()
 {
   ev.notify(150, SC_NS);
 }