1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Clarifies control flow.

This commit is contained in:
Thomas Harte 2021-07-06 20:28:32 -04:00
parent 704dc9bdcb
commit 8e0893bd42

View File

@ -35,29 +35,27 @@
for(int c = 0; c < 250000; c++) { for(int c = 0; c < 250000; c++) {
// Advance one cycle. Clock is 500,000 Hz. // Advance one cycle. Clock is 500,000 Hz.
_interruptSource->run_for(Cycles(2)); _interruptSource->run_for(Cycles(2));
--nextSequencePoint;
// Check for a status bit change.
const uint8_t newDividerState = _interruptSource->get_divider_state(); const uint8_t newDividerState = _interruptSource->get_divider_state();
const bool didToggle = (dividerState^newDividerState)&0x1; const bool didToggle = (dividerState^newDividerState)&0x1;
if(didToggle) {
++toggles;
}
dividerState = newDividerState; dividerState = newDividerState;
toggles += didToggle;
--nextSequencePoint;
// Check for the relevant interrupt. // Check for the relevant interrupt.
const uint8_t newInterrupts = _interruptSource->get_new_interrupts(); const uint8_t newInterrupts = _interruptSource->get_new_interrupts();
if(newInterrupts & 0x02) { if(newInterrupts) {
++interrupts;
XCTAssertEqual(nextSequencePoint, 0); XCTAssertEqual(nextSequencePoint, 0);
XCTAssertTrue(didToggle);
nextSequencePoint = _interruptSource->get_next_sequence_point().as<int>(); nextSequencePoint = _interruptSource->get_next_sequence_point().as<int>();
}
// Failing that, confirm that the other interrupt happend. if(newInterrupts & 0x02) {
if(!nextSequencePoint) { ++interrupts;
XCTAssertTrue(newInterrupts & 0x08); XCTAssertTrue(didToggle);
nextSequencePoint = _interruptSource->get_next_sequence_point().as<int>(); } else {
// Failing that, confirm that the other interrupt happend.
XCTAssertTrue(newInterrupts & 0x08);
}
} }
XCTAssertEqual(nextSequencePoint, _interruptSource->get_next_sequence_point().as<int>(), @"At cycle %d", c); XCTAssertEqual(nextSequencePoint, _interruptSource->get_next_sequence_point().as<int>(), @"At cycle %d", c);