source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/SelfTest/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: 10.5 KB
Line 
1/*
2 * $Id: test.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Core/SelfTest/include/test.h"
10#include "Behavioural/include/Allocation.h"
11
12void test (string name,
13           morpheo::behavioural::core::Parameters * _param)
14{
15  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
16
17#ifdef STATISTICS
18  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,CYCLE_MAX);
19#endif
20
21  Tusage_t _usage = USE_ALL;
22
23//   _usage = usage_unset(_usage,USE_SYSTEMC              );
24//   _usage = usage_unset(_usage,USE_VHDL                 );
25//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH       );
26//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);
27//   _usage = usage_unset(_usage,USE_POSITION             );
28//   _usage = usage_unset(_usage,USE_STATISTICS           );
29//   _usage = usage_unset(_usage,USE_INFORMATION          );
30
31  Core * _Core = new Core
32    (name.c_str(),
33#ifdef STATISTICS
34     _parameters_statistics,
35#endif
36     _param,
37     _usage);
38 
39#ifdef SYSTEMC
40  if (usage_is_set(_usage,USE_SYSTEMC))
41    {
42  /*********************************************************************
43   * Déclarations des signaux
44   *********************************************************************/
45  string rename;
46
47  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
48  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
49
50  ALLOC1_SC_SIGNAL(out_ICACHE_REQ_VAL         ,"out_ICACHE_REQ_VAL        ",Tcontrol_t           ,_param->_nb_icache_port);
51  ALLOC1_SC_SIGNAL( in_ICACHE_REQ_ACK         ," in_ICACHE_REQ_ACK        ",Tcontrol_t           ,_param->_nb_icache_port);
52  ALLOC1_SC_SIGNAL(out_ICACHE_REQ_THREAD_ID   ,"out_ICACHE_REQ_THREAD_ID  ",Tcontext_t           ,_param->_nb_icache_port);
53  ALLOC1_SC_SIGNAL(out_ICACHE_REQ_PACKET_ID   ,"out_ICACHE_REQ_PACKET_ID  ",Tpacket_t            ,_param->_nb_icache_port);
54  ALLOC1_SC_SIGNAL(out_ICACHE_REQ_ADDRESS     ,"out_ICACHE_REQ_ADDRESS    ",Ticache_address_t    ,_param->_nb_icache_port);
55  ALLOC1_SC_SIGNAL(out_ICACHE_REQ_TYPE        ,"out_ICACHE_REQ_TYPE       ",Ticache_type_t       ,_param->_nb_icache_port);
56
57  ALLOC1_SC_SIGNAL( in_ICACHE_RSP_VAL         ," in_ICACHE_RSP_VAL        ",Tcontrol_t           ,_param->_nb_icache_port);
58  ALLOC1_SC_SIGNAL(out_ICACHE_RSP_ACK         ,"out_ICACHE_RSP_ACK        ",Tcontrol_t           ,_param->_nb_icache_port);
59  ALLOC1_SC_SIGNAL( in_ICACHE_RSP_THREAD_ID   ," in_ICACHE_RSP_THREAD_ID  ",Tcontext_t           ,_param->_nb_icache_port);
60  ALLOC1_SC_SIGNAL( in_ICACHE_RSP_PACKET_ID   ," in_ICACHE_RSP_PACKET_ID  ",Tpacket_t            ,_param->_nb_icache_port);
61  ALLOC2_SC_SIGNAL( in_ICACHE_RSP_INSTRUCTION ," in_ICACHE_RSP_INSTRUCTION",Ticache_instruction_t,_param->_nb_icache_port,_param->_icache_nb_instruction[it1]);
62  ALLOC1_SC_SIGNAL( in_ICACHE_RSP_ERROR       ," in_ICACHE_RSP_ERROR      ",Ticache_error_t      ,_param->_nb_icache_port);
63
64  ALLOC1_SC_SIGNAL(out_DCACHE_REQ_VAL         ,"out_DCACHE_REQ_VAL        ",Tcontrol_t           ,_param->_nb_dcache_port);
65  ALLOC1_SC_SIGNAL( in_DCACHE_REQ_ACK         ," in_DCACHE_REQ_ACK        ",Tcontrol_t           ,_param->_nb_dcache_port);
66  ALLOC1_SC_SIGNAL(out_DCACHE_REQ_THREAD_ID   ,"out_DCACHE_REQ_THREAD_ID  ",Tcontext_t           ,_param->_nb_dcache_port);
67  ALLOC1_SC_SIGNAL(out_DCACHE_REQ_PACKET_ID   ,"out_DCACHE_REQ_PACKET_ID  ",Tpacket_t            ,_param->_nb_dcache_port);
68  ALLOC1_SC_SIGNAL(out_DCACHE_REQ_ADDRESS     ,"out_DCACHE_REQ_ADDRESS    ",Tdcache_address_t    ,_param->_nb_dcache_port);
69  ALLOC1_SC_SIGNAL(out_DCACHE_REQ_WDATA       ,"out_DCACHE_REQ_WDATA      ",Tdcache_data_t       ,_param->_nb_dcache_port);
70  ALLOC1_SC_SIGNAL(out_DCACHE_REQ_TYPE        ,"out_DCACHE_REQ_TYPE       ",Tdcache_type_t       ,_param->_nb_dcache_port);
71                                                                                                 
72  ALLOC1_SC_SIGNAL( in_DCACHE_RSP_VAL         ," in_DCACHE_RSP_VAL        ",Tcontrol_t           ,_param->_nb_dcache_port);
73  ALLOC1_SC_SIGNAL(out_DCACHE_RSP_ACK         ,"out_DCACHE_RSP_ACK        ",Tcontrol_t           ,_param->_nb_dcache_port);
74  ALLOC1_SC_SIGNAL( in_DCACHE_RSP_THREAD_ID   ," in_DCACHE_RSP_THREAD_ID  ",Tcontext_t           ,_param->_nb_dcache_port);
75  ALLOC1_SC_SIGNAL( in_DCACHE_RSP_PACKET_ID   ," in_DCACHE_RSP_PACKET_ID  ",Tpacket_t            ,_param->_nb_dcache_port);
76  ALLOC1_SC_SIGNAL( in_DCACHE_RSP_RDATA       ," in_DCACHE_RSP_RDATA      ",Tdcache_data_t       ,_param->_nb_dcache_port);
77  ALLOC1_SC_SIGNAL( in_DCACHE_RSP_ERROR       ," in_DCACHE_RSP_ERROR      ",Tdcache_error_t      ,_param->_nb_dcache_port);
78                                                                                                 
79  ALLOC1_SC_SIGNAL( in_INTERRUPT_ENABLE       ," in_INTERRUPT_ENABLE      ",Tcontrol_t           ,_param->_nb_thread);
80 
81  /********************************************************
82   * Instanciation
83   ********************************************************/
84 
85  msg(_("<%s> : Instanciation of _Core.\n"),name.c_str());
86
87  (*(_Core->in_CLOCK))        (*(in_CLOCK));
88  (*(_Core->in_NRESET))       (*(in_NRESET));
89
90  INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_VAL         ,_param->_nb_icache_port);
91  INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_REQ_ACK         ,_param->_nb_icache_port);
92  if (_param->_have_port_icache_thread_id)
93  INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_THREAD_ID   ,_param->_nb_icache_port);
94  if (_param->_have_port_icache_packet_id)
95  INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_PACKET_ID   ,_param->_nb_icache_port);
96  INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_ADDRESS     ,_param->_nb_icache_port);
97  INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_TYPE        ,_param->_nb_icache_port);
98
99  INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_VAL         ,_param->_nb_icache_port);
100  INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_RSP_ACK         ,_param->_nb_icache_port);
101  if (_param->_have_port_icache_thread_id)
102  INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_THREAD_ID   ,_param->_nb_icache_port);
103  if (_param->_have_port_icache_packet_id)
104  INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_PACKET_ID   ,_param->_nb_icache_port);
105  INSTANCE2_SC_SIGNAL(_Core, in_ICACHE_RSP_INSTRUCTION ,_param->_nb_icache_port,_param->_icache_nb_instruction[it1]);
106  INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_ERROR       ,_param->_nb_icache_port);
107
108  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_VAL         ,_param->_nb_dcache_port);
109  INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_REQ_ACK         ,_param->_nb_dcache_port);
110  if (_param->_have_port_dcache_thread_id)
111  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_THREAD_ID   ,_param->_nb_dcache_port);
112  if (_param->_have_port_dcache_packet_id)
113  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_PACKET_ID   ,_param->_nb_dcache_port);
114  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_ADDRESS     ,_param->_nb_dcache_port);
115  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_WDATA       ,_param->_nb_dcache_port);
116  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_TYPE        ,_param->_nb_dcache_port);
117
118  INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_VAL         ,_param->_nb_dcache_port);
119  INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_RSP_ACK         ,_param->_nb_dcache_port);
120  if (_param->_have_port_dcache_thread_id)
121  INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_THREAD_ID   ,_param->_nb_dcache_port);
122  if (_param->_have_port_dcache_packet_id)
123  INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_PACKET_ID   ,_param->_nb_dcache_port);
124  INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_RDATA       ,_param->_nb_dcache_port);
125  INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_ERROR       ,_param->_nb_dcache_port);
126
127  INSTANCE1_SC_SIGNAL(_Core, in_INTERRUPT_ENABLE       ,_param->_nb_thread);
128
129  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
130   
131  Time * _time = new Time();
132
133  /********************************************************
134   * Simulation - Begin
135   ********************************************************/
136
137  // Initialisation
138
139  const uint32_t seed = 0;
140//const uint32_t seed = static_cast<uint32_t>(time(NULL));
141
142  srand(seed);
143
144  SC_START(0);
145  LABEL("Initialisation");
146
147  LABEL("Reset");
148  in_NRESET->write(0);
149  SC_START(5);
150  in_NRESET->write(1); 
151
152  LABEL("Loop of Test");
153
154  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
155    {
156      LABEL("Iteration %d",iteration);
157
158      SC_START(1);
159    }
160
161  /********************************************************
162   * Simulation - End
163   ********************************************************/
164
165  TEST_OK ("End of Simulation");
166  delete _time;
167
168  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
169
170  delete in_CLOCK;
171  delete in_NRESET;
172
173  DELETE1_SC_SIGNAL(out_ICACHE_REQ_VAL         ,_param->_nb_icache_port);
174  DELETE1_SC_SIGNAL( in_ICACHE_REQ_ACK         ,_param->_nb_icache_port);
175  DELETE1_SC_SIGNAL(out_ICACHE_REQ_THREAD_ID   ,_param->_nb_icache_port);
176  DELETE1_SC_SIGNAL(out_ICACHE_REQ_PACKET_ID   ,_param->_nb_icache_port);
177  DELETE1_SC_SIGNAL(out_ICACHE_REQ_ADDRESS     ,_param->_nb_icache_port);
178  DELETE1_SC_SIGNAL(out_ICACHE_REQ_TYPE        ,_param->_nb_icache_port);
179 
180  DELETE1_SC_SIGNAL( in_ICACHE_RSP_VAL         ,_param->_nb_icache_port);
181  DELETE1_SC_SIGNAL(out_ICACHE_RSP_ACK         ,_param->_nb_icache_port);
182  DELETE1_SC_SIGNAL( in_ICACHE_RSP_THREAD_ID   ,_param->_nb_icache_port);
183  DELETE1_SC_SIGNAL( in_ICACHE_RSP_PACKET_ID   ,_param->_nb_icache_port);
184  DELETE1_SC_SIGNAL( in_ICACHE_RSP_ERROR       ,_param->_nb_icache_port);
185  DELETE2_SC_SIGNAL( in_ICACHE_RSP_INSTRUCTION ,_param->_nb_icache_port,_param->_icache_nb_instruction[it1]);
186 
187  DELETE1_SC_SIGNAL(out_DCACHE_REQ_VAL         ,_param->_nb_dcache_port);
188  DELETE1_SC_SIGNAL( in_DCACHE_REQ_ACK         ,_param->_nb_dcache_port);
189  DELETE1_SC_SIGNAL(out_DCACHE_REQ_THREAD_ID   ,_param->_nb_dcache_port);
190  DELETE1_SC_SIGNAL(out_DCACHE_REQ_PACKET_ID   ,_param->_nb_dcache_port);
191  DELETE1_SC_SIGNAL(out_DCACHE_REQ_ADDRESS     ,_param->_nb_dcache_port);
192  DELETE1_SC_SIGNAL(out_DCACHE_REQ_WDATA       ,_param->_nb_dcache_port);
193  DELETE1_SC_SIGNAL(out_DCACHE_REQ_TYPE        ,_param->_nb_dcache_port);
194 
195  DELETE1_SC_SIGNAL( in_DCACHE_RSP_VAL         ,_param->_nb_dcache_port);
196  DELETE1_SC_SIGNAL(out_DCACHE_RSP_ACK         ,_param->_nb_dcache_port);
197  DELETE1_SC_SIGNAL( in_DCACHE_RSP_THREAD_ID   ,_param->_nb_dcache_port);
198  DELETE1_SC_SIGNAL( in_DCACHE_RSP_PACKET_ID   ,_param->_nb_dcache_port);
199  DELETE1_SC_SIGNAL( in_DCACHE_RSP_RDATA       ,_param->_nb_dcache_port);
200  DELETE1_SC_SIGNAL( in_DCACHE_RSP_ERROR       ,_param->_nb_dcache_port);
201 
202  DELETE1_SC_SIGNAL( in_INTERRUPT_ENABLE       ,_param->_nb_thread);
203    }
204#endif
205
206  delete _Core;
207#ifdef STATISTICS
208  delete _parameters_statistics;
209#endif
210}
Note: See TracBrowser for help on using the repository browser.