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_vgmn.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(3); |
---|
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::VciVgmn<vci_param> *ringp; |
---|
225 | soclib::caba::VciVgmn<vci_param> *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, 1000000, 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, 1000000, 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, 1000000, 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 | ringp = new soclib::caba::VciVgmn<vci_param> |
---|
280 | ("ringp",maptabp, 5, 7, /*3*/1, 8); |
---|
281 | vcixicu = new soclib::caba::VciXicu<vci_param> |
---|
282 | ("vcixicu", maptabp, IntTab(4), 4 /* npti */, 2 /* nhwi */, 4 /* nwti */, 12 /* nirq */); |
---|
283 | signal_icu_irq0 = new sc_signal<bool>("signal_xicu_irq0"); |
---|
284 | signal_icu_irq1 = new sc_signal<bool>("signal_xicu_irq1"); |
---|
285 | #if 1 |
---|
286 | } |
---|
287 | } |
---|
288 | #pragma omp section |
---|
289 | { |
---|
290 | #pragma omp critical |
---|
291 | { |
---|
292 | #endif |
---|
293 | proc3 = new soclib::caba::VciCcVCacheWrapperV4<vci_param, proc_iss > |
---|
294 | ("proc3", 3, maptabp, maptabc, IntTab(3),IntTab(3),IntTab(3), |
---|
295 | 8,8,8,8,4,64,16,4,64,16,4, 4, 0, 0, 4, 1000000, DEBUG_CYCLE, true); |
---|
296 | signal_proc3_it0 = new sc_signal<bool>("mips3_it0"); |
---|
297 | signal_proc3_it1 = new sc_signal<bool>("mips3_it1"); |
---|
298 | signal_proc3_it2 = new sc_signal<bool>("mips3_it2"); |
---|
299 | signal_proc3_it3 = new sc_signal<bool>("mips3_it3"); |
---|
300 | signal_proc3_it4 = new sc_signal<bool>("mips3_it4"); |
---|
301 | signal_proc3_it5 = new sc_signal<bool>("mips3_it5"); |
---|
302 | xram = new soclib::caba::VciSimpleRam<vci_param> |
---|
303 | ("xram", IntTab(0), maptabx, loader); |
---|
304 | memc = new soclib::caba::VciMemCacheV4<vci_param> |
---|
305 | ("memc",maptabp,maptabc,maptabx,IntTab(0),IntTab(4),IntTab(0), IntTab(4),16,256,16, 1024, 4, 4, DEBUG_CYCLE, true); |
---|
306 | signal_vci_ixr_memc = new soclib::caba::VciSignals<vci_param>("vci_ixr_memc"); |
---|
307 | ringc = new soclib::caba::VciVgmn<vci_param> |
---|
308 | ("ringc",maptabc, 5, 5, /*2*/1, 8); |
---|
309 | #ifdef VCI_LOGGER_ON_L1 |
---|
310 | soclib::caba::VciLogger<vci_param> vci_logger0("vci_logger0",maptabp); |
---|
311 | #endif |
---|
312 | #ifdef VCI_LOGGER_ON_ROM |
---|
313 | soclib::caba::VciLogger<vci_param> vci_logger1("vci_logger1",maptabp); |
---|
314 | #endif |
---|
315 | #ifdef VCI_LOGGER_ON_L1_TGT |
---|
316 | soclib::caba::VciLogger<vci_param> vci_logger2("vci_logger2",maptabp); |
---|
317 | #endif |
---|
318 | } |
---|
319 | } |
---|
320 | } |
---|
321 | |
---|
322 | proc0->p_clk(signal_clk); |
---|
323 | proc0->p_resetn(*signal_resetn); |
---|
324 | proc0->p_irq[0](*signal_proc0_it0); |
---|
325 | proc0->p_irq[1](*signal_proc0_it1); |
---|
326 | proc0->p_irq[2](*signal_proc0_it2); |
---|
327 | proc0->p_irq[3](*signal_proc0_it3); |
---|
328 | proc0->p_irq[4](*signal_proc0_it4); |
---|
329 | proc0->p_irq[5](*signal_proc0_it5); |
---|
330 | proc0->p_vci_ini_d(*signal_vci_ini_rw_proc0); |
---|
331 | proc0->p_vci_ini_c(*signal_vci_ini_c_proc0); |
---|
332 | proc0->p_vci_tgt_c(*signal_vci_tgt_proc0); |
---|
333 | |
---|
334 | proc1->p_clk(signal_clk); |
---|
335 | proc1->p_resetn(*signal_resetn); |
---|
336 | proc1->p_irq[0](*signal_proc1_it0); |
---|
337 | proc1->p_irq[1](*signal_proc1_it1); |
---|
338 | proc1->p_irq[2](*signal_proc1_it2); |
---|
339 | proc1->p_irq[3](*signal_proc1_it3); |
---|
340 | proc1->p_irq[4](*signal_proc1_it4); |
---|
341 | proc1->p_irq[5](*signal_proc1_it5); |
---|
342 | proc1->p_vci_ini_d(*signal_vci_ini_rw_proc1); |
---|
343 | proc1->p_vci_ini_c(*signal_vci_ini_c_proc1); |
---|
344 | proc1->p_vci_tgt_c(*signal_vci_tgt_proc1); |
---|
345 | |
---|
346 | proc2->p_clk(signal_clk); |
---|
347 | proc2->p_resetn(*signal_resetn); |
---|
348 | proc2->p_irq[0](*signal_proc2_it0); |
---|
349 | proc2->p_irq[1](*signal_proc2_it1); |
---|
350 | proc2->p_irq[2](*signal_proc2_it2); |
---|
351 | proc2->p_irq[3](*signal_proc2_it3); |
---|
352 | proc2->p_irq[4](*signal_proc2_it4); |
---|
353 | proc2->p_irq[5](*signal_proc2_it5); |
---|
354 | proc2->p_vci_ini_d(*signal_vci_ini_rw_proc2); |
---|
355 | proc2->p_vci_ini_c(*signal_vci_ini_c_proc2); |
---|
356 | proc2->p_vci_tgt_c(*signal_vci_tgt_proc2); |
---|
357 | |
---|
358 | proc3->p_clk(signal_clk); |
---|
359 | proc3->p_resetn(*signal_resetn); |
---|
360 | proc3->p_irq[0](*signal_proc3_it0); |
---|
361 | proc3->p_irq[1](*signal_proc3_it1); |
---|
362 | proc3->p_irq[2](*signal_proc3_it2); |
---|
363 | proc3->p_irq[3](*signal_proc3_it3); |
---|
364 | proc3->p_irq[4](*signal_proc3_it4); |
---|
365 | proc3->p_irq[5](*signal_proc3_it5); |
---|
366 | proc3->p_vci_ini_d(*signal_vci_ini_rw_proc3); |
---|
367 | proc3->p_vci_ini_c(*signal_vci_ini_c_proc3); |
---|
368 | proc3->p_vci_tgt_c(*signal_vci_tgt_proc3); |
---|
369 | |
---|
370 | rom->p_clk(signal_clk); |
---|
371 | rom->p_resetn(*signal_resetn); |
---|
372 | rom->p_vci(*signal_vci_tgt_rom); |
---|
373 | |
---|
374 | vcixicu->p_resetn(*signal_resetn); |
---|
375 | vcixicu->p_clk(signal_clk); |
---|
376 | vcixicu->p_vci(*signal_vci_xicu); |
---|
377 | vcixicu->p_hwi[0](*signal_icu_irq0); |
---|
378 | vcixicu->p_hwi[1](*signal_icu_irq1); |
---|
379 | vcixicu->p_irq[0](*signal_proc0_it0); |
---|
380 | vcixicu->p_irq[1](*signal_proc0_it1); |
---|
381 | vcixicu->p_irq[2](*signal_proc0_it2); |
---|
382 | vcixicu->p_irq[3](*signal_proc1_it0); |
---|
383 | vcixicu->p_irq[4](*signal_proc1_it1); |
---|
384 | vcixicu->p_irq[5](*signal_proc1_it2); |
---|
385 | vcixicu->p_irq[6](*signal_proc2_it0); |
---|
386 | vcixicu->p_irq[7](*signal_proc2_it1); |
---|
387 | vcixicu->p_irq[8](*signal_proc2_it2); |
---|
388 | vcixicu->p_irq[9](*signal_proc3_it0); |
---|
389 | vcixicu->p_irq[10](*signal_proc3_it1); |
---|
390 | vcixicu->p_irq[11](*signal_proc3_it2); |
---|
391 | |
---|
392 | #ifdef VCI_LOGGER_ON_L1 |
---|
393 | vci_logger0.p_clk(signal_clk); |
---|
394 | vci_logger0.p_resetn(*signal_resetn); |
---|
395 | vci_logger0.p_vci(*signal_vci_ini_rw_proc0); |
---|
396 | #endif |
---|
397 | |
---|
398 | #ifdef VCI_LOGGER_ON_ROM |
---|
399 | vci_logger1.p_clk(signal_clk); |
---|
400 | vci_logger1.p_resetn(*signal_resetn); |
---|
401 | vci_logger1.p_vci(*signal_vci_tgt_rom); |
---|
402 | #endif |
---|
403 | |
---|
404 | #ifdef VCI_LOGGER_ON_L1_TGT |
---|
405 | vci_logger2.p_clk(signal_clk); |
---|
406 | vci_logger2.p_resetn(*signal_resetn); |
---|
407 | vci_logger2.p_vci(*signal_vci_tgt_proc1); |
---|
408 | #endif |
---|
409 | |
---|
410 | vcitty->p_clk(signal_clk); |
---|
411 | vcitty->p_resetn(*signal_resetn); |
---|
412 | vcitty->p_vci(*signal_vci_tty); |
---|
413 | vcitty->p_irq[0](*signal_icu_irq0); |
---|
414 | |
---|
415 | vcisimh->p_clk(signal_clk); |
---|
416 | vcisimh->p_resetn(*signal_resetn); |
---|
417 | vcisimh->p_vci(*signal_vci_simh); |
---|
418 | |
---|
419 | memc->p_clk(signal_clk); |
---|
420 | memc->p_resetn(*signal_resetn); |
---|
421 | memc->p_vci_tgt(*signal_vci_tgt_memc); |
---|
422 | memc->p_vci_tgt_cleanup(*signal_vci_tgt_cleanup_memc); |
---|
423 | memc->p_vci_ini(*signal_vci_ini_memc); |
---|
424 | memc->p_vci_ixr(*signal_vci_ixr_memc); |
---|
425 | |
---|
426 | vcibd->p_clk(signal_clk); |
---|
427 | vcibd->p_resetn(*signal_resetn); |
---|
428 | vcibd->p_vci_target(*signal_vci_vcibd_t); |
---|
429 | vcibd->p_vci_initiator(*signal_vci_vcibd_i); |
---|
430 | vcibd->p_irq(*signal_icu_irq1); |
---|
431 | |
---|
432 | vcifb->p_clk(signal_clk); |
---|
433 | vcifb->p_resetn(*signal_resetn); |
---|
434 | vcifb->p_vci(*signal_vci_fb); |
---|
435 | |
---|
436 | xram->p_clk(signal_clk); |
---|
437 | xram->p_resetn(*signal_resetn); |
---|
438 | xram->p_vci(*signal_vci_ixr_memc); |
---|
439 | |
---|
440 | ringp->p_clk(signal_clk); |
---|
441 | ringp->p_resetn(*signal_resetn); |
---|
442 | |
---|
443 | ringc->p_clk(signal_clk); |
---|
444 | ringc->p_resetn(*signal_resetn); |
---|
445 | |
---|
446 | ringp->p_to_initiator[0](*signal_vci_ini_rw_proc0); |
---|
447 | ringp->p_to_initiator[1](*signal_vci_ini_rw_proc1); |
---|
448 | ringp->p_to_initiator[2](*signal_vci_ini_rw_proc2); |
---|
449 | ringp->p_to_initiator[3](*signal_vci_ini_rw_proc3); |
---|
450 | ringp->p_to_initiator[4](*signal_vci_vcibd_i); |
---|
451 | |
---|
452 | ringc->p_to_initiator[0](*signal_vci_ini_c_proc0); |
---|
453 | ringc->p_to_initiator[1](*signal_vci_ini_c_proc1); |
---|
454 | ringc->p_to_initiator[2](*signal_vci_ini_c_proc2); |
---|
455 | ringc->p_to_initiator[3](*signal_vci_ini_c_proc3); |
---|
456 | ringc->p_to_initiator[4](*signal_vci_ini_memc); |
---|
457 | |
---|
458 | ringp->p_to_target[0](*signal_vci_tgt_memc); |
---|
459 | ringp->p_to_target[1](*signal_vci_tgt_rom); |
---|
460 | ringp->p_to_target[2](*signal_vci_vcibd_t); |
---|
461 | ringp->p_to_target[3](*signal_vci_tty); |
---|
462 | ringp->p_to_target[4](*signal_vci_xicu); |
---|
463 | ringp->p_to_target[5](*signal_vci_simh); |
---|
464 | ringp->p_to_target[6](*signal_vci_fb); |
---|
465 | |
---|
466 | ringc->p_to_target[0](*signal_vci_tgt_proc0); |
---|
467 | ringc->p_to_target[1](*signal_vci_tgt_proc1); |
---|
468 | ringc->p_to_target[2](*signal_vci_tgt_proc2); |
---|
469 | ringc->p_to_target[3](*signal_vci_tgt_proc3); |
---|
470 | ringc->p_to_target[4](*signal_vci_tgt_cleanup_memc); |
---|
471 | |
---|
472 | |
---|
473 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
474 | *signal_resetn = false; |
---|
475 | |
---|
476 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
477 | *signal_resetn = true; |
---|
478 | /* |
---|
479 | * execute 10 million cycle, compute how many time it took and |
---|
480 | * print the clock frequency |
---|
481 | */ |
---|
482 | #ifndef DEBUG |
---|
483 | //#define STATS_CYCLES 100000000ULL |
---|
484 | #define STATS_CYCLES 1000000ULL |
---|
485 | int n = 0; |
---|
486 | do_debug = 0; |
---|
487 | no_debug: |
---|
488 | proc0->iss_set_debug_mask(0); |
---|
489 | proc1->iss_set_debug_mask(0); |
---|
490 | proc2->iss_set_debug_mask(0); |
---|
491 | proc3->iss_set_debug_mask(0); |
---|
492 | while (do_debug == 0) { |
---|
493 | if (gettimeofday(&t1, NULL) != 0) { |
---|
494 | perror("gettimeofday"); |
---|
495 | return EXIT_FAILURE; |
---|
496 | } |
---|
497 | sc_start(STATS_CYCLES); |
---|
498 | n += STATS_CYCLES; |
---|
499 | if (gettimeofday(&t2, NULL) != 0) { |
---|
500 | perror("gettimeofday"); |
---|
501 | return EXIT_FAILURE; |
---|
502 | } |
---|
503 | ms1 = (uint64_t)t1.tv_sec * 1000ULL + (uint64_t)t1.tv_usec / 1000; |
---|
504 | ms2 = (uint64_t)t2.tv_sec * 1000ULL + (uint64_t)t2.tv_usec / 1000; |
---|
505 | std::cerr << "cycle " << n << " platform clock frequency " << (double)STATS_CYCLES / (double)(ms2 - ms1) << "Khz" << std::endl; |
---|
506 | } |
---|
507 | proc0->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
508 | proc1->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
509 | proc2->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
510 | proc3->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
511 | while (do_debug) { |
---|
512 | proc0->print_trace(); |
---|
513 | signal_vci_ini_rw_proc0->print_trace("proc_ini_d"); |
---|
514 | signal_vci_tgt_proc0->print_trace("proc_tgt_c"); |
---|
515 | signal_vci_ini_c_proc0->print_trace("proc_ini_c"); |
---|
516 | |
---|
517 | proc1->print_trace(); |
---|
518 | signal_vci_ini_rw_proc1->print_trace("proc_ini_d"); |
---|
519 | signal_vci_tgt_proc1->print_trace("proc_tgt_c"); |
---|
520 | signal_vci_ini_c_proc1->print_trace("proc_ini_c"); |
---|
521 | |
---|
522 | proc2->print_trace(); |
---|
523 | signal_vci_ini_rw_proc2->print_trace("proc_ini_d"); |
---|
524 | signal_vci_tgt_proc2->print_trace("proc_tgt_c"); |
---|
525 | signal_vci_ini_c_proc2->print_trace("proc_ini_c"); |
---|
526 | |
---|
527 | proc3->print_trace(); |
---|
528 | signal_vci_ini_rw_proc3->print_trace("proc_ini_d"); |
---|
529 | signal_vci_tgt_proc3->print_trace("proc_tgt_c"); |
---|
530 | signal_vci_ini_c_proc3->print_trace("proc_ini_c"); |
---|
531 | |
---|
532 | memc->print_trace(); |
---|
533 | signal_vci_tgt_memc->print_trace("memc_tgt_d"); |
---|
534 | signal_vci_tgt_cleanup_memc->print_trace("memc_tgt_c"); |
---|
535 | signal_vci_ini_memc->print_trace("memc_ini_c"); |
---|
536 | n++; |
---|
537 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
538 | } |
---|
539 | goto no_debug; |
---|
540 | //sc_start(250000000); |
---|
541 | #else |
---|
542 | memc->start_monitor(0x12fc, 4); |
---|
543 | proc0->iss_set_debug_mask(0); |
---|
544 | proc1->iss_set_debug_mask(0); |
---|
545 | proc2->iss_set_debug_mask(0); |
---|
546 | proc3->iss_set_debug_mask(0); |
---|
547 | sc_start(DEBUG_CYCLE); |
---|
548 | int n = DEBUG_CYCLE; |
---|
549 | proc0->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
550 | proc1->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
551 | proc2->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
552 | proc3->iss_set_debug_mask(MIPS32_DEBUG_CPU|MIPS32_DEBUG_DATA); |
---|
553 | #if 0 |
---|
554 | while (n < DEBUG_END) { |
---|
555 | std::cout << "cycle " << std::dec << n << std::endl; |
---|
556 | sc_start(10000); |
---|
557 | n+= 10000; |
---|
558 | } |
---|
559 | #endif |
---|
560 | while (n < DEBUG_END) { |
---|
561 | std::cout << "****************** cycle " << std::dec << n |
---|
562 | << std::endl; |
---|
563 | proc0->cache_monitor(0x12fc); |
---|
564 | proc0->print_trace(); |
---|
565 | signal_vci_ini_rw_proc0->print_trace("proc_ini_d"); |
---|
566 | signal_vci_tgt_proc0->print_trace("proc_tgt_c"); |
---|
567 | signal_vci_ini_c_proc0->print_trace("proc_ini_c"); |
---|
568 | |
---|
569 | proc1->print_trace(); |
---|
570 | signal_vci_ini_rw_proc1->print_trace("proc_ini_d"); |
---|
571 | signal_vci_tgt_proc1->print_trace("proc_tgt_c"); |
---|
572 | signal_vci_ini_c_proc1->print_trace("proc_ini_c"); |
---|
573 | |
---|
574 | proc2->print_trace(); |
---|
575 | signal_vci_ini_rw_proc2->print_trace("proc_ini_d"); |
---|
576 | signal_vci_tgt_proc2->print_trace("proc_tgt_c"); |
---|
577 | signal_vci_ini_c_proc2->print_trace("proc_ini_c"); |
---|
578 | |
---|
579 | proc3->print_trace(); |
---|
580 | signal_vci_ini_rw_proc3->print_trace("proc_ini_d"); |
---|
581 | signal_vci_tgt_proc3->print_trace("proc_tgt_c"); |
---|
582 | signal_vci_ini_c_proc3->print_trace("proc_ini_c"); |
---|
583 | |
---|
584 | memc->print_trace(); |
---|
585 | signal_vci_tgt_memc->print_trace("memc_tgt_d"); |
---|
586 | signal_vci_tgt_cleanup_memc->print_trace("memc_tgt_c"); |
---|
587 | signal_vci_ini_memc->print_trace("memc_ini_c"); |
---|
588 | n++; |
---|
589 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
590 | } |
---|
591 | #endif |
---|
592 | |
---|
593 | return EXIT_FAILURE; |
---|
594 | |
---|
595 | } |
---|
596 | |
---|
597 | int sc_main (int argc, char *argv[]) |
---|
598 | { |
---|
599 | try { |
---|
600 | return _main(argc, argv); |
---|
601 | } catch (std::exception &e) { |
---|
602 | std::cout << e.what() << std::endl; |
---|
603 | } catch (...) { |
---|
604 | std::cout << "Unknown exception occured" << std::endl; |
---|
605 | throw; |
---|
606 | } |
---|
607 | return 1; |
---|
608 | } |
---|
609 | |
---|