Пример #1
0
///////////////////////////////////////////////////////////////////////////////
//
//	Write
//
///////////////////////////////////////////////////////////////////////////////
void DataRAM::Write(unsigned int addr, unsigned int data)
{		
	if ( addr >= m_RAMSize )
	{
		cout << "Écriture hors de la plage de la RAM" << endl;
		
		// Fin de la simulation
		sc_stop();
	}
	else
	{			
		// On copie le contenu de la mémoire
		memcpy( (void*)((unsigned int)(m_ptrRAM) + addr), &data, 4);
	}
}
Пример #2
0
void display::entry(){

  //  Reading Data when valid if high
  tmp1 = result.read();
  cout << "Display : " << tmp1 << " " 
       /* << " at time " << sc_time_stamp() << endl; */
       << " at time " << sc_time_stamp().to_double() << endl;
  i++;
  if(i == 24) {
    cout << "Simulation of " << i << " items finished" 
	 /* << " at time " << sc_time_stamp() << endl; */
	 << " at time " << sc_time_stamp().to_double() << endl;
    sc_stop();
  };
}
Пример #3
0
void Source::run() 
{
	dc_enable.write(0);
    wait(1,SC_PS);
    dc_enable.write(1);
    wait();

	for(int i=0;i<maxc;i++)
    {
        dc_input.write(i);
        wait();
    }

    sc_stop();
}
Пример #4
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();
		}
	}
Пример #5
0
/*
 *
 * main (although perhaps under a different name)
 *
 * Bring the system up and start the event dispatch loops.
 * Make invocations to the user hooks during the different phases
 * of bringup, run and shutdown.
 *
 */
int sc_main ( int argc, char* argv[] )
{
  UserInitializationCallout();
  UserPreOoaInitializationCallout();
  gpssysc_sys* gpssysc_top = 0;
  gpssysc_top = new gpssysc_sys("gpssysc_sys");

  UserPostOoaInitializationCallout();
  //--- Steady State Simulation
  sc_start();
  UserPreShutdownCallout();
  sc_stop();
  UserPostShutdownCallout();
  delete gpssysc_top;
  return 0;
}
Пример #6
0
void tb::entry() 
{
  cout << "Begin Simulation" << endl;

        reset_sig = 1;
	cont1 = 0;
        i1 = 0;
        i2 = 0;
        single_cycle;
        reset_sig = 0;
 
	i1 = 5;
        single_cycle;
        single_cycle;
        single_cycle;
        single_cycle;
        single_cycle;
        single_cycle;

        set_value(cont1,1);
        single_cycle;
        single_cycle;
	
        test_value(o1,2);
        test_value(o2,3);
 
        // 2nd iteration. Test 'else' clause.
        i1 = 0;
        i2 = 0;
	cont1 = 0;
        single_cycle;
        single_cycle;
        single_cycle;
        single_cycle;
 
        test_value(o1,2);
        test_value(o2,3);
 
        long_wait;
 

  cout << "End Simulation" << endl;

  sc_stop();

}
Пример #7
0
void display::entry(){
    int i = 0;
    
    wait(2);
    while(1) {
	//  Reading Data, and Counter i,j is counted up.
	while (in_valid.read()==false) wait();
	cout << "Display : " << in_data1.read() << " "
	     << in_data2.read() << " "
	     << in_data3.read() << " "
	     << in_data4.read() << " "
	     << " at " << sc_time_stamp() << endl;
	i++;
	if(i == 24) 	    sc_stop();
        wait();
    }
}
Пример #8
0
 void prc_driver()
 {
    sc_uint<2> pattern;
    d.write(0);
    clk.write(0);
    pattern = 0;
    do
    {
       wait(5, SC_NS);
       pattern++;
       d.write(pattern[1]);
       clk.write(pattern[0]);
    }
    while(0x3 != pattern);
    wait(5, SC_NS);
    sc_stop();
 }
