> Both. If it's in RAM, you have to keep track of whether it's been overwritten,
> which can introduce significant overhead.
I think my approach to the problem would be to partition memory space into equal sized regions and keep a bitmap. For every memory write I would set the bit associated with the region containing the memory address. Then in the dispatch loop, the code would clear the cache if the region to be executed has been written and the bitmap would also be cleared. Writes to the current execution region would also require code to do an early exit back to the dispatch loop.
For Nuance, I didn't really have to worry about this. None of the games use self-modifying code. The main processor is cached so the cache only needs to be flushed when the appropriate BIOS call is made. The three other processors are not cached but local memory is split into IRAM and DTRAM and the only way to access external memory is through DMA. The only check I make is to clear the cache for DMA reads from external memory to local IRAM. I assume that any code in the DTRAM area will be loaded by the main MPE via BIOS. This handles all existing situations so far. The instruction encodings are convoluted enough that self-modifying code would probably be more expensive than non-modifying code in both terms of speed and space so I'm not really concerned about supporting it.
> > This is how the Nuon Aries3 processor works.
> Speaking of which, is there a programmer's manual for this processor? I'd love
> to add it to my little collection of CPU/DSP documentation :)
The public version of the official documentation set is in the SDK which you can get from [url]http://www.nuon-dome.com[/url] in the downloads section. Its very detailed but there are some errors, mostly typos except in the case of the BCLR description where the real-world flag behavior is different from what is shown in the architecture document. It also omits a lot of *cough*nuances*cough*, particularly involving pixel DMA for Z-buffered formats. Most importantly, the architecture document does not contain explain the decoding scheme and completely omits instruction encodings. For these, you have to go to my instruction encoding document which is on [url]http://emuforge.org[/url] in the files section of the forums.