source: trunk/Platforms/Test/src/test.cpp @ 132

Last change on this file since 132 was 132, checked in by rosiere, 15 years ago

1) add constant method - compatibility with SystemC
2) add Script to test sensitive list
3) fix bug in sensitive list

  • Property svn:keywords set to Id
File size: 30.5 KB
Line 
1/*
2 * $Id: test.cpp 132 2009-07-11 16:39:35Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Platforms : Morpheo + Environment
7 */
8
9#define CYCLE_MAX 0
10
11#include "../include/test.h"
12
13#include "Environment.h"
14#include "Behavioural/include/Allocation.h"
15#include "Common/include/Time.h"
16#include "../../../IPs/systemC/shared/mapping_memory.h"
17#include "../../../IPs/systemC/processor/Morpheo/Common/include/Test.h"
18
19using namespace std;
20using namespace environment;
21using namespace morpheo;
22
23int test(string   filename_simulator,
24         string   filename_generator,
25         string   filename_instance ,
26         string   filename_software ,
27         uint32_t nb_cache_dedicated,
28         uint32_t nb_cache_shared   ,
29         uint32_t cache_size        ,
30         uint32_t cache_ratio       ,
31         morpheo::behavioural::custom::custom_information_t (*get_custom_information) (void)
32          )
33{
34  //==============================================================================
35  //===== [ DECLARATION ]=========================================================
36  //==============================================================================
37
38
39  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40  //~~~~~ [ Morpheo  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 
43  // 1) Translation
44  if (setlocale (LC_ALL, "") == NULL)
45    {
46      cerr << "Error setlocale." << endl;
47      exit (EXIT_FAILURE);
48    }
49 
50  // 2) Morpheo Construction
51  Morpheo * morpheo = new Morpheo
52    ("morpheo",
53     filename_simulator, 
54     filename_generator, 
55     filename_instance ,
56     get_custom_information
57     );
58
59  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60  //~~~~~ [ Environment  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62
63  uint32_t    nb_thread = morpheo->_nb_thread;
64  uint32_t    nb_entity = 1;
65
66  // Cache access
67  uint32_t  * iaccess_nb_context    = new uint32_t [nb_entity];
68  uint32_t  * iaccess_nb_instruction= new uint32_t [nb_entity];
69  uint32_t  * iaccess_nb_packet     = new uint32_t [nb_entity];
70  uint32_t  * iaccess_size_address  = new uint32_t [nb_entity];
71  uint32_t  * iaccess_size_data     = new uint32_t [nb_entity];
72 
73  uint32_t  * daccess_nb_context    = new uint32_t [nb_entity];
74  uint32_t  * daccess_nb_packet     = new uint32_t [nb_entity];
75  uint32_t  * daccess_size_address  = new uint32_t [nb_entity];
76  uint32_t  * daccess_size_data     = new uint32_t [nb_entity];
77 
78  uint32_t  * buffer_irsp_size      = new uint32_t [nb_entity];
79  uint32_t  * buffer_drsp_size      = new uint32_t [nb_entity];
80 
81  for (uint32_t i=0; i<nb_entity; i++)
82    {
83      iaccess_nb_context     [i] = morpheo->_nb_thread;
84      iaccess_nb_instruction [i] = max<uint32_t>(morpheo->_icache_nb_instruction,morpheo->_nb_icache_port);
85      iaccess_nb_packet      [i] = 1<<morpheo->_size_icache_packet_id;
86      iaccess_size_address   [i] = morpheo->_size_icache_address;
87      iaccess_size_data      [i] = morpheo->_size_icache_instruction;
88     
89      daccess_nb_context     [i] = morpheo->_nb_thread;
90      daccess_nb_packet      [i] = 1<<morpheo->_size_dcache_packet_id;
91      daccess_size_address   [i] = morpheo->_size_dcache_address;
92      daccess_size_data      [i] = morpheo->_size_dcache_data;
93     
94      buffer_irsp_size       [i] =  8;
95      buffer_drsp_size       [i] =  8;
96    }
97
98  uint32_t cache_nb_line       ;
99  uint32_t cache_size_line     ;
100  uint32_t cache_size_word     ;
101  uint32_t cache_associativity ;
102  uint32_t cache_hit_latence   ;
103  uint32_t cache_miss_penality ;
104
105  // Instruction/Data cache
106  uint32_t  * icache_nb_level      = new uint32_t   [nb_entity];
107  uint32_t  * icache_nb_port       = new uint32_t   [nb_entity];
108  uint32_t ** icache_nb_line       = new uint32_t * [nb_entity];
109  uint32_t ** icache_size_line     = new uint32_t * [nb_entity];
110  uint32_t ** icache_size_word     = new uint32_t * [nb_entity];
111  uint32_t ** icache_associativity = new uint32_t * [nb_entity];
112  uint32_t ** icache_hit_latence   = new uint32_t * [nb_entity];
113  uint32_t ** icache_miss_penality = new uint32_t * [nb_entity];
114
115  uint32_t  * dcache_nb_level      = new uint32_t   [nb_entity];
116  uint32_t  * dcache_nb_port       = new uint32_t   [nb_entity];
117  uint32_t ** dcache_nb_line       = new uint32_t * [nb_entity];
118  uint32_t ** dcache_size_line     = new uint32_t * [nb_entity];
119  uint32_t ** dcache_size_word     = new uint32_t * [nb_entity];
120  uint32_t ** dcache_associativity = new uint32_t * [nb_entity];
121  uint32_t ** dcache_hit_latence   = new uint32_t * [nb_entity];
122  uint32_t ** dcache_miss_penality = new uint32_t * [nb_entity];
123 
124  for (uint32_t i=0; i<nb_entity; i++)
125    {
126      cache_size_word     = max(max<uint32_t>(morpheo->_icache_nb_instruction,morpheo->_nb_icache_port)*morpheo->_size_icache_instruction,morpheo->_size_dcache_data)/8;
127      cache_size_line     = 8;
128
129      if (cache_size<(cache_size_line*cache_size_word))
130        {
131          cerr << "cache is too small" << endl;
132          exit(EXIT_FAILURE);
133        }
134
135      cache_nb_line       = cache_size/(cache_size_line*cache_size_word);
136      cache_associativity = 1;
137      cache_hit_latence   = 1;
138      cache_miss_penality = 5;
139
140      icache_nb_level      [i]    = nb_cache_dedicated;
141      icache_nb_port       [i]    = morpheo->_nb_icache_port;
142      icache_nb_line       [i]    = new uint32_t [icache_nb_level[i]];
143      icache_size_line     [i]    = new uint32_t [icache_nb_level[i]];
144      icache_size_word     [i]    = new uint32_t [icache_nb_level[i]];
145      icache_associativity [i]    = new uint32_t [icache_nb_level[i]];
146      icache_hit_latence   [i]    = new uint32_t [icache_nb_level[i]];
147      icache_miss_penality [i]    = new uint32_t [icache_nb_level[i]];
148
149      dcache_nb_level      [i]    = icache_nb_level [i];
150      dcache_nb_port       [i]    = morpheo->_nb_dcache_port;
151      dcache_nb_line       [i]    = new uint32_t [dcache_nb_level[i]];
152      dcache_size_line     [i]    = new uint32_t [dcache_nb_level[i]];
153      dcache_size_word     [i]    = new uint32_t [dcache_nb_level[i]];
154      dcache_associativity [i]    = new uint32_t [dcache_nb_level[i]];
155      dcache_hit_latence   [i]    = new uint32_t [dcache_nb_level[i]];
156      dcache_miss_penality [i]    = new uint32_t [dcache_nb_level[i]];
157     
158      for (uint32_t j=0; j<icache_nb_level[i]; ++j)
159        {
160          icache_nb_line       [i][j] = cache_nb_line      ;
161          icache_size_line     [i][j] = cache_size_line    ;
162          icache_size_word     [i][j] = cache_size_word    ;
163          icache_associativity [i][j] = cache_associativity;
164          icache_hit_latence   [i][j] = cache_hit_latence  ;
165          icache_miss_penality [i][j] = cache_miss_penality;
166
167          dcache_nb_line       [i][j] = cache_nb_line      ;
168          dcache_size_line     [i][j] = cache_size_line    ;
169          dcache_size_word     [i][j] = cache_size_word    ;
170          dcache_associativity [i][j] = cache_associativity;
171          dcache_hit_latence   [i][j] = cache_hit_latence  ;
172          dcache_miss_penality [i][j] = cache_miss_penality;
173
174          cache_nb_line       *= cache_ratio;
175          cache_size_line     *= cache_ratio;
176//        cache_size_word     *= cache_ratio;
177          cache_associativity *= cache_ratio;
178          cache_hit_latence   *= cache_ratio;
179          cache_miss_penality *= cache_ratio;
180        }
181    }
182 
183  // Cache shared
184  uint32_t * cache_shared_nb_line       = new uint32_t [nb_cache_shared];
185  uint32_t * cache_shared_size_line     = new uint32_t [nb_cache_shared];
186  uint32_t * cache_shared_size_word     = new uint32_t [nb_cache_shared];
187  uint32_t * cache_shared_associativity = new uint32_t [nb_cache_shared];
188  uint32_t * cache_shared_hit_latence   = new uint32_t [nb_cache_shared];
189  uint32_t * cache_shared_miss_penality = new uint32_t [nb_cache_shared];
190
191  for (uint32_t i=0; i<nb_cache_shared; ++i)
192    {
193      cache_shared_nb_line       [i] = cache_nb_line      ;
194      cache_shared_size_line     [i] = cache_size_line    ;
195      cache_shared_size_word     [i] = cache_size_word    ;
196      cache_shared_associativity [i] = cache_associativity;
197      cache_shared_hit_latence   [i] = cache_hit_latence  ;
198      cache_shared_miss_penality [i] = cache_miss_penality;
199
200      cache_nb_line       *= cache_ratio;
201      cache_size_line     *= cache_ratio;
202//    cache_size_word     *= cache_ratio;
203      cache_associativity *= cache_ratio;
204      cache_hit_latence   *= cache_ratio;
205      cache_miss_penality *= cache_ratio;
206    }
207 
208  // TTY
209  uint32_t   nb_component_tty = 1;
210  uint32_t * tty_address = new uint32_t [nb_component_tty];
211  uint32_t * nb_tty      = new uint32_t [nb_component_tty];
212  for (uint32_t i=0; i<nb_component_tty; ++i)
213    {
214      tty_address [i] = TTY_BASE;
215      nb_tty      [i] = nb_thread;
216    }
217  string  ** name_tty    = new string * [nb_component_tty];
218  for (uint32_t i=0; i<nb_component_tty; ++i)
219    {
220      name_tty [i]    = new string [nb_tty[i]];
221      for (uint32_t j=0; j<nb_tty[i]; ++j)
222        name_tty [i][j] = "tty_"+toString(i)+"_"+toString(j);
223    }
224
225  // Ramlock
226  uint32_t   nb_component_ramlock = 1;
227  uint32_t * ramlock_address = new uint32_t [nb_component_ramlock];
228  uint32_t * nb_lock         = new uint32_t [nb_component_ramlock];
229  for (uint32_t i=0; i<nb_component_ramlock; ++i)
230    {
231      ramlock_address [i] = RAMLOCK_BASE;
232      nb_lock         [i] = 100*nb_thread;
233    }
234
235  // Sim2OS
236  uint32_t sim2os_address = SIM2OS_BASE;
237  uint32_t sim2os_size    = SIM2OS_SIZE;
238
239  SOCLIB_SEGMENT_TABLE * segtable = new SOCLIB_SEGMENT_TABLE;
240  segtable->setMSBNumber    (8);
241  segtable->setDefaultTarget(0,0);
242
243  // Add a segment    ,name          ,address of base   ,size              ,global index,local index,uncache
244  segtable->addSegment("text"        ,TEXT_BASE         ,TEXT_SIZE         ,0           ,0          ,false);
245  segtable->addSegment("data"        ,DATA_CACHED_BASE  ,DATA_CACHED_SIZE  ,0           ,0          ,false);
246  segtable->addSegment("data_stack"  ,DATA_STACK_BASE   ,DATA_STACK_SIZE   ,0           ,0          ,false);
247  segtable->addSegment("data_unc"    ,DATA_UNCACHED_BASE,DATA_UNCACHED_SIZE,0           ,0          ,true );
248
249  Parameters * param_environment = new Parameters
250    (nb_thread,
251     nb_entity,
252     
253     iaccess_nb_context,
254     iaccess_nb_instruction,
255     iaccess_nb_packet,
256     iaccess_size_address,
257     iaccess_size_data,
258     
259     daccess_nb_context,
260     daccess_nb_packet,
261     daccess_size_address,
262     daccess_size_data,
263     
264     buffer_irsp_size,
265     buffer_drsp_size,
266     
267     icache_nb_level     ,
268     icache_nb_port      ,
269     icache_nb_line      ,
270     icache_size_line    ,
271     icache_size_word    ,
272     icache_associativity,
273     icache_hit_latence  ,
274     icache_miss_penality,
275     dcache_nb_level     ,
276     dcache_nb_port      ,
277     dcache_nb_line      ,
278     dcache_size_line    ,
279     dcache_size_word    ,
280     dcache_associativity,
281     dcache_hit_latence  ,
282     dcache_miss_penality,
283
284     nb_cache_shared               ,
285//   cache_shared_nb_port          ,
286     cache_shared_nb_line          ,
287     cache_shared_size_line        ,
288     cache_shared_size_word        ,
289     cache_shared_associativity    ,
290     cache_shared_hit_latence      ,
291     cache_shared_miss_penality    ,
292     
293     nb_component_tty,
294     tty_address,
295     nb_tty,
296     name_tty,
297     false,
298     
299     nb_component_ramlock,
300     ramlock_address,
301     nb_lock,
302     
303     sim2os_address,
304     sim2os_size,
305     segtable
306     );
307 
308//   cout << param_environment->print(0) << endl;
309
310  segtable->print();
311 
312  Environment * environment = new Environment ("environment",param_environment);
313 
314  const char * sections_text [] = {".text",NULL}; 
315  const char * sections_data [] = {".data",".rodata",".bss",".sdata",".sbss", NULL}; 
316 
317  if (environment->init("text"   , filename_software.c_str(), sections_text) == false) exit (EXIT_FAILURE);
318  if (environment->init("data"   , filename_software.c_str(), sections_data) == false) exit (EXIT_FAILURE);
319
320  //==============================================================================
321  //===== [ SIGNAL ]==============================================================
322  //==============================================================================
323#ifdef SYSTEMCASS_SPECIFIC
324  sc_clock              *  CLOCK  = new sc_clock ("clock", 1.0, 0.5); 
325#else
326  sc_time period (TIME_PERIOD, TIME_UNIT);
327  sc_clock              *  CLOCK  = new sc_clock ("clock", period);     
328#endif
329  sc_signal<Tcontrol_t> *  NRESET = new sc_signal<Tcontrol_t> ("NRESET");
330
331  sc_signal<Tcontrol_t           >  ** ICACHE_REQ_VAL        ;
332  sc_signal<Tcontrol_t           >  ** ICACHE_REQ_ACK        ;
333  sc_signal<Ticache_context_t    >  ** ICACHE_REQ_THREAD_ID  ;
334  sc_signal<Ticache_packet_t     >  ** ICACHE_REQ_PACKET_ID  ;
335  sc_signal<Ticache_address_t    >  ** ICACHE_REQ_ADDRESS    ;
336  sc_signal<Ticache_type_t       >  ** ICACHE_REQ_TYPE       ;
337
338  sc_signal<Tcontrol_t           >  ** ICACHE_RSP_VAL        ;
339  sc_signal<Tcontrol_t           >  ** ICACHE_RSP_ACK        ;
340  sc_signal<Ticache_context_t    >  ** ICACHE_RSP_THREAD_ID  ;
341  sc_signal<Ticache_packet_t     >  ** ICACHE_RSP_PACKET_ID  ;
342  sc_signal<Ticache_instruction_t> *** ICACHE_RSP_INSTRUCTION;
343  sc_signal<Ticache_error_t      >  ** ICACHE_RSP_ERROR      ;
344
345  sc_signal<Tcontrol_t           >  ** DCACHE_REQ_VAL        ;
346  sc_signal<Tcontrol_t           >  ** DCACHE_REQ_ACK        ;
347  sc_signal<Tdcache_context_t    >  ** DCACHE_REQ_THREAD_ID  ;
348  sc_signal<Tdcache_packet_t     >  ** DCACHE_REQ_PACKET_ID  ;
349  sc_signal<Tdcache_address_t    >  ** DCACHE_REQ_ADDRESS    ;
350  sc_signal<Tdcache_data_t       >  ** DCACHE_REQ_WDATA      ;
351  sc_signal<Tdcache_type_t       >  ** DCACHE_REQ_TYPE       ;
352
353  sc_signal<Tcontrol_t           >  ** DCACHE_RSP_VAL        ;
354  sc_signal<Tcontrol_t           >  ** DCACHE_RSP_ACK        ;
355  sc_signal<Tdcache_context_t    >  ** DCACHE_RSP_THREAD_ID  ;
356  sc_signal<Tdcache_packet_t     >  ** DCACHE_RSP_PACKET_ID  ;
357  sc_signal<Tdcache_data_t       >  ** DCACHE_RSP_RDATA      ;
358  sc_signal<Tdcache_error_t      >  ** DCACHE_RSP_ERROR      ;
359
360  sc_signal<Tcontrol_t           >  ** INTERRUPT_ENABLE      ;
361
362  ALLOC1_SC_SIGNAL(ICACHE_REQ_VAL         ,"ICACHE_REQ_VAL        ",Tcontrol_t           ,morpheo->_nb_icache_port);
363  ALLOC1_SC_SIGNAL(ICACHE_REQ_ACK         ,"ICACHE_REQ_ACK        ",Tcontrol_t           ,morpheo->_nb_icache_port);
364  ALLOC1_SC_SIGNAL(ICACHE_REQ_THREAD_ID   ,"ICACHE_REQ_THREAD_ID  ",Ticache_context_t    ,morpheo->_nb_icache_port);
365  ALLOC1_SC_SIGNAL(ICACHE_REQ_PACKET_ID   ,"ICACHE_REQ_PACKET_ID  ",Ticache_packet_t     ,morpheo->_nb_icache_port);
366  ALLOC1_SC_SIGNAL(ICACHE_REQ_ADDRESS     ,"ICACHE_REQ_ADDRESS    ",Ticache_address_t    ,morpheo->_nb_icache_port);
367  ALLOC1_SC_SIGNAL(ICACHE_REQ_TYPE        ,"ICACHE_REQ_TYPE       ",Ticache_type_t       ,morpheo->_nb_icache_port);
368
369  ALLOC1_SC_SIGNAL(ICACHE_RSP_VAL         ,"ICACHE_RSP_VAL        ",Tcontrol_t           ,morpheo->_nb_icache_port);
370  ALLOC1_SC_SIGNAL(ICACHE_RSP_ACK         ,"ICACHE_RSP_ACK        ",Tcontrol_t           ,morpheo->_nb_icache_port);
371  ALLOC1_SC_SIGNAL(ICACHE_RSP_THREAD_ID   ,"ICACHE_RSP_THREAD_ID  ",Ticache_context_t    ,morpheo->_nb_icache_port);
372  ALLOC1_SC_SIGNAL(ICACHE_RSP_PACKET_ID   ,"ICACHE_RSP_PACKET_ID  ",Ticache_packet_t     ,morpheo->_nb_icache_port);
373  ALLOC2_SC_SIGNAL(ICACHE_RSP_INSTRUCTION ,"ICACHE_RSP_INSTRUCTION",Ticache_instruction_t,morpheo->_nb_icache_port,morpheo->_icache_nb_instruction[it1]);
374  ALLOC1_SC_SIGNAL(ICACHE_RSP_ERROR       ,"ICACHE_RSP_ERROR      ",Ticache_error_t      ,morpheo->_nb_icache_port);
375
376  ALLOC1_SC_SIGNAL(DCACHE_REQ_VAL         ,"DCACHE_REQ_VAL        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
377  ALLOC1_SC_SIGNAL(DCACHE_REQ_ACK         ,"DCACHE_REQ_ACK        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
378  ALLOC1_SC_SIGNAL(DCACHE_REQ_THREAD_ID   ,"DCACHE_REQ_THREAD_ID  ",Tdcache_context_t    ,morpheo->_nb_dcache_port);
379  ALLOC1_SC_SIGNAL(DCACHE_REQ_PACKET_ID   ,"DCACHE_REQ_PACKET_ID  ",Tdcache_packet_t     ,morpheo->_nb_dcache_port);
380  ALLOC1_SC_SIGNAL(DCACHE_REQ_ADDRESS     ,"DCACHE_REQ_ADDRESS    ",Tdcache_address_t    ,morpheo->_nb_dcache_port);
381  ALLOC1_SC_SIGNAL(DCACHE_REQ_WDATA       ,"DCACHE_REQ_WDATA      ",Tdcache_data_t       ,morpheo->_nb_dcache_port);
382  ALLOC1_SC_SIGNAL(DCACHE_REQ_TYPE        ,"DCACHE_REQ_TYPE       ",Tdcache_type_t       ,morpheo->_nb_dcache_port);
383                                                                                         
384  ALLOC1_SC_SIGNAL(DCACHE_RSP_VAL         ,"DCACHE_RSP_VAL        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
385  ALLOC1_SC_SIGNAL(DCACHE_RSP_ACK         ,"DCACHE_RSP_ACK        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
386  ALLOC1_SC_SIGNAL(DCACHE_RSP_THREAD_ID   ,"DCACHE_RSP_THREAD_ID  ",Tdcache_context_t    ,morpheo->_nb_dcache_port);
387  ALLOC1_SC_SIGNAL(DCACHE_RSP_PACKET_ID   ,"DCACHE_RSP_PACKET_ID  ",Tdcache_packet_t     ,morpheo->_nb_dcache_port);
388  ALLOC1_SC_SIGNAL(DCACHE_RSP_RDATA       ,"DCACHE_RSP_RDATA      ",Tdcache_data_t       ,morpheo->_nb_dcache_port);
389  ALLOC1_SC_SIGNAL(DCACHE_RSP_ERROR       ,"DCACHE_RSP_ERROR      ",Tdcache_error_t      ,morpheo->_nb_dcache_port);
390                                                                                         
391  ALLOC1_SC_SIGNAL(INTERRUPT_ENABLE       ,"INTERRUPT_ENABLE      ",Tcontrol_t           ,morpheo->_nb_thread);
392
393  //==============================================================================
394  //===== [ INSTANCE ]============================================================
395  //==============================================================================
396
397  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398  //~~~~~ [ Morpheo  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
400 
401  (*(morpheo->in_CLOCK))        (*(CLOCK));
402  (*(morpheo->in_NRESET))       (*(NRESET));
403
404  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_VAL         ,ICACHE_REQ_VAL         ,morpheo->_nb_icache_port);
405  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_REQ_ACK         ,ICACHE_REQ_ACK         ,morpheo->_nb_icache_port);
406  if (morpheo->_have_port_icache_thread_id)
407  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_THREAD_ID   ,ICACHE_REQ_THREAD_ID   ,morpheo->_nb_icache_port);
408  if (morpheo->_have_port_icache_packet_id)
409  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_PACKET_ID   ,ICACHE_REQ_PACKET_ID   ,morpheo->_nb_icache_port);
410  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_ADDRESS     ,ICACHE_REQ_ADDRESS     ,morpheo->_nb_icache_port);
411  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_TYPE        ,ICACHE_REQ_TYPE        ,morpheo->_nb_icache_port);
412                                                                                                                     
413  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_VAL         ,ICACHE_RSP_VAL         ,morpheo->_nb_icache_port);
414  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_RSP_ACK         ,ICACHE_RSP_ACK         ,morpheo->_nb_icache_port);
415  if (morpheo->_have_port_icache_thread_id)
416  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_THREAD_ID   ,ICACHE_RSP_THREAD_ID   ,morpheo->_nb_icache_port);
417  if (morpheo->_have_port_icache_packet_id)
418  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_PACKET_ID   ,ICACHE_RSP_PACKET_ID   ,morpheo->_nb_icache_port);
419  _INSTANCE2_SC_SIGNAL(morpheo, in_ICACHE_RSP_INSTRUCTION ,ICACHE_RSP_INSTRUCTION ,morpheo->_nb_icache_port,morpheo->_icache_nb_instruction[it1]);
420  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_ERROR       ,ICACHE_RSP_ERROR       ,morpheo->_nb_icache_port);
421                                                                                                                     
422  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_VAL         ,DCACHE_REQ_VAL         ,morpheo->_nb_dcache_port);
423  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_REQ_ACK         ,DCACHE_REQ_ACK         ,morpheo->_nb_dcache_port);
424  if (morpheo->_have_port_dcache_thread_id)
425  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_THREAD_ID   ,DCACHE_REQ_THREAD_ID   ,morpheo->_nb_dcache_port);
426  if (morpheo->_have_port_dcache_packet_id)
427  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_PACKET_ID   ,DCACHE_REQ_PACKET_ID   ,morpheo->_nb_dcache_port);
428  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_ADDRESS     ,DCACHE_REQ_ADDRESS     ,morpheo->_nb_dcache_port);
429  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_WDATA       ,DCACHE_REQ_WDATA       ,morpheo->_nb_dcache_port);
430  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_TYPE        ,DCACHE_REQ_TYPE        ,morpheo->_nb_dcache_port);
431                                                                                                                     
432  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_VAL         ,DCACHE_RSP_VAL         ,morpheo->_nb_dcache_port);
433  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_RSP_ACK         ,DCACHE_RSP_ACK         ,morpheo->_nb_dcache_port);
434  if (morpheo->_have_port_dcache_thread_id)
435  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_THREAD_ID   ,DCACHE_RSP_THREAD_ID   ,morpheo->_nb_dcache_port);
436  if (morpheo->_have_port_dcache_packet_id)
437  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_PACKET_ID   ,DCACHE_RSP_PACKET_ID   ,morpheo->_nb_dcache_port);
438  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_RDATA       ,DCACHE_RSP_RDATA       ,morpheo->_nb_dcache_port);
439  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_ERROR       ,DCACHE_RSP_ERROR       ,morpheo->_nb_dcache_port);
440                                                                                                                     
441  _INSTANCE1_SC_SIGNAL(morpheo, in_INTERRUPT_ENABLE       ,INTERRUPT_ENABLE       ,morpheo->_nb_thread);
442
443  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
444  //~~~~~ [ Environment ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446
447  (*(environment->CLOCK))        (*(CLOCK));
448  (*(environment->NRESET))       (*(NRESET));
449
450  for (uint32_t i=0; i<morpheo->_nb_icache_port; ++i)
451    {
452  (*(environment->ICACHE_REQ_VAL         [0][i]   )) (*(ICACHE_REQ_VAL         [i]   ));
453  (*(environment->ICACHE_REQ_ACK         [0][i]   )) (*(ICACHE_REQ_ACK         [i]   ));
454  (*(environment->ICACHE_REQ_CONTEXT_ID  [0][i]   )) (*(ICACHE_REQ_THREAD_ID   [i]   ));
455  (*(environment->ICACHE_REQ_PACKET_ID   [0][i]   )) (*(ICACHE_REQ_PACKET_ID   [i]   ));
456  (*(environment->ICACHE_REQ_ADDRESS     [0][i]   )) (*(ICACHE_REQ_ADDRESS     [i]   ));
457  (*(environment->ICACHE_REQ_TYPE        [0][i]   )) (*(ICACHE_REQ_TYPE        [i]   ));
458                                                                                     
459  (*(environment->ICACHE_RSP_VAL         [0][i]   )) (*(ICACHE_RSP_VAL         [i]   ));
460  (*(environment->ICACHE_RSP_ACK         [0][i]   )) (*(ICACHE_RSP_ACK         [i]   ));
461  (*(environment->ICACHE_RSP_CONTEXT_ID  [0][i]   )) (*(ICACHE_RSP_THREAD_ID   [i]   ));
462  (*(environment->ICACHE_RSP_PACKET_ID   [0][i]   )) (*(ICACHE_RSP_PACKET_ID   [i]   ));
463  (*(environment->ICACHE_RSP_ERROR       [0][i]   )) (*(ICACHE_RSP_ERROR       [i]   ));
464
465  for (uint32_t j=0; j<morpheo->_icache_nb_instruction[i]; ++j)
466  (*(environment->ICACHE_RSP_INSTRUCTION [0][i][j])) (*(ICACHE_RSP_INSTRUCTION [i][j]));
467    }
468  for (uint32_t i=0; i<morpheo->_nb_dcache_port; ++i)
469    {
470  (*(environment->DCACHE_REQ_VAL         [0][i]   )) (*(DCACHE_REQ_VAL         [i]   ));
471  (*(environment->DCACHE_REQ_ACK         [0][i]   )) (*(DCACHE_REQ_ACK         [i]   ));
472  (*(environment->DCACHE_REQ_CONTEXT_ID  [0][i]   )) (*(DCACHE_REQ_THREAD_ID   [i]   ));
473  (*(environment->DCACHE_REQ_PACKET_ID   [0][i]   )) (*(DCACHE_REQ_PACKET_ID   [i]   ));
474  (*(environment->DCACHE_REQ_ADDRESS     [0][i]   )) (*(DCACHE_REQ_ADDRESS     [i]   ));
475  (*(environment->DCACHE_REQ_WDATA       [0][i]   )) (*(DCACHE_REQ_WDATA       [i]   ));
476  (*(environment->DCACHE_REQ_TYPE        [0][i]   )) (*(DCACHE_REQ_TYPE        [i]   ));
477                                                                                     
478  (*(environment->DCACHE_RSP_VAL         [0][i]   )) (*(DCACHE_RSP_VAL         [i]   ));
479  (*(environment->DCACHE_RSP_ACK         [0][i]   )) (*(DCACHE_RSP_ACK         [i]   ));
480  (*(environment->DCACHE_RSP_CONTEXT_ID  [0][i]   )) (*(DCACHE_RSP_THREAD_ID   [i]   ));
481  (*(environment->DCACHE_RSP_PACKET_ID   [0][i]   )) (*(DCACHE_RSP_PACKET_ID   [i]   ));
482  (*(environment->DCACHE_RSP_RDATA       [0][i]   )) (*(DCACHE_RSP_RDATA       [i]   ));
483  (*(environment->DCACHE_RSP_ERROR       [0][i]   )) (*(DCACHE_RSP_ERROR       [i]   ));
484    }
485
486//_INSTANCE2_SC_SIGNAL(environment,INTERRUPT_ENABLE       ,1,morpheo->_nb_thread);
487
488  //==============================================================================
489  //===== [ SIMULATION ]==========================================================
490  //==============================================================================
491
492  // initialisation
493 
494  cerr << "<test> Simulation Init" << endl;
495
496  sc_time t (0, TIME_UNIT);
497  sc_start(t);
498
499  cerr << "<test> Simulation Start" << endl;
500
501  bool morpheo_error = false;
502  try 
503    {
504      Time * _time_global = new Time();
505     
506      for (uint32_t i=0; i<morpheo->_nb_thread; ++i)
507        INTERRUPT_ENABLE[i]->write(0);
508     
509      NRESET->write(0);
510      SC_START(5);
511      NRESET->write(1); 
512     
513      // Infinite loop
514      do
515        {
516          //       Time * _time_local = new Time();
517          SC_START(100000);
518          //       delete _time_local;
519        } while (not morpheo    ->simulation_end() and // morpheo condition stop
520                 not environment->simulation_end());   // test ok
521      delete _time_global;
522    }
523  catch (morpheo::ErrorMorpheo & error)
524    {
525      std::cerr << error.what() << std::endl
526                << STR_KO << std::endl;
527
528      morpheo_error = true;
529    }
530
531  bool morpheo_end     = morpheo->simulation_end();
532  bool environment_end = environment->simulation_end();
533
534
535  //==============================================================================
536  //===== [ DESTRUCTION ]=========================================================
537  //==============================================================================
538
539  delete CLOCK;
540  delete NRESET;
541
542  DELETE1_SC_SIGNAL(ICACHE_REQ_VAL         ,morpheo->_nb_icache_port);
543  DELETE1_SC_SIGNAL(ICACHE_REQ_ACK         ,morpheo->_nb_icache_port);
544  DELETE1_SC_SIGNAL(ICACHE_REQ_THREAD_ID   ,morpheo->_nb_icache_port);
545  DELETE1_SC_SIGNAL(ICACHE_REQ_PACKET_ID   ,morpheo->_nb_icache_port);
546  DELETE1_SC_SIGNAL(ICACHE_REQ_ADDRESS     ,morpheo->_nb_icache_port);
547  DELETE1_SC_SIGNAL(ICACHE_REQ_TYPE        ,morpheo->_nb_icache_port);
548 
549  DELETE1_SC_SIGNAL(ICACHE_RSP_VAL         ,morpheo->_nb_icache_port);
550  DELETE1_SC_SIGNAL(ICACHE_RSP_ACK         ,morpheo->_nb_icache_port);
551  DELETE1_SC_SIGNAL(ICACHE_RSP_THREAD_ID   ,morpheo->_nb_icache_port);
552  DELETE1_SC_SIGNAL(ICACHE_RSP_PACKET_ID   ,morpheo->_nb_icache_port);
553  DELETE1_SC_SIGNAL(ICACHE_RSP_ERROR       ,morpheo->_nb_icache_port);
554  DELETE2_SC_SIGNAL(ICACHE_RSP_INSTRUCTION ,morpheo->_nb_icache_port,morpheo->_icache_nb_instruction[it1]);
555 
556  DELETE1_SC_SIGNAL(DCACHE_REQ_VAL         ,morpheo->_nb_dcache_port);
557  DELETE1_SC_SIGNAL(DCACHE_REQ_ACK         ,morpheo->_nb_dcache_port);
558  DELETE1_SC_SIGNAL(DCACHE_REQ_THREAD_ID   ,morpheo->_nb_dcache_port);
559  DELETE1_SC_SIGNAL(DCACHE_REQ_PACKET_ID   ,morpheo->_nb_dcache_port);
560  DELETE1_SC_SIGNAL(DCACHE_REQ_ADDRESS     ,morpheo->_nb_dcache_port);
561  DELETE1_SC_SIGNAL(DCACHE_REQ_WDATA       ,morpheo->_nb_dcache_port);
562  DELETE1_SC_SIGNAL(DCACHE_REQ_TYPE        ,morpheo->_nb_dcache_port);
563 
564  DELETE1_SC_SIGNAL(DCACHE_RSP_VAL         ,morpheo->_nb_dcache_port);
565  DELETE1_SC_SIGNAL(DCACHE_RSP_ACK         ,morpheo->_nb_dcache_port);
566  DELETE1_SC_SIGNAL(DCACHE_RSP_THREAD_ID   ,morpheo->_nb_dcache_port);
567  DELETE1_SC_SIGNAL(DCACHE_RSP_PACKET_ID   ,morpheo->_nb_dcache_port);
568  DELETE1_SC_SIGNAL(DCACHE_RSP_RDATA       ,morpheo->_nb_dcache_port);
569  DELETE1_SC_SIGNAL(DCACHE_RSP_ERROR       ,morpheo->_nb_dcache_port);
570 
571  DELETE1_SC_SIGNAL(INTERRUPT_ENABLE       ,morpheo->_nb_thread);
572
573  delete    environment;
574
575  delete    param_environment;
576  delete    segtable;
577
578  delete [] nb_lock        ;
579  delete [] ramlock_address;
580
581  for (uint32_t i=0;i<nb_component_tty;++i)
582    delete [] name_tty [i];
583  delete [] name_tty;
584  delete [] nb_tty;
585  delete [] tty_address;
586
587  delete [] cache_shared_miss_penality;
588  delete [] cache_shared_hit_latence  ;
589  delete [] cache_shared_associativity;
590  delete [] cache_shared_size_word    ;
591  delete [] cache_shared_size_line    ;
592  delete [] cache_shared_nb_line      ;
593
594  for (uint32_t i=0; i<nb_entity; i++)
595    {
596      delete [] dcache_miss_penality [i];
597      delete [] dcache_hit_latence   [i];
598      delete [] dcache_associativity [i];
599      delete [] dcache_size_word     [i];
600      delete [] dcache_size_line     [i];
601      delete [] dcache_nb_line       [i];
602    }
603  delete [] dcache_miss_penality  ;
604  delete [] dcache_hit_latence    ;
605  delete [] dcache_associativity  ;
606  delete [] dcache_size_word      ;
607  delete [] dcache_size_line      ;
608  delete [] dcache_nb_line        ;
609  delete [] dcache_nb_level       ;
610  delete [] dcache_nb_port        ;
611
612  for (uint32_t i=0; i<nb_entity; i++)
613    {
614      delete [] icache_miss_penality [i];
615      delete [] icache_hit_latence   [i];
616      delete [] icache_associativity [i];
617      delete [] icache_size_word     [i];
618      delete [] icache_size_line     [i];
619      delete [] icache_nb_line       [i];
620    }
621  delete [] icache_miss_penality;
622  delete [] icache_hit_latence  ;
623  delete [] icache_associativity;
624  delete [] icache_size_word    ;
625  delete [] icache_size_line    ;
626  delete [] icache_nb_line      ;
627  delete [] icache_nb_level     ;
628  delete [] icache_nb_port      ;
629
630  delete [] buffer_drsp_size      ;
631  delete [] buffer_irsp_size      ;
632  delete [] daccess_size_data     ;
633  delete [] daccess_size_address  ;
634  delete [] daccess_nb_packet     ;
635  delete [] daccess_nb_context    ;
636  delete [] iaccess_size_data     ;
637  delete [] iaccess_size_address  ;
638  delete [] iaccess_nb_packet     ;
639  delete [] iaccess_nb_instruction;
640  delete [] iaccess_nb_context    ;
641
642  delete    morpheo;
643
644  bool test_ok = false;
645  if (not morpheo_error)
646    {
647      if (not morpheo_end and not environment_end)
648        {
649          cerr << "<test> Simulation End : Unknow" << endl;
650        }
651      else
652        {
653          if (morpheo_end)
654            {
655              cout << "<test> Simulation End : MORPHEO" << endl;
656              test_ok = true;
657            }
658          if (environment_end)
659            {
660              cout << "<test> Simulation End : ENVIRONMENT" << endl;
661              test_ok = true;
662            }
663        }
664    }
665
666  if (test_ok)
667    {
668      cout << STR_OK << endl;
669      return EXIT_SUCCESS;
670    }
671  else
672    {
673      cout << STR_KO << endl;
674      return EXIT_FAILURE;
675    }
676}
Note: See TracBrowser for help on using the repository browser.