From 9b99a0b3bcd3b39387a900492c48193c357fa0df Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Wed, 17 Jul 2024 20:24:41 +0200 Subject: [PATCH] start with z80pio tests --- src/chips/z80pio.zig | 4 ++-- tests/build.zig | 1 + tests/z80pio.test.zig | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/z80pio.test.zig diff --git a/src/chips/z80pio.zig b/src/chips/z80pio.zig index b7a1df6..efc3ccf 100644 --- a/src/chips/z80pio.zig +++ b/src/chips/z80pio.zig @@ -2,7 +2,7 @@ const bitutils = @import("common").bitutils; const mask = bitutils.mask; const maskm = bitutils.maskm; -const Z80IRQ = @import("z80irq").Z80IRQ; +const Z80IRQ = @import("z80irq.zig").Z80IRQ; /// Z80 PIO pin declarations pub const Pins = struct { @@ -197,7 +197,7 @@ pub fn Z80PIO(comptime P: Pins, comptime Bus: anytype) type { } pub fn reset(self: *Self) void { - self.reset_active = false; + self.reset_active = true; for (&self.ports) |*port| { port.mode = MODE.INPUT; port.output = 0; diff --git a/tests/build.zig b/tests/build.zig index 1f536f1..6d596de 100644 --- a/tests/build.zig +++ b/tests/build.zig @@ -39,6 +39,7 @@ pub fn build(b: *Build, opts: Options) void { "memory", "ay3891", "z80ctc", + "z80pio", }; const test_step = b.step("test", "Run unit tests"); inline for (unit_tests) |name| { diff --git a/tests/z80pio.test.zig b/tests/z80pio.test.zig new file mode 100644 index 0000000..32964b5 --- /dev/null +++ b/tests/z80pio.test.zig @@ -0,0 +1,21 @@ +const std = @import("std"); +const expect = std.testing.expect; +const chipz = @import("chipz"); +const z80pio = chipz.chips.z80pio; + +const Bus = u64; +const Z80PIO = z80pio.Z80PIO(z80pio.DefaultPins, Bus); + +const MODE = Z80PIO.MODE; +const INTCTRL = Z80PIO.INTCTRL; + +test "init Z80PIO" { + const pio = Z80PIO.init(); + try expect(pio.reset_active); + for (&pio.ports) |*p| { + try expect(p.mode == MODE.INPUT); + try expect(p.int_mask == 0xFF); + } +} + +// FIXME: more tests