Monday, December 15, 2008

RAMble

This is another old article from the depths of my hard drive, its going up partially for my own reference as the address space sizes per bit is useful from time to time, and also coz I might as well make it public again, someone may find it useful/interesting too.

Its all about RAM and how it is addressed....

Despite the complexity of the chips themselves the actual way they are used is pretty simple. Every RAM chip has address input lines, and data I/O lines. At this point its worth saying that RAM chips come in different types with different capacity per location. I am working with 8 bit chips predominantly as I am working with an 8 bit system. By 8 bit I mean that every memory location (as defined by the address lines) contains 8 bits - 1 byte. You can get 16 bit chips that hold 16 bits (aka a WORD) per location. They also have a CS (chip select) and a WR (write) line, the last two lines are control signals, in most systems you will have multiple RAM chips sat on the same bus, they will be connected together in a ladder formation on the board, but then can be thought of as piggybacking on top of each other, with the address and data lines all connected. The CS line tells the chip to shutup or to be active, when its told to shut up it turns off its data lines and does not talk on the data bus, clearly you should only have 1 RAM chip active at any given time or you would get confusion on the bus. By bus I just mean the group of 8 data lines, literally just 8 copper tracks that run from the RAM to the CPU.

The address bus comprises of 16 lines from the CPU and these just refer to a certain number, starting with A0 these lines are named A0 to A15.

The addressable memory of a system is not actually tied to the "bit" number of the CPU, i.e. an 8 bit CPU does not necessarily have 8 bits of address space. The Z80 is an 8 bit CPU, but it has a 16 bit address space. With its 16 address lines (A0-A15) it can refer to 65535 distinct memory locations. Think of the address spaces as a binary number - if you have 16 digits, in binary these can be either on or off, the largest decimal number a 16 bit binary number can describe is 65535. Each of these memory locations contains 8 bits, or 1 byte, therefore the Z80 can access a maximum of 65535x8 bits, which is 64KB. To access any larger amount you would need additional address lines, adding 1 more address line (A16 - i.e. the 17th address line) would permit you to address 128KB of RAM if its an 8 bit system. Some early supercomputers actually had 18 bit address spaces which permit you to define enough memory locations for 256KB.

Any 8 bit computer that claims to have more than 64KB is actually using paging, the CPU can only be connected to 64KB at any given time. As the RAM chips share the same data bus - ie the same set of copper tracks to the CPU it is possible to shut them all down bar the single RAM chip that is in use at that time. Usually this is done in 32KB lumps, the lower 32KB remains constantly connected to the CPU (otherwise it would forget what it was doing) and the upper 32KB is swapped in and out as required. As long as only 1 RAM chip is active at any given time the system works. Due to the way binary numbers work and the fact that the system work on electrical voltage states it is possible to use the address line activity to shut down or activate the right chip. If each chip holds a maximum of 32KB then if the 16th address line is high (ie a 1) then you rig up the logic to put the lower 32KB chip in standby, and bring the upper 32KB chip back to life. After all if that address line stays high then the memory it is accessing at that point has to be above 32KB, ie in the upper RAM chip.

Of course even with paging in blocks of RAM the whole 64KB limit was a severe limitation, recently processors have hit the limit of the 32bit address space. Back in 1988 when CPUs moved to a 32bit bus the amount of addressable space seemed beyond anyone's wildest dreams, a whole 4 Gigabytes, memory that would cost more than the price of 2 or 3 houses. Imagine spending 900,000 pounds on RAM today and you get the idea of how impossible it seemed that we would get there, but with only 32 digits that can be 0 or 1 you can only define 4GB of address space. A 32 bit PC will never be able to see more than 4GB of ram, it is blind to anything above that, due to various reasons you wont actually get al whole lot of use out of your 4th GB as the address space is borrowed for other purposes as when the standards were laid down it was thought that there would never be any physical RAM at those address locations.

Some PCs will not support RAM up to 4GB anyway - this is because they chose an upper number when designing the board and didn't etch a full complement of 32 address lines. If they only gave the board 30 lines the max you could ever get the system to see would be 1GB. The fewer address lines the simpler the board can be, the fewer board layers are needed and the cheaper it all becomes to make. The CPU still has a 32bit address space but the system bus only has 30 bits to play with. The Atari ST used a M68000 a 16 bit processor with in-theory a 32 bit bus, in theory the 68000 could address 4GB but the upper 8 bit of the address space were simply ignored when it came to talk to the bus, it only has 24 bits of address space, the CPU would have needed 4 more pins to cope with a full 32bit address space. Ditching the upper byte meant the 68000 could address a maximum of 16MB, but in the ST the memory management unit and the PCB were only wired with 22 address lines, so the max an ST could ever see and use (without modifications involving wires soldered onto the CPU) was 4MB, a shed load of RAM for the time. Spending the money deploying a full 32bit address bus would be money wasted making the board much more complicated to support memory amounts that users would never install.

