Beispiel #1
0
        public void AddCpuMemoryAndIoSpace_MemoryAndIoSpaceConnectsToCpu()
        {
            var uut = new SimulationModelBuilder();

            uut.AddCpuMemory();
            uut.AddCpuIoSpace();

            uut.Model.Memory.Should().NotBeNull();
            uut.Model.Memory.Address.IsConnected.Should().BeTrue();
            uut.Model.Memory.Data.IsConnected.Should().BeTrue();
            uut.Model.Memory.ChipEnable.IsConnected.Should().BeTrue();
            uut.Model.Memory.OutputEnable.IsConnected.Should().BeTrue();
            uut.Model.Memory.WriteEnable.IsConnected.Should().BeTrue();

            uut.Model.IoSpace.Should().NotBeNull();
            uut.Model.IoSpace.Address.IsConnected.Should().BeTrue();
            uut.Model.IoSpace.Data.IsConnected.Should().BeTrue();
            uut.Model.IoSpace.ChipEnable.IsConnected.Should().BeTrue();
            uut.Model.IoSpace.OutputEnable.IsConnected.Should().BeTrue();
            uut.Model.IoSpace.WriteEnable.IsConnected.Should().BeTrue();

            uut.Model.Cpu.Address.IsConnected.Should().BeTrue();
            uut.Model.Cpu.Data.IsConnected.Should().BeTrue();
            uut.Model.Cpu.IoRequest.IsConnected.Should().BeTrue();
            uut.Model.Cpu.Read.IsConnected.Should().BeTrue();
            uut.Model.Cpu.Write.IsConnected.Should().BeTrue();

            uut.Model.Address.Should().NotBeNull();
            uut.Model.Data.Should().NotBeNull();
        }
Beispiel #2
0
        public void AddInputPort_CpuMemory_ConnectedAndAddedToModel()
        {
            var uut = new SimulationModelBuilder();

            uut.AddCpuMemory();
            var inputPort = uut.AddInputPort(0x10, "Test");

            uut.Model.Components.Should().HaveCount(3); // decoder/invertor/or
            uut.Model.InputPorts.Should().HaveCount(1);

            inputPort.Output.IsConnected.Should().BeTrue();
            inputPort.PortEnable.IsConnected.Should().BeTrue();
        }
Beispiel #3
0
        protected SimulationModel CreateModel(string file)
        {
            var builder = new SimulationModelBuilder();

            builder.AddCpuClockGen();
            builder.AddCpuMemory();
            builder.AddOutputPort(0x20, "ConsoleOut");
            //builder.AddLogicAnalyzer();

            var bytes = LoadFile(file);

            builder.Model.Memory.Write(bytes);

            return(builder.Model);
        }
Beispiel #4
0
        protected SimulationModelBuilder CreateModelBuilder(string file, ushort bss = 0x1000)
        {
            var builder = new SimulationModelBuilder();

            builder.AddCpuClockGen();
            builder.AddCpuMemory();

            var bytes = LoadFile(file);

            builder.Model.Memory.Write(bytes);

            if (bss > 0)
            {
                builder.Model.Memory.Fill(bss, new BusData8(0), bytes.Length);
            }

            return(builder);
        }
Beispiel #5
0
        public void AddInputPort_InitialState_IsPropegated()
        {
            var uut = new SimulationModelBuilder();

            uut.AddCpuMemory();
            ((IDirectMemoryAccess <BusData8>)uut.Model.Memory)[0] = new BusData8(0); // nop
            uut.AddCpuClockGen();
            var inputPort = uut.AddInputPort(0x10, "Test");

            uut.AddLogicAnalyzer();

            inputPort.DataBuffer.Write(new BusData8(0xFF));

            uut.Model.ClockGen.SquareWave(4);

            Console.WriteLine(uut.Model.LogicAnalyzer.ToWaveJson());

            inputPort.DataBuffer.Read().ToByte().Should().Be(0xFF);
        }
        private SimulationModel ExecuteTest(OpcodeByte ob, Func <Zim80.CpuZ80.CpuZ80, int> preTest)
        {
            var builder = new SimulationModelBuilder();

            builder.AddCpuClockGen();
            builder.AddCpuMemory();
            builder.AddLogicAnalyzer();

            builder.Model.Memory.Write(
                new byte[] { 0xED, ob.Value, 0, 0, Value1, Value2, Value2, Value1, 0, 0, 0, 0, 0, 0, 0, 0 }
                );

            builder.Model.Cpu.FillRegisters();
            int cycles = preTest(builder.Model.Cpu);

            builder.Model.ClockGen.SquareWave(cycles);

            Console.WriteLine(builder.Model.LogicAnalyzer.ToWaveJson());

            return(builder.Model);
        }