コード例 #1
0
 @Override
 protected void onRisingClockEdge(Microinstruction m) {
   AccMicroinstr mi = (AccMicroinstr) getCurrentMicroinstruction();
   if (mi.pcw) {
     PC.clock();
   }
   if (mi.irw) {
     IR.clock();
   }
   if (mi.psww) {
     psw.clock();
   }
   if (mi.aw) {
     A.clock();
   }
   if (mi.mwr) {
     try {
       systemBus.write(ab, db, SystemBus.M_16);
     } catch (Exception ex) {
       System.out.println(ex.getMessage());
       System.exit(1);
     }
   }
 }
コード例 #2
0
        @Override
        protected void onLogic(Microinstruction mi) {
          AccMicroinstr m = (AccMicroinstr) mi;
          short op1 = 0, op2 = 0;

          ab =
              (short)
                  ((!m.aoe)
                      ? 0xFFFF
                      : (m.asel == 0) ? IR.getQ() : (m.asel == 1) ? PC.getQ() : 0x10);

          if (m.moe) {
            if (!m.aoe) {
              java.lang.System.out.printf("Error: address bus in Z state\n");
              java.lang.System.exit(1);
            }
            if (m.doe) {
              java.lang.System.out.printf(
                  "Error: bus conflict on DB (moe and doe active simultaneously)\n");
              java.lang.System.exit(1);
            }

            try {
              db = systemBus.read(ab, SystemBus.M_16);
            } catch (Exception ex) {
              System.out.println(ex.getMessage());
              System.exit(1);
            }
          }

          switch (m.src1s) {
            case 0:
              op1 = IR.getQ();
              break;
            case 1:
              op1 = db;
              break;
            case 2:
              op1 = (short) m.k;
              break;
          }

          switch (m.src2s) {
            case 0:
              op2 = IR.getQ();
              break;
            case 1:
              op2 = PC.getQ();
              break;
            case 2:
              op2 = A.getQ();
              break;
            case 3:
              op2 = psw.output();
              break;
          }
          aluo = alu.exec(m.aluop, op1, op2, aluo, psw);

          if (m.asel == 2 && m.aoe) {
            ab = aluo;
          }

          if (m.doe) {
            db = aluo;
          } else if (!m.moe) {
            db = (short) 0xFFFF;
          }

          // BUSes -> Registers
          PC.setD(aluo);
          IR.setD(db);
          A.setD(aluo);

          if (controller.getState() == 0) {
            print(true);
          }
          print(false);
        }