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

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

1) Stat_list : fix retire old and new register bug
2) Stat_list : remove read_counter and valid flag, because validation of destination is in retire step (not in commit step)
3) Model : add class Model (cf Morpheo.sim)
4) Allocation : alloc_interface_begin and alloc_interface_end to delete temporary array.
5) Script : add distexe.sh
6) Add Comparator, Multiplier, Divider. But this component are not implemented
7) Software : add Dhrystone

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