예제 #1
0
        public void Tick()
        {
            MainBusComponent mock0 = NSubstitute.Substitute.ForPartsOf <StubMainBusComponent>(bus);
            MainBusComponent mock1 = NSubstitute.Substitute.ForPartsOf <StubMainBusComponent>(bus);
            MainBusComponent mock2 = NSubstitute.Substitute.ForPartsOf <StubMainBusComponent>(bus);

            Assert.AreEqual(3, bus.components.Count);

            bus.tick();

            Received.InOrder(() =>
            {
                mock0.clockRise();
                mock1.clockRise();
                mock2.clockRise();
                mock0.clockFall();
                mock1.clockFall();
                mock2.clockFall();
            });
        }
예제 #2
0
        public void VonNeumannLoop()
        {
            //TODO: Add interrupt Capabilities here somewhere
            //The processor should complete a single step of the loop in a clock pulse
            ram.store(add_addi_bin, 0, (ulong)add_addi_bin.Length, 0);

            // Step 1: Fetch Instruction
            // Step 2: Decode Instruction
            // Step 3: Read Source Operands [This step may include interaction with the Main Bus]
            // Step 3.up: put command and address on the bus
            // Step 3.down: pull the data off the bus and clear it
            // Step 4: Execute
            // Step 5: Write Destination Operand
            // Step 6: Move PC to next position +4 or jump location

            Assert.AreEqual(Kore.CPU.Cycle.Off, cpu.state);
            cpu.turnOn();
            Assert.AreEqual(Kore.CPU.Cycle.Init, cpu.state);
            bus.tick();
            for (int i = 1; i <= 100; i++)
            {
                Assert.AreEqual(Kore.CPU.Cycle.Fetch, cpu.state);
                bus.tick();
                Assert.AreEqual(Kore.CPU.Cycle.Decode, cpu.state);
                bus.tick();
                Assert.AreEqual(Kore.CPU.Cycle.Read, cpu.state);
                bus.tick();
                Assert.AreEqual(Kore.CPU.Cycle.Exec, cpu.state);
                bus.tick();
                Assert.AreEqual(Kore.CPU.Cycle.Write, cpu.state);
                bus.tick();
                Assert.AreEqual(Kore.CPU.Cycle.MovPC, cpu.state);
                bus.tick();
                Assert.AreEqual(i * 4, cpu.registers.getR(Register.PC));
            }
        }