Beispiel #1
0
        public void NoBusRead(byte expectedValue, SystemRegister registerId, ControlLineId lineId)
        {
            var clock = new Mock <IClock>();

            clock.Setup(x => x.AddConnectedComponent(It.IsAny <IClockConnectedComponent>()));

            var bus = new Mock <IBus>();

            bus.SetupGet(x => x.Value).Returns(expectedValue);

            var controlUnit = new Mock <IControlUnit>();

            ControlLine busInputLine = new ControlLine(lineId);

            controlUnit.Setup(x => x.GetControlLine(lineId)).Returns(busInputLine);

            Register reg = new Register(registerId, clock.Object, bus.Object, controlUnit.Object);

            busInputLine.State = false;
            reg.OnRisingEdge();

            // A register should not read a value when it's controlline is low
            Assert.Equal(0, reg.Value);
        }
Beispiel #2
0
        public void ReadValueFromBus(byte expectedValue, SystemRegister registerId, ControlLineId lineId)
        {
            var clock = new Mock <IClock>();

            clock.Setup(x => x.AddConnectedComponent(It.IsAny <IClockConnectedComponent>()));

            var bus = new Mock <IBus>();

            bus.SetupGet(x => x.Value).Returns(expectedValue);

            var controlUnit = new Mock <IControlUnit>();

            ControlLine busInputLine = new ControlLine(lineId);

            controlUnit.Setup(x => x.GetControlLine(lineId)).Returns(busInputLine);

            Register reg = new Register(registerId, clock.Object, bus.Object, controlUnit.Object);

            busInputLine.State = true;
            reg.OnRisingEdge();

            // Register has it's input line high so should read the value currently on the bus
            Assert.Equal(expectedValue, reg.Value);
        }
Beispiel #3
0
 public ControlLine(ControlLineId id)
 {
     Id    = id;
     State = false;
 }
Beispiel #4
0
 public ControlLine GetControlLine(ControlLineId lineId)
 {
     return(controlLines[lineId]);
 }