So I am working on a question that requires me to find the linear address.

Here's some information:
Main memory size is 8GB, which translates to $$2^{3} * 2^{30} = 2^{33}$$.
Block size is 16KB each, which translates to $$2^{4} * 2^{10} = 2^{14}$$.

I was then required to find:

(i) The number of blocks in main memory:
$$2^{33}/2^{14} = 2^{19}$$ blocks.

(ii) The number of bits required to address a block:
$$19$$ bits.

(iii) The number of bits required for an offset within a block.
I am not so sure if I did this bit correctly, but I ended up with:
$$2^{14}$$ bits.

These are the parts that I'm having trouble calculating or knowing what to do. Can I be guided accordingly, please?
(a) Block 32, byte 100 (b) Block 1000 byte 1800.

(v) The block and offset of a byte for the linear address:
(a) 32431 (b) 232156

• Using $2^{14}$ bits for the offset would be extremely wasteful. – Yuval Filmus Nov 7 '18 at 7:16
• I made a mistake, I meant 14 bits for the offset – pythonprogrammer12 Nov 7 '18 at 22:02
• Sounds much better. – Yuval Filmus Nov 7 '18 at 22:14

Suppose that a memory of size $$M$$ is divided into blocks of size $$B$$:

• Block 0 consists of cells $$0,\ldots,B-1$$.
• Block 1 consists of cells $$B,\ldots,2B-1$$.
• Block 2 consists of cells $$2B,\ldots,3B-1$$.
• Block $$k$$ consists of cells $$kB,\ldots,(k+1)B-1$$.

The "linear address" of a cell is its address in the memory.

Another way of addressing it is by giving which block it belongs to, and what is its offset inside the block. For example, linear address $$B+2$$ corresponds to block 1, offset 2.

Given a block and an offset, you can easily compute the corresponding linear address; and given the linear address, you can easily compute the block and the offset. Rather than spelling out the arithmetic, I challenge you to come up with the requisite formulas. Using these formulas, you can complete your exercise.

• Hmm. So from what I gathered...if I were to compute the linear address for Block 32, byte 100, it would be $32B + 100$, but B here is $2^{14}$. So the overall size would be $32 * 2^{14} + 100$. – pythonprogrammer12 Nov 7 '18 at 23:19
• Am I correct for this? I will be working on coming up with the formulas – pythonprogrammer12 Nov 7 '18 at 23:19
• Yes, that’s the idea. – Yuval Filmus Nov 7 '18 at 23:20
• So I tried working out the formula for finding the block and offset. I came up with it being the linear address divided by $2^{14}$. And the remainder would be the block number? – pythonprogrammer12 Nov 7 '18 at 23:57
• Try your formula on a few cases and see if it works. – Yuval Filmus Nov 7 '18 at 23:58