gergoerdi / clash-spaceinvaders

Intel 8080-based Space Invaders arcade machine implemented on an FPGA, written in CLaSH
MIT License
47 stars 3 forks source link

Proper memory access arbitration between video system and CPU #2

Closed gergoerdi closed 5 years ago

gergoerdi commented 5 years ago

Get rid of doubled VRAM by simply not letting the CPU access VRAM while it is needed by the video system:

gergoerdi commented 5 years ago

Note that because we have access to dual-port block RAM, there is no need to arbitrate on writes.

gergoerdi commented 5 years ago

One easy (but perhaps, too easy) way to implement it would be to completely suspend the CPU during drawing the visible portion of the screen. Since we run the CPU at 12x the original speed, we probably have enough time during non-visible parts to do everything.

Not sure if this would be pedagogically a useful intermediate step towards proper read arbitration.

gergoerdi commented 5 years ago

I've implemented this in 0fb3adc3cbb by changing cpuInMem to a Maybe value, and passing in Nothing when the video system is reading, once every 8 virtual (16 physical) pixels, into a shift-out register. The CPU aborts the current cycle's work in readMem if cpuInMem is Nothing, and retries in the next cycle.