jac_goudsmit wrote:
The idea is not restrained to 2 CPUs. As long as only one CPU at a time has a clock that's in the HIGH state, you're good.
Good point, though it would somewhat defeat the point of having multiple cores (or at least, more than two), since they'd effectively be operating in a round-robin fashion rather than truly in parallel.
Also, I've thought about it a little more, and the high/low clock solution doesn't actually solve the underlying issue with RMW instructions (though I do agree is removes the need for dual-port RAM)....
Example:
CPU A enters an INC RMW cycle, reads out a '5' from memory.
CPU B, on the low half of the cycle, starts an INC RMW cycle, reads '5' from the same memory.
CPU A, writes back '5'+1 = '6'.
CPU B, writes back '5'+1 = '6'.
We now have '6' in the memory when we ought to have had '7'. Had ML been used to block CPU B, the answer would have been the correct '7'.
---
The circuit pictured in the attachment
almost does what I need...
When the Slave attempts to access the shared RAM whilst the Master's ML is asserted then the BUSY signal to the slave is asserted, stopping it in its tracks until the Master releases its ML. The 7475 flip-flop ensures once one of the two BUSY signals are asserted, the other one cannot be asserted until both have been deasserted, since there's never a reason to block both simultaniously: this ensures forward progress is always made
All of the above is true of the reverse relationship as well.
There are two problems with this circuit: if the Master and Slave both assert their MLs or CEs in the same cycle with either or both of the other signals also asserted, then both BUSY outputs might be asserted, halting all forward progress. The other problem is that the circuit unecessarily stops the Slave when the Master's ML is asserted but it is not accessing the shared RAM (i.e. Master CE is not asserted), and vice-versa.
EDIT: ... and I just thought of another complication. Say Slave CE and Master ML are asserted, so the slave gets halted by BUSY. Now the Master continues and happens to access the same memory address that the Slave was in the middle of writing - because BUSY is hooked up to the 6502's RDY input, the address bus etc on the dual-port RAM is still on the same address. This causes the dual-port RAM to report a contention, which causes it to assert the Master's BUSY signal. Now both BUSYs are asserted and no forward progress is possible. Though actually this may not be possible since ML is asserted first during a read, so maybe the blocked side would always block on a read, which would be OK? .... maybe it would just be easier to ban RMW instructions on the shared RAM, this is getting complicated.
_________________
Want to design a PCB for your project? I strongly recommend
KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of
Retro Computing and
Arduino components you might find useful.