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?
(iv) The linear address for:
(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

  • $\begingroup$ Using $2^{14}$ bits for the offset would be extremely wasteful. $\endgroup$ – Yuval Filmus Nov 7 '18 at 7:16
  • $\begingroup$ I made a mistake, I meant 14 bits for the offset $\endgroup$ – pythonprogrammer12 Nov 7 '18 at 22:02
  • $\begingroup$ Sounds much better. $\endgroup$ – 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.

  • $\begingroup$ 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$. $\endgroup$ – pythonprogrammer12 Nov 7 '18 at 23:19
  • $\begingroup$ Am I correct for this? I will be working on coming up with the formulas $\endgroup$ – pythonprogrammer12 Nov 7 '18 at 23:19
  • $\begingroup$ Yes, that’s the idea. $\endgroup$ – Yuval Filmus Nov 7 '18 at 23:20
  • $\begingroup$ 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? $\endgroup$ – pythonprogrammer12 Nov 7 '18 at 23:57
  • $\begingroup$ Try your formula on a few cases and see if it works. $\endgroup$ – Yuval Filmus Nov 7 '18 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.