public void BusDecoderAnd_DecodeAnd_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 and = new AndGate() { Name = "and" }; and.AddInput().ConnectTo(decoder.Output); var enable = and.AddInput().CreateConnection(); var output = and.Output.CreateConnection(); busInput.Write(new BusData8(Value)); decoder.Output.Level.Should().Be(DigitalLevel.High); output.DigitalSignal.Level.Should().Be(DigitalLevel.Low); enable.Write(DigitalLevel.High); output.DigitalSignal.Level.Should().Be(DigitalLevel.High); }
public void TestInitialize() { _uut = new BusDecoder(); _output = _uut.Output.CreateConnection(); var inputBus = new Bus(16); _uut.Input.ConnectTo(inputBus); _input = new BusMaster(inputBus); _input.IsEnabled = true; }
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); }