1 | #define DEBUG_CYCLE (0) |
---|
2 | #define DEBUG_END (DEBUG_CYCLE + 330000) |
---|
3 | #define DEBUG |
---|
4 | #define DEBUG_CYCLE (-1) |
---|
5 | #define DEBUG_END (DEBUG_CYCLE + 33000) |
---|
6 | #undef DEBUG |
---|
7 | #include <systemc> |
---|
8 | #include <sys/time.h> |
---|
9 | #include <iostream> |
---|
10 | #include <cstdlib> |
---|
11 | #include <cstdarg> |
---|
12 | #ifdef _OPENMP |
---|
13 | #include <omp.h> |
---|
14 | #endif |
---|
15 | |
---|
16 | #include "mapping_table.h" |
---|
17 | #include "mips32.h" |
---|
18 | #include "vci_simple_ram.h" |
---|
19 | #include "vci_multi_tty.h" |
---|
20 | #include "vci_simple_ring_fast.h" |
---|
21 | #include "vci_mem_cache_v4.h" |
---|
22 | #include "vci_cc_vcache_wrapper_v4.h" |
---|
23 | #include "vci_logger.h" |
---|
24 | #include "vci_xicu.h" |
---|
25 | #include "vci_block_device_tsar_v4.h" |
---|
26 | #include "vci_simhelper.h" |
---|
27 | #include "vci_framebuffer.h" |
---|
28 | |
---|
29 | #ifdef USE_GDB_SERVER |
---|
30 | #include "iss/gdbserver.h" |
---|
31 | #endif |
---|
32 | |
---|
33 | // #define VCI_LOGGER_ON_L1 |
---|
34 | //#define VCI_LOGGER_ON_ROM |
---|
35 | //#define VCI_LOGGER_ON_L1_TGT |
---|
36 | |
---|
37 | #include "segmentation.h" |
---|
38 | |
---|
39 | bool do_debug; |
---|
40 | |
---|
41 | int _main(int argc, char *argv[]) |
---|
42 | { |
---|
43 | uint64_t ms1, ms2; |
---|
44 | struct timeval t1, t2; |
---|
45 | using namespace sc_core; |
---|
46 | // Avoid repeating these everywhere |
---|
47 | using soclib::common::IntTab; |
---|
48 | using soclib::common::Segment; |
---|
49 | |
---|
50 | // set requested parallelims |
---|
51 | #ifdef _OPENMP |
---|
52 | omp_set_dynamic(false); |
---|
53 | omp_set_num_threads(5); |
---|
54 | //omp_set_num_threads(1); |
---|
55 | std::cerr << "Built with openmp version " << _OPENMP << std::endl; |
---|
56 | #endif |
---|
57 | |
---|
58 | if (argc < 3) { |
---|
59 | std::cerr << "usage: " << argv[0] << " <ELF boot image> <disk image>" << std::endl; |
---|
60 | exit(1); |
---|
61 | } |
---|
62 | |
---|
63 | // Define VCI parameters |
---|
64 | #define cell_width 4 |
---|
65 | #define address_width 32 |
---|
66 | #define plen_width 8 |
---|
67 | #define error_width 2 |
---|
68 | #define clen_width 1 |
---|
69 | #define rflag_width 1 |
---|
70 | #define srcid_width 5 |
---|
71 | #define pktid_width 4 |
---|
72 | #define trdid_width 4 |
---|
73 | #define wrplen_width 1 |
---|
74 | |
---|
75 | typedef soclib::caba::VciParams<cell_width, |
---|
76 | plen_width, |
---|
77 | address_width, |
---|
78 | error_width, |
---|
79 | clen_width, |
---|
80 | rflag_width, |
---|
81 | srcid_width, |
---|
82 | pktid_width, |
---|
83 | trdid_width, |
---|
84 | wrplen_width> vci_param; |
---|
85 | typedef soclib::common::Mips32ElIss proc_iss; |
---|
86 | // Mapping table |
---|
87 | |
---|
88 | soclib::common::MappingTable maptabp(32, IntTab(8), IntTab(8), 0xF0000000); |
---|
89 | |
---|
90 | maptabp.add(Segment("mc_m" , RAM_BASE , RAM_SIZE , IntTab(0), true)); |
---|
91 | maptabp.add(Segment("boot", ROM_BASE, ROM_SIZE, IntTab(1), true)); |
---|
92 | maptabp.add(Segment("bd", BD_BASE, BD_SIZE, IntTab(2), false)); |
---|
93 | maptabp.add(Segment("tty" , TTY_BASE , TTY_SIZE , IntTab(3), false)); |
---|
94 | maptabp.add(Segment("xicu" , XICU_BASE , XICU_SIZE , IntTab(4), false)); |
---|
95 | maptabp.add(Segment("simh", SIMH_BASE, SIMH_SIZE, IntTab(5), false)); |
---|
96 | maptabp.add(Segment("fb", FB_BASE, FB_SIZE, IntTab(6), false)); |
---|
97 | |
---|
98 | std::cout << maptabp << std::endl; |
---|
99 | |
---|
100 | soclib::common::MappingTable maptabc(32, IntTab(srcid_width), IntTab(srcid_width), 0xF0000000); |
---|
101 | maptabc.add(Segment("c_proc0" , 0 << (address_width - srcid_width) , 0x10 , IntTab(0), false)); |
---|
102 | maptabc.add(Segment("c_proc1" , 1 << (address_width - srcid_width) , 0x10 , IntTab(1), false)); |
---|
103 | maptabc.add(Segment("c_proc2" , 2 << (address_width - srcid_width) , 0x10 , IntTab(2), false)); |
---|
104 | maptabc.add(Segment("c_proc3" , 3 << (address_width - srcid_width) , 0x10 , IntTab(3), false)); |
---|
105 | maptabc.add(Segment("mc_m" , 4 << (address_width - srcid_width) , 0x10 , IntTab(4), false )); |
---|
106 | |
---|
107 | std::cout << maptabc << std::endl; |
---|
108 | |
---|
109 | soclib::common::MappingTable maptabx(32, IntTab(8), IntTab(8), 0x30000000); |
---|
110 | maptabx.add(Segment("xram" , RAM_BASE , RAM_SIZE , IntTab(0), false)); |
---|
111 | |
---|
112 | |
---|
113 | std::cout << maptabx << std::endl; |
---|
114 | |
---|
115 | // Signals |
---|
116 | |
---|
117 | sc_clock signal_clk ("clk"); |
---|
118 | sc_signal<bool> *signal_resetn; |
---|
119 | signal_resetn = new sc_signal<bool>("resetn"); |
---|
120 | |
---|
121 | sc_signal<bool> *signal_proc0_it0; |
---|
122 | sc_signal<bool> *signal_proc0_it1; |
---|
123 | sc_signal<bool> *signal_proc0_it2; |
---|
124 | sc_signal<bool> *signal_proc0_it3; |
---|
125 | sc_signal<bool> *signal_proc0_it4; |
---|
126 | sc_signal<bool> *signal_proc0_it5; |
---|
127 | |
---|
128 | sc_signal<bool> *signal_proc1_it0; |
---|
129 | sc_signal<bool> *signal_proc1_it1; |
---|
130 | sc_signal<bool> *signal_proc1_it2; |
---|
131 | sc_signal<bool> *signal_proc1_it3; |
---|
132 | sc_signal<bool> *signal_proc1_it4; |
---|
133 | sc_signal<bool> *signal_proc1_it5; |
---|
134 | |
---|
135 | sc_signal<bool> *signal_proc2_it0; |
---|
136 | sc_signal<bool> *signal_proc2_it1; |
---|
137 | sc_signal<bool> *signal_proc2_it2; |
---|
138 | sc_signal<bool> *signal_proc2_it3; |
---|
139 | sc_signal<bool> *signal_proc2_it4; |
---|
140 | sc_signal<bool> *signal_proc2_it5; |
---|
141 | |
---|
142 | sc_signal<bool> *signal_proc3_it0; |
---|
143 | sc_signal<bool> *signal_proc3_it1; |
---|
144 | sc_signal<bool> *signal_proc3_it2; |
---|
145 | sc_signal<bool> *signal_proc3_it3; |
---|
146 | sc_signal<bool> *signal_proc3_it4; |
---|
147 | sc_signal<bool> *signal_proc3_it5; |
---|
148 | |
---|
149 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_rw_proc0; |
---|
150 | signal_vci_ini_rw_proc0 = new soclib::caba::VciSignals<vci_param>("vci_ini_rw_proc0"); |
---|
151 | std::cerr << "signal_vci_ini_rw_proc0 " << sizeof(*signal_vci_ini_rw_proc0) << "@" << signal_vci_ini_rw_proc0 << std::endl; |
---|
152 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_c_proc0; |
---|
153 | signal_vci_ini_c_proc0 = new soclib::caba::VciSignals<vci_param>("vci_ini_c_proc0"); |
---|
154 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_proc0; |
---|
155 | signal_vci_tgt_proc0 = new soclib::caba::VciSignals<vci_param>("vci_tgt_proc0"); |
---|
156 | |
---|
157 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_rw_proc1; |
---|
158 | signal_vci_ini_rw_proc1 = new soclib::caba::VciSignals<vci_param>("vci_ini_rw_proc1"); |
---|
159 | std::cerr << "signal_vci_ini_rw_proc1 " << sizeof(*signal_vci_ini_rw_proc1) << "@" << signal_vci_ini_rw_proc1 << std::endl; |
---|
160 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_c_proc1; |
---|
161 | signal_vci_ini_c_proc1 = new soclib::caba::VciSignals<vci_param>("vci_ini_c_proc1"); |
---|
162 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_proc1; |
---|
163 | signal_vci_tgt_proc1 = new soclib::caba::VciSignals<vci_param>("vci_tgt_proc1"); |
---|
164 | |
---|
165 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_rw_proc2; |
---|
166 | signal_vci_ini_rw_proc2 = new soclib::caba::VciSignals<vci_param>("vci_ini_rw_proc2"); |
---|
167 | std::cerr << "signal_vci_ini_rw_proc2 " << sizeof(*signal_vci_ini_rw_proc2) << "@" << signal_vci_ini_rw_proc2 << std::endl; |
---|
168 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_c_proc2; |
---|
169 | signal_vci_ini_c_proc2 = new soclib::caba::VciSignals<vci_param>("vci_ini_c_proc2"); |
---|
170 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_proc2; |
---|
171 | signal_vci_tgt_proc2 = new soclib::caba::VciSignals<vci_param>("vci_tgt_proc2"); |
---|
172 | |
---|
173 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_rw_proc3; |
---|
174 | signal_vci_ini_rw_proc3 = new soclib::caba::VciSignals<vci_param>("vci_ini_rw_proc3"); |
---|
175 | std::cerr << "signal_vci_ini_rw_proc3 " << sizeof(*signal_vci_ini_rw_proc3) << "@" << signal_vci_ini_rw_proc3 << std::endl; |
---|
176 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_c_proc3; |
---|
177 | signal_vci_ini_c_proc3 = new soclib::caba::VciSignals<vci_param>("vci_ini_c_proc3"); |
---|
178 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_proc3; |
---|
179 | signal_vci_tgt_proc3 = new soclib::caba::VciSignals<vci_param>("vci_tgt_proc3"); |
---|
180 | |
---|
181 | soclib::caba::VciSignals<vci_param> *signal_vci_tty; |
---|
182 | signal_vci_tty = new soclib::caba::VciSignals<vci_param>("signal_vci_tty"); |
---|
183 | soclib::caba::VciSignals<vci_param> *signal_vci_fb; |
---|
184 | signal_vci_fb = new soclib::caba::VciSignals<vci_param>("signal_vci_fb"); |
---|
185 | soclib::caba::VciSignals<vci_param> *signal_vci_simh; |
---|
186 | signal_vci_simh = new soclib::caba::VciSignals<vci_param>("signal_vci_simh"); |
---|
187 | |
---|
188 | |
---|
189 | soclib::caba::VciSignals<vci_param> *signal_vci_xicu; |
---|
190 | signal_vci_xicu = new soclib::caba::VciSignals<vci_param>("signal_vci_xicu"); |
---|
191 | soclib::caba::VciSignals<vci_param> *signal_vci_vcibd_i; |
---|
192 | signal_vci_vcibd_i = new soclib::caba::VciSignals<vci_param>("signal_vci_vcibd_i"); |
---|
193 | soclib::caba::VciSignals<vci_param> *signal_vci_vcibd_t; |
---|
194 | signal_vci_vcibd_t = new soclib::caba::VciSignals<vci_param>("signal_vci_vcibd_t"); |
---|
195 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_rom; |
---|
196 | signal_vci_tgt_rom = new soclib::caba::VciSignals<vci_param>("vci_tgt_rom"); |
---|
197 | |
---|
198 | soclib::caba::VciSignals<vci_param> *signal_vci_ixr_memc; |
---|
199 | soclib::caba::VciSignals<vci_param> *signal_vci_ini_memc; |
---|
200 | signal_vci_ini_memc = new soclib::caba::VciSignals<vci_param>("vci_ini_memc"); |
---|
201 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_memc; |
---|
202 | signal_vci_tgt_memc = new soclib::caba::VciSignals<vci_param>("vci_tgt_memc"); |
---|
203 | soclib::caba::VciSignals<vci_param> *signal_vci_tgt_cleanup_memc; |
---|
204 | signal_vci_tgt_cleanup_memc = new soclib::caba::VciSignals<vci_param>("vci_tgt_cleanup_memc"); |
---|
205 | |
---|
206 | sc_signal<bool> *signal_icu_irq0; |
---|
207 | sc_signal<bool> *signal_icu_irq1; |
---|
208 | |
---|
209 | soclib::common::Loader loader(argv[1]); |
---|
210 | |
---|
211 | // init_rw init_c tgt |
---|
212 | soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > *proc0; |
---|
213 | soclib::caba::VciSimpleRam<vci_param> *rom; |
---|
214 | soclib::caba::VciSimpleRam<vci_param> *xram; |
---|
215 | soclib::caba::VciMemCacheV4<vci_param> *memc; |
---|
216 | soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > *proc1; |
---|
217 | soclib::caba::VciXicu<vci_param> *vcixicu; |
---|
218 | soclib::caba::VciMultiTty<vci_param> *vcitty; |
---|
219 | soclib::caba::VciFrameBuffer<vci_param> *vcifb; |
---|
220 | soclib::caba::VciSimhelper<vci_param> *vcisimh; |
---|
221 | soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > *proc2; |
---|
222 | soclib::caba::VciBlockDeviceTsarV4<vci_param> *vcibd; |
---|
223 | soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > *proc3; |
---|
224 | soclib::caba::VciSimpleRingFast<vci_param, 40, 33> *ringp; |
---|
225 | soclib::caba::VciSimpleRingFast<vci_param, 40, 33> *ringc; |
---|
226 | #pragma omp parallel sections |
---|
227 | { |
---|
228 | #pragma omp section |
---|
229 | { |
---|
230 | #pragma omp critical |
---|
231 | { |
---|
232 | proc0 = new soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > |
---|
233 | ("proc0", 0, maptabp, maptabc, IntTab(0),IntTab(0),IntTab(0), |
---|
234 | 8,8,8,8,4,64,16,4,64,16,4, 4, 0, 0, 4, 50000, DEBUG_CYCLE, true); |
---|
235 | signal_proc0_it0 = new sc_signal<bool>("mips0_it0"); |
---|
236 | signal_proc0_it1 = new sc_signal<bool>("mips0_it1"); |
---|
237 | signal_proc0_it2 = new sc_signal<bool>("mips0_it2"); |
---|
238 | signal_proc0_it3 = new sc_signal<bool>("mips0_it3"); |
---|
239 | signal_proc0_it4 = new sc_signal<bool>("mips0_it4"); |
---|
240 | signal_proc0_it5 = new sc_signal<bool>("mips0_it5"); |
---|
241 | vcisimh = new soclib::caba::VciSimhelper<vci_param> |
---|
242 | ("vcisimh", IntTab(5), maptabp); |
---|
243 | proc1 = new soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > |
---|
244 | ("proc1", 1, maptabp, maptabc, IntTab(1),IntTab(1),IntTab(1), |
---|
245 | 8,8,8,8,4,64,16,4,64,16,4, 4, 0, 0, 4, 50000, DEBUG_CYCLE, true); |
---|
246 | signal_proc1_it0 = new sc_signal<bool>("mips1_it0"); |
---|
247 | signal_proc1_it1 = new sc_signal<bool>("mips1_it1"); |
---|
248 | signal_proc1_it2 = new sc_signal<bool>("mips1_it2"); |
---|
249 | signal_proc1_it3 = new sc_signal<bool>("mips1_it3"); |
---|
250 | signal_proc1_it4 = new sc_signal<bool>("mips1_it4"); |
---|
251 | signal_proc1_it5 = new sc_signal<bool>("mips1_it5"); |
---|
252 | vcitty = new soclib::caba::VciMultiTty<vci_param> |
---|
253 | ("vcitty", IntTab(3), maptabp, "vcitty0", NULL); |
---|
254 | vcifb = new soclib::caba::VciFrameBuffer<vci_param> |
---|
255 | ("vcifb", IntTab(6), maptabp, FB_XSIZE, FB_YSIZE, soclib::common::FbController::RGB_32); |
---|
256 | |
---|
257 | rom = new soclib::caba::VciSimpleRam<vci_param> |
---|
258 | ("rom", IntTab(1), maptabp, loader); |
---|
259 | vcibd = new soclib::caba::VciBlockDeviceTsarV4<vci_param> |
---|
260 | ("vcitbd", maptabp, IntTab(4), IntTab(2), argv[2]); |
---|
261 | |
---|
262 | #if 1 |
---|
263 | } |
---|
264 | } |
---|
265 | #pragma omp section |
---|
266 | { |
---|
267 | #pragma omp critical |
---|
268 | { |
---|
269 | #endif |
---|
270 | proc2 = new soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > |
---|
271 | ("proc2", 2, maptabp, maptabc, IntTab(2),IntTab(2),IntTab(2), |
---|
272 | 8,8,8,8,4,64,16,4,64,16,4, 4, 0, 0, 4, 50000, DEBUG_CYCLE, true); |
---|
273 | signal_proc2_it0 = new sc_signal<bool>("mips2_it0"); |
---|
274 | signal_proc2_it1 = new sc_signal<bool>("mips2_it1"); |
---|
275 | signal_proc2_it2 = new sc_signal<bool>("mips2_it2"); |
---|
276 | signal_proc2_it3 = new sc_signal<bool>("mips2_it3"); |
---|
277 | signal_proc2_it4 = new sc_signal<bool>("mips2_it4"); |
---|
278 | signal_proc2_it5 = new sc_signal<bool>("mips2_it5"); |
---|
279 | vcixicu = new soclib::caba::VciXicu<vci_param> |
---|
280 | ("vcixicu", maptabp, IntTab(4), 4 /* npti */, 2 /* nhwi */, 4 /* nwti */, 12 /* nirq */); |
---|
281 | signal_icu_irq0 = new sc_signal<bool>("signal_xicu_irq0"); |
---|
282 | signal_icu_irq1 = new sc_signal<bool>("signal_xicu_irq1"); |
---|
283 | #if 1 |
---|
284 | } |
---|
285 | } |
---|
286 | #pragma omp section |
---|
287 | { |
---|
288 | #pragma omp critical |
---|
289 | { |
---|
290 | #endif |
---|
291 | ringc = new soclib::caba::VciSimpleRingFast<vci_param, 40, 33> |
---|
292 | ("ringc",maptabc, IntTab(), 4, 5, 5); |
---|
293 | #if 1 |
---|
294 | } |
---|
295 | } |
---|
296 | #pragma omp section |
---|
297 | { |
---|
298 | #pragma omp critical |
---|
299 | { |
---|
300 | #endif |
---|
301 | ringp = new soclib::caba::VciSimpleRingFast<vci_param, 40, 33> |
---|
302 | ("ringp",maptabp, IntTab(), 4, 5, 7); |
---|
303 | #if 1 |
---|
304 | } |
---|
305 | } |
---|
306 | #pragma omp section |
---|
307 | { |
---|
308 | #pragma omp critical |
---|
309 | { |
---|
310 | #endif |
---|
311 | proc3 = new soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > |
---|
312 | ("proc3", 3, maptabp, maptabc, IntTab(3),IntTab(3),IntTab(3), |
---|
313 | 8,8,8,8,4,64,16,4,64,16,4, 4, 0, 0, 4, 50000, DEBUG_CYCLE, true); |
---|
314 | signal_proc3_it0 = new sc_signal<bool>("mips3_it0"); |
---|
315 | signal_proc3_it1 = new sc_signal<bool>("mips3_it1"); |
---|
316 | signal_proc3_it2 = new sc_signal<bool>("mips3_it2"); |
---|
317 | signal_proc3_it3 = new sc_signal<bool>("mips3_it3"); |
---|
318 | signal_proc3_it4 = new sc_signal<bool>("mips3_it4"); |
---|
319 | signal_proc3_it5 = new sc_signal<bool>("mips3_it5"); |
---|
320 | xram = new soclib::caba::VciSimpleRam<vci_param> |
---|
321 | ("xram", IntTab(0), maptabx, loader); |
---|
322 | memc = new soclib::caba::VciMemCacheV4<vci_param> |
---|
323 | ("memc",maptabp,maptabc,maptabx,IntTab(0),IntTab(4),IntTab(0), IntTab(4),16,256,16, 1024, 4, 4, DEBUG_CYCLE, true); |
---|
324 | signal_vci_ixr_memc = new soclib::caba::VciSignals<vci_param>("vci_ixr_memc"); |
---|
325 | #ifdef VCI_LOGGER_ON_L1 |
---|
326 | soclib::caba::VciLogger<vci_param> vci_logger0("vci_logger0",maptabp); |
---|
327 | #endif |
---|
328 | #ifdef VCI_LOGGER_ON_ROM |
---|
329 | soclib::caba::VciLogger<vci_param> vci_logger1("vci_logger1",maptabp); |
---|
330 | #endif |
---|
331 | #ifdef VCI_LOGGER_ON_L1_TGT |
---|
332 | soclib::caba::VciLogger<vci_param> vci_logger2("vci_logger2",maptabp); |
---|
333 | #endif |
---|
334 | } |
---|
335 | } |
---|
336 | } |
---|
337 | |
---|
338 | proc0->p_clk(signal_clk); |
---|
339 | proc0->p_resetn(*signal_resetn); |
---|
340 | proc0->p_irq[0](*signal_proc0_it0); |
---|
341 | proc0->p_irq[1](*signal_proc0_it1); |
---|
342 | proc0->p_irq[2](*signal_proc0_it2); |
---|
343 | proc0->p_irq[3](*signal_proc0_it3); |
---|
344 | proc0->p_irq[4](*signal_proc0_it4); |
---|
345 | proc0->p_irq[5](*signal_proc0_it5); |
---|
346 | proc0->p_vci_ini_d(*signal_vci_ini_rw_proc0); |
---|
347 | proc0->p_vci_ini_c(*signal_vci_ini_c_proc0); |
---|
348 | proc0->p_vci_tgt_c(*signal_vci_tgt_proc0); |
---|
349 | |
---|
350 | proc1->p_clk(signal_clk); |
---|
351 | proc1->p_resetn(*signal_resetn); |
---|
352 | proc1->p_irq[0](*signal_proc1_it0); |
---|
353 | proc1->p_irq[1](*signal_proc1_it1); |
---|
354 | proc1->p_irq[2](*signal_proc1_it2); |
---|
355 | proc1->p_irq[3](*signal_proc1_it3); |
---|
356 | proc1->p_irq[4](*signal_proc1_it4); |
---|
357 | proc1->p_irq[5](*signal_proc1_it5); |
---|
358 | proc1->p_vci_ini_d(*signal_vci_ini_rw_proc1); |
---|
359 | proc1->p_vci_ini_c(*signal_vci_ini_c_proc1); |
---|
360 | proc1->p_vci_tgt_c(*signal_vci_tgt_proc1); |
---|
361 | |
---|
362 | proc2->p_clk(signal_clk); |
---|
363 | proc2->p_resetn(*signal_resetn); |
---|
364 | proc2->p_irq[0](*signal_proc2_it0); |
---|
365 | proc2->p_irq[1](*signal_proc2_it1); |
---|
366 | proc2->p_irq[2](*signal_proc2_it2); |
---|
367 | proc2->p_irq[3](*signal_proc2_it3); |
---|
368 | proc2->p_irq[4](*signal_proc2_it4); |
---|
369 | proc2->p_irq[5](*signal_proc2_it5); |
---|
370 | proc2->p_vci_ini_d(*signal_vci_ini_rw_proc2); |
---|
371 | proc2->p_vci_ini_c(*signal_vci_ini_c_proc2); |
---|
372 | proc2->p_vci_tgt_c(*signal_vci_tgt_proc2); |
---|
373 | |
---|
374 | proc3->p_clk(signal_clk); |
---|
375 | proc3->p_resetn(*signal_resetn); |
---|
376 | proc3->p_irq[0](*signal_proc3_it0); |
---|
377 | proc3->p_irq[1](*signal_proc3_it1); |
---|
378 | proc3->p_irq[2](*signal_proc3_it2); |
---|
379 | proc3->p_irq[3](*signal_proc3_it3); |
---|
380 | proc3->p_irq[4](*signal_proc3_it4); |
---|
381 | proc3->p_irq[5](*signal_proc3_it5); |
---|
382 | proc3->p_vci_ini_d(*signal_vci_ini_rw_proc3); |
---|
383 | proc3->p_vci_ini_c(*signal_vci_ini_c_proc3); |
---|
384 | proc3->p_vci_tgt_c(*signal_vci_tgt_proc3); |
---|
385 | |
---|
386 | rom->p_clk(signal_clk); |
---|
387 | rom->p_resetn(*signal_resetn); |
---|
388 | rom->p_vci(*signal_vci_tgt_rom); |
---|
389 | |
---|
390 | vcixicu->p_resetn(*signal_resetn); |
---|
391 | vcixicu->p_clk(signal_clk); |
---|
392 | vcixicu->p_vci(*signal_vci_xicu); |
---|
393 | vcixicu->p_hwi[0](*signal_icu_irq0); |
---|
394 | vcixicu->p_hwi[1](*signal_icu_irq1); |
---|
395 | vcixicu->p_irq[0](*signal_proc0_it0); |
---|
396 | vcixicu->p_irq[1](*signal_proc0_it1); |
---|
397 | vcixicu->p_irq[2](*signal_proc0_it2); |
---|
398 | vcixicu->p_irq[3](*signal_proc1_it0); |
---|
399 | vcixicu->p_irq[4](*signal_proc1_it1); |
---|
400 | vcixicu->p_irq[5](*signal_proc1_it2); |
---|
401 | vcixicu->p_irq[6](*signal_proc2_it0); |
---|
402 | vcixicu->p_irq[7](*signal_proc2_it1); |
---|
403 | vcixicu->p_irq[8](*signal_proc2_it2); |
---|
404 | vcixicu->p_irq[9](*signal_proc3_it0); |
---|
405 | vcixicu->p_irq[10](*signal_proc3_it1); |
---|
406 | vcixicu->p_irq[11](*signal_proc3_it2); |
---|
407 | |
---|
408 | #ifdef VCI_LOGGER_ON_L1 |
---|
409 | vci_logger0.p_clk(signal_clk); |
---|
410 | vci_logger0.p_resetn(*signal_resetn); |
---|
411 | vci_logger0.p_vci(*signal_vci_ini_rw_proc0); |
---|
412 | #endif |
---|
413 | |
---|
414 | #ifdef VCI_LOGGER_ON_ROM |
---|
415 | vci_logger1.p_clk(signal_clk); |
---|
416 | vci_logger1.p_resetn(*signal_resetn); |
---|
417 | vci_logger1.p_vci(*signal_vci_tgt_rom); |
---|
418 | #endif |
---|
419 | |
---|
420 | #ifdef VCI_LOGGER_ON_L1_TGT |
---|
421 | vci_logger2.p_clk(signal_clk); |
---|
422 | vci_logger2.p_resetn(*signal_resetn); |
---|
423 | vci_logger2.p_vci(*signal_vci_tgt_proc1); |
---|
424 | #endif |
---|
425 | |
---|
426 | vcitty->p_clk(signal_clk); |
---|
427 | vcitty->p_resetn(*signal_resetn); |
---|
428 | vcitty->p_vci(*signal_vci_tty); |
---|
429 | vcitty->p_irq[0](*signal_icu_irq0); |
---|
430 | |
---|
431 | vcisimh->p_clk(signal_clk); |
---|
432 | vcisimh->p_resetn(*signal_resetn); |
---|
433 | vcisimh->p_vci(*signal_vci_simh); |
---|
434 | |
---|
435 | memc->p_clk(signal_clk); |
---|
436 | memc->p_resetn(*signal_resetn); |
---|
437 | memc->p_vci_tgt(*signal_vci_tgt_memc); |
---|
438 | memc->p_vci_tgt_cleanup(*signal_vci_tgt_cleanup_memc); |
---|
439 | memc->p_vci_ini(*signal_vci_ini_memc); |
---|
440 | memc->p_vci_ixr(*signal_vci_ixr_memc); |
---|
441 | |
---|
442 | vcibd->p_clk(signal_clk); |
---|
443 | vcibd->p_resetn(*signal_resetn); |
---|
444 | vcibd->p_vci_target(*signal_vci_vcibd_t); |
---|
445 | vcibd->p_vci_initiator(*signal_vci_vcibd_i); |
---|
446 | vcibd->p_irq(*signal_icu_irq1); |
---|
447 | |
---|
448 | vcifb->p_clk(signal_clk); |
---|
449 | vcifb->p_resetn(*signal_resetn); |
---|
450 | vcifb->p_vci(*signal_vci_fb); |
---|
451 | |
---|
452 | xram->p_clk(signal_clk); |
---|
453 | xram->p_resetn(*signal_resetn); |
---|
454 | xram->p_vci(*signal_vci_ixr_memc); |
---|
455 | |
---|
456 | ringp->p_clk(signal_clk); |
---|
457 | ringp->p_resetn(*signal_resetn); |
---|
458 | |
---|
459 | ringc->p_clk(signal_clk); |
---|
460 | ringc->p_resetn(*signal_resetn); |
---|
461 | |
---|
462 | ringp->p_to_initiator[0](*signal_vci_ini_rw_proc0); |
---|
463 | ringp->p_to_initiator[1](*signal_vci_ini_rw_proc1); |
---|
464 | ringp->p_to_initiator[2](*signal_vci_ini_rw_proc2); |
---|
465 | ringp->p_to_initiator[3](*signal_vci_ini_rw_proc3); |
---|
466 | ringp->p_to_initiator[4](*signal_vci_vcibd_i); |
---|
467 | |
---|
468 | ringc->p_to_initiator[0](*signal_vci_ini_c_proc0); |
---|
469 | ringc->p_to_initiator[1](*signal_vci_ini_c_proc1); |
---|
470 | ringc->p_to_initiator[2](*signal_vci_ini_c_proc2); |
---|
471 | ringc->p_to_initiator[3](*signal_vci_ini_c_proc3); |
---|
472 | ringc->p_to_initiator[4](*signal_vci_ini_memc); |
---|
473 | |
---|
474 | ringp->p_to_target[0](*signal_vci_tgt_memc); |
---|
475 | ringp->p_to_target[1](*signal_vci_tgt_rom); |
---|
476 | ringp->p_to_target[2](*signal_vci_vcibd_t); |
---|
477 | ringp->p_to_target[3](*signal_vci_tty); |
---|
478 | ringp->p_to_target[4](*signal_vci_xicu); |
---|
479 | ringp->p_to_target[5](*signal_vci_simh); |
---|
480 | ringp->p_to_target[6](*signal_vci_fb); |
---|
481 | |
---|
482 | ringc->p_to_target[0](*signal_vci_tgt_proc0); |
---|
483 | ringc->p_to_target[1](*signal_vci_tgt_proc1); |
---|
484 | ringc->p_to_target[2](*signal_vci_tgt_proc2); |
---|
485 | ringc->p_to_target[3](*signal_vci_tgt_proc3); |
---|
486 | ringc->p_to_target[4](*signal_vci_tgt_cleanup_memc); |
---|
487 | |
---|
488 | |
---|
489 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
490 | *signal_resetn = false; |
---|
491 | |
---|
492 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
493 | *signal_resetn = true; |
---|
494 | /* |
---|
495 | * execute 10 million cycle, compute how many time it took and |
---|
496 | * print the clock frequency |
---|
497 | */ |
---|
498 | #ifndef DEBUG |
---|
499 | //#define STATS_CYCLES 100000000ULL |
---|
500 | #define STATS_CYCLES 1000000ULL |
---|
501 | int n = 0; |
---|
502 | do_debug = 0; |
---|
503 | no_debug: |
---|
504 | proc0->iss_set_debug_mask(0); |
---|
505 | proc1->iss_set_debug_mask(0); |
---|
506 | proc2->iss_set_debug_mask(0); |
---|
507 | proc3->iss_set_debug_mask(0); |
---|
508 | while (do_debug == 0) { |
---|
509 | if (gettimeofday(&t1, NULL) != 0) { |
---|
510 | perror("gettimeofday"); |
---|
511 | return EXIT_FAILURE; |
---|
512 | } |
---|
513 | sc_start(STATS_CYCLES); |
---|
514 | n += STATS_CYCLES; |
---|
515 | if (gettimeofday(&t2, NULL) != 0) { |
---|
516 | perror("gettimeofday"); |
---|
517 | return EXIT_FAILURE; |
---|
518 | } |
---|
519 | ms1 = (uint64_t)t1.tv_sec * 1000ULL + (uint64_t)t1.tv_usec / 1000; |
---|
520 | ms2 = (uint64_t)t2.tv_sec * 1000ULL + (uint64_t)t2.tv_usec / 1000; |
---|
521 | std::cerr << "cycle " << n << " platform clock frequency " << (double)STATS_CYCLES / (double)(ms2 - ms1) << "Khz" << std::endl; |
---|
522 | } |
---|
523 | proc0->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
524 | proc1->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
525 | proc2->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
526 | proc3->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
527 | while (do_debug) { |
---|
528 | proc0->print_trace(); |
---|
529 | signal_vci_ini_rw_proc0->print_trace("proc_ini_d"); |
---|
530 | signal_vci_tgt_proc0->print_trace("proc_tgt_c"); |
---|
531 | signal_vci_ini_c_proc0->print_trace("proc_ini_c"); |
---|
532 | |
---|
533 | proc1->print_trace(); |
---|
534 | signal_vci_ini_rw_proc1->print_trace("proc_ini_d"); |
---|
535 | signal_vci_tgt_proc1->print_trace("proc_tgt_c"); |
---|
536 | signal_vci_ini_c_proc1->print_trace("proc_ini_c"); |
---|
537 | |
---|
538 | proc2->print_trace(); |
---|
539 | signal_vci_ini_rw_proc2->print_trace("proc_ini_d"); |
---|
540 | signal_vci_tgt_proc2->print_trace("proc_tgt_c"); |
---|
541 | signal_vci_ini_c_proc2->print_trace("proc_ini_c"); |
---|
542 | |
---|
543 | proc3->print_trace(); |
---|
544 | signal_vci_ini_rw_proc3->print_trace("proc_ini_d"); |
---|
545 | signal_vci_tgt_proc3->print_trace("proc_tgt_c"); |
---|
546 | signal_vci_ini_c_proc3->print_trace("proc_ini_c"); |
---|
547 | |
---|
548 | memc->print_trace(); |
---|
549 | signal_vci_tgt_memc->print_trace("memc_tgt_d"); |
---|
550 | signal_vci_tgt_cleanup_memc->print_trace("memc_tgt_c"); |
---|
551 | signal_vci_ini_memc->print_trace("memc_ini_c"); |
---|
552 | n++; |
---|
553 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
554 | } |
---|
555 | goto no_debug; |
---|
556 | //sc_start(250000000); |
---|
557 | #else |
---|
558 | memc->start_monitor(0x12fc, 4); |
---|
559 | proc0->iss_set_debug_mask(0); |
---|
560 | proc1->iss_set_debug_mask(0); |
---|
561 | proc2->iss_set_debug_mask(0); |
---|
562 | proc3->iss_set_debug_mask(0); |
---|
563 | sc_start(DEBUG_CYCLE); |
---|
564 | int n = DEBUG_CYCLE; |
---|
565 | proc0->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
566 | proc1->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
567 | proc2->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
568 | proc3->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
569 | #if 0 |
---|
570 | while (n < DEBUG_END) { |
---|
571 | std::cout << "cycle " << std::dec << n << std::endl; |
---|
572 | sc_start(10000); |
---|
573 | n+= 10000; |
---|
574 | } |
---|
575 | #endif |
---|
576 | while (n < DEBUG_END) { |
---|
577 | std::cout << "****************** cycle " << std::dec << n |
---|
578 | << std::endl; |
---|
579 | proc0->cache_monitor(0x12fc); |
---|
580 | proc0->print_trace(); |
---|
581 | signal_vci_ini_rw_proc0->print_trace("proc_ini_d"); |
---|
582 | signal_vci_tgt_proc0->print_trace("proc_tgt_c"); |
---|
583 | signal_vci_ini_c_proc0->print_trace("proc_ini_c"); |
---|
584 | |
---|
585 | proc1->print_trace(); |
---|
586 | signal_vci_ini_rw_proc1->print_trace("proc_ini_d"); |
---|
587 | signal_vci_tgt_proc1->print_trace("proc_tgt_c"); |
---|
588 | signal_vci_ini_c_proc1->print_trace("proc_ini_c"); |
---|
589 | |
---|
590 | proc2->print_trace(); |
---|
591 | signal_vci_ini_rw_proc2->print_trace("proc_ini_d"); |
---|
592 | signal_vci_tgt_proc2->print_trace("proc_tgt_c"); |
---|
593 | signal_vci_ini_c_proc2->print_trace("proc_ini_c"); |
---|
594 | |
---|
595 | proc3->print_trace(); |
---|
596 | signal_vci_ini_rw_proc3->print_trace("proc_ini_d"); |
---|
597 | signal_vci_tgt_proc3->print_trace("proc_tgt_c"); |
---|
598 | signal_vci_ini_c_proc3->print_trace("proc_ini_c"); |
---|
599 | |
---|
600 | memc->print_trace(); |
---|
601 | signal_vci_tgt_memc->print_trace("memc_tgt_d"); |
---|
602 | signal_vci_tgt_cleanup_memc->print_trace("memc_tgt_c"); |
---|
603 | signal_vci_ini_memc->print_trace("memc_ini_c"); |
---|
604 | n++; |
---|
605 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
606 | } |
---|
607 | #endif |
---|
608 | |
---|
609 | return EXIT_FAILURE; |
---|
610 | |
---|
611 | } |
---|
612 | |
---|
613 | int sc_main (int argc, char *argv[]) |
---|
614 | { |
---|
615 | try { |
---|
616 | return _main(argc, argv); |
---|
617 | } catch (std::exception &e) { |
---|
618 | std::cout << e.what() << std::endl; |
---|
619 | } catch (...) { |
---|
620 | std::cout << "Unknown exception occured" << std::endl; |
---|
621 | throw; |
---|
622 | } |
---|
623 | return 1; |
---|
624 | } |
---|
625 | |
---|