1 | /* |
---|
2 | * $Id: test.cpp 110 2009-02-19 16:31:47Z 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 | ALLOC1_SC_SIGNAL(out_ICACHE_REQ_VAL ,"out_ICACHE_REQ_VAL ",Tcontrol_t ,_param->_nb_icache_port); |
---|
56 | ALLOC1_SC_SIGNAL( in_ICACHE_REQ_ACK ," in_ICACHE_REQ_ACK ",Tcontrol_t ,_param->_nb_icache_port); |
---|
57 | ALLOC1_SC_SIGNAL(out_ICACHE_REQ_THREAD_ID ,"out_ICACHE_REQ_THREAD_ID ",Tcontext_t ,_param->_nb_icache_port); |
---|
58 | ALLOC1_SC_SIGNAL(out_ICACHE_REQ_PACKET_ID ,"out_ICACHE_REQ_PACKET_ID ",Tpacket_t ,_param->_nb_icache_port); |
---|
59 | ALLOC1_SC_SIGNAL(out_ICACHE_REQ_ADDRESS ,"out_ICACHE_REQ_ADDRESS ",Ticache_address_t ,_param->_nb_icache_port); |
---|
60 | ALLOC1_SC_SIGNAL(out_ICACHE_REQ_TYPE ,"out_ICACHE_REQ_TYPE ",Ticache_type_t ,_param->_nb_icache_port); |
---|
61 | |
---|
62 | ALLOC1_SC_SIGNAL( in_ICACHE_RSP_VAL ," in_ICACHE_RSP_VAL ",Tcontrol_t ,_param->_nb_icache_port); |
---|
63 | ALLOC1_SC_SIGNAL(out_ICACHE_RSP_ACK ,"out_ICACHE_RSP_ACK ",Tcontrol_t ,_param->_nb_icache_port); |
---|
64 | ALLOC1_SC_SIGNAL( in_ICACHE_RSP_THREAD_ID ," in_ICACHE_RSP_THREAD_ID ",Tcontext_t ,_param->_nb_icache_port); |
---|
65 | ALLOC1_SC_SIGNAL( in_ICACHE_RSP_PACKET_ID ," in_ICACHE_RSP_PACKET_ID ",Tpacket_t ,_param->_nb_icache_port); |
---|
66 | ALLOC2_SC_SIGNAL( in_ICACHE_RSP_INSTRUCTION ," in_ICACHE_RSP_INSTRUCTION",Ticache_instruction_t,_param->_nb_icache_port,_param->_icache_nb_instruction[it1]); |
---|
67 | ALLOC1_SC_SIGNAL( in_ICACHE_RSP_ERROR ," in_ICACHE_RSP_ERROR ",Ticache_error_t ,_param->_nb_icache_port); |
---|
68 | |
---|
69 | ALLOC1_SC_SIGNAL(out_DCACHE_REQ_VAL ,"out_DCACHE_REQ_VAL ",Tcontrol_t ,_param->_nb_dcache_port); |
---|
70 | ALLOC1_SC_SIGNAL( in_DCACHE_REQ_ACK ," in_DCACHE_REQ_ACK ",Tcontrol_t ,_param->_nb_dcache_port); |
---|
71 | ALLOC1_SC_SIGNAL(out_DCACHE_REQ_THREAD_ID ,"out_DCACHE_REQ_THREAD_ID ",Tcontext_t ,_param->_nb_dcache_port); |
---|
72 | ALLOC1_SC_SIGNAL(out_DCACHE_REQ_PACKET_ID ,"out_DCACHE_REQ_PACKET_ID ",Tpacket_t ,_param->_nb_dcache_port); |
---|
73 | ALLOC1_SC_SIGNAL(out_DCACHE_REQ_ADDRESS ,"out_DCACHE_REQ_ADDRESS ",Tdcache_address_t ,_param->_nb_dcache_port); |
---|
74 | ALLOC1_SC_SIGNAL(out_DCACHE_REQ_WDATA ,"out_DCACHE_REQ_WDATA ",Tdcache_data_t ,_param->_nb_dcache_port); |
---|
75 | ALLOC1_SC_SIGNAL(out_DCACHE_REQ_TYPE ,"out_DCACHE_REQ_TYPE ",Tdcache_type_t ,_param->_nb_dcache_port); |
---|
76 | |
---|
77 | ALLOC1_SC_SIGNAL( in_DCACHE_RSP_VAL ," in_DCACHE_RSP_VAL ",Tcontrol_t ,_param->_nb_dcache_port); |
---|
78 | ALLOC1_SC_SIGNAL(out_DCACHE_RSP_ACK ,"out_DCACHE_RSP_ACK ",Tcontrol_t ,_param->_nb_dcache_port); |
---|
79 | ALLOC1_SC_SIGNAL( in_DCACHE_RSP_THREAD_ID ," in_DCACHE_RSP_THREAD_ID ",Tcontext_t ,_param->_nb_dcache_port); |
---|
80 | ALLOC1_SC_SIGNAL( in_DCACHE_RSP_PACKET_ID ," in_DCACHE_RSP_PACKET_ID ",Tpacket_t ,_param->_nb_dcache_port); |
---|
81 | ALLOC1_SC_SIGNAL( in_DCACHE_RSP_RDATA ," in_DCACHE_RSP_RDATA ",Tdcache_data_t ,_param->_nb_dcache_port); |
---|
82 | ALLOC1_SC_SIGNAL( in_DCACHE_RSP_ERROR ," in_DCACHE_RSP_ERROR ",Tdcache_error_t ,_param->_nb_dcache_port); |
---|
83 | |
---|
84 | ALLOC1_SC_SIGNAL( in_INTERRUPT_ENABLE ," in_INTERRUPT_ENABLE ",Tcontrol_t ,_param->_nb_thread); |
---|
85 | |
---|
86 | /******************************************************** |
---|
87 | * Instanciation |
---|
88 | ********************************************************/ |
---|
89 | |
---|
90 | msg(_("<%s> : Instanciation of _Core.\n"),name.c_str()); |
---|
91 | |
---|
92 | (*(_Core->in_CLOCK)) (*(in_CLOCK)); |
---|
93 | (*(_Core->in_NRESET)) (*(in_NRESET)); |
---|
94 | |
---|
95 | INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_VAL ,_param->_nb_icache_port); |
---|
96 | INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_REQ_ACK ,_param->_nb_icache_port); |
---|
97 | if (_param->_have_port_icache_thread_id) |
---|
98 | INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_THREAD_ID ,_param->_nb_icache_port); |
---|
99 | if (_param->_have_port_icache_packet_id) |
---|
100 | INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_PACKET_ID ,_param->_nb_icache_port); |
---|
101 | INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_ADDRESS ,_param->_nb_icache_port); |
---|
102 | INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_REQ_TYPE ,_param->_nb_icache_port); |
---|
103 | |
---|
104 | INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_VAL ,_param->_nb_icache_port); |
---|
105 | INSTANCE1_SC_SIGNAL(_Core,out_ICACHE_RSP_ACK ,_param->_nb_icache_port); |
---|
106 | if (_param->_have_port_icache_thread_id) |
---|
107 | INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_THREAD_ID ,_param->_nb_icache_port); |
---|
108 | if (_param->_have_port_icache_packet_id) |
---|
109 | INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_PACKET_ID ,_param->_nb_icache_port); |
---|
110 | INSTANCE2_SC_SIGNAL(_Core, in_ICACHE_RSP_INSTRUCTION ,_param->_nb_icache_port,_param->_icache_nb_instruction[it1]); |
---|
111 | INSTANCE1_SC_SIGNAL(_Core, in_ICACHE_RSP_ERROR ,_param->_nb_icache_port); |
---|
112 | |
---|
113 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_VAL ,_param->_nb_dcache_port); |
---|
114 | INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_REQ_ACK ,_param->_nb_dcache_port); |
---|
115 | if (_param->_have_port_dcache_thread_id) |
---|
116 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_THREAD_ID ,_param->_nb_dcache_port); |
---|
117 | if (_param->_have_port_dcache_packet_id) |
---|
118 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_PACKET_ID ,_param->_nb_dcache_port); |
---|
119 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_ADDRESS ,_param->_nb_dcache_port); |
---|
120 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_WDATA ,_param->_nb_dcache_port); |
---|
121 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_REQ_TYPE ,_param->_nb_dcache_port); |
---|
122 | |
---|
123 | INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_VAL ,_param->_nb_dcache_port); |
---|
124 | INSTANCE1_SC_SIGNAL(_Core,out_DCACHE_RSP_ACK ,_param->_nb_dcache_port); |
---|
125 | if (_param->_have_port_dcache_thread_id) |
---|
126 | INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_THREAD_ID ,_param->_nb_dcache_port); |
---|
127 | if (_param->_have_port_dcache_packet_id) |
---|
128 | INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_PACKET_ID ,_param->_nb_dcache_port); |
---|
129 | INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_RDATA ,_param->_nb_dcache_port); |
---|
130 | INSTANCE1_SC_SIGNAL(_Core, in_DCACHE_RSP_ERROR ,_param->_nb_dcache_port); |
---|
131 | |
---|
132 | INSTANCE1_SC_SIGNAL(_Core, in_INTERRUPT_ENABLE ,_param->_nb_thread); |
---|
133 | |
---|
134 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
135 | |
---|
136 | Time * _time = new Time(); |
---|
137 | |
---|
138 | /******************************************************** |
---|
139 | * Simulation - Begin |
---|
140 | ********************************************************/ |
---|
141 | |
---|
142 | // Initialisation |
---|
143 | |
---|
144 | const uint32_t seed = 0; |
---|
145 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
146 | |
---|
147 | srand(seed); |
---|
148 | |
---|
149 | SC_START(0); |
---|
150 | LABEL("Initialisation"); |
---|
151 | |
---|
152 | LABEL("Reset"); |
---|
153 | in_NRESET->write(0); |
---|
154 | SC_START(5); |
---|
155 | in_NRESET->write(1); |
---|
156 | |
---|
157 | LABEL("Loop of Test"); |
---|
158 | |
---|
159 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
160 | { |
---|
161 | LABEL("Iteration %d",iteration); |
---|
162 | |
---|
163 | SC_START(1); |
---|
164 | } |
---|
165 | |
---|
166 | /******************************************************** |
---|
167 | * Simulation - End |
---|
168 | ********************************************************/ |
---|
169 | |
---|
170 | TEST_OK ("End of Simulation"); |
---|
171 | delete _time; |
---|
172 | |
---|
173 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
174 | |
---|
175 | delete in_CLOCK; |
---|
176 | delete in_NRESET; |
---|
177 | |
---|
178 | DELETE1_SC_SIGNAL(out_ICACHE_REQ_VAL ,_param->_nb_icache_port); |
---|
179 | DELETE1_SC_SIGNAL( in_ICACHE_REQ_ACK ,_param->_nb_icache_port); |
---|
180 | DELETE1_SC_SIGNAL(out_ICACHE_REQ_THREAD_ID ,_param->_nb_icache_port); |
---|
181 | DELETE1_SC_SIGNAL(out_ICACHE_REQ_PACKET_ID ,_param->_nb_icache_port); |
---|
182 | DELETE1_SC_SIGNAL(out_ICACHE_REQ_ADDRESS ,_param->_nb_icache_port); |
---|
183 | DELETE1_SC_SIGNAL(out_ICACHE_REQ_TYPE ,_param->_nb_icache_port); |
---|
184 | |
---|
185 | DELETE1_SC_SIGNAL( in_ICACHE_RSP_VAL ,_param->_nb_icache_port); |
---|
186 | DELETE1_SC_SIGNAL(out_ICACHE_RSP_ACK ,_param->_nb_icache_port); |
---|
187 | DELETE1_SC_SIGNAL( in_ICACHE_RSP_THREAD_ID ,_param->_nb_icache_port); |
---|
188 | DELETE1_SC_SIGNAL( in_ICACHE_RSP_PACKET_ID ,_param->_nb_icache_port); |
---|
189 | DELETE1_SC_SIGNAL( in_ICACHE_RSP_ERROR ,_param->_nb_icache_port); |
---|
190 | DELETE2_SC_SIGNAL( in_ICACHE_RSP_INSTRUCTION ,_param->_nb_icache_port,_param->_icache_nb_instruction[it1]); |
---|
191 | |
---|
192 | DELETE1_SC_SIGNAL(out_DCACHE_REQ_VAL ,_param->_nb_dcache_port); |
---|
193 | DELETE1_SC_SIGNAL( in_DCACHE_REQ_ACK ,_param->_nb_dcache_port); |
---|
194 | DELETE1_SC_SIGNAL(out_DCACHE_REQ_THREAD_ID ,_param->_nb_dcache_port); |
---|
195 | DELETE1_SC_SIGNAL(out_DCACHE_REQ_PACKET_ID ,_param->_nb_dcache_port); |
---|
196 | DELETE1_SC_SIGNAL(out_DCACHE_REQ_ADDRESS ,_param->_nb_dcache_port); |
---|
197 | DELETE1_SC_SIGNAL(out_DCACHE_REQ_WDATA ,_param->_nb_dcache_port); |
---|
198 | DELETE1_SC_SIGNAL(out_DCACHE_REQ_TYPE ,_param->_nb_dcache_port); |
---|
199 | |
---|
200 | DELETE1_SC_SIGNAL( in_DCACHE_RSP_VAL ,_param->_nb_dcache_port); |
---|
201 | DELETE1_SC_SIGNAL(out_DCACHE_RSP_ACK ,_param->_nb_dcache_port); |
---|
202 | DELETE1_SC_SIGNAL( in_DCACHE_RSP_THREAD_ID ,_param->_nb_dcache_port); |
---|
203 | DELETE1_SC_SIGNAL( in_DCACHE_RSP_PACKET_ID ,_param->_nb_dcache_port); |
---|
204 | DELETE1_SC_SIGNAL( in_DCACHE_RSP_RDATA ,_param->_nb_dcache_port); |
---|
205 | DELETE1_SC_SIGNAL( in_DCACHE_RSP_ERROR ,_param->_nb_dcache_port); |
---|
206 | |
---|
207 | DELETE1_SC_SIGNAL( in_INTERRUPT_ENABLE ,_param->_nb_thread); |
---|
208 | } |
---|
209 | #endif |
---|
210 | |
---|
211 | delete _Core; |
---|
212 | #ifdef STATISTICS |
---|
213 | delete _parameters_statistics; |
---|
214 | #endif |
---|
215 | } |
---|