// Helper Methods: private static string ToHadesString(this Component component) { return(component switch { ANDGate and => $"hades.models.gatter.And{and.NumberOfInputs} {and.Name} {and.Pos.X * 3}0 {and.Pos.Y * 3}0 @N 1001 1.0E-8", INVGate inv => $"hades.models.gatter.Inv {inv.Name} {inv.Pos.X * 3}0 {inv.Pos.Y * 3}0 @N 1001 5.0E-9", NANDGate nand => $"hades.models.gatter.Nand{nand.NumberOfInputs} {nand.Name} {nand.Pos.X * 3}0 {nand.Pos.Y * 3}0 @N 1001 1.0E-8", NORGate nor => $"hades.models.gatter.Nor{nor.NumberOfInputs} {nor.Name} {nor.Pos.X * 3}0 {nor.Pos.Y * 3}0 @N 1001 1.0E-8", ORGate or => $"hades.models.gatter.Or{or.NumberOfInputs} {or.Name} {or.Pos.X * 3}0 {or.Pos.Y * 3}0 @N 1001 1.0E-8", XNORGate xnor => $"hades.models.gatter.Xnor{xnor.NumberOfInputs} {xnor.Name} {xnor.Pos.X * 3}0 {xnor.Pos.Y * 3}0 @N 1001 1.0E-8", XORGate xor => $"hades.models.gatter.Xor{xor.NumberOfInputs} {xor.Name} {xor.Pos.X * 3}0 {xor.Pos.Y * 3}0 @N 1001 1.0E-8", InputPulse ip => $"hades.models.io.PulseSwitch {ip.Name} {ip.Pos.X * 3}0 {ip.Pos.Y * 3}0 @N 1001 0.1 null", InputClock ic => $"hades.models.io.ClockGen {ic.Name} {ic.Pos.X * 3}0 {ic.Pos.Y * 3}0 @N 1001 {InputClock.MsToSec()} 0.5 0.0", Input i => $"hades.models.io.Ipin {i.Name} {i.Pos.X * 3}0 {i.Pos.Y * 3}0 @N 1001 {i.IsActive}", Output o => $"hades.models.io.Opin {o.Name} {o.Pos.X * 3}0 {o.Pos.Y * 3}0 @N 1001 5.0E-9", _ => throw new ComponentNotFoundException(component.GetType().ToString()) });
public Quad_Xnor_Gates() : base(8, 4) { Gate gateA = new XNORGate(); int indexA = AddGate(gateA); Gate gateB = new XNORGate(); int indexB = AddGate(gateB); Gate gateC = new XNORGate(); int indexC = AddGate(gateC); Gate gateD = new XNORGate(); int indexD = AddGate(gateD); // Gate A AddWire(ID, new Wire(0, 0, indexA, false)); AddWire(ID, new Wire(1, 1, indexA, false)); AddWire(gateA.ID, new Wire(0, 0, -1, true)); // Gate B AddWire(ID, new Wire(2, 0, indexB, false)); AddWire(ID, new Wire(3, 1, indexB, false)); AddWire(gateB.ID, new Wire(0, 1, -1, true)); // Gate C AddWire(ID, new Wire(4, 0, indexC, false)); AddWire(ID, new Wire(5, 1, indexC, false)); AddWire(gateC.ID, new Wire(0, 2, -1, true)); // Gate D AddWire(ID, new Wire(6, 0, indexD, false)); AddWire(ID, new Wire(7, 1, indexD, false)); AddWire(gateD.ID, new Wire(0, 3, -1, true)); }
public void XNOR() { PowerSupplier power1 = new PowerSupplier(); PowerSupplier power2 = new PowerSupplier(); XNORGate xnorGate = new XNORGate(); IndicatorLight light = new IndicatorLight(); xnorGate.Output.ConnectTo(light.Input); Assert.IsTrue(light.Lighting); xnorGate.Input1.ConnectTo(power1.Output); xnorGate.Input2.ConnectTo(power2.Output); Assert.IsTrue(light.Lighting); power1.On(); power2.Off(); Assert.IsFalse(light.Lighting); power1.Off(); power2.On(); Assert.IsFalse(light.Lighting); power1.On(); power2.On(); Assert.IsTrue(light.Lighting); power1.Off(); power2.Off(); Assert.IsTrue(light.Lighting); }