Size of virtual addresses

I am stuck with this issue which I am studying tomorrow. (I understand the concept of virtual or physical addresses, page frames, address bus, etc.)

If you're using 4K pages with 128KB of RAM and a 32-bit address bus, how big can a virtual address be? How many regular page frames can you have?

EDIT: I believe the answer is 2 ^ 32 and 2 ^ 20. I just don't know how to calculate this.

0


source to share


1 answer


Your answers are correct.

With a 32-bit address bus, you can access virtual space from 2 ^ 32 unique addresses.

Each 4K page uses 2 ^ 12 (physical) addresses, so you can fit (2 ^ 32) / (2 ^ 12) = 2 ^ 20 pages into space.

Good luck with your exam!


Edit to answer questions in comments:

How do you know you cannot access more than 2 ^ 32 addresses?



A 32-bit address bus means that there are 32 wires connected to the destination RAM - each wire is represented by one of the bits. Each wire is held at either high or low voltage, depending on whether the corresponding bit is 1 or 0, and each particular combination of ones and zeros represented by a 32-bit value such as 0xFFFF0000 selects the appropriate memory location. With 32 wires, there are 2 ^ 32 unique voltage combinations on the address pins, which means you can access 2 ^ 32 locations.

How about 4K page size?

If the system has a 4K page size, that means that the RAM chips on each page have 12 address bits (because 2 ^ 12 = 4K). If your hypothetical system has 128KB of RAM, you need 128KB / 4K = 32 pages or a set of RAM chips. So you can use 12 bits to select the physical address on each chip by routing the same 12 wires to the 12 address pins on each RAM chip. Then use 5 more wires to select which of the 32 pages contains the required address. We used 12 + 5 = 17 address bits to access 2 ^ 17 = 128KB of RAM.

Let's take the last step and imagine that 128KB of RAM is on the memory card. But with a 32-bit address bus, you have 32-17 = 15 address bits left! You can use these bits to select one of the memory cards 2 ^ 15 = 32768, which gives you a total virtual address space of 2 ^ 32 = 4G RAM.

Is it useful outside of RAM and memory cards?

A common practice is to divide the large set of bits, like the address, into smaller subgroups to make them more manageable. Sometimes they are separated for physical reasons such as address contacts and memory cards; in other cases it is for logical reasons such as IP addresses and subnets. The beauty is that the implementation details are irrelevant to the end user. If you access memory at 0x48C7D3AB, you don’t care which of the RAM chips it is in, or how the memory works, if there is a memory location. And when you go to 67.199.15.132 you don't care if the computer is on a class C subnet as long as it takes your priorities. :-)

+6


source







All Articles