This source file includes following definitions.
- doAppendCycleInstructionFetch_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #define L68_PI_AP \
21 do { if (cpu.tweaks.l68_mode) cpu.cu.APUCycleBits |= 04000; } while (0)
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 static ALWAYS_INLINE word24 doAppendCycleInstructionFetch_ (cpu_state_t * cpup, word36 * data, uint nWords, const bool full) {
69
70 static int evcnt = 0;
71 DCDstruct * i = & cpu.currentInstruction;
72 (void)evcnt;
73 DBGAPP ("doAppendCycleInstructionFetch(Entry) thisCycle=INSTRUCTION_FETCH\r\n");
74 DBGAPP ("doAppendCycleInstructionFetch(Entry) lastCycle=%s\r\n", str_pct (cpu.apu.lastCycle));
75 DBGAPP ("doAppendCycleInstructionFetch(Entry) CA %06o\r\n", cpu.TPR.CA);
76 DBGAPP ("doAppendCycleInstructionFetch(Entry) n=%2u\r\n", nWords);
77 DBGAPP ("doAppendCycleInstructionFetch(Entry) PPR.PRR=%o PPR.PSR=%05o\r\n", cpu.PPR.PRR, cpu.PPR.PSR);
78 DBGAPP ("doAppendCycleInstructionFetch(Entry) TPR.TRR=%o TPR.TSR=%05o\r\n", cpu.TPR.TRR, cpu.TPR.TSR);
79
80 if (i->b29) {
81 DBGAPP ("doAppendCycleInstructionFetch(Entry) isb29 PRNO %o\r\n", GET_PRN (IWB_IRODD));
82 }
83
84 uint this = UC_INSTRUCTION_FETCH;
85
86 word24 finalAddress = 0;
87 word24 pageAddress = 0;
88 word3 RSDWH_R1 = 0;
89 word14 bound = 0;
90 word1 p = 0;
91 bool paged = false;
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 #if defined(TEST_UCACHE)
117 bool cacheHit;
118 cacheHit = false;
119 #endif
120
121
122 if (i->opcode == 0610 && ! i->opcodeX) {
123
124 goto skip_ucache;
125 }
126
127
128 if (cpu.rRALR) {
129
130 goto skip_ucache;
131 }
132
133
134
135
136
137
138 if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
139 || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
140
141 goto skip_ucache;
142 }
143
144
145
146
147 #if defined(TEST_UCACHE)
148 word24 cachedAddress;
149 word3 cachedR1;
150 word14 cachedBound;
151 word1 cachedP;
152 bool cachedPaged;
153 cacheHit =
154 ucCacheCheck (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, & cachedBound, & cachedP, & cachedAddress, & cachedR1, & cachedPaged);
155 goto miss_ucache;
156 #else
157 if (! ucCacheCheck (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, & bound, & p, & pageAddress, & RSDWH_R1, & paged))
158 goto miss_ucache;
159 #endif
160
161 if (paged) {
162 finalAddress = pageAddress + (cpu.TPR.CA & OS18MASK);
163 } else {
164 finalAddress = pageAddress + cpu.TPR.CA;
165 }
166 cpu.RSDWH_R1 = RSDWH_R1;
167
168
169
170
171
172
173 if (full)
174 {
175 set_apu_status (cpup, paged ? apuStatus_FAP : apuStatus_FANP);
176 L68_PI_AP;
177 }
178 cpu.apu.lastCycle = INSTRUCTION_FETCH;
179 goto HI;
180
181 skip_ucache:;
182
183 #if defined(UCACHE_STATS)
184 cpu.uCache.skips[this] ++;
185 #endif
186
187 miss_ucache:;
188
189 bool nomatch = true;
190 if (cpu.tweaks.enable_wam) {
191
192
193
194
195
196 nomatch = ((i->opcode == 0232 || i->opcode == 0254 ||
197 i->opcode == 0154 || i->opcode == 0173) &&
198 i->opcodeX ) ||
199 ((i->opcode == 0557 || i->opcode == 0257) &&
200 ! i->opcodeX);
201 }
202
203 processor_cycle_type lastCycle = cpu.apu.lastCycle;
204 cpu.apu.lastCycle = INSTRUCTION_FETCH;
205
206 DBGAPP ("doAppendCycleInstructionFetch(Entry) XSF %o\r\n", cpu.cu.XSF);
207
208 PNL (L68_ (cpu.apu.state = 0;))
209
210 cpu.RSDWH_R1 = 0;
211
212 cpu.acvFaults = 0;
213
214
215 #define FMSG(x)
216 FMSG (char * acvFaultsMsg = "<unknown>";)
217
218
219
220
221
222
223
224
225
226
227
228
229 PNL (cpu.APUMemAddr = cpu.TPR.CA;)
230
231 DBGAPP ("doAppendCycleInstructionFetch(A)\r\n");
232
233
234 if (nomatch || ! fetch_sdw_from_sdwam (cpup, cpu.TPR.TSR)) {
235
236 DBGAPP ("doAppendCycleInstructionFetch(A):SDW for segment %05o not in SDWAM\r\n", cpu.TPR.TSR);
237
238 DBGAPP ("doAppendCycleInstructionFetch(A):DSBR.U=%o\r\n", cpu.DSBR.U);
239
240 if (cpu.DSBR.U == 0) {
241 fetch_dsptw (cpup, cpu.TPR.TSR);
242
243 if (! cpu.PTW0.DF)
244 doFault (FAULT_DF0 + cpu.PTW0.FC, fst_zero, "doAppendCycleInstructionFetch(A): PTW0.F == 0");
245
246 if (! cpu.PTW0.U)
247 modify_dsptw (cpup, cpu.TPR.TSR);
248
249 fetch_psdw (cpup, cpu.TPR.TSR);
250 } else
251 fetch_nsdw (cpup, cpu.TPR.TSR);
252
253 if (cpu.SDW0.DF == 0) {
254 DBGAPP ("doAppendCycleInstructionFetch(A): SDW0.F == 0! " "Initiating directed fault\r\n");
255
256 doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
257 }
258
259 load_sdwam (cpup, cpu.TPR.TSR, nomatch);
260 }
261 DBGAPP ("doAppendCycleInstructionFetch(A) R1 %o R2 %o R3 %o E %o\r\n", cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.SDW->E);
262
263
264 RSDWH_R1 = cpu.RSDWH_R1 = cpu.SDW->R1;
265
266
267
268
269
270
271
272
273
274
275
276 DBGAPP ("doAppendCycleInstructionFetch(B)\r\n");
277
278
279
280
281 if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3)) {
282
283 cpu.acvFaults |= ACV0;
284 PNL (L68_ (cpu.apu.state |= apu_FLT;))
285 FMSG (acvFaultsMsg = "acvFaults(B) C(SDW.R1) <= C(SDW.R2) <= " "C(SDW .R3)";)
286 }
287
288
289
290
291
292
293
294 if (i->opcode == 0610 && ! i->opcodeX)
295 goto C;
296
297 if (lastCycle == RTCD_OPERAND_FETCH)
298 sim_warn ("%s: lastCycle == RTCD_OPERAND_FETCH opcode %0#o\r\n", __func__, i->opcode);
299
300
301
302
303
304
305
306 goto F;
307
308
309
310
311
312
313
314 C:;
315 DBGAPP ("doAppendCycleInstructionFetch(C)\r\n");
316
317
318
319
320
321
322
323
324
325 if (cpu.TPR.TRR < cpu.SDW->R1 || cpu.TPR.TRR > cpu.SDW->R2) {
326 DBGAPP ("ACV1 c\r\n");
327 DBGAPP ("acvFaults(C) ACV1 ! ( C(SDW .R1) %o <= C(TPR.TRR) %o <= C(SDW .R2) %o )\r\n", cpu.SDW->R1, cpu.TPR.TRR, cpu.SDW->R2);
328
329 cpu.acvFaults |= ACV1;
330 PNL (L68_ (cpu.apu.state |= apu_FLT;))
331 FMSG (acvFaultsMsg = "acvFaults(C) C(SDW.R1 > C(TPR.TRR) > C(SDW.R2)";)
332 }
333
334 if (! cpu.SDW->E) {
335 DBGAPP ("ACV2 a\r\n");
336 DBGAPP ("doAppendCycleInstructionFetch(C) ACV2\r\n");
337
338 cpu.acvFaults |= ACV2;
339 PNL (L68_ (cpu.apu.state |= apu_FLT;))
340 FMSG (acvFaultsMsg = "acvFaults(C) SDW.E";)
341 }
342 if (cpu.TPR.TRR > cpu.PPR.PRR)
343 sim_warn ("rtcd: outbound call cpu.TPR.TRR %d cpu.PPR.PRR %d\r\n", cpu.TPR.TRR, cpu.PPR.PRR);
344
345 if (cpu.TPR.TRR < cpu.PPR.PRR) {
346 DBGAPP ("ACV11\r\n");
347 DBGAPP ("doAppendCycleInstructionFetch(C) ACV11\r\n");
348
349 cpu.acvFaults |= ACV11;
350 PNL (L68_ (cpu.apu.state |= apu_FLT;))
351 FMSG (acvFaultsMsg = "acvFaults(C) TRR>=PRR";)
352 }
353
354 D:;
355 DBGAPP ("doAppendCycleInstructionFetch(D)\r\n");
356
357
358
359
360
361 if (cpu.rRALR == 0)
362 goto G;
363
364
365 if (! (cpu.PPR.PRR < cpu.rRALR)) {
366 DBGAPP ("ACV13\r\n");
367 DBGAPP ("acvFaults(D) C(PPR.PRR) %o < RALR %o\r\n", cpu.PPR.PRR, cpu.rRALR);
368 cpu.acvFaults |= ACV13;
369 PNL (L68_ (cpu.apu.state |= apu_FLT;))
370 FMSG (acvFaultsMsg = "acvFaults(D) C(PPR.PRR) < RALR";)
371 }
372
373 goto G;
374
375
376
377
378
379
380
381 F:;
382 PNL (L68_ (cpu.apu.state |= apu_PIAU;))
383 DBGAPP ("doAppendCycleInstructionFetch(F): transfer or instruction fetch\r\n");
384
385
386
387
388
389
390 if (cpu.TPR.TRR < cpu.SDW->R1 || cpu.TPR.TRR > cpu.SDW->R2) {
391 DBGAPP ("ACV1 a/b\r\n");
392 DBGAPP ("acvFaults(F) ACV1 !( C(SDW .R1) %o <= C(TPR.TRR) %o <= C(SDW .R2) %o )\r\n", cpu.SDW->R1, cpu.TPR.TRR, cpu.SDW->R2);
393 cpu.acvFaults |= ACV1;
394 PNL (L68_ (cpu.apu.state |= apu_FLT;))
395 FMSG (acvFaultsMsg = "acvFaults(F) C(TPR.TRR) < C(SDW .R1)";)
396 }
397
398 if (! cpu.SDW->E) {
399 DBGAPP ("ACV2 c\r\n");
400 DBGAPP ("doAppendCycleInstructionFetch(F) ACV2\r\n");
401 cpu.acvFaults |= ACV2;
402 PNL (L68_ (cpu.apu.state |= apu_FLT;))
403 FMSG (acvFaultsMsg = "acvFaults(F) SDW .E set OFF";)
404 }
405
406
407 if (cpu.PPR.PRR != cpu.TPR.TRR) {
408 DBGAPP ("ACV12\r\n");
409 DBGAPP ("doAppendCycleInstructionFetch(F) ACV12\r\n");
410
411 cpu.acvFaults |= ACV12;
412 PNL (L68_ (cpu.apu.state |= apu_FLT;))
413 FMSG (acvFaultsMsg = "acvFaults(F) C(PPR.PRR) != C(TPR.TRR)";)
414 }
415
416 goto D;
417
418
419
420
421
422
423
424 G:;
425
426 DBGAPP ("doAppendCycleInstructionFetch(G)\r\n");
427
428
429 if (((cpu.TPR.CA >> 4) & 037777) > cpu.SDW->BOUND) {
430 DBGAPP ("ACV15\r\n");
431 DBGAPP ("doAppendCycleInstructionFetch(G) ACV15\r\n");
432 cpu.acvFaults |= ACV15;
433 PNL (L68_ (cpu.apu.state |= apu_FLT;))
434 FMSG (acvFaultsMsg = "acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND";)
435 DBGAPP ("acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND\r\n" " CA %06o CA>>4 & 037777 %06o SDW->BOUND %06o",
436 cpu.TPR.CA, ((cpu.TPR.CA >> 4) & 037777), cpu.SDW->BOUND);
437 }
438 bound = cpu.SDW->BOUND;
439 p = cpu.SDW->P;
440
441 if (cpu.acvFaults) {
442 DBGAPP ("doAppendCycleInstructionFetch(G) acvFaults\r\n");
443 PNL (L68_ (cpu.apu.state |= apu_FLT;))
444
445 doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults}, "ACV fault");
446 }
447
448
449 if (cpu.SDW->U)
450 goto H;
451
452
453
454
455 DBGAPP ("doAppendCycleInstructionFetch(G) CA %06o\r\n", cpu.TPR.CA);
456 if (nomatch ||
457 ! fetch_ptw_from_ptwam (cpup, cpu.SDW->POINTER, cpu.TPR.CA)) {
458 fetch_ptw (cpup, cpu.SDW, cpu.TPR.CA);
459 if (! cpu.PTW0.DF) {
460
461 doFault (FAULT_DF0 + cpu.PTW0.FC, (_fault_subtype) {.bits=0}, "PTW0.F == 0");
462 }
463 loadPTWAM (cpup, cpu.SDW->POINTER, cpu.TPR.CA, nomatch);
464 }
465
466
467
468
469
470
471
472
473 if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
474 || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
475 do_ptw2 (cpup, cpu.SDW, cpu.TPR.CA);
476 }
477 goto I;
478
479
480
481
482
483
484
485 H:;
486 DBGAPP ("doAppendCycleInstructionFetch(H): FANP\r\n");
487
488 paged = false;
489
490 PNL (L68_ (cpu.apu.state |= apu_FANP;))
491
492
493
494
495
496
497
498
499 set_apu_status (cpup, apuStatus_FANP);
500 L68_PI_AP;
501
502 DBGAPP ("doAppendCycleInstructionFetch(H): SDW->ADDR=%08o CA=%06o\r\n", cpu.SDW->ADDR, cpu.TPR.CA);
503
504 pageAddress = (cpu.SDW->ADDR & 077777760);
505 finalAddress = (cpu.SDW->ADDR & 077777760) + cpu.TPR.CA;
506 finalAddress &= 0xffffff;
507 PNL (cpu.APUMemAddr = finalAddress;)
508
509 DBGAPP ("doAppendCycleInstructionFetch(H:FANP): (%05o:%06o) finalAddress=%08o\r\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
510
511 goto HI;
512
513 I:;
514
515
516
517 DBGAPP ("doAppendCycleInstructionFetch(I): FAP\r\n");
518
519 paged = true;
520
521
522 set_apu_status (cpup, apuStatus_FAP);
523 L68_PI_AP;
524 PNL (L68_ (cpu.apu.state |= apu_FAP;))
525
526 word24 y2 = cpu.TPR.CA % 1024;
527
528 pageAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6);
529
530
531 finalAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6) + y2;
532 finalAddress &= 0xffffff;
533 PNL (cpu.APUMemAddr = finalAddress;)
534
535 L68_ (
536 if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
537 add_l68_APU_history (cpup, APUH_FAP);
538 )
539
540 DBGAPP ("doAppendCycleInstructionFetch(H:FAP): (%05o:%06o) finalAddress=%08o\r\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
541
542 HI:
543 DBGAPP ("doAppendCycleInstructionFetch(HI)\r\n");
544
545 #if defined(TEST_UCACHE)
546 if (cacheHit) {
547 bool err = false;
548 if (cachedAddress != pageAddress) {
549 sim_printf ("cachedAddress %08o != pageAddress %08o\r\n", cachedAddress, pageAddress);
550 err = true;
551 }
552 if (cachedR1 != RSDWH_R1) {
553 sim_printf ("cachedR1 %01o != RSDWH_R1 %01o\r\n", cachedR1, RSDWH_R1);
554 err = true;
555 }
556 if (cachedBound != bound) {
557 sim_printf ("cachedBound %01o != bound %01o\r\n", cachedBound, bound);
558 err = true;
559 }
560 if (cachedPaged != paged) {
561 sim_printf ("cachedPaged %01o != paged %01o\r\n", cachedPaged, paged);
562 err = true;
563 }
564 if (err) {
565 # if defined(HDBG)
566 HDBGPrint ();
567 # endif
568 sim_printf ("ins fetch err %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
569 exit (1);
570 }
571
572 # if defined(HDBG)
573 hdbgNote ("doAppendCycleOperandRead.h", "test hit %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
574 # endif
575 } else {
576
577 # if defined(HDBG)
578 hdbgNote ("doAppendCycleOperandRead.h", "test miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
579 # endif
580 }
581 #endif
582 #if defined(TEST_UCACHE)
583 if (cacheHit) {
584 if (cachedPaged != paged) sim_printf ("cachedPaged %01o != paged %01o\r\n", cachedPaged, paged);
585
586 }
587 else
588 {
589
590 }
591 #endif
592
593 ucCacheSave (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, bound, p, pageAddress, RSDWH_R1, paged);
594 evcnt ++;
595
596 cpu.cu.XSF = 1;
597 sim_debug (DBG_TRACEEXT, & cpu_dev, "loading of cpu.TPR.TSR sets XSF to 1\r\n");
598
599 if (full)
600 cache_readN (cpup, finalAddress, data, nWords, "INSTRUCTION_FETCH");
601 else
602 core_readN_fast (cpup, finalAddress, data, nWords, "INSTRUCTION_FETCH");
603
604
605
606
607
608
609
610
611
612 DBGAPP ("doAppendCycleInstructionFetch(L)\r\n");
613
614
615
616 if (i->opcode == 0610 && ! i->opcodeX) {
617
618
619 CPTUR (cptUsePRn + 0);
620 CPTUR (cptUsePRn + 1);
621 CPTUR (cptUsePRn + 2);
622 CPTUR (cptUsePRn + 3);
623 CPTUR (cptUsePRn + 4);
624 CPTUR (cptUsePRn + 5);
625 CPTUR (cptUsePRn + 6);
626 CPTUR (cptUsePRn + 7);
627 cpu.PR[0].RNR =
628 cpu.PR[1].RNR =
629 cpu.PR[2].RNR =
630 cpu.PR[3].RNR =
631 cpu.PR[4].RNR =
632 cpu.PR[5].RNR =
633 cpu.PR[6].RNR =
634 cpu.PR[7].RNR = cpu.TPR.TRR;
635 #if defined(TESTING)
636 HDBGRegPRW (0, "app rtcd");
637 HDBGRegPRW (1, "app rtcd");
638 HDBGRegPRW (2, "app rtcd");
639 HDBGRegPRW (3, "app rtcd");
640 HDBGRegPRW (4, "app rtcd");
641 HDBGRegPRW (5, "app rtcd");
642 HDBGRegPRW (6, "app rtcd");
643 HDBGRegPRW (7, "app rtcd");
644 #endif
645 }
646 goto KL;
647
648 KL:
649 DBGAPP ("doAppendCycleInstructionFetch(KL)\r\n");
650
651
652 cpu.PPR.PSR = cpu.TPR.TSR;
653
654 cpu.PPR.IC = cpu.TPR.CA;
655
656 goto M;
657
658 M:
659 DBGAPP ("doAppendCycleInstructionFetch(M)\r\n");
660
661
662 if (cpu.TPR.TRR == 0) {
663
664
665 cpu.PPR.P = p;
666 } else {
667
668 cpu.PPR.P = 0;
669 }
670
671 PNL (cpu.APUDataBusOffset = cpu.TPR.CA;)
672 PNL (cpu.APUDataBusAddr = finalAddress;)
673
674 PNL (L68_ (cpu.apu.state |= apu_FA;))
675
676 DBGAPP ("doAppendCycleInstructionFetch (Exit) PRR %o PSR %05o P %o IC %06o\r\n",
677 cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
678 DBGAPP ("doAppendCycleInstructionFetch (Exit) TRR %o TSR %05o TBR %02o CA %06o\r\n",
679 cpu.TPR.TRR, cpu.TPR.TSR, cpu.TPR.TBR, cpu.TPR.CA);
680
681 return finalAddress;
682 }
683 #undef TEST_UCACHE