Пример #9
0
void Stim::action()
{
  wait();

  for (sc_int<8> i = -10; i < 10; i=i+2) {
    a.write(i);                         // can convert to sc_bv via assignment
    for (sc_int<8> j = -10; j < 10; j=j+2 ) {
      b.write(j);
      wait();
    }
  }

  a.write(0);
  b.write(0);
  wait();

  sc_stop();
}
Пример #10
0
void
stimgen::entry()
{
  bool_vector8	d;

//  in1.write("0101_1001");
  in1.write("01011001");
  wait(2);

  cout << "IN1 = "  << in1.read() << endl;
  cout << "O1 = "   << o1.read() 
       << "  O2 = " << o2.read() << endl;
  cout << "O3 = "   << o3.read() << endl;
  cout << "O4 = "   << o4.read() << endl;
  cout << "O5 = "   << o5.read() << endl;

  sc_stop();
}
Пример #11
0
void TestSem::body_1()
{
    unsigned int loop_counter=0;
    char buf[BUFSIZ];
    
    while (loop_counter++<10 && !sem_1.wait())
    {
        sprintf(buf, "time %f => thread1 : took semaphore %d times\n",
                sc_time_stamp().to_double(), loop_counter);
        cout << buf << flush;
}

    sprintf(buf, "time %f => thread1 : value of semaphore = %d\n",
            sc_time_stamp().to_double(), sem_1.get_value());
    cout << buf << flush;
    
    sc_stop();
}
Пример #12
0
void stimulus::entry() {

    reset.write(true);
    wait();
    reset.write(false);

    sc_signed tmp1(8);
    sc_signed tmp2(8);
    long           tmp3;
    int            tmp4;
    short          tmp5;
    char           tmp6;

    int counter = 0;

    tmp1 = "0b11011011";
    tmp2 = "0b00000001";
    tmp3 = 1;
    tmp4 = -1;
    tmp5 = 20000;
    tmp6 = 'R';

    while(counter<100){
       out_valid.write(true);    
       out_value1.write(tmp1);
       out_value2.write(tmp2);
       out_value3.write(tmp3);
       out_value4.write(tmp4);
       out_value5.write(tmp5);
       out_value6.write(tmp6);
       cout << "Stimuli: " << tmp1 << " " << tmp2 << " " << tmp3 << " " << tmp4 << " " << tmp5 << " " << endl;
       tmp1 = tmp1 + 1;
       tmp2 = tmp2 + 1;
       tmp3 = tmp3 + 1;
       tmp4 = tmp4 + 1;
       tmp5 = tmp5 + 1;
       tmp6 = tmp6 + 1;
       do { wait(); } while (in_ack==false);
       out_valid.write(false);
       counter++;
       wait();
    }
    sc_stop();
}
Пример #13
0
void stim::entry()
{

// VARIABLE INITIALIZATION
  sc_unsigned	a_tmp(data_width);
  sc_unsigned	b_tmp(data_width);
  bool		c_tmp;
  int 		i, j;

// RESET CYCLE
  reset.write(0);
  wait(2);
   
  reset.write(1);
  wait();
  cout  << sc_time_stamp() << "\t : "
        << "RESET off \t...by stim" << endl;

// STIMULUS GENERATION
  c_tmp = 0;

  for (i=0; i<16; i++) {
    for (j=0; j<16; j++) {     
      a_tmp = j;
      b_tmp = i;
      c_tmp = !c_tmp;

      a.write(a_tmp);	
      b.write(b_tmp);	
      cin.write(c_tmp);

      ready.write(1);
      // wait();
      do { wait(); } while ( done != 1 );

      ready.write(0);
      // do { wait(); } while (done == 1); 
      wait();
    }
  }
 
  sc_stop(); 
   
}
Пример #14
0
void scRegisterFile::entry4()
{
  	uint32_t i=in_REG_PC;
#if defined(DEBUG)
	if(i>0x11) {
	 cout<<" error04:try to access register which doesn't exist. "<<endl;
	 sc_stop();
	}
#endif
	if(m_rw==0)
    {  
		inout_n_Data_PC=*r[i];
	}else
	{
		*r[i]=inout_n_Data_PC;
		//	cout<<"port pc:"<<hex<<(*r[15])<<"="<<hex<<inout_n_Data_PC<<endl;
		m_rw=0;
	}
}
Пример #15
0
/* to terminate the execution */
board_realvieweb::~board_realvieweb(void)
{
    printf("\n");
    printm(d_realvieweb, "board_realvieweb destructor");
    double diff;
    uint32_t pc;

    /* termination information */
    sc_stop();
    time_end = clock();
    diff = (double)(time_end - time_start) / (double)(CLOCKS_PER_SEC);
    /*
    arm->regRead(&pc, PC);
    printm(d_realvieweb, "system terminated@0x%.8x", pc);
    */
    printm(d_realvieweb, "total simulation time = %f seconds", diff);

    //SDL_Quit();
}
void polyIntegral_TB::stimulus(void){
	double a = -5;
	double b = +5;
	double i = a;
	double result_TB = 0.0;
	double result_module = 0.0;
	
	initializeModule();

	/* Generate the Stimulus */
	while(  i <= b ){
		
		valid.write(1);
		oReady.write(1);
		result_TB = evaluatePolyIntegral ( i, b);
		/* Write generted test values to outpur ports */
		lower_lim.write(i);
		upper_lim.write(b);

		do{
			wait();	
		}while(ready.read()== 0);
		
		valid.write(0);
		
		do{
			wait();
		}while(oValid.read() == 0);
		
		result_module = F.read();
		oReady.write(0);

		cout <<"t = "<<sc_time_stamp()<<"\t, limits("
		     << i <<" ," <<b<<" )\t"<<" , Correct result = " 
		     <<result_TB << "\tCalculated Result : "
                       << result_module << "\t Relative Error = "
                       <<(result_TB - result_module )<< endl;

		i = i + 0.25;
		wait();
	}
	sc_stop();
}
Пример #17
0
void top::testbed(){
	while(true){
		wait(long_time);
		cout << "Testbed started... " << endl;
		wait(long_time);
		finger(0);
		wait(long_time);
		finger(3);
		finger(4);
		finger(1);
		finger(9);
		finger(6);
		finger(8);
		finger(7);
		finger(2);
		finger(5);
		sc_stop ();	
	}
}
Пример #18
0
void scRegisterFile::entry()
{
	uint32_t i=in_REG;
	#if defined(DEBUG)
	if(i>0x11) {
	 cout<<" error00:try to access register which doesn't exist. "<<endl;
	 sc_stop();
	}
#endif
	if(m_rw==0)
    {  
		inout_n_Data=*(r[i]);
         //cout<<"read port0:"<<"r"<<hex<<i<<"="<<inout_n_Data<<endl;
	}else
	{	//cout<<"port0:"<<"r"<<hex<<i<<"="<<inout_n_Data<<endl;
		(*r[i])=inout_n_Data;
        m_rw=0;
	}
}
Пример #19
0
void scRegisterFile::entry2()
{
  	uint32_t i=in_REG2;
	#if defined(DEBUG)
	if(i>0x11) {
	 cout<<" error02:try to access register which doesn't exist. "<<endl;
	 sc_stop();
	}
#endif
	if(m_rw==0)
    {  
		inout_n_Data2=*r[i];
	//	cout<<(*r[15])<<"read reg"<<endl;
	}else
	{
		(*r[i])=inout_n_Data2;
	//	cout<<"port2:"<<"r"<<hex<<i<<"="<<inout_n_Data2<<endl;
		m_rw=0;
	}
}
Пример #20
0
void displayp::entry()
{
  bool_vector 	last_prime;

  while (true) {
    
    last_prime = prime.read();
    wait();

    do {
       wait();
       } while (prime.read() == last_prime);

    cout << prime.read().to_uint() << endl;

    if (prime.read().to_uint() > 40)  {
	sc_stop();
    }
  }
}
Пример #21
0
void uvm_phase_controller::stop_run(stop_reason_enum reason) 
{
    static bool invoked = false; 

    if (!invoked) {
        invoked = true;
    } else {
        // stop_run() has already been called;
        // this can happen if uvm_stop_request has been called 
        // but the stop processes do not all return; then global_timeout and
        // stop_timeout will expire at same time, and both will call 
        // stop_run() 
        return;
    }

    m_stop_reason = reason;
    if (m_stop_mode == UVM_SC_STOP) {
        sc_stop();
    }
}
Пример #22
0
void SCBus::batch_thread()
{
	cout << "SCBus: batch_thread() started @ " << sc_time_stamp() << endl;

    SCBusPacket packet;
    set_wall_time_us(0);
    double target_time_us = 0;
    double last_time_us = 0;

    while (true)
    {
        //cout << "SCBus: batch_thread() loop executed @ " << sc_time_stamp() << endl;

        if (batch_fifo.empty()) {
            cout << "SCBus: batch_thread() input FIFO empty @ " << sc_time_stamp() << endl;
            wait(1, SC_MS);
            sc_stop();
            return;
        }

        packet = batch_fifo.front();
        batch_fifo.pop();

        target_time_us = packet.header.timestamp;

        // SystemC timing
        wait(sc_time(target_time_us, SC_US) - sc_time_stamp());
        cout << "SCBus: batch_thread() SystemC wait ended @ " << sc_time_stamp() << " ["
            << get_wall_time_us()/1e6 << " s]" << endl;

        // Wall clock timing
        while (get_wall_time_us() < target_time_us) {}
        last_time_us = get_wall_time_us();
        cout << "SCBus: batch_thread() wall clock wait ended @ " << sc_time_stamp() << " ["
            << get_wall_time_us()/1e6 << " s]" << endl;

        for (int i = 0; i < packet.header.length; i++) {
            rx_fifo.push(packet.data[i]);
        }
    }
}
Пример #23
0
void driver::entry()
{
  control.write(true);
  out.write(false);
  wait();
  cout << "Input is = " << in.read() << endl;
    
  control.write(false);
  wait();
  cout << "Input is = " << in.read() << endl;

  control.write(true);
  out.write(true);
  wait();
  cout << "Input is = " << in.read() << endl;
    
  control.write(false);
  wait();
  cout << "Input is = " << in.read() << endl;
  sc_stop();
} // end of entry function
Пример #24
0
void proc2::entry()
{
  int i;

  data_ack.write(false);
  wait();
  
  while (true) {
    do { wait(); } while (data_ready != true);
    i = data.read();
    cout << "Proc2: Received data = " << i << " at time " << 
      sc_time_stamp() << endl;
    if (i > 12) {
      sc_stop();
    }
    data_ack.write(true);
    wait();
    do { wait(); } while (data_ready != false);
    data_ack.write(false);
  }
} // end of entry function
Пример #25
0
///////////////////////////////////////////////////////////////////////////////
//
//	thread
//
///////////////////////////////////////////////////////////////////////////////
void Bubble::thread(void)
{
	/*
	
	À compléter
	
	*/
	while (1)

	{
		// Read amount of elements to sort
		unsigned int nbElements = readPort->Read(0);
		
		// Read those elements
		unsigned int* elements;
		elements = new unsigned int[nbElements];
		for (unsigned int i = 0; i < nbElements; i++)
		{
			elements[i] = readPort->Read((i + 1) * 4);
		}

		// Sort those value
		bubbleSort(elements, nbElements);

		// Write them in mermory
		for (unsigned int i = 0; i < nbElements; i++)
		{
			writePort->Write((i + 1) * 4, elements[i]);
		}

		// Free memory
		delete []elements;
		elements = nullptr;

		// Stopping the app
		sc_stop();
		wait();
	}
}
Пример #26
0
//----------------------------
// Receive data thread
//---------------------------
void test_decim::recv(){

  // Variables declaration
  float filter_out_write=0;

  out_filter_file = fopen (OUTFILENAME, "wt");

  if(!out_filter_file){
    cout << "Could not open " << OUTFILENAME << "\n";
    sc_stop();
    exit (-1);
  }


  wait();

  while(true){
    filter_out_write = odata.read();
    fprintf(out_filter_file,"%f\n",filter_out_write);
    wait();
  }
}
Пример #27
0
// Driver's output actions.
void
driver_mod::driver_out_proc()
{
    //  while (true) {
    cout << "Driver is up @ " << sc_time_stamp() << endl;

    // Car is at rest.
    speed_set = 0;
    reset = false;
    start = false;
    wait();

    cout << "Driver started the car @ " << sc_time_stamp() << endl;
    cout << "Driver set the speed to 40 km/h @ " << sc_time_stamp() << endl;
    start = true;
    speed_set = 40;
    wait();

    cout << "Driver set the speed to 120 km/h @ " << sc_time_stamp() << endl;
    speed_set = 120;
    wait();

    cout << "Driver reset the partial distance odometer @ "
         << sc_time_stamp() << endl;
    cout << "Driver set the speed to 60 km/h @ " << sc_time_stamp() << endl;
    reset = true;
    speed_set = 60;
    wait();

    cout << "Driver set the speed to 40 km/h @ " << sc_time_stamp() << endl;
    speed_set = 40;
    wait();

    cout << "Driver stopped the car @ " << sc_time_stamp() << endl;
    wait();

    sc_stop();
    //  }
}
Пример #28
0
	void thread()
	{
		my_exception   exception;
		your_exception other_exception;
		for (;;)
		{
			wait(3);
			cout << sc_time_stamp() << " throwing my exception " << endl;
			m_monitor_handle.throw_it(exception);
			wait();

			// test that both exceptions appear.

			cout << sc_time_stamp() << " throwing my exception " << endl;
			m_monitor_handle.throw_it(exception);
			cout << sc_time_stamp() << " throwing your exception " << endl;
			m_monitor_handle.throw_it(other_exception);
			wait();
			wait();
			sc_stop();
		}
	}
