private void UpdateIoStep5() { var step53X87NotIr4 = _and.Apply(Step5, PinStates.ThreeXEight[7], _not.Apply(_instruction[4])); // sets PinStates.RegB.Set = NewPinState(PinStates.RegB.Set, step53X87NotIr4); PinStates.IoClk.Enable = NewPinState(PinStates.IoClk.Enable, ClkEAnd(step53X87NotIr4)); }
private bool ApplyXor(bool a, bool b) { var notA = _not.Apply(a); var notB = _not.Apply(b); var nAndA = _nAnd.Apply(a, notB); var nAndB = _nAnd.Apply(notA, b); return(_nAnd.Apply(nAndA, nAndB)); }
public (bool equal, bool ALarger, bool output) AreEqual(bool a, bool b, bool aboveBitIsEqual, bool aboveBitALarger) { var unequal = _xOr.Apply(a, b); var equal = _not.Apply(unequal); var equalAndAboveBitEqual = _and.Apply(equal, aboveBitIsEqual); var aLarger = _and.Apply(aboveBitIsEqual, unequal, a); var aLargerOrAboveALarger = _or.Apply(aLarger, aboveBitALarger); return(equalAndAboveBitEqual, aLargerOrAboveALarger, unequal); }
/// <summary> /// A decoder takes inputs like a truth table. /// So using the GenerateCombinations method we can no what inputs need to be negated based on the truth table /// </summary> /// <param name="combinations"></param> /// <param name="inputList"></param> /// <returns></returns> private IEnumerable <List <bool> > CreateGatesInputs(IEnumerable <BitList> combinations, IEnumerable <bool> inputList) { var input = inputList.Reverse().ToList(); return(combinations.Select( combination => combination.Select( (bit, bitIndex) => bit ? input[bitIndex] : _not.Apply(input[bitIndex])).ToList() ) .ToList()); }
public IByte Apply(IByte input, bool bus1) { Input = input; Set = bus1; var one = input[0]; var rest = input.Skip(1).ToArray(); var notBus1 = _not.Apply(bus1); var notAndRest = rest.Select(s => _and.Apply(s, notBus1)).ToList(); var orOneAndBus1 = _or.Apply(one, bus1); var output = notAndRest.Prepend(orOneAndBus1).ToArray(); Output = _byteFactory.Create(output); _updateWire(Output); return(Output); }
public StepperOutput Step(bool clk, bool reset) { var notReset = _not.Apply(reset); var notClk = _not.Apply(clk); var resetOrNotClk = _or.Apply(notClk, reset); var clkOrReset = _or.Apply(clk, reset); var m0 = _memoryGates[0].Apply(notReset, resetOrNotClk); var m1 = _memoryGates[1].Apply(m0, clkOrReset); var m2 = _memoryGates[2].Apply(m1, resetOrNotClk); var m3 = _memoryGates[3].Apply(m2, clkOrReset); var m4 = _memoryGates[4].Apply(m3, resetOrNotClk); var m5 = _memoryGates[5].Apply(m4, clkOrReset); var m6 = _memoryGates[6].Apply(m5, resetOrNotClk); var m7 = _memoryGates[7].Apply(m6, clkOrReset); var m8 = _memoryGates[8].Apply(m7, resetOrNotClk); var m9 = _memoryGates[9].Apply(m8, clkOrReset); var m10 = _memoryGates[10].Apply(m9, resetOrNotClk); var m11 = _memoryGates[11].Apply(m10, clkOrReset); var notM1 = _not.Apply(m1); var notM3 = _not.Apply(m3); var notM5 = _not.Apply(m5); var notM7 = _not.Apply(m7); var notM9 = _not.Apply(m9); var notM11 = _not.Apply(m11); var step1 = _or.Apply(reset, notM1); var step2 = _and.Apply(m1, notM3); var step3 = _and.Apply(m3, notM5); var step4 = _and.Apply(m5, notM7); var step5 = _and.Apply(m7, notM9); var step6 = _and.Apply(m9, notM11); _step7 = m11; var stepperArray = new[] { step1, step2, step3, step4, step5, step6, _step7 }; return(new StepperOutput(stepperArray)); }
public IByte Invert(IByte input) { return(_byteFactory.Create(input.Select(s => _not.Apply(s)).ToArray())); }
public bool Apply(params bool[] bits) { var negatedBits = bits.Select(s => _not.Apply(s)).ToArray(); return(_nAnd.Apply(negatedBits)); }
public bool IsZero(IByte input) { var orRes = _or.Apply(input.ToArray()); return(_not.Apply(orRes)); }
public bool Apply(params bool[] bits) { return(_not.Apply(_and.Apply(bits))); }