root/src/dps8/doAppendCycleInstructionFetch.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. doAppendCycleInstructionFetch_

   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 45d63e9a-171d-11ee-b7ed-80ee73e9b8e7
   5  *
   6  * ---------------------------------------------------------------------------
   7  *
   8  * Copyright (c) 2022-2023 Charles Anthony
   9  * Copyright (c) 2022-2023 Jeffrey H. Johnson
  10  * Copyright (c) 2022-2025 The DPS8M Development Team
  11  *
  12  * This software is made available under the terms of the ICU License.
  13  * See the LICENSE.md file at the top-level directory of this distribution.
  14  *
  15  * ---------------------------------------------------------------------------
  16  */
  17 
  18 // L68: the APU status of an instruction fetch append cycle keeps PI-AP
  19 // with FAP/FANP; a fault then stores both in SCU word 0 (PA865 01A, PA885)
  20 #define L68_PI_AP \
  21   do { if (cpu.tweaks.l68_mode) cpu.cu.APUCycleBits |= 04000; } while (0)
  22 
  23 //
  24 //    A get SDW
  25 //       |
  26 //       V
  27 //    B last cycle = RTCD operand fetch?
  28 //       Yes                            No
  29 //        |                              |
  30 //        V                              V
  31 //    C check ring brackets           F check ring brackets
  32 //        |                              |
  33 //        +------------------------------+
  34 //        |
  35 //        V
  36 //    D check RALR
  37 //        |
  38 //        V
  39 //    G check bound
  40 //      paged?
  41 //       Yes                            No
  42 //        |                              |
  43 //        V                              |
  44 //    G1 get PTW                         |
  45 //        |                              |
  46 //        V                              V
  47 //    I calc. paged address           H calc. unpaged address
  48 //        |                              |
  49 //        +------------------------------+
  50 //        |
  51 //        V
  52 //    HI set XSF
  53 //       read memory
  54 //        |
  55 //        V
  56 //    L lastcyle RTCD operand fetch handling
  57 //        |
  58 //        V
  59 //    KL set PSR, IC
  60 //        |
  61 //        V
  62 //    M  set P
  63 //        |
  64 //        V
  65 //    EXIT  return final address
  66 
  67 // Compiled twice (see FULL_MODEL_ON and dps8_append.c)
  68 static ALWAYS_INLINE word24 doAppendCycleInstructionFetch_ (cpu_state_t * cpup, word36 * data, uint nWords, const bool full) {
     /* [previous][next][first][last][top][bottom][index][help] */
  69 //sim_printf ("doAppendCycleInstructionFetch %05o:%06o\r\n",
  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 // ucache logic:
  94 // The cache will hit if:
  95 //   No CAMS/CAMP instruction has been executed.
  96 //   The segment number matches the cached value.
  97 //   The offset is on the same page as the cached value.
  98 //
  99 // doAppendCycle (INSTRUCTION_FETCH) checks:
 100 //   associative memory: Don't Care. If the cache hits, the WAM won't be
 101 //     queried which is the best case condition.
 102 //   lastCycle: Set to INSTRUCTION_FETCH.
 103 //   RSDWH_R1: Restored from cache.
 104 //   lastCycle == RTCD_OPERAND_FETCH. One would think that RTCD would always
 105 //     go to a new page, but that is not guaranteed; skip ucache.
 106 //   rRALR. Since it is before a segment change, the ucache will always miss.
 107 //   Ring brackets.  They will be the same, so recheck is unnecessary.
 108 //   ACVs: They will be the same, so recheck is unnecessary.
 109 //   SDW/PTW : They will be the same, so recheck is unnecessary.
 110 //   Prepage mode:  Skip ucache.
 111 //   History registers... Hm. skip for now; Values could be stashed...
 112 
 113 // Is this cycle a candidate for ucache?
 114 
 115 //#define TEST_UCACHE
 116 #if defined(TEST_UCACHE)
 117   bool cacheHit;
 118   cacheHit = false; // Assume skip...
 119 #endif
 120 
 121   // lastCycle == RTCD_OPERAND_FETCH
 122   if (i->opcode == 0610  && ! i->opcodeX) {
 123     //sim_printf ("skip RTCD\r\n");
 124     goto skip_ucache;
 125   }
 126 
 127   // RALR
 128   if (cpu.rRALR) {
 129     //sim_printf ("skip rRALR\r\n");
 130     goto skip_ucache;
 131   }
 132 
 133   // Prepage mode?
 134   // check for "uninterruptible" EIS instruction
 135   // ISOLTS-878 02: mvn,cmpn,mvne,ad3d; obviously also
 136   // ad2/3d,sb2/3d,mp2/3d,dv2/3d
 137   // DH03 p.8-13: probably also mve,btd,dtb
 138   if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220
 139       || (i->opcode & 0770)== 020|| (i->opcode & 0770) == 0300)) {
 140     //sim_printf ("skip uninterruptible\r\n");
 141     goto skip_ucache;
 142   }
 143 
 144 // Yes; check the ucache
 145 
 146 //#define TEST_UCACHE
 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 // ucache hit; housekeeping...
 169   //sim_printf ("hit  %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 170 
 171   // the APU status of the cycle, as the miss path sets it (PA865 03A)
 172   // (3) and (5), see FULL_MODEL_ON
 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   //sim_printf ("miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 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     // AL39: The associative memory is ignored (forced to "no match") during
 192     // address preparation.
 193     // lptp,lptr,lsdp,lsdr,sptp,sptr,ssdp,ssdr
 194     // Unfortunately, ISOLTS doesn't try to execute any of these in append mode.
 195     // XXX should this be only for OPERAND_READ and OPERAND_STORE?
 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 //#define FMSG(x) x
 215 #define FMSG(x)
 216   FMSG (char * acvFaultsMsg = "<unknown>";)
 217 
 218 ////////////////////////////////////////
 219 //
 220 // Sheet 2: "A"
 221 //
 222 ////////////////////////////////////////
 223 
 224 //
 225 //  A:
 226 //    Get SDW
 227 
 228   //PNL (cpu.APUMemAddr = address;)
 229   PNL (cpu.APUMemAddr = cpu.TPR.CA;)
 230 
 231   DBGAPP ("doAppendCycleInstructionFetch(A)\r\n");
 232 
 233   // is SDW for C(TPR.TSR) in SDWAM?
 234   if (nomatch || ! fetch_sdw_from_sdwam (cpup, cpu.TPR.TSR)) {
 235     // No
 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); // load SDW0 from descriptor segment table.
 252 
 253     if (cpu.SDW0.DF == 0) {
 254       DBGAPP ("doAppendCycleInstructionFetch(A): SDW0.F == 0! " "Initiating directed fault\r\n");
 255       // initiate a directed fault ...
 256       doFault (FAULT_DF0 + cpu.SDW0.FC, fst_zero, "SDW0.F == 0");
 257     }
 258     // load SDWAM .....
 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   // Yes...
 264   RSDWH_R1 = cpu.RSDWH_R1 = cpu.SDW->R1;
 265 
 266 ////////////////////////////////////////
 267 //
 268 // Sheet 3: "B"
 269 //
 270 ////////////////////////////////////////
 271 
 272 //
 273 // B: Check the ring
 274 //
 275 
 276   DBGAPP ("doAppendCycleInstructionFetch(B)\r\n");
 277 
 278   // check ring bracket consistency
 279 
 280   //C(SDW.R1) <= C(SDW.R2) <= C(SDW .R3)?
 281   if (! (cpu.SDW->R1 <= cpu.SDW->R2 && cpu.SDW->R2 <= cpu.SDW->R3)) {
 282     // Set fault ACV0 = IRO
 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   // lastCycle == RTCD_OPERAND_FETCH
 289   // if a fault happens between the RTCD_OPERAND_FETCH and the INSTRUCTION_FETCH
 290   // of the next instruction - this happens about 35 time for just booting  and
 291   // shutting down multics -- a stored lastCycle is useless.
 292   // the opcode is preserved across faults and only replaced as the
 293   // INSTRUCTION_FETCH succeeds.
 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   // B1: The operand is one of: an instruction, data to be read or data to be
 302   //     written
 303   //
 304 
 305   // Transfer or instruction fetch?
 306   goto F;
 307 
 308 ////////////////////////////////////////
 309 //
 310 // Sheet 4: "C" "D"
 311 //
 312 ////////////////////////////////////////
 313 
 314 C:;
 315   DBGAPP ("doAppendCycleInstructionFetch(C)\r\n");
 316 
 317   //
 318   // check ring bracket for instruction fetch after rtcd instruction
 319   //
 320   //   allow outbound transfers (cpu.TPR.TRR >= cpu.PPR.PRR)
 321   //
 322 
 323   // C(TPR.TRR) < C(SDW.R1)?
 324   // C(TPR.TRR) > C(SDW.R2)?
 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     //Set fault ACV1 = OEB
 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   // SDW.E set ON?
 334   if (! cpu.SDW->E) {
 335     DBGAPP ("ACV2 a\r\n");
 336     DBGAPP ("doAppendCycleInstructionFetch(C) ACV2\r\n");
 337     //Set fault ACV2 = E-OFF
 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   // C(TPR.TRR) >= C(PPR.PRR)
 345   if (cpu.TPR.TRR < cpu.PPR.PRR) {
 346     DBGAPP ("ACV11\r\n");
 347     DBGAPP ("doAppendCycleInstructionFetch(C) ACV11\r\n");
 348     //Set fault ACV11 = INRET
 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   // transfer or instruction fetch
 358 
 359   // check ring alarm to catch outbound transfers
 360 
 361   if (cpu.rRALR == 0)
 362     goto G;
 363 
 364   // C(PPR.PRR) < RALR?
 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 // Sheet 6: "F"
 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   // check ring bracket for instruction fetch
 387   //
 388 
 389   // C(TPR.TRR) > C(SDW .R2)?
 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   // SDW .E set ON?
 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   // C(PPR.PRR) = C(TPR.TRR)?
 407   if (cpu.PPR.PRR != cpu.TPR.TRR) {
 408     DBGAPP ("ACV12\r\n");
 409     DBGAPP ("doAppendCycleInstructionFetch(F) ACV12\r\n");
 410     //Set fault ACV12 = CRT
 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 // Sheet 7: "G"
 421 //
 422 ////////////////////////////////////////
 423 
 424 G:;
 425 
 426   DBGAPP ("doAppendCycleInstructionFetch(G)\r\n");
 427 
 428   //C(TPR.CA)0,13 > SDW.BOUND?
 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     // Initiate an access violation fault
 445     doFault (FAULT_ACV, (_fault_subtype) {.fault_acv_subtype=cpu.acvFaults}, "ACV fault");
 446   }
 447 
 448   // is segment C(TPR.TSR) paged?
 449   if (cpu.SDW->U)
 450     goto H; // Not paged
 451 
 452   // Yes. segment is paged ...
 453   // is PTW for C(TPR.CA) in PTWAM?
 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       // initiate a directed fault
 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); // load PTW0 to PTWAM
 464   }
 465 
 466   // Prepage mode?
 467   // check for "uninterruptible" EIS instruction
 468   // ISOLTS-878 02: mvn,cmpn,mvne,ad3d; obviously also
 469   // ad2/3d,sb2/3d,mp2/3d,dv2/3d
 470   // DH03 p.8-13: probably also mve,btd,dtb
 471 
 472   // XXX: PVS-Studio says that "i->opcodeX" is ALWAYS FALSE in the following check:
 473   if (i->opcodeX && ((i->opcode & 0770)== 0200|| (i->opcode & 0770) == 0220 //-V560
 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 // Sheet 8: "H", "I"
 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 // Set PTW.M
 516 
 517   DBGAPP ("doAppendCycleInstructionFetch(I): FAP\r\n");
 518 
 519   paged = true;
 520 
 521   // final address paged
 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   // AL39: The hardware ignores low order bits of the main memory page
 530   // address according to page size
 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     //sim_printf ("hit  %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 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     //sim_printf ("miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 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   //sim_printf ("hit  %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 586 }
 587 else
 588 {
 589   //sim_printf ("miss %d %05o:%06o\r\n", evcnt, cpu.TPR.TSR, cpu.TPR.CA);
 590 }
 591 #endif
 592 
 593   ucCacheSave (cpup, this, cpu.TPR.TSR, cpu.TPR.CA, bound, p, pageAddress, RSDWH_R1, paged);
 594 evcnt ++;
 595   // isolts 870
 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 // Sheet 10: "K", "L", "M", "N"
 607 //
 608 ////////////////////////////////////////
 609 
 610 //L:; // Transfer or instruction fetch
 611 
 612   DBGAPP ("doAppendCycleInstructionFetch(L)\r\n");
 613 
 614   // lastCycle == RTCD_OPERAND_FETCH
 615 
 616   if (i->opcode == 0610  && ! i->opcodeX) {
 617     // C(PPR.PRR) -> C(PRn.RNR) for n = (0, 1, ..., 7)
 618     // Use TRR here; PRR not set until KL
 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   // C(TPR.TSR) -> C(PPR.PSR)
 652   cpu.PPR.PSR = cpu.TPR.TSR;
 653   // C(TPR.CA) -> C(PPR.IC)
 654   cpu.PPR.IC = cpu.TPR.CA;
 655 
 656   goto M;
 657 
 658 M: // Set P
 659   DBGAPP ("doAppendCycleInstructionFetch(M)\r\n");
 660 
 661   // C(TPR.TRR) = 0?
 662   if (cpu.TPR.TRR == 0) {
 663     // C(SDW.P) -> C(PPR.P)
 664     //cpu.PPR.P = cpu.SDW->P;
 665     cpu.PPR.P = p;
 666   } else {
 667     // 0 C(PPR.P)
 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

/* [previous][next][first][last][top][bottom][index][help] */