This source file includes following definitions.
- doAppendCycleIndirectWordFetch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 word24 doAppendCycleIndirectWordFetch (cpu_state_t * cpup, word36 * data, uint nWords) {
55 DCDstruct * i = & cpu.currentInstruction;
56 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) thisCycle=INDIRECT_WORD_FETCH\n");
57 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) lastCycle=%s\n", str_pct (cpu.apu.lastCycle));
58 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) CA %06o\n", cpu.TPR.CA);
59 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) n=%2u\n", nWords);
60 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) PPR.PRR=%o PPR.PSR=%05o\n", cpu.PPR.PRR, cpu.PPR.PSR);
61 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) TPR.TRR=%o TPR.TSR=%05o\n", cpu.TPR.TRR, cpu.TPR.TSR);
62
63 if (i->b29) {
64 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) isb29 PRNO %o\n", GET_PRN (IWB_IRODD));
65 }
66
67 uint this = UC_INDIRECT_WORD_FETCH;
68
69 word24 finalAddress = 0;
70 word24 pageAddress = 0;
71 word3 RSDWH_R1 = 0;
72 word14 bound = 0;
73 word1 p = 0;
74 bool paged = false;
75
76
77 #undef IDWF_CACHE
78
79 #if defined(IDWF_CACHE)
80
81
82
83
84
85
86
87 if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
88 || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
89
90 goto skip_ucache;
91 }
92
93
94 if (! ucCacheCheck (this, cpu.TPR.TSR, cpu.TPR.CA, & bound, & p, & pageAddress, & RSDWH_R1, & paged))
95 goto miss_ucache;
96
97 if (paged) {
98 finalAddress = pageAddress + (cpu.TPR.CA & OS18MASK);
99 } else {
100 finalAddress = pageAddress + cpu.TPR.CA;
101 }
102 cpu.RSDWH_R1 = RSDWH_R1;
103
104 cpu.apu.lastCycle = INDIRECT_WORD_FETCH;
105 goto HI;
106
107 skip_ucache:;
108 # if defined(UCACHE_STATS)
109 cpu.uCache.skips[this] ++;
110 # endif
111
112 miss_ucache:;
113
114 #endif
115
116 bool nomatch = true;
117 if (cpu.tweaks.enable_wam) {
118
119
120
121
122
123 nomatch = ((i->opcode == 0232 || i->opcode == 0254 ||
124 i->opcode == 0154 || i->opcode == 0173) &&
125 i->opcodeX ) ||
126 ((i->opcode == 0557 || i->opcode == 0257) &&
127 ! i->opcodeX);
128 }
129
130 processor_cycle_type lastCycle = cpu.apu.lastCycle;
131 cpu.apu.lastCycle = INDIRECT_WORD_FETCH;
132
133 DBGAPP ("doAppendCycleIndirectWordFetch(Entry) XSF %o\n", cpu.cu.XSF);
134
135 PNL (L68_ (cpu.apu.state = 0;))
136
137 cpu.RSDWH_R1 = 0;
138
139 cpu.acvFaults = 0;
140
141
142 #define FMSG(x)
143 FMSG (char * acvFaultsMsg = "<unknown>";)
144
145
146
147
148
149
150
151
152 word3 n = 0;
153
154
155
156
157
158
159
160
161
162
163
164
165 PNL (cpu.APUMemAddr = cpu.TPR.CA;)
166
167 DBGAPP ("doAppendCycleIndirectWordFetch(A)\n");
168
169
170 if (nomatch || ! fetch_sdw_from_sdwam (cpup, cpu.TPR.TSR)) {
171
172 DBGAPP ("doAppendCycleIndirectWordFetch(A):SDW for segment %05o not in SDWAM\n", cpu.TPR.TSR);
173 DBGAPP ("doAppendCycleIndirectWordFetch(A):DSBR.U=%o\n", cpu.DSBR.U);
174
175 if (cpu.DSBR.U == 0) {
176 fetch_dsptw (cpup, cpu.TPR.TSR);
177
178 if (! cpu.PTW0.DF)
179 doFault (FAULT_DF0 + cpu.PTW0.FC, fst_zero, "doAppendCycleIndirectWordFetch(A): PTW0.F == 0");
180
181 if (! cpu.PTW0.U)
182 modify_dsptw (cpup, cpu.TPR.TSR);
183
184 fetch_psdw (cpup, cpu.TPR.TSR);
185 } else
186 fetch_nsdw (cpup, cpu.TPR.TSR);
187
188 if (cpu.SDW0.DF == 0) {
189 DBGAPP ("doAppendCycleIndirectWordFetch(A): SDW0.F == 0! " "Initiating directed fault\n");
190
191 doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
192 }
193
194 load_sdwam (cpup, cpu.TPR.TSR, nomatch);
195 }
196 DBGAPP ("doAppendCycleIndirectWordFetch(A) R1 %o R2 %o R3 %o E %o\n", cpu.SDW->R1, cpu.SDW->R2, cpu.SDW->R3, cpu.SDW->E);
197
198
199 RSDWH_R1 = cpu.RSDWH_R1 = cpu.SDW->R1;
200
201
202
203
204
205
206
207
208
209
210
211 DBGAPP ("doAppendCycleIndirectWordFetch(B)\n");
212
213
214
215
216 if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3)) {
217
218 cpu.acvFaults |= ACV0;
219 PNL (L68_ (cpu.apu.state |= apu_FLT;))
220 FMSG (acvFaultsMsg = "acvFaults(B) C(SDW.R1) <= C(SDW.R2) <= " "C(SDW .R3)";)
221 }
222
223
224
225
226
227
228
229 if (lastCycle == RTCD_OPERAND_FETCH)
230 sim_warn ("%s: lastCycle == RTCD_OPERAND_FETCH opcode %0#o\n", __func__, i->opcode);
231
232
233
234
235
236
237
238
239
240
241 DBGAPP ("doAppendCycleIndirectWordFetch(B):!STR-OP\n");
242
243
244
245 if (cpu.TPR.TRR > cpu.SDW->R2) {
246 DBGAPP ("ACV3\n");
247 DBGAPP ("doAppendCycleIndirectWordFetch(B) ACV3\n");
248
249 cpu.acvFaults |= ACV3;
250 PNL (L68_ (cpu.apu.state |= apu_FLT;))
251 FMSG (acvFaultsMsg = "acvFaults(B) C(TPR.TRR) > C(SDW .R2)";)
252 }
253
254 if (cpu.SDW->R == 0) {
255
256 cpu.TPR.TRR = cpu.PPR.PRR;
257
258
259 if (cpu.PPR.PSR != cpu.TPR.TSR) {
260 DBGAPP ("ACV4\n");
261 DBGAPP ("doAppendCycleIndirectWordFetch(B) ACV4\n");
262
263 cpu.acvFaults |= ACV4;
264 PNL (L68_ (cpu.apu.state |= apu_FLT;))
265 FMSG (acvFaultsMsg = "acvFaults(B) C(PPR.PSR) = C(TPR.TSR)";)
266
267
268
269 }
270 }
271
272
273
274
275
276
277
278
279
280
281
282 DBGAPP ("doAppendCycleIndirectWordFetch(G)\n");
283
284
285 if (((cpu.TPR.CA >> 4) & 037777) > cpu.SDW->BOUND) {
286 DBGAPP ("ACV15\n");
287 DBGAPP ("doAppendCycleIndirectWordFetch(G) ACV15\n");
288 cpu.acvFaults |= ACV15;
289 PNL (L68_ (cpu.apu.state |= apu_FLT;))
290 FMSG (acvFaultsMsg = "acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND";)
291 DBGAPP ("acvFaults(G) C(TPR.CA)0,13 > SDW.BOUND\n" " CA %06o CA>>4 & 037777 %06o SDW->BOUND %06o",
292 cpu.TPR.CA, ((cpu.TPR.CA >> 4) & 037777), cpu.SDW->BOUND);
293 }
294 bound = cpu.SDW->BOUND;
295 p = cpu.SDW->P;
296
297 if (cpu.acvFaults) {
298 DBGAPP ("doAppendCycleIndirectWordFetch(G) acvFaults\n");
299 PNL (L68_ (cpu.apu.state |= apu_FLT;))
300
301 doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults}, "ACV fault");
302 }
303
304
305 if (cpu.SDW->U)
306 goto H;
307
308
309
310
311 DBGAPP ("doAppendCycleIndirectWordFetch(G) CA %06o\n", cpu.TPR.CA);
312 if (nomatch ||
313 ! fetch_ptw_from_ptwam (cpup, cpu.SDW->POINTER, cpu.TPR.CA)) {
314 fetch_ptw (cpup, cpu.SDW, cpu.TPR.CA);
315 if (! cpu.PTW0.DF) {
316
317 doFault (FAULT_DF0 + cpu.PTW0.FC, (_fault_subtype) {.bits=0}, "PTW0.F == 0");
318 }
319 loadPTWAM (cpup, cpu.SDW->POINTER, cpu.TPR.CA, nomatch);
320 }
321
322
323
324
325
326
327 if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
328 || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
329 do_ptw2 (cpup, cpu.SDW, cpu.TPR.CA);
330 }
331 goto I;
332
333
334
335
336
337
338
339 H:;
340 DBGAPP ("doAppendCycleIndirectWordFetch(H): FANP\n");
341
342 paged = false;
343
344 PNL (L68_ (cpu.apu.state |= apu_FANP;))
345
346
347
348
349
350
351
352
353 set_apu_status (cpup, apuStatus_FANP);
354
355 DBGAPP ("doAppendCycleIndirectWordFetch(H): SDW->ADDR=%08o CA=%06o \n", cpu.SDW->ADDR, cpu.TPR.CA);
356
357 pageAddress = (cpu.SDW->ADDR & 077777760);
358 finalAddress = (cpu.SDW->ADDR & 077777760) + cpu.TPR.CA;
359 finalAddress &= 0xffffff;
360 PNL (cpu.APUMemAddr = finalAddress;)
361
362 DBGAPP ("doAppendCycleIndirectWordFetch(H:FANP): (%05o:%06o) finalAddress=%08o\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
363
364 goto HI;
365
366 I:;
367
368
369
370 DBGAPP ("doAppendCycleIndirectWordFetch(I): FAP\n");
371
372 paged = true;
373
374
375 set_apu_status (cpup, apuStatus_FAP);
376 PNL (L68_ (cpu.apu.state |= apu_FAP;))
377
378 word24 y2 = cpu.TPR.CA % 1024;
379
380 pageAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6);
381
382
383 finalAddress = (((word24)cpu.PTW->ADDR & 0777760) << 6) + y2;
384 finalAddress &= 0xffffff;
385 PNL (cpu.APUMemAddr = finalAddress;)
386
387 #if defined(L68)
388 if (cpu.MR_cache.emr && cpu.MR_cache.ihr)
389 add_APU_history (APUH_FAP);
390 #endif
391 DBGAPP ("doAppendCycleIndirectWordFetch(H:FAP): (%05o:%06o) finalAddress=%08o\n", cpu.TPR.TSR, cpu.TPR.CA, finalAddress);
392
393
394
395 HI:
396 DBGAPP ("doAppendCycleIndirectWordFetch(HI)\n");
397
398 ucCacheSave (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, bound, p, pageAddress, RSDWH_R1, paged);
399
400
401 cpu.cu.XSF = 1;
402 sim_debug (DBG_TRACEEXT, & cpu_dev, "loading of cpu.TPR.TSR sets XSF to 1\n");
403
404 core_readN (cpup, finalAddress, data, nWords, "INDIRECT_WORD_FETCH");
405
406
407
408
409
410
411
412
413
414 DBGAPP ("doAppendCycleIndirectWordFetch(J)\n");
415
416
417 word6 tag = GET_TAG (IWB_IRODD);
418 if ((GET_TM (tag) == TM_IR || GET_TM (tag) == TM_RI) && (cpu.TPR.CA & 1) == 0) {
419 if (ISITS (* data))
420 goto O;
421 if (ISITP (* data))
422 goto P;
423 }
424
425 goto Exit;
426
427
428
429
430
431
432
433 O:;
434 DBGAPP ("doAppendCycleIndirectWordFetch(O)\n");
435 word3 its_RNR = GET_ITS_RN (data);
436 DBGAPP ("doAppendCycleIndirectWordFetch(O) TRR %o RSDWH.R1 %o ITS.RNR %o\n",
437 cpu.TPR.TRR, cpu.RSDWH_R1, its_RNR);
438
439
440
441 cpu.TPR.TRR = max3 (its_RNR, cpu.TPR.TRR, cpu.RSDWH_R1);
442 DBGAPP ("doAppendCycleIndirectWordFetch(O) Set TRR to %o\n", cpu.TPR.TRR);
443
444 goto Exit;
445
446 P:;
447
448 DBGAPP ("doAppendCycleIndirectWordFetch(P)\n");
449
450 n = GET_ITP_PRNUM (data);
451 DBGAPP ("doAppendCycleIndirectWordFetch(P) TRR %o RSDWH.R1 %o PR[n].RNR %o\n",
452 cpu.TPR.TRR, cpu.RSDWH_R1, cpu.PR[n].RNR);
453
454
455
456 cpu.TPR.TRR = max3 (cpu.PR[n].RNR, cpu.TPR.TRR, cpu.RSDWH_R1);
457 DBGAPP ("doAppendCycleIndirectWordFetch(P) Set TRR to %o\n", cpu.TPR.TRR);
458
459 goto Exit;
460
461 Exit:;
462
463 PNL (cpu.APUDataBusOffset = cpu.TPR.CA;)
464 PNL (cpu.APUDataBusAddr = finalAddress;)
465
466 PNL (L68_ (cpu.apu.state |= apu_FA;))
467
468 DBGAPP ("doAppendCycleIndirectWordFetch (Exit) PRR %o PSR %05o P %o IC %06o\n",
469 cpu.PPR.PRR, cpu.PPR.PSR, cpu.PPR.P, cpu.PPR.IC);
470 DBGAPP ("doAppendCycleIndirectWordFetch (Exit) TRR %o TSR %05o TBR %02o CA %06o\n",
471 cpu.TPR.TRR, cpu.TPR.TSR, cpu.TPR.TBR, cpu.TPR.CA);
472
473 return finalAddress;
474 }