Distributor edge generator re-anchoring stretches the CKP period ~0.2%

Open Beginner friendly
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rust
Domain
embedded-iot

Research direction

Start in src/engine.rs at EngineState::check_distributor_pulses and inspect how last_int0_cycle and cycles_per_ckp are used. Adjust the timing anchor so the CKP period preserves its remainder rather than snapping to total_cycles, while retaining the documented single pending SFR_IRQ behavior. Done means the measured CKP rate approaches the 1100/s ideal without reintroducing edge loss.

Written by the indexing model from the issue text.

Description

emulation-core enhancement

Carried over from the previous session's task "Fix interrupt-edge coalescing (CKP/CYP edge loss)" — the loss-causing parts are already fixed and verified; what remains is a small, bounded timing-fidelity nit.

Already fixed (no edge loss observed)

  • Edges arriving while interrupts are blocked are latched, not dropped: handle_pending_interrupts ORs incoming edges into SFR_IRQ before checking MIE/IE (src/interrupts.rs), with regression test pending_edges_remain_latched_while_interrupts_are_blocked. Landed in 773e6ca.
  • CYP cannot be missed: it is delivered as a sticky transition-detector status bit (SFR_TRNS (0x46).0, bus::signal_cyp) that the ROM read-clears in its TDC ISR. Landed in 0de4569.
  • Measured at steady 5500 rpm: CKP 1098/s (ideal 1100), TDC 183/s (ideal 183.3), CYP sync 45/s — no loss; CPU not interrupt-starved (92.7% main context).

Residual nit (this issue)

EngineState::check_distributor_pulses (src/engine.rs) emits at most one CKP edge per call and re-anchors last_int0_cycle = total_cycles. Since it runs once per instruction, each CKP period is stretched by up to one instruction's cycles — the measured ~0.2% shortfall (1098/s vs 1100/s). Fix is to advance the anchor by cycles_per_ckp (carrying the remainder) instead of snapping to total_cycles.

Note: two edges of the same source arriving before service still merge into one pending SFR_IRQ bit — that is faithful to the real hardware's single request flag and should not be "fixed".

Dominant language
Rust
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from VIRUXE/hondaecu-cli

All issues in VIRUXE/hondaecu-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.