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

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

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 27.9 KB
Line 
1/*
2 * $Id: test.cpp 88 2008-12-10 18:31:39Z 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_unc",DATA_UNCACHED_BASE,DATA_UNCACHED_SIZE,0           ,0          ,true );
246
247  Parameters * param_environment = new Parameters
248    (nb_entity,
249     
250     iaccess_nb_context,
251     iaccess_nb_instruction,
252     iaccess_nb_packet,
253     iaccess_size_address,
254     iaccess_size_data,
255     
256     daccess_nb_context,
257     daccess_nb_packet,
258     daccess_size_address,
259     daccess_size_data,
260     
261     buffer_irsp_size,
262     buffer_drsp_size,
263     
264     icache_nb_level     ,
265     icache_nb_port      ,
266     icache_nb_line      ,
267     icache_size_line    ,
268     icache_size_word    ,
269     icache_associativity,
270     icache_hit_latence  ,
271     icache_miss_penality,
272     dcache_nb_level     ,
273     dcache_nb_port      ,
274     dcache_nb_line      ,
275     dcache_size_line    ,
276     dcache_size_word    ,
277     dcache_associativity,
278     dcache_hit_latence  ,
279     dcache_miss_penality,
280
281     nb_cache_shared               ,
282//   cache_shared_nb_port          ,
283     cache_shared_nb_line          ,
284     cache_shared_size_line        ,
285     cache_shared_size_word        ,
286     cache_shared_associativity    ,
287     cache_shared_hit_latence      ,
288     cache_shared_miss_penality    ,
289     
290     nb_component_tty,
291     tty_address,
292     nb_tty,
293     name_tty,
294     false,
295     
296     nb_component_ramlock,
297     ramlock_address,
298     nb_lock,
299     
300     sim2os_address,
301     sim2os_size,
302     segtable
303     );
304 
305  cout << param_environment->print(0) << endl;
306
307  segtable->print();
308 
309  Environment * environment = new Environment ("environment",param_environment);
310 
311  const char * sections_text [] = {".text",NULL}; 
312  const char * sections_data [] = {".data",".rodata",".bss",".sdata",".sbss", NULL}; 
313 
314  if (environment->init("text"   , filename_software.c_str(), sections_text) == false) exit (EXIT_FAILURE);
315  if (environment->init("data"   , filename_software.c_str(), sections_data) == false) exit (EXIT_FAILURE);
316
317  //==============================================================================
318  //===== [ SIGNAL ]==============================================================
319  //==============================================================================
320
321  sc_clock              *  CLOCK  = new sc_clock ("clock", 1.0, 0.5);   
322  sc_signal<Tcontrol_t> *  NRESET = new sc_signal<Tcontrol_t> ("NRESET");
323
324  ALLOC1_SC_SIGNAL(ICACHE_REQ_VAL         ,"ICACHE_REQ_VAL        ",Tcontrol_t           ,morpheo->_nb_icache_port);
325  ALLOC1_SC_SIGNAL(ICACHE_REQ_ACK         ,"ICACHE_REQ_ACK        ",Tcontrol_t           ,morpheo->_nb_icache_port);
326  ALLOC1_SC_SIGNAL(ICACHE_REQ_THREAD_ID   ,"ICACHE_REQ_THREAD_ID  ",Ticache_context_t    ,morpheo->_nb_icache_port);
327  ALLOC1_SC_SIGNAL(ICACHE_REQ_PACKET_ID   ,"ICACHE_REQ_PACKET_ID  ",Ticache_packet_t     ,morpheo->_nb_icache_port);
328  ALLOC1_SC_SIGNAL(ICACHE_REQ_ADDRESS     ,"ICACHE_REQ_ADDRESS    ",Ticache_address_t    ,morpheo->_nb_icache_port);
329  ALLOC1_SC_SIGNAL(ICACHE_REQ_TYPE        ,"ICACHE_REQ_TYPE       ",Ticache_type_t       ,morpheo->_nb_icache_port);
330
331  ALLOC1_SC_SIGNAL(ICACHE_RSP_VAL         ,"ICACHE_RSP_VAL        ",Tcontrol_t           ,morpheo->_nb_icache_port);
332  ALLOC1_SC_SIGNAL(ICACHE_RSP_ACK         ,"ICACHE_RSP_ACK        ",Tcontrol_t           ,morpheo->_nb_icache_port);
333  ALLOC1_SC_SIGNAL(ICACHE_RSP_THREAD_ID   ,"ICACHE_RSP_THREAD_ID  ",Ticache_context_t    ,morpheo->_nb_icache_port);
334  ALLOC1_SC_SIGNAL(ICACHE_RSP_PACKET_ID   ,"ICACHE_RSP_PACKET_ID  ",Ticache_packet_t     ,morpheo->_nb_icache_port);
335  ALLOC2_SC_SIGNAL(ICACHE_RSP_INSTRUCTION ,"ICACHE_RSP_INSTRUCTION",Ticache_instruction_t,morpheo->_nb_icache_port,morpheo->_icache_nb_instruction[it1]);
336  ALLOC1_SC_SIGNAL(ICACHE_RSP_ERROR       ,"ICACHE_RSP_ERROR      ",Ticache_error_t      ,morpheo->_nb_icache_port);
337
338  ALLOC1_SC_SIGNAL(DCACHE_REQ_VAL         ,"DCACHE_REQ_VAL        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
339  ALLOC1_SC_SIGNAL(DCACHE_REQ_ACK         ,"DCACHE_REQ_ACK        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
340  ALLOC1_SC_SIGNAL(DCACHE_REQ_THREAD_ID   ,"DCACHE_REQ_THREAD_ID  ",Tdcache_context_t    ,morpheo->_nb_dcache_port);
341  ALLOC1_SC_SIGNAL(DCACHE_REQ_PACKET_ID   ,"DCACHE_REQ_PACKET_ID  ",Tdcache_packet_t     ,morpheo->_nb_dcache_port);
342  ALLOC1_SC_SIGNAL(DCACHE_REQ_ADDRESS     ,"DCACHE_REQ_ADDRESS    ",Tdcache_address_t    ,morpheo->_nb_dcache_port);
343  ALLOC1_SC_SIGNAL(DCACHE_REQ_WDATA       ,"DCACHE_REQ_WDATA      ",Tdcache_data_t       ,morpheo->_nb_dcache_port);
344  ALLOC1_SC_SIGNAL(DCACHE_REQ_TYPE        ,"DCACHE_REQ_TYPE       ",Tdcache_type_t       ,morpheo->_nb_dcache_port);
345                                                                                         
346  ALLOC1_SC_SIGNAL(DCACHE_RSP_VAL         ,"DCACHE_RSP_VAL        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
347  ALLOC1_SC_SIGNAL(DCACHE_RSP_ACK         ,"DCACHE_RSP_ACK        ",Tcontrol_t           ,morpheo->_nb_dcache_port);
348  ALLOC1_SC_SIGNAL(DCACHE_RSP_THREAD_ID   ,"DCACHE_RSP_THREAD_ID  ",Tdcache_context_t    ,morpheo->_nb_dcache_port);
349  ALLOC1_SC_SIGNAL(DCACHE_RSP_PACKET_ID   ,"DCACHE_RSP_PACKET_ID  ",Tdcache_packet_t     ,morpheo->_nb_dcache_port);
350  ALLOC1_SC_SIGNAL(DCACHE_RSP_RDATA       ,"DCACHE_RSP_RDATA      ",Tdcache_data_t       ,morpheo->_nb_dcache_port);
351  ALLOC1_SC_SIGNAL(DCACHE_RSP_ERROR       ,"DCACHE_RSP_ERROR      ",Tdcache_error_t      ,morpheo->_nb_dcache_port);
352                                                                                         
353  ALLOC1_SC_SIGNAL(INTERRUPT_ENABLE       ,"INTERRUPT_ENABLE      ",Tcontrol_t           ,morpheo->_nb_thread);
354
355  //==============================================================================
356  //===== [ INSTANCE ]============================================================
357  //==============================================================================
358
359  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360  //~~~~~ [ Morpheo  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362 
363  (*(morpheo->in_CLOCK))        (*(CLOCK));
364  (*(morpheo->in_NRESET))       (*(NRESET));
365
366  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_VAL         ,ICACHE_REQ_VAL         ,morpheo->_nb_icache_port);
367  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_REQ_ACK         ,ICACHE_REQ_ACK         ,morpheo->_nb_icache_port);
368  if (morpheo->_have_port_icache_thread_id)
369  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_THREAD_ID   ,ICACHE_REQ_THREAD_ID   ,morpheo->_nb_icache_port);
370  if (morpheo->_have_port_icache_packet_id)
371  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_PACKET_ID   ,ICACHE_REQ_PACKET_ID   ,morpheo->_nb_icache_port);
372  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_ADDRESS     ,ICACHE_REQ_ADDRESS     ,morpheo->_nb_icache_port);
373  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_REQ_TYPE        ,ICACHE_REQ_TYPE        ,morpheo->_nb_icache_port);
374                                                                                                                     
375  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_VAL         ,ICACHE_RSP_VAL         ,morpheo->_nb_icache_port);
376  _INSTANCE1_SC_SIGNAL(morpheo,out_ICACHE_RSP_ACK         ,ICACHE_RSP_ACK         ,morpheo->_nb_icache_port);
377  if (morpheo->_have_port_icache_thread_id)
378  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_THREAD_ID   ,ICACHE_RSP_THREAD_ID   ,morpheo->_nb_icache_port);
379  if (morpheo->_have_port_icache_packet_id)
380  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_PACKET_ID   ,ICACHE_RSP_PACKET_ID   ,morpheo->_nb_icache_port);
381  _INSTANCE2_SC_SIGNAL(morpheo, in_ICACHE_RSP_INSTRUCTION ,ICACHE_RSP_INSTRUCTION ,morpheo->_nb_icache_port,morpheo->_icache_nb_instruction[it1]);
382  _INSTANCE1_SC_SIGNAL(morpheo, in_ICACHE_RSP_ERROR       ,ICACHE_RSP_ERROR       ,morpheo->_nb_icache_port);
383                                                                                                                     
384  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_VAL         ,DCACHE_REQ_VAL         ,morpheo->_nb_dcache_port);
385  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_REQ_ACK         ,DCACHE_REQ_ACK         ,morpheo->_nb_dcache_port);
386  if (morpheo->_have_port_dcache_thread_id)
387  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_THREAD_ID   ,DCACHE_REQ_THREAD_ID   ,morpheo->_nb_dcache_port);
388  if (morpheo->_have_port_dcache_packet_id)
389  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_PACKET_ID   ,DCACHE_REQ_PACKET_ID   ,morpheo->_nb_dcache_port);
390  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_ADDRESS     ,DCACHE_REQ_ADDRESS     ,morpheo->_nb_dcache_port);
391  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_WDATA       ,DCACHE_REQ_WDATA       ,morpheo->_nb_dcache_port);
392  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_REQ_TYPE        ,DCACHE_REQ_TYPE        ,morpheo->_nb_dcache_port);
393                                                                                                                     
394  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_VAL         ,DCACHE_RSP_VAL         ,morpheo->_nb_dcache_port);
395  _INSTANCE1_SC_SIGNAL(morpheo,out_DCACHE_RSP_ACK         ,DCACHE_RSP_ACK         ,morpheo->_nb_dcache_port);
396  if (morpheo->_have_port_dcache_thread_id)
397  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_THREAD_ID   ,DCACHE_RSP_THREAD_ID   ,morpheo->_nb_dcache_port);
398  if (morpheo->_have_port_dcache_packet_id)
399  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_PACKET_ID   ,DCACHE_RSP_PACKET_ID   ,morpheo->_nb_dcache_port);
400  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_RDATA       ,DCACHE_RSP_RDATA       ,morpheo->_nb_dcache_port);
401  _INSTANCE1_SC_SIGNAL(morpheo, in_DCACHE_RSP_ERROR       ,DCACHE_RSP_ERROR       ,morpheo->_nb_dcache_port);
402                                                                                                                     
403  _INSTANCE1_SC_SIGNAL(morpheo, in_INTERRUPT_ENABLE       ,INTERRUPT_ENABLE       ,morpheo->_nb_thread);
404
405  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406  //~~~~~ [ Environment ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
408
409  (*(environment->CLOCK))        (*(CLOCK));
410  (*(environment->NRESET))       (*(NRESET));
411
412  for (uint32_t i=0; i<morpheo->_nb_icache_port; ++i)
413    {
414  (*(environment->ICACHE_REQ_VAL         [0][i]   )) (*(ICACHE_REQ_VAL         [i]   ));
415  (*(environment->ICACHE_REQ_ACK         [0][i]   )) (*(ICACHE_REQ_ACK         [i]   ));
416  (*(environment->ICACHE_REQ_CONTEXT_ID  [0][i]   )) (*(ICACHE_REQ_THREAD_ID   [i]   ));
417  (*(environment->ICACHE_REQ_PACKET_ID   [0][i]   )) (*(ICACHE_REQ_PACKET_ID   [i]   ));
418  (*(environment->ICACHE_REQ_ADDRESS     [0][i]   )) (*(ICACHE_REQ_ADDRESS     [i]   ));
419  (*(environment->ICACHE_REQ_TYPE        [0][i]   )) (*(ICACHE_REQ_TYPE        [i]   ));
420                                                                                     
421  (*(environment->ICACHE_RSP_VAL         [0][i]   )) (*(ICACHE_RSP_VAL         [i]   ));
422  (*(environment->ICACHE_RSP_ACK         [0][i]   )) (*(ICACHE_RSP_ACK         [i]   ));
423  (*(environment->ICACHE_RSP_CONTEXT_ID  [0][i]   )) (*(ICACHE_RSP_THREAD_ID   [i]   ));
424  (*(environment->ICACHE_RSP_PACKET_ID   [0][i]   )) (*(ICACHE_RSP_PACKET_ID   [i]   ));
425  (*(environment->ICACHE_RSP_ERROR       [0][i]   )) (*(ICACHE_RSP_ERROR       [i]   ));
426
427  for (uint32_t j=0; j<morpheo->_icache_nb_instruction[i]; ++j)
428  (*(environment->ICACHE_RSP_INSTRUCTION [0][i][j])) (*(ICACHE_RSP_INSTRUCTION [i][j]));
429    }
430  for (uint32_t i=0; i<morpheo->_nb_dcache_port; ++i)
431    {
432  (*(environment->DCACHE_REQ_VAL         [0][i]   )) (*(DCACHE_REQ_VAL         [i]   ));
433  (*(environment->DCACHE_REQ_ACK         [0][i]   )) (*(DCACHE_REQ_ACK         [i]   ));
434  (*(environment->DCACHE_REQ_CONTEXT_ID  [0][i]   )) (*(DCACHE_REQ_THREAD_ID   [i]   ));
435  (*(environment->DCACHE_REQ_PACKET_ID   [0][i]   )) (*(DCACHE_REQ_PACKET_ID   [i]   ));
436  (*(environment->DCACHE_REQ_ADDRESS     [0][i]   )) (*(DCACHE_REQ_ADDRESS     [i]   ));
437  (*(environment->DCACHE_REQ_WDATA       [0][i]   )) (*(DCACHE_REQ_WDATA       [i]   ));
438  (*(environment->DCACHE_REQ_TYPE        [0][i]   )) (*(DCACHE_REQ_TYPE        [i]   ));
439                                                                                     
440  (*(environment->DCACHE_RSP_VAL         [0][i]   )) (*(DCACHE_RSP_VAL         [i]   ));
441  (*(environment->DCACHE_RSP_ACK         [0][i]   )) (*(DCACHE_RSP_ACK         [i]   ));
442  (*(environment->DCACHE_RSP_CONTEXT_ID  [0][i]   )) (*(DCACHE_RSP_THREAD_ID   [i]   ));
443  (*(environment->DCACHE_RSP_PACKET_ID   [0][i]   )) (*(DCACHE_RSP_PACKET_ID   [i]   ));
444  (*(environment->DCACHE_RSP_RDATA       [0][i]   )) (*(DCACHE_RSP_RDATA       [i]   ));
445  (*(environment->DCACHE_RSP_ERROR       [0][i]   )) (*(DCACHE_RSP_ERROR       [i]   ));
446    }
447
448//_INSTANCE2_SC_SIGNAL(environment,INTERRUPT_ENABLE       ,1,morpheo->_nb_thread);
449
450  //==============================================================================
451  //===== [ SIMULATION ]==========================================================
452  //==============================================================================
453
454  // initialisation
455  cerr << "<test> Simulation Init" << endl;
456
457  sc_start(0);
458
459  cerr << "<test> Simulation Start" << endl;
460
461  Time * _time_global = new Time();
462
463  for (uint32_t i=0; i<morpheo->_nb_thread; ++i)
464    INTERRUPT_ENABLE[i]->write(0);
465
466  NRESET->write(0);
467  SC_START(5);
468  NRESET->write(1); 
469
470  // Infinite loop
471  do
472    {
473//       Time * _time_local = new Time();
474      SC_START(100000);
475//       delete _time_local;
476    } while (not morpheo    ->simulation_end() and // morpheo condition stop
477             not environment->simulation_end());   // test ok
478  delete _time_global;
479
480  bool morpheo_end     = morpheo->simulation_end();
481  bool environment_end = environment->simulation_end();
482
483
484  //==============================================================================
485  //===== [ DESTRUCTION ]=========================================================
486  //==============================================================================
487
488  delete CLOCK;
489  delete NRESET;
490
491  DELETE1_SC_SIGNAL(ICACHE_REQ_VAL         ,morpheo->_nb_icache_port);
492  DELETE1_SC_SIGNAL(ICACHE_REQ_ACK         ,morpheo->_nb_icache_port);
493  DELETE1_SC_SIGNAL(ICACHE_REQ_THREAD_ID   ,morpheo->_nb_icache_port);
494  DELETE1_SC_SIGNAL(ICACHE_REQ_PACKET_ID   ,morpheo->_nb_icache_port);
495  DELETE1_SC_SIGNAL(ICACHE_REQ_ADDRESS     ,morpheo->_nb_icache_port);
496  DELETE1_SC_SIGNAL(ICACHE_REQ_TYPE        ,morpheo->_nb_icache_port);
497 
498  DELETE1_SC_SIGNAL(ICACHE_RSP_VAL         ,morpheo->_nb_icache_port);
499  DELETE1_SC_SIGNAL(ICACHE_RSP_ACK         ,morpheo->_nb_icache_port);
500  DELETE1_SC_SIGNAL(ICACHE_RSP_THREAD_ID   ,morpheo->_nb_icache_port);
501  DELETE1_SC_SIGNAL(ICACHE_RSP_PACKET_ID   ,morpheo->_nb_icache_port);
502  DELETE1_SC_SIGNAL(ICACHE_RSP_ERROR       ,morpheo->_nb_icache_port);
503  DELETE2_SC_SIGNAL(ICACHE_RSP_INSTRUCTION ,morpheo->_nb_icache_port,morpheo->_icache_nb_instruction[it1]);
504 
505  DELETE1_SC_SIGNAL(DCACHE_REQ_VAL         ,morpheo->_nb_dcache_port);
506  DELETE1_SC_SIGNAL(DCACHE_REQ_ACK         ,morpheo->_nb_dcache_port);
507  DELETE1_SC_SIGNAL(DCACHE_REQ_THREAD_ID   ,morpheo->_nb_dcache_port);
508  DELETE1_SC_SIGNAL(DCACHE_REQ_PACKET_ID   ,morpheo->_nb_dcache_port);
509  DELETE1_SC_SIGNAL(DCACHE_REQ_ADDRESS     ,morpheo->_nb_dcache_port);
510  DELETE1_SC_SIGNAL(DCACHE_REQ_WDATA       ,morpheo->_nb_dcache_port);
511  DELETE1_SC_SIGNAL(DCACHE_REQ_TYPE        ,morpheo->_nb_dcache_port);
512 
513  DELETE1_SC_SIGNAL(DCACHE_RSP_VAL         ,morpheo->_nb_dcache_port);
514  DELETE1_SC_SIGNAL(DCACHE_RSP_ACK         ,morpheo->_nb_dcache_port);
515  DELETE1_SC_SIGNAL(DCACHE_RSP_THREAD_ID   ,morpheo->_nb_dcache_port);
516  DELETE1_SC_SIGNAL(DCACHE_RSP_PACKET_ID   ,morpheo->_nb_dcache_port);
517  DELETE1_SC_SIGNAL(DCACHE_RSP_RDATA       ,morpheo->_nb_dcache_port);
518  DELETE1_SC_SIGNAL(DCACHE_RSP_ERROR       ,morpheo->_nb_dcache_port);
519 
520  DELETE1_SC_SIGNAL(INTERRUPT_ENABLE       ,morpheo->_nb_thread);
521
522  delete    morpheo;
523 
524  delete    environment;
525
526  delete    param_environment;
527  delete    segtable;
528
529  delete [] nb_lock        ;
530  delete [] ramlock_address;
531  for (uint32_t i=0;i<nb_component_tty;++i)
532    delete [] name_tty [i];
533  delete [] name_tty;
534  delete [] tty_address;
535
536  delete [] cache_shared_miss_penality;
537  delete [] cache_shared_hit_latence  ;
538  delete [] cache_shared_associativity;
539  delete [] cache_shared_size_word    ;
540  delete [] cache_shared_size_line    ;
541  delete [] cache_shared_nb_line      ;
542
543  for (uint32_t i=0; i<nb_entity; i++)
544    {
545      delete [] icache_miss_penality [i];
546      delete [] icache_hit_latence   [i];
547      delete [] icache_associativity [i];
548      delete [] icache_size_word     [i];
549      delete [] icache_size_line     [i];
550      delete [] icache_nb_line       [i];
551    }
552  delete [] icache_miss_penality;
553  delete [] icache_hit_latence  ;
554  delete [] icache_associativity;
555  delete [] icache_size_word    ;
556  delete [] icache_size_line    ;
557  delete [] icache_nb_line      ;
558
559  for (uint32_t i=0; i<nb_entity; i++)
560    {
561      delete [] dcache_miss_penality [i];
562      delete [] dcache_hit_latence   [i];
563      delete [] dcache_associativity [i];
564      delete [] dcache_size_word     [i];
565      delete [] dcache_size_line     [i];
566      delete [] dcache_nb_line       [i];
567    }
568  delete [] dcache_miss_penality  ;
569  delete [] dcache_hit_latence    ;
570  delete [] dcache_associativity  ;
571  delete [] dcache_size_word      ;
572  delete [] dcache_size_line      ;
573  delete [] dcache_nb_line        ;
574
575  delete [] buffer_drsp_size      ;
576  delete [] buffer_irsp_size      ;
577  delete [] daccess_size_data     ;
578  delete [] daccess_size_address  ;
579  delete [] daccess_nb_packet     ;
580  delete [] daccess_nb_context    ;
581  delete [] iaccess_size_data     ;
582  delete [] iaccess_size_address  ;
583  delete [] iaccess_nb_packet     ;
584  delete [] iaccess_nb_instruction;
585  delete [] iaccess_nb_context    ;
586
587  bool test_ok = false;
588  if (not morpheo_end and not environment_end)
589    {
590      cerr << "<test> Simulation End : Unknow" << endl;
591    }
592  else
593    {
594      if (morpheo_end)
595        cout << "<test> Simulation End : MORPHEO" << endl;
596      if (environment_end)
597        {
598          cout << "<test> Simulation End : ENVIRONMENT" << endl;
599          test_ok = true;
600        }
601    }
602     
603  if (test_ok)
604    {
605      cout << STR_OK << endl;
606      return EXIT_SUCCESS;
607    }
608  else
609    {
610      cout << STR_KO << endl;
611      return EXIT_FAILURE;
612    }
613}
Note: See TracBrowser for help on using the repository browser.