AROS Vision
Modern and free Amiga-Compatible Experience on Amiga and PC
Memory Management in Amiga
The Amiga had one of the most innovative memory architectures of the 1980s. Unlike a typical PC, where the CPU controlled all memory access, the Amiga's memory was shared between the CPU and a set of custom chips (Agnus, Denise, Paula). This led to the concepts of Chip RAM and Fast RAM.
Overview
Chip RAM Accessible by CPU + Custom Chips Typical use Graphics, sprites, sound samples, bitplanes
Fast RAM Accessible by CPU only Typical use Programs, data, calculations, operating system
The key difference is:
Chip RAM is shared.
Fast RAM belongs exclusively to the CPU.
Chip RAM
Chip RAM is directly accessible by:
Motorola 68000 CPU
Agnus (DMA controller)
Denise (graphics)
Paula (audio, floppy, serial)
The custom chips continuously fetch graphics and audio data from Chip RAM using DMA (Direct Memory Access).
Example
Suppose a game stores:
Screen bitplanes
Sprites
Audio samples
All of these must reside in Chip RAM because the custom chips need direct access.
Chip RAM
+------------------+
| Program |
| Graphics |
| Sprites |
| Sound Samples |
+------------------+
Why Chip RAM Can Be Slow
The CPU does not have exclusive use of the memory bus.
During each memory cycle:
CPU may need memory
Agnus may need memory
Audio DMA may need memory
Disk DMA may need memory
Sprite DMA may need memory
All compete for access.
Agnus acts like a traffic controller.
Memory Bus
|
+--> CPU
|
+--> Audio DMA
|
+--> Video DMA
|
+--> Disk DMA
If the custom chips are busy displaying a high-resolution screen with many sprites, the CPU must wait longer.
This is called bus contention.
Fast RAM
Fast RAM was introduced to solve this problem.
Only the CPU can access Fast RAM.
Since no custom chip competes for the memory bus:
every cycle belongs to the CPU
execution becomes significantly faster
Fast RAM
+------------------+
| Program Code |
| Variables |
| Stack |
+------------------+
CPU <-----> Fast RAM
Custom Chips
X
|
No access
Why Is It Called "Fast"?
Not because the memory chips themselves are necessarily faster.
It is faster because:
the CPU never has to share it.
A 7.14 MHz 68000 in an Amiga 500 can often gain 20-50% performance simply by executing code from Fast RAM instead of Chip RAM.
Memory Map Example
Typical Amiga 500 with expansion:
000000 - 07FFFF 512 KB Chip RAM
080000 - 1FFFFF Expansion Area
200000 - 9FFFFF Fast RAM
A00000 - BFFFFF Custom Chips
C00000 - D7FFFF ROM / Autoconfig
F80000 - FFFFFF Kickstart ROM
(The exact map varies by model.)
The Role of Agnus
Agnus is the heart of memory management.
Responsibilities:
DMA controller
Memory arbiter
Refresh control
Copper execution
Blitter access
When several devices want memory simultaneously:
Agnus decides who gets the next cycle.
Video DMA gets highest priority.
Audio DMA gets high priority.
Disk DMA gets high priority.
Blitter gets remaining DMA slots.
CPU gets cycles that are left.
Simplified:
Highest Priority
|
| Video DMA
| Audio DMA
| Disk DMA
| Sprites
| Blitter
| CPU
|
Lowest Priority
This is why heavy graphics activity can slow a 68000 considerably.
DMA (Direct Memory Access)
DMA is what makes the Amiga special.
Custom chips can read memory directly without CPU intervention.
For example:
Playing Sound
Instead of:
CPU -> read sample
CPU -> send to sound chip
CPU -> repeat thousands of times
the Amiga does:
Paula DMA -> fetch sample from Chip RAM
The CPU can continue doing other work.
Fast RAM and the 68020/68030
The advantage becomes even greater on accelerated systems.
Amiga 1200
Typical configuration:
2 MB Chip RAM
8 MB Fast RAM
68030 CPU
Programs running in Fast RAM may execute several times faster than from Chip RAM because:
68020/68030 use instruction caches
wider memory paths
burst accesses
Chip RAM remains limited by access from the custom chipset.
The "32-bit Fast RAM" Advantage
On Amiga 3000 and Amiga 4000 systems:
Chip RAM bus: typically 16-bit
Fast RAM bus: often 32-bit
Therefore:
68030
|
32-bit Fast RAM
|
very high bandwidth
while graphics data still resides in Chip RAM.
What Happens When a Program Starts?
Workbench or CLI loads a program.
The operating system tries to allocate memory intelligently.
Typically:
Code -> Fast RAM
Stack -> Fast RAM
Data -> Fast RAM
Bitmaps -> Chip RAM
Audio -> Chip RAM
Programmers can explicitly request memory types:
AllocMem(size, MEMF_CHIP);
or
AllocMem(size, MEMF_FAST);