Exemple #1
0
        public void MultipleProviders_OneWritesAtaTime_NoConflicts()
        {
            var provider1 = new DigitalSignalProvider();
            var provider2 = new DigitalSignalProvider();
            var signal    = new DigitalSignal();

            provider1.ConnectTo(signal);
            provider2.ConnectTo(signal);

            provider1.Write(DigitalLevel.High);
            provider1.Write(DigitalLevel.Floating);
            provider2.Write(DigitalLevel.Low);
            provider2.Write(DigitalLevel.Floating);
            provider1.Write(DigitalLevel.PosEdge);
        }
Exemple #2
0
        public void Connected_WriteHighTwice_NoChange()
        {
            var uut    = new DigitalSignalProvider();
            var signal = new DigitalSignal();

            uut.ConnectTo(signal);
            uut.Write(DigitalLevel.High);

            var levels = new List <DigitalLevel>();

            signal.OnChanged += (s, e) => levels.Add(e.Level);

            var count = uut.Write(DigitalLevel.High);

            count.Should().Be(0);
            levels.Should().HaveCount(count);
        }
Exemple #3
0
        public void MultipleProviders_OneWrites_NoConflicts()
        {
            var provider1 = new DigitalSignalProvider();
            var provider2 = new DigitalSignalProvider();
            var signal    = new DigitalSignal();

            provider1.ConnectTo(signal);
            provider2.ConnectTo(signal);

            provider1.Write(DigitalLevel.High);
        }
Exemple #4
0
        public void Connected_WriteHigh_LevelIsHigh()
        {
            var uut    = new DigitalSignalProvider();
            var signal = new DigitalSignal();

            uut.ConnectTo(signal);

            uut.Write(DigitalLevel.High);

            uut.Level.Should().Be(DigitalLevel.High);
            signal.Level.Should().Be(DigitalLevel.High);
        }
Exemple #5
0
        public void Enable_PosEdge_CapturedValue()
        {
            var value = NewValue(Value);

            _input.Write(value);

            _portEnable.Write(DigitalLevel.PosEdge);

            _uut.DataStream.Data.First().ToByte().Should().Be(Value);
        }
Exemple #6
0
 private void Initialize()
 {
     // startup state
     _addressBus.IsEnabled = true;
     _busAcknowledge.Write(DigitalLevel.High);
     _halt.Write(DigitalLevel.High);
     _ioRequest.Write(DigitalLevel.High);
     _memoryRequest.Write(DigitalLevel.High);
     _machineCycle1.Write(DigitalLevel.High);
     _refresh.Write(DigitalLevel.High);
     _read.Write(DigitalLevel.High);
     _write.Write(DigitalLevel.High);
 }
        public void Connect_WriteProvider_ConsumerSeesChanges()
        {
            var provider = new DigitalSignalProvider();
            var consumer = new DigitalSignalConsumer();
            var signal   = new DigitalSignal();

            provider.ConnectTo(signal);
            consumer.ConnectTo(signal);

            provider.Write(DigitalLevel.High);

            consumer.Level.Should().Be(DigitalLevel.High);
        }
        public void Connect_WriteProvider_EventTriggered()
        {
            var provider = new DigitalSignalProvider();
            var consumer = new DigitalSignalConsumer();
            var signal   = new DigitalSignal();

            provider.ConnectTo(signal);
            consumer.ConnectTo(signal);
            consumer.MonitorEvents();

            provider.Write(DigitalLevel.High);

            consumer.ShouldRaise("OnChanged");
        }
Exemple #9
0
        public void Connected_WriteHigh_TriggersEvent()
        {
            var uut    = new DigitalSignalProvider();
            var signal = new DigitalSignal();

            uut.ConnectTo(signal);

            signal.MonitorEvents();
            uut.Write(DigitalLevel.High);

            signal.ShouldRaise("OnChanged");
            uut.Level.Should().Be(DigitalLevel.High);
            signal.Level.Should().Be(DigitalLevel.High);
        }
        public void Write_MultipleConsumers_AllSeeChangedLevel()
        {
            var provider  = new DigitalSignalProvider();
            var consumer1 = new DigitalSignalConsumer();
            var consumer2 = new DigitalSignalConsumer();
            var signal    = new DigitalSignal();

            provider.ConnectTo(signal);
            consumer1.ConnectTo(signal);
            consumer2.ConnectTo(signal);

            provider.Write(DigitalLevel.High);

            consumer1.Level.Should().Be(DigitalLevel.High);
            consumer2.Level.Should().Be(DigitalLevel.High);
        }
Exemple #11
0
        public void Connected_WriteHigh_MovesToHigh()
        {
            var uut    = new DigitalSignalProvider();
            var signal = new DigitalSignal();

            uut.ConnectTo(signal);

            var levels = new List <DigitalLevel>();

            signal.OnChanged += (s, e) => levels.Add(e.Level);

            var count = uut.Write(DigitalLevel.High);

            count.Should().Be(3);
            levels.Should().HaveCount(count);
            levels[0].Should().Be(DigitalLevel.Low);
            levels[1].Should().Be(DigitalLevel.PosEdge);
            levels[2].Should().Be(DigitalLevel.High);
        }
Exemple #12
0
        public void Enable_PosEdge_ReleaseValue()
        {
            _portEnable.Write(DigitalLevel.Low);

            _output.Value.ToByte().Should().Be(Value);
        }