translate virtual address to physical address

It is given that virtual address is 16 bit long.
Hence, there are 2^16 addresses in the virtual address space.
Page Size is given to be 4 KB ( there are 4K (4 * (2 ^ 10) )addresses in a page), so the number of pages will be ( 2^16 ) / ( 2 ^ 12 ) = 2 ^ 4.
To address each page 4 bits are required.
The most significant 4 bits in the virtual address will denote the page number being referred and the remaining 12 bits will be the page offset.

One thing to remember is page size (in the virtual address space ) is always same as the frame size in the main memory. Hence the last 12 bits will remain same in the physical address as that of the virtual address.

To get the frame address in the main memory just use the first 4 bits.
Example: Consider the virtual address 0xACA1
Here A in ACA1 denotes the page number ( 10 ) and corresponding frame no is 5 ( 0101) hence the resulting physical address will be → 0x5CA1.


To translate a virtual address to a physical address (applies ONLY to this homework question), we need to know 2 things:

  • Page Size
  • Number of bits for virtual address

In this example: 16-bit system, 4KB page size and physical memory size is 64KB.

First of all we need to determine the number of needed bits to act as offset inside page.
log2(Page-Size) = log2(4096) = 12 bits for offset

Out of the 16 bits for virtual address, 12 are for offset, that means each process has 2^4 = 16 virtual pages. Each entry in page table stores the corresponding frame accommodating the page. For example:

enter image description here

Now lets translate!

First of all for ease of work lets convert 0xE12C to binary.

0xE12C = (1110 0001 0010 1100) in base 2
1110 = 14 in decimal
Entry 14 in P.T => Page frame 3.

Lets concatenate it to the 12 offset bits

Answer: (0011 0001 0010 1100) = 0x312C

Another example: 0x3A9D

0x3A9D = 0011 1010 1001 1101
0011 = 3
PageTable[3] = 10
10 in decimal = 1010 in binary
1010 1010 1001 1101 in binary = 0xAA9D