Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relation between address lines and memory?

These are my assignments:

Write a program to find the number of address lines in an n Kbytes of memory. Assume that n is always to the power of 2.

Sample input: 2

Sample output: 11

I don't need specific coding help, but I don't know the relation between address lines and memory.

like image 236
Aafra Qazi Avatar asked Jul 06 '15 09:07

Aafra Qazi


2 Answers

To express in very easy terms, without any bus-multiplexing, the number of bits required to address a memory is the number of lines (address or data) required to access that memory.

Quoting from the Wikipedia article,

a system with a 32-bit address bus can address 232 (4,294,967,296) memory locations.

for a simple example, consider this, you have 3 address lines (A, B, C), so the values which can be formed using 3 bits are

A B C
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Total 8 values. So using ABC, you can access any of those eight values, i.e., you can reach any of those memory addresses.

So, TL;DR, the simple relationship is, with n number of lines, we can represent 2n number of addresses.

like image 131
Sourav Ghosh Avatar answered Nov 24 '22 06:11

Sourav Ghosh


An address line usually refers to a physical connection between a CPU/chipset and memory. They specify which address to access in the memory. So the task is to find out how many bits are required to pass the input number as an address.

In your example, the input is 2 kilobytes = 2048 = 2^11, hence the answer 11. If your input is 64 kilobytes, the answer is 16 (65536 = 2^16).

like image 37
DarkDust Avatar answered Nov 24 '22 04:11

DarkDust