public void Write_HighPosEdge_High() { var uut = new OrGate(); var input1 = uut.AddInput().CreateConnection(); var input2 = uut.AddInput().CreateConnection(); var output = uut.Output.CreateConnection(); input1.Write(DigitalLevel.High); input2.Write(DigitalLevel.PosEdge); uut.Output.Level.Should().Be(DigitalLevel.High); }
public void Write_LowLow_Low() { var uut = new OrGate(); var input1 = uut.AddInput().CreateConnection(); var input2 = uut.AddInput().CreateConnection(); var output = uut.Output.CreateConnection(); input1.Write(DigitalLevel.Low); input2.Write(DigitalLevel.Low); uut.Output.Level.Should().Be(DigitalLevel.Low); }
public void Write_HighHighLowHigh_High() { var uut = new OrGate(); var input1 = uut.AddInput().CreateConnection(); var input2 = uut.AddInput().CreateConnection(); var input3 = uut.AddInput().CreateConnection(); var input4 = uut.AddInput().CreateConnection(); var output = uut.Output.CreateConnection(); input1.Write(DigitalLevel.High); input2.Write(DigitalLevel.High); input3.Write(DigitalLevel.Low); input4.Write(DigitalLevel.High); uut.Output.Level.Should().Be(DigitalLevel.High); }
// can be removed; just trying out stuff public void BasicComposite_NoBuilders() { var notGate = new NotGate(); notGate.SetInput(Generator.AnInactiveSignal()); var orGate = new OrGate(); orGate.AddInput(Generator.AnInactiveSignal()); orGate.AddInput(Generator.AnActiveSignal()); var andGate = new AndGate(); andGate.AddInput(notGate); andGate.AddInput(orGate); Assert.True(andGate.Output()); }
public OrGate Build() { var gate = new OrGate(); foreach (var input in _inputs) { gate.AddInput(input); } return(gate); }
public void BusDecoderInvertorOr_DecodeOr_OutputActiveWhenEnabled() { const byte Value = 0x10; var decoder = new BusDecoder("decoder"); decoder.AddValue(Value); decoder.Input.ConnectTo(new Bus <BusData8>("bus")); var busInput = decoder.Input.CreateConnection(); busInput.IsEnabled = true; var invertor = new InvertorGate() { Name = "inv" }; invertor.Input.ConnectTo(decoder.Output); var or = new OrGate() { Name = "or" }; or.AddInput().ConnectTo(invertor.Output); var enable = or.AddInput().CreateConnection(); enable.Write(DigitalLevel.High); var output = or.Output.CreateConnection(); busInput.Write(new BusData8(Value)); decoder.Output.Level.Should().Be(DigitalLevel.High); invertor.Output.Level.Should().Be(DigitalLevel.Low); output.DigitalSignal.Level.Should().Be(DigitalLevel.High); enable.Write(DigitalLevel.Low); output.DigitalSignal.Level.Should().Be(DigitalLevel.Low); }
public InputPort AddInputPort(Bus address, Bus data, ushort ioAddress, string name = null) { if (name == null) { name = string.Empty; } var decoder = new BusDecoder(address, name + "-InputAddressDecoder"); decoder.AddValue(ioAddress); AddComponent(decoder); var invertor = new InvertorGate() { Name = name + "-InAddressDecodeInvertor" }; AddComponent(invertor); decoder.Output.ConnectTo(invertor.Input); var or = new OrGate() { Name = name + "-InPortEnableIO" }; or.AddInput().ConnectTo(Model.Cpu.IoRequest); or.AddInput().ConnectTo(Model.Cpu.Read); or.AddInput().ConnectTo(invertor.Output); AddComponent(or); var inputPort = new InputPort(data, name); AddInputPort(inputPort); inputPort.PortEnable.ConnectTo(or.Output); return(inputPort); }