source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/SelfTest/src/test.cpp @ 81

Last change on this file since 81 was 81, checked in by rosiere, 16 years ago
  • Finish Environment (and test)
  • Continue predictor_unit
  • Add external tools
  • svn keyword "Id" set
  • Property svn:keywords set to Id
File size: 12.7 KB
Line 
1/*
2 * $Id: test.cpp 81 2008-04-15 18:40:01Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/SelfTest/include/test.h"
10#include "Common/include/Test.h"
11#include "Behavioural/include/Allocation.h"
12
13#define NB_ITERATION  1
14#define CYCLE_MAX     (128*NB_ITERATION)
15
16#define LABEL(str...)                                                   \
17  {                                                                     \
18    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
19    msg (str);                                                          \
20    msg (_("\n"));                                                      \
21  } while(0)
22
23#define SC_START(cycle_offset)                                                       \
24  do                                                                                 \
25    {                                                                                \
26      /*cout << "SC_START (begin)" << endl;*/                                        \
27                                                                                     \
28      uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time());          \
29      if (cycle_offset != 0)                                                         \
30        {                                                                            \
31          cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \
32        }                                                                            \
33                                                                                     \
34      if (cycle_current > CYCLE_MAX)                                                 \
35        {                                                                            \
36          TEST_KO("Maximal cycles Reached");                                         \
37        }                                                                            \
38                                                                                     \
39      sc_start(cycle_offset);                                                        \
40                                                                                     \
41      /*cout << "SC_START (end  )" << endl;*/                                        \
42    } while(0)
43
44void test (string name,
45           morpheo::behavioural::core::multi_front_end::front_end::ifetch_unit::Parameters * _param)
46{
47  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
48
49#ifdef STATISTICS
50  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
51#endif
52
53  Ifetch_unit * _Ifetch_unit = new Ifetch_unit (name.c_str(),
54#ifdef STATISTICS
55                                             _parameters_statistics,
56#endif
57                                             _param);
58 
59#ifdef SYSTEMC
60  /*********************************************************************
61   * Déclarations des signaux
62   *********************************************************************/
63  string rename;
64
65  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
66  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
67
68  ALLOC_SC_SIGNAL (out_ICACHE_REQ_VAL                     ,"out_ICACHE_REQ_VAL                     ",Tcontrol_t           );
69  ALLOC_SC_SIGNAL ( in_ICACHE_REQ_ACK                     ," in_ICACHE_REQ_ACK                     ",Tcontrol_t           );
70//ALLOC_SC_SIGNAL (out_ICACHE_REQ_THREAD_ID               ,"out_ICACHE_REQ_THREAD_ID               ",Tcontext_t           );
71  ALLOC_SC_SIGNAL (out_ICACHE_REQ_PACKET_ID               ,"out_ICACHE_REQ_PACKET_ID               ",Tpacket_t            );
72  ALLOC_SC_SIGNAL (out_ICACHE_REQ_ADDRESS                 ,"out_ICACHE_REQ_ADDRESS                 ",Ticache_instruction_t);
73  ALLOC_SC_SIGNAL (out_ICACHE_REQ_TYPE                    ,"out_ICACHE_REQ_TYPE                    ",Ticache_type_t       );
74  ALLOC_SC_SIGNAL ( in_ICACHE_RSP_VAL                     ," in_ICACHE_RSP_VAL                     ",Tcontrol_t           );
75  ALLOC_SC_SIGNAL (out_ICACHE_RSP_ACK                     ,"out_ICACHE_RSP_ACK                     ",Tcontrol_t           );
76//ALLOC_SC_SIGNAL ( in_ICACHE_RSP_THREAD_ID               ," in_ICACHE_RSP_THREAD_ID               ",Tcontext_t           );
77  ALLOC_SC_SIGNAL ( in_ICACHE_RSP_PACKET_ID               ," in_ICACHE_RSP_PACKET_ID               ",Tpacket_t            );
78  ALLOC1_SC_SIGNAL( in_ICACHE_RSP_INSTRUCTION             ," in_ICACHE_RSP_INSTRUCTION             ",Ticache_instruction_t,_param->_nb_instruction);
79  ALLOC_SC_SIGNAL ( in_ICACHE_RSP_ERROR                   ," in_ICACHE_RSP_ERROR                   ",Ticache_error_t      );
80  ALLOC_SC_SIGNAL (out_PREDICT_VAL                        ,"out_PREDICT_VAL                        ",Tcontrol_t           );
81  ALLOC_SC_SIGNAL ( in_PREDICT_ACK                        ," in_PREDICT_ACK                        ",Tcontrol_t           );
82  ALLOC_SC_SIGNAL (out_PREDICT_PC_PREVIOUS                ,"out_PREDICT_PC_PREVIOUS                ",Tgeneral_address_t   );
83  ALLOC_SC_SIGNAL (out_PREDICT_PC_CURRENT                 ,"out_PREDICT_PC_CURRENT                 ",Tgeneral_address_t   );
84  ALLOC_SC_SIGNAL (out_PREDICT_PC_CURRENT_IS_DS_TAKE      ,"out_PREDICT_PC_CURRENT_IS_DS_TAKE      ",Tcontrol_t           );
85  ALLOC_SC_SIGNAL ( in_PREDICT_PC_NEXT                    ," in_PREDICT_PC_NEXT                    ",Tgeneral_address_t   );
86  ALLOC_SC_SIGNAL ( in_PREDICT_PC_NEXT_IS_DS_TAKE         ," in_PREDICT_PC_NEXT_IS_DS_TAKE         ",Tcontrol_t           );
87  ALLOC1_SC_SIGNAL( in_PREDICT_INSTRUCTION_ENABLE         ," in_PREDICT_INSTRUCTION_ENABLE         ",Tcontrol_t           ,_param->_nb_instruction);
88  ALLOC_SC_SIGNAL ( in_PREDICT_INST_IFETCH_PTR            ," in_PREDICT_INST_IFETCH_PTR            ",Tinst_ifetch_ptr_t   );
89  ALLOC_SC_SIGNAL ( in_PREDICT_BRANCH_STATE               ," in_PREDICT_BRANCH_STATE               ",Tbranch_state_t      );
90  ALLOC_SC_SIGNAL ( in_PREDICT_BRANCH_UPDATE_PREDICTION_ID," in_PREDICT_BRANCH_UPDATE_PREDICTION_ID",Tprediction_ptr_t    );
91  ALLOC1_SC_SIGNAL(out_DECOD_VAL                          ,"out_DECOD_VAL                          ",Tcontrol_t           ,_param->_nb_instruction);
92  ALLOC1_SC_SIGNAL( in_DECOD_ACK                          ," in_DECOD_ACK                          ",Tcontrol_t           ,_param->_nb_instruction);
93  ALLOC1_SC_SIGNAL(out_DECOD_INSTRUCTION                  ,"out_DECOD_INSTRUCTION                  ",Tinstruction_t       ,_param->_nb_instruction);
94//ALLOC_SC_SIGNAL (out_DECOD_CONTEXT_ID                   ,"out_DECOD_CONTEXT_ID                   ",Tcontext_t           );
95  ALLOC_SC_SIGNAL (out_DECOD_ADDRESS                      ,"out_DECOD_ADDRESS                      ",Tgeneral_address_t   );
96  ALLOC_SC_SIGNAL (out_DECOD_INST_IFETCH_PTR              ,"out_DECOD_INST_IFETCH_PTR              ",Tinst_ifetch_ptr_t   );
97  ALLOC_SC_SIGNAL (out_DECOD_BRANCH_STATE                 ,"out_DECOD_BRANCH_STATE                 ",Tbranch_state_t      );
98  ALLOC_SC_SIGNAL (out_DECOD_BRANCH_UPDATE_PREDICTION_ID  ,"out_DECOD_BRANCH_UPDATE_PREDICTION_ID  ",Tprediction_ptr_t    );
99  ALLOC_SC_SIGNAL (out_DECOD_EXCEPTION                    ,"out_DECOD_EXCEPTION                    ",Texception_t         );
100  ALLOC_SC_SIGNAL ( in_EVENT_VAL                          ," in_EVENT_VAL                          ",Tcontrol_t           );
101  ALLOC_SC_SIGNAL (out_EVENT_ACK                          ,"out_EVENT_ACK                          ",Tcontrol_t           );
102  ALLOC_SC_SIGNAL ( in_EVENT_ADDRESS                      ," in_EVENT_ADDRESS                      ",Tgeneral_address_t   );
103 
104  /********************************************************
105   * Instanciation
106   ********************************************************/
107 
108  msg(_("<%s> : Instanciation of _Ifetch_unit.\n"),name.c_str());
109
110  (*(_Ifetch_unit->in_CLOCK))        (*(in_CLOCK));
111  (*(_Ifetch_unit->in_NRESET))       (*(in_NRESET));
112
113  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_ICACHE_REQ_VAL                     );
114  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_ICACHE_REQ_ACK                     );
115//INSTANCE_SC_SIGNAL (_Ifetch_unit,out_ICACHE_REQ_THREAD_ID               );
116  if (_param->_have_port_queue_ptr)
117  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_ICACHE_REQ_PACKET_ID               );
118  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_ICACHE_REQ_ADDRESS                 );
119  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_ICACHE_REQ_TYPE                    );
120  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_ICACHE_RSP_VAL                     );
121  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_ICACHE_RSP_ACK                     );
122//INSTANCE_SC_SIGNAL (_Ifetch_unit, in_ICACHE_RSP_THREAD_ID               );
123  if (_param->_have_port_queue_ptr)
124  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_ICACHE_RSP_PACKET_ID               );
125  INSTANCE1_SC_SIGNAL(_Ifetch_unit, in_ICACHE_RSP_INSTRUCTION             ,_param->_nb_instruction);
126  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_ICACHE_RSP_ERROR                   );
127  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_PREDICT_VAL                        );
128  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_PREDICT_ACK                        );
129  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_PREDICT_PC_PREVIOUS                );
130  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_PREDICT_PC_CURRENT                 );
131  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_PREDICT_PC_CURRENT_IS_DS_TAKE      );
132  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_PREDICT_PC_NEXT                    );
133  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_PREDICT_PC_NEXT_IS_DS_TAKE         );
134  INSTANCE1_SC_SIGNAL(_Ifetch_unit, in_PREDICT_INSTRUCTION_ENABLE         ,_param->_nb_instruction);
135  if (_param->_have_port_instruction_ptr)
136  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_PREDICT_INST_IFETCH_PTR            );
137  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_PREDICT_BRANCH_STATE               );
138  if (_param->_have_port_branch_update_prediction_id)
139  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_PREDICT_BRANCH_UPDATE_PREDICTION_ID);
140  INSTANCE1_SC_SIGNAL(_Ifetch_unit,out_DECOD_VAL                          ,_param->_nb_instruction);
141  INSTANCE1_SC_SIGNAL(_Ifetch_unit, in_DECOD_ACK                          ,_param->_nb_instruction);
142  INSTANCE1_SC_SIGNAL(_Ifetch_unit,out_DECOD_INSTRUCTION                  ,_param->_nb_instruction);
143//INSTANCE_SC_SIGNAL (_Ifetch_unit,out_DECOD_CONTEXT_ID                   );
144  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_DECOD_ADDRESS                      );
145  if (_param->_have_port_instruction_ptr)
146  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_DECOD_INST_IFETCH_PTR              );
147  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_DECOD_BRANCH_STATE                 );
148  if (_param->_have_port_branch_update_prediction_id)
149  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_DECOD_BRANCH_UPDATE_PREDICTION_ID  );
150  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_DECOD_EXCEPTION                    );
151  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_EVENT_VAL                          );
152  INSTANCE_SC_SIGNAL (_Ifetch_unit,out_EVENT_ACK                          );
153  INSTANCE_SC_SIGNAL (_Ifetch_unit, in_EVENT_ADDRESS                      );
154
155  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
156   
157  Time * _time = new Time();
158
159  /********************************************************
160   * Simulation - Begin
161   ********************************************************/
162
163  // Initialisation
164
165  const uint32_t seed = 0;
166//const uint32_t seed = static_cast<uint32_t>(time(NULL));
167
168  srand(seed);
169
170  SC_START(0);
171  LABEL("Initialisation");
172
173  LABEL("Reset");
174  in_NRESET->write(0);
175  SC_START(5);
176  in_NRESET->write(1); 
177
178  LABEL("Loop of Test");
179
180  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
181    {
182      LABEL("Iteration %d",iteration);
183
184      SC_START(100);
185    }
186
187  /********************************************************
188   * Simulation - End
189   ********************************************************/
190
191  TEST_OK ("End of Simulation");
192  delete _time;
193
194  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
195
196  delete in_CLOCK;
197  delete in_NRESET;
198
199  delete    out_ICACHE_REQ_VAL                      ;
200  delete     in_ICACHE_REQ_ACK                      ;
201//delete    out_ICACHE_REQ_THREAD_ID                ;
202  delete    out_ICACHE_REQ_PACKET_ID                ;
203  delete    out_ICACHE_REQ_ADDRESS                  ;
204  delete    out_ICACHE_REQ_TYPE                     ;
205
206  delete     in_ICACHE_RSP_VAL                      ;
207  delete    out_ICACHE_RSP_ACK                      ;
208//delete     in_ICACHE_RSP_THREAD_ID                ;
209  delete     in_ICACHE_RSP_PACKET_ID                ;
210  delete []  in_ICACHE_RSP_INSTRUCTION              ;
211  delete     in_ICACHE_RSP_ERROR                    ;
212
213  delete    out_PREDICT_VAL                         ;
214  delete     in_PREDICT_ACK                         ;
215  delete    out_PREDICT_PC_PREVIOUS                 ;
216  delete    out_PREDICT_PC_CURRENT                  ;
217  delete    out_PREDICT_PC_CURRENT_IS_DS_TAKE       ;
218  delete     in_PREDICT_PC_NEXT                     ;
219  delete     in_PREDICT_PC_NEXT_IS_DS_TAKE          ;
220  delete []  in_PREDICT_INSTRUCTION_ENABLE          ;
221  delete     in_PREDICT_INST_IFETCH_PTR             ;
222  delete     in_PREDICT_BRANCH_STATE                ;
223  delete     in_PREDICT_BRANCH_UPDATE_PREDICTION_ID ;
224
225  delete [] out_DECOD_VAL                           ;
226  delete []  in_DECOD_ACK                           ;
227  delete [] out_DECOD_INSTRUCTION                   ;
228//delete    out_DECOD_CONTEXT_ID                    ;
229  delete    out_DECOD_ADDRESS                       ;
230  delete    out_DECOD_INST_IFETCH_PTR               ;
231  delete    out_DECOD_BRANCH_STATE                  ;
232  delete    out_DECOD_BRANCH_UPDATE_PREDICTION_ID   ;
233  delete    out_DECOD_EXCEPTION                     ;
234
235  delete     in_EVENT_VAL                           ;
236  delete    out_EVENT_ACK                           ;
237  delete     in_EVENT_ADDRESS                       ;
238#endif
239
240  delete _Ifetch_unit;
241#ifdef STATISTICS
242  delete _parameters_statistics;
243#endif
244}
Note: See TracBrowser for help on using the repository browser.