timing adjustments
This commit is contained in:
@@ -166,11 +166,11 @@ class BenchReplayResult:
|
||||
class ReplayConfig:
|
||||
boot_steps: int = 250_000
|
||||
per_byte_steps: int = 5_000
|
||||
steps_per_second: int = 65_000
|
||||
post_log_steps: int = 50_000
|
||||
interval_steps: int = 512
|
||||
frt1_ocia_steps: int = 512
|
||||
frt2_ocia_steps: int = 512
|
||||
frt1_ocia_steps: int | None = None
|
||||
frt2_ocia_steps: int | None = None
|
||||
clock_hz: int = 10_000_000
|
||||
p9_fast_path: bool = True
|
||||
p9_fast_input: int = 0xFF
|
||||
|
||||
@@ -232,6 +232,7 @@ def run_bench_replay(log_path: Path, *, rom_path: Path | None = None, config: Re
|
||||
interval_steps=config.interval_steps,
|
||||
frt1_ocia_steps=config.frt1_ocia_steps,
|
||||
frt2_ocia_steps=config.frt2_ocia_steps,
|
||||
clock_hz=config.clock_hz,
|
||||
p9_fast_path_enabled=config.p9_fast_path,
|
||||
p9_fast_default_input_byte=config.p9_fast_input,
|
||||
)
|
||||
@@ -243,6 +244,7 @@ def run_bench_replay(log_path: Path, *, rom_path: Path | None = None, config: Re
|
||||
f"SCR={emulator.sci1.scr:02X} SSR={emulator.sci1.ssr:02X} "
|
||||
f"rx_serviceable={int(_rx_ready(emulator))} "
|
||||
f"sci1_priority={_sci1_priority(emulator)} interrupt_mask={_interrupt_mask(emulator)} "
|
||||
f"clock_hz={emulator.clock_hz} "
|
||||
f"lcd_display={emulator.memory.lcd.display_text(lines=4)!r}"
|
||||
)
|
||||
|
||||
@@ -251,7 +253,7 @@ def run_bench_replay(log_path: Path, *, rom_path: Path | None = None, config: Re
|
||||
for host in bench_log.tx_frames:
|
||||
delta_ms = 0 if previous_tx_ms is None else max(0, host.timestamp_ms - previous_tx_ms)
|
||||
tx_frame_start_before_delay = len(emulator.sci1.tx_frames)
|
||||
steps_before = _run_steps_for_ms(emulator, delta_ms, config.steps_per_second, context)
|
||||
steps_before = _run_cycles_for_ms(emulator, delta_ms, config.clock_hz, context)
|
||||
gap_frames = tuple(emulator.sci1.tx_frames[tx_frame_start_before_delay:])
|
||||
tx_frame_start = len(emulator.sci1.tx_frames)
|
||||
steps_during_rx = _inject_host_frame(emulator, host.frame, config.per_byte_steps, context)
|
||||
@@ -335,9 +337,9 @@ def build_arg_parser() -> argparse.ArgumentParser:
|
||||
parser.add_argument("--rom", type=Path, help="ROM image path; defaults to ROM/M27C512@DIP28_1.BIN")
|
||||
parser.add_argument("--boot-steps", type=int, default=ReplayConfig.boot_steps)
|
||||
parser.add_argument("--per-byte-steps", type=int, default=ReplayConfig.per_byte_steps)
|
||||
parser.add_argument("--steps-per-second", type=int, default=ReplayConfig.steps_per_second)
|
||||
parser.add_argument("--post-log-steps", type=int, default=ReplayConfig.post_log_steps)
|
||||
parser.add_argument("--interval-steps", type=int, default=ReplayConfig.interval_steps)
|
||||
parser.add_argument("--clock-hz", type=lambda text: int(text, 0), default=ReplayConfig.clock_hz)
|
||||
parser.add_argument("--frt1-ocia-steps", type=int, default=ReplayConfig.frt1_ocia_steps)
|
||||
parser.add_argument("--frt2-ocia-steps", type=int, default=ReplayConfig.frt2_ocia_steps)
|
||||
parser.add_argument("--no-p9-fast-path", action="store_true", help="disable shortcut handling for known P9 routines")
|
||||
@@ -355,11 +357,11 @@ def main(argv: list[str] | None = None) -> int:
|
||||
config=ReplayConfig(
|
||||
boot_steps=args.boot_steps,
|
||||
per_byte_steps=args.per_byte_steps,
|
||||
steps_per_second=args.steps_per_second,
|
||||
post_log_steps=args.post_log_steps,
|
||||
interval_steps=args.interval_steps,
|
||||
frt1_ocia_steps=args.frt1_ocia_steps,
|
||||
frt2_ocia_steps=args.frt2_ocia_steps,
|
||||
clock_hz=args.clock_hz,
|
||||
p9_fast_path=not args.no_p9_fast_path,
|
||||
p9_fast_input=args.p9_fast_input,
|
||||
),
|
||||
@@ -383,9 +385,19 @@ def _inject_host_frame(emulator: H8536Emulator, frame: bytes, per_byte_steps: in
|
||||
return steps_total
|
||||
|
||||
|
||||
def _run_steps_for_ms(emulator: H8536Emulator, delta_ms: int, steps_per_second: int, context: RunContext) -> int:
|
||||
steps = int((max(0, delta_ms) * max(1, steps_per_second)) / 1000)
|
||||
return _run_steps(emulator, steps, context)
|
||||
def _run_cycles_for_ms(emulator: H8536Emulator, delta_ms: int, clock_hz: int, context: RunContext) -> int:
|
||||
target_delta_cycles = int((max(0, delta_ms) * max(1, clock_hz)) / 1000)
|
||||
target_cycles = emulator.cpu.cycles + target_delta_cycles
|
||||
completed = 0
|
||||
while emulator.cpu.cycles < target_cycles:
|
||||
context.record_pc(emulator.cpu.pc)
|
||||
try:
|
||||
emulator.step()
|
||||
except UnsupportedInstruction as exc:
|
||||
context.unsupported = str(exc)
|
||||
break
|
||||
completed += 1
|
||||
return completed
|
||||
|
||||
|
||||
def _run_steps(emulator: H8536Emulator, steps: int, context: RunContext) -> int:
|
||||
|
||||
Reference in New Issue
Block a user