// SPDX-FileCopyrightText: 2026 Jeffrey C. Ollie // // SPDX-License-Identifier: MIT const std = @import("std"); pub const FakeClock = struct { const Self = @This(); cycles: u64, /// Starts the clock at zero. The speed is accepted and ignored: nothing /// here waits on real time, it only counts. pub fn init(self: *Self, clock_speed: ?u128) void { _ = clock_speed; self.cycles = 0; } /// How many cycles have elapsed since the last reset. pub fn read(self: *const Self) u64 { return self.cycles; } /// Spends cycles. Every bus access calls this, so the count is a tally of /// what the processor did rather than a delay. pub fn sleep(self: *Self, cycles: u8) void { self.cycles +%= cycles; } /// Puts the cycle count back to zero. pub fn reset(self: *Self) void { self.cycles = 0; } };