Skip to content

Commit

Permalink
start with z80pio tests
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Jul 17, 2024
1 parent 595584f commit 9b99a0b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/chips/z80pio.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
21 changes: 21 additions & 0 deletions tests/z80pio.test.zig
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9b99a0b

Please sign in to comment.