Пример #1
0
        //here we initialize and connect all the components, as in Figure 5.9 in the book
        public CPU16()
        {
            Size = 16;

            Instruction        = new WireSet(Size);
            MemoryInput        = new WireSet(Size);
            MemoryOutput       = new WireSet(Size);
            MemoryAddress      = new WireSet(Size);
            InstructionAddress = new WireSet(Size);
            MemoryWrite        = new Wire();
            Reset = new Wire();

            m_gALU = new ALU(Size);
            m_rPC  = new Counter(Size);
            m_rA   = new MultiBitRegister(Size);
            m_rD   = new MultiBitRegister(Size);

            m_gAMux  = new BitwiseMux(Size);
            m_gMAMux = new BitwiseMux(Size);

            m_gAMux.ConnectInput1(Instruction);
            m_gAMux.ConnectInput2(m_gALU.Output);

            m_rA.ConnectInput(m_gAMux.Output);

            m_gMAMux.ConnectInput1(m_rA.Output);
            m_gMAMux.ConnectInput2(MemoryInput);
            m_gALU.InputY.ConnectInput(m_gMAMux.Output);

            m_gALU.InputX.ConnectInput(m_rD.Output);

            m_rD.ConnectInput(m_gALU.Output);

            MemoryOutput.ConnectInput(m_gALU.Output);
            MemoryAddress.ConnectInput(m_rA.Output);

            InstructionAddress.ConnectInput(m_rPC.Output);
            m_rPC.ConnectInput(m_rA.Output);
            m_rPC.ConnectReset(Reset);

            //now, we call the code that creates the control unit
            ConnectControls();
        }
Пример #2
0
        //private Wire wi1, wi2;

        //here we initialize and connect all the components, as in Figure 5.9 in the book
        public CPU16()
        {
            wi1      = new Wire();
            wi2      = new Wire();
            and_D    = new AndGate();
            and_MW   = new AndGate();
            and_JM0  = new AndGate();
            and_JM1  = new AndGate();
            and_JM2  = new AndGate();
            and_JMP  = new AndGate();
            not_Zero = new NotGate();
            not_Neg  = new NotGate();
            not_A    = new NotGate();
            J_0      = new Wire();
            JGT      = new Wire();
            JEQ      = new Wire();
            JGE      = new Wire();
            JLT      = new Wire();
            JNE      = new Wire();
            JLE      = new Wire();
            J_1      = new Wire();
            JMP      = new WireSet(3);
            or_A     = new OrGate();
            or_JMP   = new OrGate();

            Size = 16;

            Instruction        = new WireSet(Size);
            MemoryInput        = new WireSet(Size);
            MemoryOutput       = new WireSet(Size);
            MemoryAddress      = new WireSet(Size);
            InstructionAddress = new WireSet(Size);
            MemoryWrite        = new Wire();
            Reset = new Wire();

            m_gALU = new ALU(Size);
            m_rPC  = new Counter(Size);
            m_rA   = new MultiBitRegister(Size);
            m_rD   = new MultiBitRegister(Size);

            m_gAMux  = new BitwiseMux(Size);
            m_gMAMux = new BitwiseMux(Size);

            m_gAMux.ConnectInput1(Instruction);
            m_gAMux.ConnectInput2(m_gALU.Output);

            m_rA.ConnectInput(m_gAMux.Output);

            m_gMAMux.ConnectInput1(m_rA.Output);
            m_gMAMux.ConnectInput2(MemoryInput);
            m_gALU.InputY.ConnectInput(m_gMAMux.Output);

            m_gALU.InputX.ConnectInput(m_rD.Output);

            m_rD.ConnectInput(m_gALU.Output);

            MemoryOutput.ConnectInput(m_gALU.Output);
            MemoryAddress.ConnectInput(m_rA.Output);

            InstructionAddress.ConnectInput(m_rPC.Output);
            m_rPC.ConnectInput(m_rA.Output);
            m_rPC.ConnectReset(Reset);

            //now, we call the code that creates the control unit
            ConnectControls();
        }