RecoSim  1.0
 All Classes Files Functions Variables Enumerations
TB_Intermediate_OUT.h
Go to the documentation of this file.
1 
11 #include "user_parameters.h"
12 #ifndef TB_INTERMEDIATE_OUT_TESTBENCH_FILE_H
13 #define TB_INTERMEDIATE_OUT_TESTBENCH_FILE_H
14 
15 /*****************************************************************************/
16 /************************** BEGIN USER SPACE ********************************/
17 
18 /*******************/
19 /* Input TestBench */
20 template<int Ni>
21 void TB_Intermediate_OUT(Testbench_in_interface<Ni> &tb_interface) {
22 
23  /* Default Behavior */
24 
25  // Verify data 'on-the-fly'
26  int nb_transactions_received = 0;
27  int nb_diff = 0;
28  int last_transaction_count[Ni];
29  for(int i = 0; i < Ni; i++) last_transaction_count[i] = 0;
30 
31  while(nb_transactions_received != NB_TRANSACTIONS_TO_SEND * Ni) {
32 
33  /* Time out right before end of simulation */
34  sc_time timeout(Reconfiguration_manager::getMaximumSimulationTime() - sc_time_stamp() - sc_time(1, SC_US));
35  wait(timeout, tb_interface.TB_IF_transaction_received_event());
36 
37  //got new transaction release second application
38  //for (int i=0; i<NB_SLICES_APPLICATION; i++)
39  //{
40  //TB_lock[i].notify();
41  //}
42  //Slice_lock_OUT.post();
43 
44  if(sc_time_stamp() == Reconfiguration_manager::getMaximumSimulationTime() - sc_time(1, SC_US)) {
45  /* Reached end of simulation due to timeout, something is wrong with the testbench */
46  cout << "CRITICAL WARNING: End of simulation reached but testbench thread is still waiting for transactions..." << endl;
47  cout << "Testbench name: " << tb_interface.TB_IF_name();
48  cout << "Consider revising:" << endl;
49  cout << " - Testbench to wait for less transactions" << endl;
50  cout << " - Module algorithms to send data more often" << endl;
51  return;
52  }
53  else {
54  /* Event(s) received */
55  for(int i = 0; i < Ni; i++) {
56  if(tb_interface.TB_IF_get_nb_transactions_received_per_socket(i) != last_transaction_count[i]) {
57  // Data received on this socket
58  // Check data
59  int *data_ptr = tb_interface.TB_IF_get_data_in_ptr(i);
60  for(int j = 0; j < 16; j++) {
61  if(data_ptr[j] != ((last_transaction_count[i] << 16) | j)) {
62  nb_diff++;
63  cout << "Socket " << i << ", Transaction " << last_transaction_count[i] << ", Data " << j << " -> " << hex << data_ptr[j] << " (expected " << ((last_transaction_count[i] << 16) | j) << ")" << endl;
64  }
65  }
66 
67  // Update transaction count
68  last_transaction_count[i]++;
69 
70  break;
71  }
72  }
73 
74  nb_transactions_received++;
75  }
76 
77 
78  }
79 
80  if(nb_diff == 0) {
81  Simulation_controller::get_logfile() << endl << "==================================================" << endl;
82  Simulation_controller::get_logfile() << " CONGRATULATIONS: Simulation ended successfully " << endl;
83  Simulation_controller::get_logfile() << "==================================================" << endl << endl;
84 
85  // Communicate with the simulation controller
86  tb_interface.TB_IF_notify_simulation_controller(true);
87  } else {
88  Simulation_controller::get_logfile() << endl << "==================================================" << endl;
89  Simulation_controller::get_logfile() << " Simulation failed with " << dec << nb_diff << " errors " << endl;
90  Simulation_controller::get_logfile() << "==================================================" << endl << endl;
91 
92  exit(RECOSIM_TESTBENCH_CHECK_FAILED);
93  }
94 }
95 
96 /************************** END USER SPACE ********************************/
97 /***************************************************************************/
98 
99 #endif
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_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 int * TB_IF_get_data_in_ptr(int socketID) const =0
Get incoming data pointer.
virtual const char * TB_IF_name(void) const =0
Get testbench full name.