コード例 #1
0
ファイル: LogicTest.cs プロジェクト: obiwanjacobi/Zim80
        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);
        }
コード例 #2
0
ファイル: AndGateTest.cs プロジェクト: obiwanjacobi/Zim80
        public void Write_HighPosEdge_Low()
        {
            var uut    = new AndGate();
            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.Low);
        }
コード例 #3
0
ファイル: AndGateTest.cs プロジェクト: obiwanjacobi/Zim80
        public void Write_HighHighHighHigh_High()
        {
            var uut    = new AndGate();
            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.High);
            input4.Write(DigitalLevel.High);

            uut.Output.Level.Should().Be(DigitalLevel.High);
        }
コード例 #4
0
        //  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());
        }
コード例 #5
0
        public AndGate Build()
        {
            var gate = new AndGate();

            foreach (var input in _inputs)
            {
                gate.AddInput(input);
            }

            return(gate);
        }