Struct Frame
pub struct Frame {
pub reset_pending: bool,
pub requests: u8,
pub polled: Option<u8>,
pub deferred: Option<u8>,
pub stalled: Option<u8>,
pub stalled_before: Option<u8>,
pub polled_i: Option<u8>,
pub halted: bool,
pub dma_stalled: bool,
}Expand description
The interrupt inputs and the poll’s memory, shared by every 65xx part.
The fields are the subclassing surface (the Python frame’s underscored attributes); a host uses the methods.
Fields§
§reset_pending: bool§requests: u8IRQ_LINE | NMI_LATCH, as the host has set them.
polled: Option<u8>The chip polls its interrupt detectors in an instruction’s last
cycle, so what counts is the requests as they stood at the end of the
second-to-last cycle (NESdev, “CPU interrupts”, “Detailed interrupt
behavior”). Usually that is the requests as they stand, and polled
is None. It holds what the poll saw instead, for the next boundary
only, when that differs: a bus callback changed a request in the last
cycle, too late (deferred, see Frame::request), or the step was
BRK, an interrupt entry or reset, which do not poll (NO_POLL). A
request the host makes between steps is taken at the next boundary,
unless that step did not poll.
deferred: Option<u8>§stalled: Option<u8>The requests as a host’s last two note_stall calls found them, for a
branch’s poll: None when the read has not been stalled.
stalled_before: Option<u8>§polled_i: Option<u8>CLI, SEI and PLP change I after the chip has polled for interrupts,
so the next boundary decides on the old I. None: poll P as it is.
halted: boolThe CPU has stopped (JAM on the NMOS part); halted_cycle decides
what a step does until reset.
dma_stalled: boolThe NMOS part’s DMA input (MOS6502.dma_stalled in the reference):
set by a host whose bus callback stretched the current read cycle
with RDY low, cleared by it on the next read that is not. SHA, SHX,
SHY and TAS look at it on their write. Kept here because the bus
callback reaches the CPU only through the frame.
Implementations§
§impl Frame
impl Frame
pub fn access(&mut self)
pub fn access(&mut self)
Make an access: confirm a request change made since the last one.
The first change since the last access keeps the requests from before
it in deferred (see Frame::request). If an access comes in the
same step, the change was before the last cycle and the poll sees it;
if the step ends first, the poll saw deferred.
pub fn request(&mut self, requests: u8)
pub fn request(&mut self, requests: u8)
Change the requests, and arrange to learn whether a bus access follows.
pub fn note_stall(&mut self)
pub fn note_stall(&mut self)
Say, from inside a read callback, that RDY is holding this read (a DMA).
Call it as the stall begins and again after each halted cycle, then make the access. The halted chip repeats the cycle and its interrupt detectors keep sampling, so a request raised during the stall is polled at the end of the read it stretched, whichever cycle that is, even the last (perfect6502 with RDY held low). A taken branch’s next-opcode read, which does not poll, takes requests raised by the start of the stall’s last halted cycle, not during it (perfect6502; AccuracyCoin “Interrupt flag latency” test A).
The frame only records what the requests were at each call, in
stalled and stalled_before; a part’s branch sequence reads them
(the NMOS one does) and resets both to None.
pub fn boundary_interrupt(&mut self, p: u8) -> u8
pub fn boundary_interrupt(&mut self, p: u8) -> u8
pub fn request_reset(&mut self)
pub fn request_reset(&mut self)
Run the start sequence at the next boundary.
The start sequence begins when RESET is released (PM section 9.2), so one request is one reset, whenever the host’s board releases the line. Reset has priority over everything, and restarts a halted CPU.
pub fn clear_reset(&mut self)
pub fn clear_reset(&mut self)
Cancel a requested reset that has not yet reached a boundary.
pub fn maskable_interrupt_pending(&self) -> bool
pub fn maskable_interrupt_pending(&self) -> bool
Whether the IRQ line is asserted.
pub fn request_maskable_interrupt(&mut self)
pub fn request_maskable_interrupt(&mut self)
Assert IRQ, a level: it stays asserted until
Frame::clear_maskable_interrupt.
Taking the interrupt does not clear it; on a board the device holds IRQ low until its handler acknowledges it, and so must the host. While it is asserted and I is clear, every poll takes the interrupt.
pub fn clear_maskable_interrupt(&mut self)
pub fn clear_maskable_interrupt(&mut self)
Release IRQ.
pub fn non_maskable_interrupt_pending(&self) -> bool
pub fn non_maskable_interrupt_pending(&self) -> bool
Whether an NMI edge has been latched and not yet taken.
pub fn request_non_maskable_interrupt(&mut self)
pub fn request_non_maskable_interrupt(&mut self)
Latch an NMI edge; the next poll takes it, whatever I says.
NMI is edge-triggered: call this on the line’s falling edge. Requests made while one is pending coalesce into one NMI.
pub fn clear_non_maskable_interrupt(&mut self)
pub fn clear_non_maskable_interrupt(&mut self)
Cancel a latched NMI that has not yet been taken, even one already polled.
pub fn poll_fields(&self) -> PollFields
pub fn poll_fields(&self) -> PollFields
The frame’s part of a state snapshot.
pub fn restore_poll(&mut self, state: &PollFields)
pub fn restore_poll(&mut self, state: &PollFields)
Restore the fields Frame::poll_fields captured.