If I have an address bus of 64K, i.e. it can access 64*1024 or 65536 locations, should I also have a memory chip with 65536 locations in it? What I'm trying to ask is that do all the 65536 locations that the address bus can address have a corresponding memory location? Or can some address bus values go unused? (Like when I have 65536 address locations but my memory chip has only 32768 locations) Is such a combination acceptable?


What you are looking for is named "address decoding".

If a processor can address 64kB, its address bus is something like A[15:0]. If you use a 1kB memory chip, its addresses will be A[9:0].

There are several options :

  • Either you don't connect the bits A[15:10] of the processor. The memory will be mirrored at several "places" in the CPU address map, in this example, the same memory cell is accesssed at address 0, 1024, 2048, 3072, ... etc.
  • Or you use additional hardware to select the memory chip only when A[15:10]=00000, for example, to map the RAM only between 0 and 1023, allowing to connect other chips and map them elsewhere in the address map : ROM, IO ports...

If a memory location is not mapped, when an read access is attempted, it will generate random noise, some default value or repeat the last access. This was true on simple CPUs (for example the old 8bits CPUs)

In more advanced architectures (typically build with 16 or 32bits CPUs), accesses to non mapped memories generates an exception usually named "Bus Error".

  • $\begingroup$ What do you mean by mapping and address map? $\endgroup$ – noorav Apr 20 '19 at 3:34
  • $\begingroup$ @noorav. A CPU is never connected to a single memory. There are always RAM, ROM, some peripherals, extension boards.... Each of these parts is assigned a range of addresses = Address mapping. Most of the mapping is arbitrary, except for things like RESET vector, where the CPU starts execution at a fixed address after power-up, so that address need to be allocated to some nonvolatile memory. $\endgroup$ – TEMLIB Apr 20 '19 at 19:51
  • $\begingroup$ So would memory mapping mean assigning an address to that memory? Like, giving a number to pinpoint the physical location of that memory in a RAM? $\endgroup$ – noorav Apr 21 '19 at 6:55
  • $\begingroup$ Maybe you can look for examples : amigacoding.com/index.php/Amiga_memory_map. PCs are a bit special because of a dedicated IO ports address space. $\endgroup$ – TEMLIB Apr 21 '19 at 10:36
  • $\begingroup$ does every instruction/word in the RAM have a fixed address value that doesn't change at all and is permanent? Or does any given instruction that is stored in the memory have different address values at different times? $\endgroup$ – noorav Apr 21 '19 at 10:52

Yes. You can have a smaller memory chip. Trying to read or write an address beyond that range might cause unpredictable behavior or meaningless results, so you'd want to avoid doing that.

  • $\begingroup$ So basically, to avoid the aforementioned problem, in any computer hardware, is the size of the address bus equal to the size of the memory? $\endgroup$ – noorav Apr 19 '19 at 20:15
  • $\begingroup$ @noorav, No, it's not. $\endgroup$ – D.W. Apr 19 '19 at 21:11
  • $\begingroup$ One needs also to be careful from decoding writing to a "non-existing" address as writing to a lower address. This can be avoided by, e.g., enabling the memory's Chip Select (CS) only when the address is within the chip's limits. $\endgroup$ – Ran G. Apr 20 '19 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.