Пример #29
0
//--------------------------
// Receive data thread
//--------------------------
void test_fft::recv() {

    // Variables declaration
    float out_write_real, out_write_imag;

    out_file = fopen (OUTFILENAME, "wt");

    if(!out_file) {
        cout << "Could not open " << OUTFILENAME << "\n";
        sc_stop();
        exit (-1);
    }

    wait();

    while(true) {

        while(data_ready.read() == false)
            wait();

        data_ack.write(true);

        out_write_real = out_real.read();
        out_write_imag = out_imag.read();

        fprintf(out_file,"%f ",out_write_real);
        fprintf(out_file,"%f\n",out_write_imag);

        //  cout << "Output vector:" <<out_write_real << "+i" << out_write_imag << endl;

        wait();

        data_ack.write(false);

        wait();

    }
}
Пример #30
0
  void parent()
  {
    proc_tree( 3, 1, true , true );
    proc_tree( 3, 1, false, true );

    wait();

    // copy children (needed, since children may get reordered)
    std::vector< sc_object* > children =
      sc_get_current_process_handle().get_child_objects();

    std::vector< sc_object* >::const_iterator it = children.begin();

    while( it != children.end() )
    {
      sc_process_handle h( *it++ );
      sc_assert( h.valid() );

      std::cout << h.name() << " "
                << "kill requested "
                << "(" << h.get_process_object()->kind() << ") "
                << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
                << std::endl;

      h.kill( SC_INCLUDE_DESCENDANTS );
    }

    wait();

    std::cout << sc_get_current_process_handle().name()
              << " ended "
              << "(" << sc_time_stamp() << " @ " << sc_delta_count() << ")"
              << std::endl;

    wait();
    sc_stop();
    while(true) wait();
  }