コード例 #1
0
        public PICController(PICCommand[] cmds, PICControllerSpeed s)
        {
            Tmr0      = new PICTimer();
            WatchDog  = new PICWatchDogTimer();
            Interrupt = new PICInterruptLogic(this);
            Clocks[0] = new PICClock();
            Clocks[1] = new PICClock();
            Clocks[2] = new PICClock();
            Clocks[3] = new PICClock();
            Memory    = new PICMemory(Tmr0, Interrupt);

            Mode            = PICControllerMode.WAITING;
            SimulationSpeed = s;
            IsInSleep       = false;

            CommandList = cmds;
            breakpoints = new bool[cmds.Length];
        }
コード例 #2
0
        public PICMemory(PICTimer tmr, PICInterruptLogic il)
        {
            this.Timer     = tmr;
            this.Interrupt = il;

            SpecialRegisterEvents = new Dictionary <uint, Tuple <RegisterRead, RegisterWrite> >()
            {
                #region Linked Register && PC

                //##############################################################################
                {
                    ADDR_PCL,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p + 0x80, v); UpdatePC(v); })
                },
                {
                    ADDR_PCL + 0x80,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p - 0x80, v); UpdatePC(v); })
                },
                //##############################################################################
                {
                    ADDR_STATUS,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p + 0x80, v); })
                },
                {
                    ADDR_STATUS + 0x80,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p - 0x80, v); })
                },
                //##############################################################################
                {
                    ADDR_FSR,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p + 0x80, v); })
                },
                {
                    ADDR_FSR + 0x80,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p - 0x80, v); })
                },
                //##############################################################################
                {
                    ADDR_PCLATH,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p + 0x80, v); })
                },
                {
                    ADDR_PCLATH + 0x80,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p - 0x80, v); })
                },
                //##############################################################################
                {
                    ADDR_INTCON,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p + 0x80, v); })
                },
                {
                    ADDR_INTCON + 0x80,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); SetRegisterDirect(p - 0x80, v); })
                },

                #endregion

                #region Unimplemented

                {
                    ADDR_UNIMPL_A,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        (p) => 0,
                        (p, v) => { /* NOP */ })
                },
                {
                    ADDR_UNIMPL_B,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        (p) => 0,
                        (p, v) => { /* NOP */ })
                },

                #endregion

                #region RB0/INT Interrupt + Port RB Interrupt

                {
                    ADDR_PORT_B,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { Do_Interrupt_ADDR_PORT_B(v); SetRegisterDirect(p, v); })
                },

                #endregion

                #region Indirect Addressing

                {
                    ADDR_INDF,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        (p) =>
                    {
                        return((GetRegister(ADDR_FSR) % 0x80 == 0) ? (0) : (GetRegister(GetRegister(ADDR_FSR))));
                    },
                        (p, v) =>
                    {
                        if (GetRegister(ADDR_FSR) % 0x80 != 0)
                        {
                            SetRegister(GetRegister(ADDR_FSR), v);
                        }
                    })
                },

                {
                    ADDR_INDF + 0x80,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        (p) =>
                    {
                        return((GetRegister(ADDR_FSR) % 0x80 == 0) ? (0) : (GetRegister(GetRegister(ADDR_FSR))));
                    },
                        (p, v) =>
                    {
                        if (GetRegister(ADDR_FSR) % 0x80 != 0)
                        {
                            SetRegister(GetRegister(ADDR_FSR), v);
                        }
                    })
                },

                #endregion

                #region TMR0

                {
                    ADDR_TMR0,
                    Tuple.Create <RegisterRead, RegisterWrite>(
                        GetRegisterDirect,
                        (p, v) => { SetRegisterDirect(p, v); Timer.clearPrescaler(); })
                },

                #endregion
            };
        }