load81 wrote:
I "get" that memory mapping allows RAM/registers from one device to be overlayed into system RAM on a main device. I'm sure there is a more formal definition that I've run a fowl of with that statement. Nonetheless, it's the mechanism that lets me poke into system RAM on a C64 and have it "do stuff" with the VIC-II chip, the SID chip, etc.
What I don't get is how it gets implemented in the first place. I've always just taken for granted that it "just works."
So, let me ask: given an arbitrary chip/widget and a 6502 and 64k of RAM how do you create a memory mapping between the two in the first place?
Slightly simplified, but:
The CPU address bus is connected to all peripherals. (e.g. RAM, ROM, Sound Chip, Graphics controller, etc.)
Peripherals have an "
enable" signal input. They see the changing address bus (and data bus) but stay dormant until their enable signal input is set.
Other devices/chips connect to the CPU address bus and
decode the addresses and create the enable signals that connect to the peripherals.
Some peripherals also use the bottom address line or 3 - e.g. the 6522 VIA has 16 registers, so as well as it's enable input, it further decodes internally using the bottom 4 address lines
The decoder device(s) would be a comparator (match 8 inputs from 8 address lines to a fixed value), or a set of TTL logic gates or some other complex logic like a GAL or CPLD. A simple example might be:
Code:
Address is $0000 through $7FFF -> Set RAM enable signal
Address is $8000 through $FDFF -> Set ROM enable signal
Address is $FE00 through $FEFF -> Set VIA enable signal
Address is $FF00 through $FFFF -> Set ROM enable signal
That would create a "hole" in the ROM for some peripherals.
and that's essentially that. The decoding can be as simple (as above) or as complex (e.g. 4 x VIAs, 2 UARTs, RAM, ROM, Video chips, sound chips, joystick, and so on) as you want on your board.
-Gordon
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/