예제 #1
0
        /***************************************************************************/

        public static void elementWithCoverage(
            ILogicalElement _element
            , LogicValue.Enum _significantValue
            , LogicValue.Enum _valueToSet
            )
        {
            ILineCollection inputs  = _element.Inputs;
            ILineCollection outputs = _element.Outputs;

            if (inputs.hasUnknownStates())
            {
                outputs[0].Value = LogicValue.Enum.Unknown;
                return;
            }

            if (inputs.hasValue(_significantValue))
            {
                outputs[0].Value = _valueToSet;
                return;
            }

            if (!inputs.hasValue(LogicValue.Enum.DontCare))
            {
                outputs[0].Value = LogicValue.invert(_valueToSet);
            }
            else
            {
                outputs[0].Value = LogicValue.Enum.DontCare;
            }
        }
        /***************************************************************************/

        public void setToAllLines(LogicValue.Enum _value)
        {
            for (int i = 0; i < Size; ++i)
            {
                this[i].Value = _value;
            }
        }
예제 #3
0
        /***************************************************************************/

        public int findValue(LogicSet _set, LogicValue.Enum _targetValue)
        {
            return(_set.FindIndex(
                       (LogicValue.Enum _value) =>
            {
                return _value == _targetValue;
            }
                       ));
        }
예제 #4
0
        /***************************************************************************/

        public static void mux(ILogicalElement _element)
        {
            ILineCollection inputs = _element.Inputs;

            int totalInputsCount = inputs.Size;

            int firstAddressPortIndex = totalInputsCount - _element.modifier;

            if (inputs.hasValue(LogicValue.Enum.Unknown))
            {
                _element.Outputs[0].Value = LogicValue.Enum.Unknown;
                return;
            }

            LogicValuesNumbersConverter converter = new LogicValuesNumbersConverter();
            Numbers inputLineNumbers = converter.toNumbers(inputs, firstAddressPortIndex, totalInputsCount - 1);

            int numbersCount = inputLineNumbers.Count;

            if (numbersCount < 1)
            {
                _element.Outputs[0].Value = LogicValue.Enum.Unknown;
                return;
            }

            LogicValue.Enum inputValue = inputs[inputLineNumbers[0]].Value;

            for (int i = 1; i < numbersCount; ++i)
            {
                if (inputValue != inputs[inputLineNumbers[i]].Value)
                {
                    _element.Outputs[0].Value = LogicValue.Enum.DontCare;
                    return;
                }
            }

            _element.Outputs[0].Value = inputValue;
        }
        /***************************************************************************/

        public override bool hasValue(LogicValue.Enum _value)
        {
            return(m_line.Value == _value);
        }
        /***************************************************************************/

        public bool hasValue(LogicValue.Enum _value)
        {
            throw new MemberAccessException(
                      Resoursers.Exceptions.Messages.noLinesToCheck
                      );
        }
        /***************************************************************************/

        public void setToAllLines(LogicValue.Enum _value)
        {
            throw new Exception();
        }
        /***************************************************************************/

        public abstract bool hasValue(LogicValue.Enum _value);
예제 #9
0
        /***************************************************************************/

        public void updateValue(int _pin, LogicValue.Enum _value)
        {
            throw new NotImplementedException();
        }
        /***************************************************************************/

        public void updateValue(int _pin, LogicValue.Enum _value)
        {
            m_inputLines[_pin].Value = _value;
        }