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