/***************************************************************************/ public static void dmx(ILogicalElement _element) { ILineCollection inputs = _element.Inputs; ILineCollection outputs = _element.Outputs; if (inputs.hasValue(LogicValue.Enum.Unknown)) { outputs.setToAllLines(LogicValue.Enum.Unknown); return; } outputs.setToAllLines(LogicValue.Enum.Low); int enableIndex = inputs.Size - 1; int informationInputIndex = enableIndex - 1; if (inputs[enableIndex].Value == LogicValue.Enum.Low) { return; } if (inputs[informationInputIndex].Value == LogicValue.Enum.Low) { return; } LogicValuesNumbersConverter converter = new LogicValuesNumbersConverter(); Numbers outputLineNumbers = converter.toNumbers(inputs, 0, informationInputIndex - 1); int outputLineNumbersCount = outputLineNumbers.Count; if (outputLineNumbersCount == 1) { outputs[outputLineNumbers[0]].Value = inputs[informationInputIndex].Value; } else { for (int i = 0; i < outputLineNumbersCount; ++i) { outputs[outputLineNumbers[i]].Value = LogicValue.Enum.DontCare; } } }
/***************************************************************************/ 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; }