Add tests for new cpu

This commit is contained in:
edmccard 2012-04-08 21:28:44 -04:00
parent 04f05fbc9a
commit d343db0842
5 changed files with 76 additions and 7 deletions

View File

@ -5,7 +5,7 @@ LINK_OPTS = -L-lpthread -L-lGL -L-ldl -L-lX11 \
-L-L$(GTKD) -L-lgtkd -L-lgtkdgl \
-L-L$(DERELICT)/lib -L-lDerelictSDL -L-lDerelictUtil \
ALL_SRC = $(shell find -name "*.d")
ALL_SRC = $(shell find -name "*.d" \! -name "cpu6502.d")
ALL_OBJS = $(ALL_SRC:%.d=%.o)
all: ${ALL_OBJS}

View File

@ -798,3 +798,13 @@ string Hex2(int dec)
return HEX_DIGITS[highNybble..highNybble+1] ~
HEX_DIGITS[lowNybble..lowNybble+1];
}
//alias Cpu!("6502", false, false) T1;
//alias Cpu!("6502", false, true) T2;
//alias Cpu!("6502", true, false) T3;
//alias Cpu!("6502", true, true) T4;
//alias Cpu!("65C02", false, false) T5;
//alias Cpu!("65C02", false, true) T6;
//alias Cpu!("65C02", true, false) T7;
//alias Cpu!("65C02", true, true) T8;

View File

@ -198,22 +198,22 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative)
final ubyte readFinal(ushort addr)
{
static if (cumulative) tick(++totalCycles);
static if (cumulative) clock.tick(++totalCycles);
else
{
tick();
clock.tick();
}
return memoryRead(addr);
return memory.read(addr);
}
final void writeFinal(ushort addr, ubyte val)
{
static if (cumulative) tick(++totalCycles);
static if (cumulative) clock.tick(++totalCycles);
else
{
tick();
clock.tick();
}
memoryWrite(addr, val);
memory.write(addr, val);
}
final ushort readWord(ushort addrLo, ushort addrHi)

39
test/test_new_cpu.d Normal file
View File

@ -0,0 +1,39 @@
version(Strict)
enum s1 = true;
else
enum s1 = false;
version(Cumulative)
enum c1 = true;
else
enum c1 = false;
void main()
{
import std.stdio;
import test.base, test.cpu;
void test_func(ubyte op)
{
auto report = report_debug();
auto report2 = report_timing_debug();
version(OpFunctions) writeln("(Functions)");
version(OpDelegates) writeln("(Delegates)");
version(OpSwitch) writeln("(Switch)");
version(OpNestedSwitch) writeln("(NestedSwitch)");
alias Cpu!("6502", s1, c1) TX1;
writeln("NMOS ", s1, " ", c1, " func");
test_one_opcode!TX1(op, report);
writeln("NMOS ", s1, " ", c1, " bus");
test_opcode_timing!TX1(op, report2);
alias Cpu!("65C02", s1, c1) TX2;
writeln("CMOS ", s1, " ", c1, " func");
test_one_opcode!TX2(op, report);
writeln("CMOS ", s1, " ", c1, " bus");
test_opcode_timing!TX2(op, report2);
}
test_func(0x00);
}

20
test/test_new_cpu.sh Executable file
View File

@ -0,0 +1,20 @@
rdmd --force -version=OpDelegates -I.. -I../src test_new_cpu.d
rdmd --force -version=OpDelegates -version=Strict -I.. -I../src test_new_cpu.d
rdmd --force -version=OpDelegates -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpDelegates -version=Strict -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpFunctions -I.. -I../src test_new_cpu.d
rdmd --force -version=OpFunctions -version=Strict -I.. -I../src test_new_cpu.d
rdmd --force -version=OpFunctions -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpFunctions -version=Strict -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpSwitch -I.. -I../src test_new_cpu.d
rdmd --force -version=OpSwitch -version=Strict -I.. -I../src test_new_cpu.d
rdmd --force -version=OpSwitch -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpSwitch -version=Strict -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpNestedSwitch -I.. -I../src test_new_cpu.d
rdmd --force -version=OpNestedSwitch -version=Strict -I.. -I../src test_new_cpu.d
rdmd --force -version=OpNestedSwitch -version=Cumulative -I.. -I../src test_new_cpu.d
rdmd --force -version=OpNestedSwitch -version=Strict -version=Cumulative -I.. -I../src test_new_cpu.d