⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcodecontrolunit.java

📁 熟悉非常简单CPU模拟器 1、将所给模拟器的源程序编译成执行程序。 2、运行并观察非常简单CPU模拟器
💻 JAVA
📖 第 1 页 / 共 4 页
字号:

      if ( animationIndex == 4 )
      {
         Point pt = new Point( 141, 315 );

         setDot( 3, true, pt );
      }
      else if ( animationIndex == 5 )
      {
         Point pt = new Point( 141, 370 );

         setDot( 3, true, pt );

         updateCurrentOperations();
         updateCurrentSignals();
      }
      else if ( animationIndex == 6 )
      {
         setDot( 3, false, null );
         
         // Animation sequence done
         return ( true );
      }
      // Animation sequence not done
      return ( false );
   }

/*   public boolean animUpdCurrLogSelBT()
   {

      if ( animationIndex == 4 )
      {
         Point pt = new Point( 175, 320 );

         setDot( 1, true, pt );
      }
      else if ( animationIndex == 5 )
      {
         Point pt = new Point( 175, 365 );

         setDot( 1, true, pt );
      }
      else if ( animationIndex == 6 )
      {
         Point pt = new Point( 10, 365 );

         setDot( 1, true, pt );
      }
      else if ( animationIndex == 7 )
      {
         Point pt = new Point( 10, 244 );

         setDot( 1, true, pt );
      }
      else if ( animationIndex == 8 )
      {
         Point pt = new Point( 10, 123 );

         setDot( 1, true, pt );
      }
      else if ( animationIndex == 9 )
      {
         Point pt = new Point( 45, 123 );

         setDot( 1, true, pt );

        // updateLogicBTInput();
         updateLogicSelect();
         updateAddressMuxSignals();
      }
      else if ( animationIndex == 10 )
      {
         setDot( 1, false, null );

         // Animation sequence done
         return ( true );
      }

      // Animation sequence not done
      return ( false );
   }
*/
   public boolean animUpdCurrLogSelCond()
   {

      if ( animationIndex == 4 )
      {
         Point pt = new Point( 111, 315 );

         setDot( 2, true, pt );
      }
      else if ( animationIndex == 5 )
      {
         Point pt = new Point( 110, 360 );// was 145,350

         setDot( 2, true, pt );
      }
      else if ( animationIndex == 6 )
      {
         Point pt = new Point( 40, 360 ); //was 75,350

         setDot( 2, true, pt );
      }
      else if ( animationIndex == 7 )
      {
         Point pt = new Point( 40, 120 ); //was 75,270

         setDot( 2, true, pt );

         updateConditionMuxSelect();
       //  updateConditionMuxSignals();
      }
      else if ( animationIndex == 8 )
      {
         Point pt = new Point( 80, 120 ); // was 75,210

         setDot( 2, true, pt );

         updateLogicConditionInput();
         updateLogicSelect();
         updateAddressMuxSignals();

      }

      else if ( animationIndex == 9 )  
      {
         setDot( 2, false, null );

         // Animation sequence done
         return ( true );
      }

      // Animation sequence not done
      return ( false );
   }

   public boolean animUpdAddrMux()
   {

/*      if ( logicSelect == 0 )
      {
         // Current address + 1
         return ( animUpdAddrMuxCAP1() );
      }
*/
//System.out.println( "DEBUG ==> animUpdAddrMux-->logicSelect= " +
//            logicSelect );
      if ( logicSelect == 0 )
      {
         // Get address from microcode
         return ( animUpdAddrMuxMC() );
      }
      else 
      {
         // Get address from IR map
        updateAddressMux();
        setDot( 0, false, null );
        // return ( animUpdAddrMuxIR() );//this was active but testing something
        return ( true );
      }
   }

   public boolean animUpdAddrMuxMC()
   {

      if ( animationIndex == 9 )
      {
         Point pt = new Point( 178, 315 );

         setDot( 0, true, pt );
      }
      else if ( animationIndex == 10 )
      {
         Point pt = new Point( 178, 360 );

         setDot( 0, true, pt );
      }
      else if ( animationIndex == 11 )
      {
         Point pt = new Point( 240, 360 );

         setDot( 0, true, pt );
      }
      else if ( animationIndex == 12 )
      {
         Point pt = new Point( 240, 80 );

         setDot( 0, true, pt );
      }
      else if ( animationIndex == 13 )
      {
         Point pt = new Point( 171, 80 );

         setDot( 0, true, pt );
      }
      else if ( animationIndex == 14 )
      {
         Point pt = new Point( 171, 95 );

         setDot( 0, true, pt );

         updateAddressMux();
      }
      else if ( animationIndex == 15 )
      {
         setDot( 0, false, null );

         // Animation sequence done
         return ( true );
      }

      // Animation sequence not done
      return ( false );
   }

   public boolean animUpdAddrMuxIR()
   {

      if ( animationIndex == 9 )
      {
         Point pt = new Point( 111, 60 );

         setDot( 0, true, pt );
      }
      else if ( animationIndex == 10 )
      {
         Point pt = new Point( 111, 95 );

         setDot( 0, true, pt );

         updateAddressMux();
      }
      else if ( animationIndex == 11 )
      {
         setDot( 0, false, null );

         // Animation sequence done
         return ( true );
      }

      // Animation sequence not done
      return ( false );
   }

   public void executeUpdIRMapCycle()
   {

      if ( animationIndex == 0 )
      {
         animationIndex = 8; // might have to change to 10
      }

      if ( ! animUpdIRMapDone )
      {
         animUpdIRMapDone = animUpdIRMap();
      }

      if ( ! animUpdAddrMuxDone )
      {
         animUpdAddrMuxDone = animUpdAddrMuxIR();
      }

      if ( animUpdIRMapDone && animUpdAddrMuxDone )
      {
         animUpdIRMapDone = false;
         animUpdAddrMuxDone = false;

         animationIndex = 0;
      }
      else
      {
         animationIndex++;
      }

      if ( ! skipAnimation )
      {
         canvasRepaint();
      }

   }

   public boolean animUpdIRMap()
   {

      if ( animationIndex == 8 )
      {
         irPathEnabled = true;

         updateIRMap();
         
      }
      if ( animationIndex == 9 )
      {
         irPathEnabled = false;

         // Animation sequence done
         return ( true );
      }

      // Animation sequence not done
      return ( false );
   }

   public void setDot( int index, boolean enabled, Point pt )
   {
      oldDotEnabled[ index ] = currentDotEnabled[ index ];
      currentDotEnabled[ index ] = enabled;

      if ( enabled )
      {
         oldDotLocation[ index ] = currentDotLocation[ index ];
         currentDotLocation[ index ] = pt;
      }

   }

   public void setCLKEnabled( boolean clk )
   {
      clkEnabled = clk;
   }

   public boolean getCLKEnabled()
   {
      return ( clkEnabled );
   }

   public void setActive( boolean b )
   {
      active = b;
   }

   public boolean getActive()
   {
      return ( active );
   }

   private CPU cpu;

   private byte irMap;
   private byte addressMux;
   private byte addressRegister;
   private byte logicSelect;
   private byte conditionMuxSelect;
   private int currentOperations;
   private byte currentAddress;

   private boolean currentARPC;
   private boolean currentARDR; // added
   private boolean currentPCDR; // added
   private boolean currentARIN;
   private boolean currentARDT;
   private boolean currentPCIN;
   private boolean currentPCDT;
   private boolean currentDRM;
   private boolean currentDRAC;
   private boolean currentIRDR;
   private boolean currentRAC;
   private boolean currentZALU;
   private boolean currentTRDR;
   private boolean currentACDR;
   private boolean currentACR;
   private boolean currentPLUS;
   private boolean currentMINU;
   private boolean currentACIN;
   private boolean currentACZO;
   private boolean currentAND;
   private boolean currentOR;
   private boolean currentXOR;
   private boolean currentNOT;
   private boolean currentMDR;

   private boolean conditionMuxOutput;