1 -single byte
11 - 4 bytes
111- 8 bytes
1111- 16 bytes
11111- 32 bytes
111111-64 bytes
1111111-128 bytes
11111111- 256 bytes
111111111-512 bytes
1111111111- 1KB
11111111111- 2KB
111111111111- 4KB
1111111111111- 8KB
11111111111111- 16KB
111111111111111- 32KB
1111111111111111- 64KB
11111111111111111- 128KB
111111111111111111- 256KB
1111111111111111111- 512KB
11111111111111111111- 1MB
111111111111111111111- 2MB
1111111111111111111111- 4MB
11111111111111111111111- 8MB
111111111111111111111111- 16MB
1111111111111111111111111- 32MB
11111111111111111111111111- 64MB
111111111111111111111111111- 128MB
1111111111111111111111111111- 256MB
11111111111111111111111111111-512MB
111111111111111111111111111111- 1GB
1111111111111111111111111111111- 2GB
11111111111111111111111111111111- 4GB


Going to a 64bit address space takes you back in to the realms of insane amounts of RAM, which would again cost you more than a good few houses. 64 bits can define enough ram locations for 16Exabytes of storage. More than we will ever probably see in a home system. People have made claims about that before but this time there is probably a good reason why it will never happen, the fact that people only live for about 80 odd years. Assuming you took HD video of your entire life you would never fill 16EB of storage, and even then if you did amass that amount of data there is no way you would want to store it in a RAM system. Writing it to disk is another matter and doesn't follow the same constraint as its not based on blocks of space defined by large binary patterns. So 16EB is more RAM than you could ever fill, and you would never store that much data in that way anyway. So somewhere between 4GB and the 16EB is the figure of "more than you will ever need".

Modern 64bit PC motherboards so not have 64 address lines anyway, its pointless to design it that way. By the time that amount of RAM becomes a viable option the motherboard would have been landfill for well over a decade. The board would be significantly more difficult and expensive to make and no one would ever benefit. You can safely assume that if a modern PC board will take say 16GB of RAM, then only 34 address lines have been designed and laid out.

In fact the current 64bit CPUs don't even bother with the fully 64bit address space, the AMD Athlon X2 only has 40 address lines, the max this chip will every be able to address is 1TB, again that's more than the chip is ever likely to see in its lifetime. Even internally it can only understand address ranges that are 48 bit - or 256TB, this is its entire viewable range and applies to virtual as well as physical RAM.

111111111111111111111111111111111- 8GB
1111111111111111111111111111111111- 16GB
11111111111111111111111111111111111- 32GB
111111111111111111111111111111111111- 64GB
1111111111111111111111111111111111111- 128GB
11111111111111111111111111111111111111- 256GB
111111111111111111111111111111111111111- 512GB
1111111111111111111111111111111111111111- 1TB
11111111111111111111111111111111111111111- 2TB
111111111111111111111111111111111111111111- 4TB
1111111111111111111111111111111111111111111- 8TB
11111111111111111111111111111111111111111111- 16TB
111111111111111111111111111111111111111111111- 32TB
1111111111111111111111111111111111111111111111- 64TB
11111111111111111111111111111111111111111111111- 128TB
111111111111111111111111111111111111111111111111- 256TB
1111111111111111111111111111111111111111111111111- 512TB
11111111111111111111111111111111111111111111111111- 1PB
111111111111111111111111111111111111111111111111111- 2PB
1111111111111111111111111111111111111111111111111111- 4PB
11111111111111111111111111111111111111111111111111111- 8PB
111111111111111111111111111111111111111111111111111111- 16PB
1111111111111111111111111111111111111111111111111111111- 32PB
11111111111111111111111111111111111111111111111111111111- 64PB
111111111111111111111111111111111111111111111111111111111- 128PB
1111111111111111111111111111111111111111111111111111111111- 256PB
11111111111111111111111111111111111111111111111111111111111- 512PB
111111111111111111111111111111111111111111111111111111111111- 1EB
1111111111111111111111111111111111111111111111111111111111111- 2EB
11111111111111111111111111111111111111111111111111111111111111- 4EB
111111111111111111111111111111111111111111111111111111111111111- 8EB
1111111111111111111111111111111111111111111111111111111111111111- 16EB

Go towards 128bit/256bit/512bit address spaces and I think you start getting into the realms of more atoms than there are in the solar system, i.e. if every atom in the solar system was made part of a RAM system somehow and each atom represented 1 bit you would run out of atoms to use before you filled the address space, don't take my word for that as I have no plans to count any further. :)

3 comments:

TopCanandian said...

The thrill of the ball spinning and landing in one of the pockets is one of the things that roulette players enjoy the most. The excitement increases https://dailycandidnews.com/online-casino-streaming-the-way-its-changing-the-gambling-industry/ when the game is live.
Easy to learn: Unlike some games, you don’t need a rulebook to place bets on your favorite live roulette form. Once you get a hold of the basics, you’re good to go.

TopCanandian said...
This comment has been removed by the author.
Anonymous said...

Very rapidly this web page will be famous amid all blogging and site-building users, due to its pleasant articles or reviews Spot on with this write-up, I truly believe that this site needs a great deal more attention. I’ll probably be back again to read more, thanks for the info!

10th Class Exam Result 2022 RBSE Board | RAJASTHAN BOARD 12TH Exam RESULT 2022 NAME WISE के अनुसार चेक करें.

Followers