Jump to content

Contended memory

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 212.87.86.135 (talk) at 17:51, 27 November 2014 (Corrected layout.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Some of the ZX Spectrum's 64 KB addressable memory space is referred to as contended memory. With the rest of the memory, the Z80 microprocessor is the exclusive bus master, so its reads and writes operate at its full bus speed. Contended memory space, on the other hand, is shared between the ULA and the Z80 and the ULA always has priority. Contended memory occupies addresses 0x4000..0x7FFF of the Z80 memory map. This is the first 16 KB of RAM in the 48 KB machine but the entire RAM of the 16 KB machine.

Contention occurs as a result of the ULA reading the display and attributes data in this RAM to produce the TV video display. Contention does therefore not occur during horizontal flyback, vertical flyback or during the screen border.

Accesses to I/O are also contended if the ULA must read contended memory while the Z80 must access a ULA I/O port. ULA I/O ports are those with an even address (address bit 0 is a 0).

The Z80 must wait whenever the ULA needs to access contended memory before proceeding with its own contended memory read or write. The effect to the user is that programs making use of contended memory or contended I/O run commensurately slower than those avoiding it altogether.

Circuit

The ULA does not use the Z80's bus request/grant mechanism to become bus master during its contended memory accesses. Instead, it extends the high period of the Z80 clock input to stop all microprocessor activity. While this is less elegant than performing a bus request, it does gain contended memory access in fewer Z80 clocks. This removes any need for the ULA to read display data in advance, a benefit with the crowded circuitry in the full ULA.

The ULA connects directly to the memory system ICs while the Z80 connects to them through isolating series current-limit resistors. This allows the ULA and memory to drive each other while the Z80 is also driving the memory. The resistors save the Spectrum the expense of tristate bus driver ICs but use more current in the bus drivers of the various ICs.

References