//   private boolean logicBTInput;
   private boolean logicConditionInput;

//   private boolean hw1Enabled;
//   private boolean zEnabled;
//   private boolean notZEnabled;
   private boolean clkEnabled;

   private boolean irPathEnabled;

   private boolean nextAddrEnabled;
//   private boolean currAddrP1Enabled;
   private boolean irMapEnabled;

   private boolean[] oldDotEnabled = new boolean[ 4 ];
   private boolean[] currentDotEnabled = new boolean[ 4 ];
   private Point[] oldDotLocation = new Point[ 4 ];
   private Point[] currentDotLocation = new Point[ 4 ];

   private boolean skipAnimation;
   private boolean justUpdatedCurrentAddress;

   private int animationIndex;

   private boolean animUpdCurrAddrDone;
   private boolean animUpdCurrOperDone;
//   private boolean animUpdCurrLogSelBTDone;
   private boolean animUpdCurrLogSelCondDone;
   private boolean animUpdAddrMuxDone;
   private boolean animUpdIRMapDone;

   private boolean active;

/*   private int[] microcode =
      {
         
         COND_1 | BT_JUMP | OPER_ARPC | 0x02,                   // FETCH1
         COND_1 | BT_JUMP | OPER_PCIN | OPER_DRM | 0x03,        // FETCH2
         COND_X | BT_MAP | OPER_ARPC | OPER_IRDR | ADDR_X,      // FETCH3
         COND_1 | BT_JUMP | OPER_ARIN | OPER_PCIN | OPER_DRM
            | 0x05,                                             // LDAC1
         COND_1 | BT_JUMP | OPER_PCIN | OPER_DRM | OPER_TRDR
            | 0x06,                                             // LDAC2
         COND_1 | BT_JUMP | OPER_ARDT | 0x07,                   // LDAC3
         COND_1 | BT_JUMP | OPER_DRM | 0x21,                    // LDAC4
         COND_1 | BT_JUMP | OPER_ARIN | OPER_PCIN | OPER_DRM
            | 0x09,                                             // STAC1
         COND_1 | BT_JUMP | OPER_PCIN | OPER_DRM | OPER_TRDR
            | 0x0a,                                             // STAC2
         COND_1 | BT_JUMP | OPER_ARDT | 0x0b,                   // STAC3
         COND_1 | BT_JUMP | OPER_DRAC | 0x22,                   // STAC4
         COND_1 | BT_JUMP | OPER_RAC | 0x01,                    // MVAC1
         -1,
         -1,
         -1,
         COND_1 | BT_JUMP | OPER_ACR | 0x01,                    // MOVR1
         -1,
         -1,
         -1,
         COND_1 | BT_JUMP | OPER_ARIN | OPER_DRM | 0x15,        // JUMP1
         COND_1 | BT_JUMP | OPER_DRM | OPER_TRDR | 0x16,        // JUMP2
         COND_1 | BT_JUMP | OPER_PCDT | 0x01,                   // JUMP3
         -1,
         COND_NOT_Z | BT_JUMP | 0x29,                           // JMPZ1
         COND_1 | BT_JUMP | OPER_ARIN | OPER_DRM | 0x1a,        // JMPZY1
         COND_1 | BT_JUMP | OPER_DRM | OPER_TRDR | 0x1b,        // JMPZY2
         COND_1 | BT_JUMP | OPER_PCDT | 0x01,                   // JMPZY3
         COND_Z | BT_JUMP | 0x2d,                               // JPNZ1
         COND_1 | BT_JUMP | OPER_ARIN | OPER_DRM | 0x1e,        // JPNZY1
         COND_1 | BT_JUMP | OPER_DRM | OPER_TRDR | 0x1f,        // JPNZY2
         COND_1 | BT_JUMP | OPER_PCDT | 0x01,                   // JPNZY3
         COND_1 | BT_JUMP | OPER_ZALU | OPER_PLUS | 0x01,       // ADD1
         COND_1 | BT_JUMP | OPER_ACDR | 0x01,                   // LDAC5

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -