Files
psxrecomp/runtime/include/psx_cycles.h
T
Matthew Stanley 5d4d4bd30b phase1.0e-a: psx_cycle_count scaffold + cycle-timing arch doc
Scaffold for guest-cycle-driven peripheral timing per
docs/CYCLE_TIMING_ARCH.md. The counter is defined and exposed via
freeze_check, but psx_advance_cycles has no callers yet — counter
stays 0. Validation: zero behavior change.

Files:
- runtime/include/psx_cycles.h: extern uint64_t psx_cycle_count;
  void psx_advance_cycles(uint32_t cycles); uint64_t psx_get_cycle_count(void);
- runtime/src/psx_cycles.c: scaffold body; peripheral hooks empty
  (1.0e-b will add sio_advance, 1.0e-c will add gpu_advance, etc.)
- runtime/CMakeLists.txt: psx_cycles.c added to PSX_SHARED_SOURCES
- runtime/src/debug_server.c: freeze_check exposes psx_cycle_count
- docs/CYCLE_TIMING_ARCH.md: design doc — single cycle clock,
  generic per-block emit (no card-specific paths), MMIO-split codegen
  per explicit user direction, IRQ-pending-vs-CPU-entry separation,
  five-step migration plan (1.0e-a..e)

Validation against 0d15e2b baseline:
- t=20s/30s tx_writes match (1160/5480)
- 4x CROSS succeeds; card txn distribution unchanged (10 reach READ_DATA)
- "MC" bytes still flow at txn 0 bytes 10-11
- psx_cycle_count = 0 throughout (no callers in this slice)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 19:04:11 -07:00

30 lines
830 B
C

#ifndef PSXRECOMP_V4_PSX_CYCLES_H
#define PSXRECOMP_V4_PSX_CYCLES_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* PSX guest CPU cycle clock — the single source of truth for guest-
* visible time. Peripherals derive all schedules from this counter.
*
* Phase 1.0e-a (scaffold): the counter exists and psx_advance_cycles is
* defined, but no caller invokes psx_advance_cycles yet. Validation:
* counter remains 0 throughout a normal session. */
extern uint64_t psx_cycle_count;
/* Advance guest time. Negative or zero is a no-op. Phase 1.0e-a body
* just updates the counter; 1.0e-b adds peripheral *_advance() calls. */
void psx_advance_cycles(uint32_t cycles);
/* Read accessor for telemetry. */
uint64_t psx_get_cycle_count(void);
#ifdef __cplusplus
}
#endif
#endif /* PSXRECOMP_V4_PSX_CYCLES_H */