cen64/rsp
Giovanni Bajo 87ebca00b5 Fix a few pipelining bugs with RSP
1) Setting SP_PC was not resetting the pipeline. This caused that
changing the PC within a HALT/UNHALT sequence was still causing
previous instructions in the pipeline (at the old address) to be
executed. This is not how the hardware works: SP_PC is immediate and
discards the whole pipeline.

2) BREAK did not correctly halt the processor at the right instruction,
which in turn caused resumption after HALT to execute the wrong
set of instructions. This was caused by the fact that the SP_STATUS
change was written into the EXDF latch, which in turn takes 3 cycles
to reach completion. Instead, we now use the DFWB latch, and we cause
it to abort the RSP cycle if the processor is halted. This happens
at the beginning of next cycle, which is the correct moment.

2bis) Since we are at it, use rsp_status_write to modify the RSP in
this case, rather than a direct write to the register. This change
fixes a race condition: SP_STATUS must be accessed atomically when
cen64 runs in multithreaded mode. To use rsp_status_write, we need
to introduce a nonexisting SP_SET_BROKE bit: we use the MSB, but then
mask it out in MTC0 to avoid some code to inadvertently have that bit
set.

3) When unhalting after BREAK, it's important to keep the correct
PC which comes from the EX stage (the one that was going to be
executed if BREAK didn't occur). Before, it was using the IF PC (fetch)
which is farther in the future.

Fixes #155
2021-12-17 00:23:47 +01:00
..
cp0.c Fix a few pipelining bugs with RSP 2021-12-17 00:23:47 +01:00
cp0.h Fix a few pipelining bugs with RSP 2021-12-17 00:23:47 +01:00
cp2.c rsp: Implement CTC2. 2016-06-29 21:38:25 -04:00
cp2.h rsp: Implement CTC2. 2016-06-29 21:38:25 -04:00
cpu.c See long description 2015-07-01 18:44:21 -05:00
cpu.h Try to reduce component cycle overheads. 2016-01-30 14:58:31 -05:00
decoder.c See long description 2015-07-01 18:44:21 -05:00
decoder.h See long description 2015-07-01 18:44:21 -05:00
functions.c Fix a few pipelining bugs with RSP 2021-12-17 00:23:47 +01:00
interface.c Fix a few pipelining bugs with RSP 2021-12-17 00:23:47 +01:00
interface.h See long description 2015-07-01 18:44:21 -05:00
opcodes.c See long description 2015-07-01 18:44:21 -05:00
opcodes.h See long description 2015-07-01 18:44:21 -05:00
opcodes.md See long description 2015-07-01 18:44:21 -05:00
opcodes_priv.h rsp: Fix VNOP and VNULL 2021-03-08 20:07:19 +01:00
pipeline.c Fix a few pipelining bugs with RSP 2021-12-17 00:23:47 +01:00
pipeline.h Basic RSP LTV/STV support 2020-04-15 07:38:09 +02:00
registers.md See long description 2015-07-01 18:44:21 -05:00
vector_opcodes.md See long description 2015-07-01 18:44:21 -05:00
vfunctions.c rsp: Fix VNOP and VNULL 2021-03-08 20:07:19 +01:00