Exemplo n.º 1
0
        protected override void InternalUpdate(State[] oldState)
        {
            if (PinState[0] != oldState[0])
            {
                SetOutputOff();
                ChangeDir = true;
                BreadBoardRef.UpdateComponent(Id);
                return;
            }
            else if (ChangeDir)
            {
                ChangeDir = false;
                SetInOut(PinState[0] == State.HIGH ? true : false);
                UpdateState(false, true);
                this.oldState = (State[])PinState.Clone();
            }

            InternalUpdate(false);
        }
Exemplo n.º 2
0
        protected override void InternalUpdate(State[] oldState)
        {
            var newDir = PinState[0] == State.HIGH ? true : false;

            if (newDir != ChangeDir)
            {
                SetOutputOff();
                ChangeDir = newDir;
                BreadBoardRef.UpdateComponent(Id);
                return;
            }
            else
            {
                if (SetInOut(newDir))
                {
                    UpdateState(false, true);
                    CopyOutputsToOldState();
                }
            }

            InternalUpdate(false);
        }
Exemplo n.º 3
0
        protected override void InternalUpdate(bool reset)
        {
            // If chip enable is not low then turn off all outputs
            if (PinState[E_low] != State.LOW)
            {
                for (int i = 0; i < Pins; i++)
                {
                    if (GetPinMode(i) == PinMode.Ouput)
                    {
                        PinState[i] = State.OFF;
                    }
                }
                return;
            }

            BitArray address = new BitArray(Enumerable.Repeat(false, 11).ToArray());

            address[0]  = PinState[7] == State.HIGH;
            address[1]  = PinState[6] == State.HIGH;
            address[2]  = PinState[5] == State.HIGH;
            address[3]  = PinState[4] == State.HIGH;
            address[4]  = PinState[3] == State.HIGH;
            address[5]  = PinState[2] == State.HIGH;
            address[6]  = PinState[1] == State.HIGH;
            address[7]  = PinState[0] == State.HIGH;
            address[8]  = PinState[22] == State.HIGH;
            address[9]  = PinState[21] == State.HIGH;
            address[10] = PinState[18] == State.HIGH;

            int[] array = new int[1];
            address.CopyTo(array, 0);

            BitArray page = memory[array[0]];

            // write to word
            if (PinState[W_low] == State.LOW)
            {
                if (!clearingOutputs)
                {
                    clearingOutputs = true;
                    // Outputs were swapped so we need to wait for the states to be propagated
                    setOutputOff();
                    BreadBoardRef.UpdateComponent(Id);
                    return;
                }
                clearingOutputs = false;

                SetPinModes(8, 10, PinMode.Input);
                SetPinModes(12, 16, PinMode.Input);

                UpdateState(false, false);

                page[0] = PinState[8] == State.HIGH;
                page[1] = PinState[9] == State.HIGH;
                page[2] = PinState[10] == State.HIGH;
                page[3] = PinState[12] == State.HIGH;
                page[4] = PinState[13] == State.HIGH;
                page[5] = PinState[14] == State.HIGH;
                page[6] = PinState[15] == State.HIGH;
                page[7] = PinState[16] == State.HIGH;
            }
            else if (PinState[G_low] == State.LOW)
            {
                SetPinModes(8, 10, PinMode.Ouput);
                SetPinModes(12, 16, PinMode.Ouput);

                PinState[8]  = page[0] ? State.HIGH : State.LOW;
                PinState[9]  = page[1] ? State.HIGH : State.LOW;
                PinState[10] = page[2] ? State.HIGH : State.LOW;
                PinState[12] = page[3] ? State.HIGH : State.LOW;
                PinState[13] = page[4] ? State.HIGH : State.LOW;
                PinState[14] = page[5] ? State.HIGH : State.LOW;
                PinState[15] = page[6] ? State.HIGH : State.LOW;
                PinState[16] = page[7] ? State.HIGH : State.LOW;
            }
        }