Memory paging: Difference between revisions

From Sinclair Wiki
Jump to navigation Jump to search
Line 34: Line 34:
ROMCS is ROM Chip Select
ROMCS is ROM Chip Select


The pad 25 on solder side of [[ZX_Spectrum_16K/48K_edge_connector|edge connector]] is /ROMCS. This pad connected directly to the /CS pin of ROM. Peripherals easily "switch off" the main ROM with this pad, because the ULA /ROMCS output connected here via a 680 Ohm resistor.
The pin (really a pad) 25 on solder side of [[ZX_Spectrum_16K/48K_edge_connector|edge connector]] is /ROMCS. This pin connected directly to the /CS pin of ROM. Peripherals easily "switch off" the main ROM with this pad, because the ULA /ROMCS output connected here via a 680 Ohm resistor.


There are two limitation of this method:
There are two limitation of this method:

Revision as of 07:11, 1 May 2021

Various spectrum models and peripherals use memory paging (or memory mapping) technic to extend the 64kb memory limit of Z80 CPU.

General principles

The Z80 CPU has 16 address lines and no builtin MMU unit, so it can address maximum 64KB (2^16) memory (or I/O) space (0x0000 - 0xffff).

The original ZX Spectrum 16K/48K (or the ZX Spectrum+) only uses maximum 64KB memory (16KB ROM and 16KB or 48KB RAM), but other models (128K) and several peripheral have extra RAM or ROM.

In order to use the extra RAM or ROM machines and peripherals use some MMU (like) logic and technic:

  • /ROMCS combined with an MMU on the peripheral onboard (e.g. Interface I/II, Disk interfaces, etc)
  • built in MMU logic (e.g. 128K, +2, Timex machines)

The MMU unit determines which physical memory (ROM or RAM) address ranges (pages) reachable on which address range of the CPU (banks).

The alignement and the size of pages and banks is fixed and usually 16KB. e.g.

  • bank0 is 0x0000 to 0x3fff
  • bank1 is 0x4000 to 0x7fff
  • bank2 is 0x8000 to 0xbfff
  • bank3 is 0xc000 to 0xffff

in the CPU address space and

  • page0 is 0x00000 to 0x03fff
  • page1 is 0x04000 to 0x07fff

...

  • page7 is 0x1c000 to 0x1ffff

in the RAM.

Both method (ROMCS or builtin MMU) use some simple event to change the actual paging of ROM or RAM:

  • pull up a pad on the edge connector
  • out a byte to a specific port (e.g. 0x7ffd)
  • PC register of Z80 CPU hit a specific address
  • user press a (red) button which trigger an NMI

ROMCS method

ROMCS is ROM Chip Select

The pin (really a pad) 25 on solder side of edge connector is /ROMCS. This pin connected directly to the /CS pin of ROM. Peripherals easily "switch off" the main ROM with this pad, because the ULA /ROMCS output connected here via a 680 Ohm resistor.

There are two limitation of this method:

  • only the ROM address space (0x0000 - 0x3fff) is usable
  • there is no /ROMCS or edge connector in plus2a/b, plus3, pentagon, etc machines

MMU

MMU is Memory Management Unit.

ZX Spectrum 16/48

The ZX Spectrum 16/48 has a very symple MMU. We can say, this is only a memory management logic.

The memory address space is divided for two part:

  • lower (0x0000 - 0x7fff) where A15 (address line 15th bit) is 0
  • higher (0x8000 - 0cffff) where A15 is 1

The lower address space managed by the ULA, the higher one managed by discrete logic ICs.

The management is quite simple:

  • if /ROMCS is "floating" (or nothing to connected) the 16K ROM is mapped in the 0x0000 - 0x3fff range
  • if the /ROMCS pad connected to logical 1 (+5V) then the ROM mapped out
  • the lower 16K RAM is mapped to the 0x4000 - 0x7fff range
  • if ULA read from the range 0x4000 - 0x7fff and the CPU want to reach this address range parallel, then ULA halt the CPU (see contended memory)
  • the higher 32K RAM is mapped to the 0x8000 - 0xffff range

ZX Spectrum 128K

Other modells, clones