21 #ifndef TESTBENCH_ALGORITHM_H
22 #define TESTBENCH_ALGORITHM_H
24 #define NB_TRANSACTIONS_TO_SEND 100
48 for (
int i = 0; i < NB_TRANSACTIONS_TO_SEND; i++) {
51 #ifdef GENERATE_LOG_FILE
52 Simulation_controller::get_logfile() << endl << sc_time_stamp() <<
": " << tb_interface.
TB_IF_name() <<
" checks instantiation for following modules" << endl;
58 for(
int j = 0; j < No; j++) {
62 for(
int k = 0; k < max_packet; k++)
63 data_out_ptr[k] = (i << 16) | k;
78 #ifdef GENERATE_LOG_FILE
79 Simulation_controller::get_logfile() << sc_time_stamp() <<
": " << tb_interface.
TB_IF_name() <<
": Transaction " << i <<
" has been sent" << endl;
83 if(i != (NB_TRANSACTIONS_TO_SEND - 1)) {
85 sc_time delayToNextPacket((i + 1) * tb_interface.
TB_IF_get_period() - sc_time_stamp());
86 if(delayToNextPacket < SC_ZERO_TIME) {
87 cerr <<
"ERROR in TB: Negative delay to next packet send! Consider revising periods and other timing information" << endl;
88 exit(RECOSIM_INTERNAL_ERROR_ERRCODE);
90 wait(delayToNextPacket);
97 #ifdef GENERATE_LOG_FILE
98 Simulation_controller::get_logfile() << sc_time_stamp() <<
": " << tb_interface.
TB_IF_name() <<
": All transactions have been sent" << endl;
105 int nb_transactions_received = 0;
107 int last_transaction_count[Ni];
108 for(
int i = 0; i < Ni; i++) last_transaction_count[i] = 0;
110 while(nb_transactions_received != NB_TRANSACTIONS_TO_SEND * Ni) {
112 sc_time timeout(Reconfiguration_manager::getMaximumSimulationTime() - sc_time_stamp() - sc_time(1, SC_US));
115 if(sc_time_stamp() == Reconfiguration_manager::getMaximumSimulationTime() - sc_time(1, SC_US)) {
117 cout <<
"CRITICAL WARNING: End of simulation reached but testbench thread is still waiting for transactions..." << endl;
118 cout <<
"Testbench name: " << tb_interface.
TB_IF_name();
120 cout <<
"Consider revising:" << endl;
121 cout <<
" - Testbench to wait for less transactions" << endl;
122 cout <<
" - Module algorithms to send data more often" << endl;
129 for(
int i = 0; i < (int) sockets_with_new_transactions.size(); i++) {
130 int socketID = sockets_with_new_transactions.at(i);
135 for(
int j = 0; j < 16; j++) {
136 if(data_ptr[j] != ((last_transaction_count[socketID] << 16) | j)) {
138 cout <<
"Socket " << socketID <<
", Transaction " << last_transaction_count[socketID] <<
", Data " << j <<
" -> " << hex << data_ptr[j] <<
" (expected " << ((last_transaction_count[socketID] << 16) | j) <<
")" << endl;
143 last_transaction_count[socketID]++;
144 nb_transactions_received++;
156 Simulation_controller::get_logfile() << endl <<
"==================================================" << endl;
157 Simulation_controller::get_logfile() <<
" CONGRATULATIONS: Simulation ended successfully " << endl;
158 Simulation_controller::get_logfile() <<
"==================================================" << endl << endl;
163 Simulation_controller::get_logfile() << endl <<
"==================================================" << endl;
164 Simulation_controller::get_logfile() <<
" Simulation failed with " << dec << nb_diff <<
" errors " << endl;
165 Simulation_controller::get_logfile() <<
"==================================================" << endl << endl;
167 exit(RECOSIM_TESTBENCH_CHECK_FAILED);
virtual const sc_event & TB_IF_transaction_received_event(void) const =0
Get the event launched when a transaction has been received.
Definition: testbench_in_interface.h:31
virtual void TB_IF_nb_send_all_data(void)=0
Non-blocking data send through every socket.
virtual sc_time TB_IF_get_period(void) const =0
Get testbench period.
virtual void TB_IF_notify_simulation_controller(bool success)=0
Notifies simulation controller about success/failure of the simulation (e.g. data corruption)...
virtual const int TB_IF_get_nb_transactions_received_per_socket(int socketID) const =0
Get the number of transactions processed per socket.
virtual void TB_IF_increment_current_transaction_id(void)=0
Increments working transaction counter.
Definition: testbench_out_interface.h:31
virtual int * TB_IF_get_data_in_ptr(int socketID) const =0
Get incoming data pointer.
virtual string TB_IF_get_connection_name(int id) const =0
Get the name of the connection bound to a particular socket.
virtual int TB_IF_get_packet_size(int ID) const =0
Get socket packet size.
virtual vector< int > TB_IF_get_sockets_with_new_transactions(void)=0
Get a list of the sockets that received a new transaction since last function call. WARNING: Calling this function will reset the vector stored within the testbench and hence should be stored in a new vector within the algorithm thread.
virtual int * TB_IF_get_data_out_ptr(int socketID) const =0
Get pointer to ougoing data structure.
virtual const char * TB_IF_name(void) const =0
Get testbench full name.
virtual const sc_event & TB_IF_all_responses_received_event(void) const =0
Watch the event issued once all TLM responses have been sent from following modules to testbench...
virtual const char * TB_IF_name(void) const =0
Get testbench full name.