Kodewerx

Our culture has advanced beyond all that you could possibly comprehend with one hundred percent of your brain.
It is currently Thu Oct 03, 2024 12:56 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [solved]
PostPosted: Wed Oct 08, 2014 2:21 pm 
Offline
Kommunist
Kommunist
User avatar

Joined: Wed Oct 08, 2014 2:15 pm
Posts: 5
Hey, long time lurker here, couldn't use my other account for some reason so I just made this for now. I'm finally studying computer science and just started. I got this question however at one of my lectures and since my lecturer doesn't have the best English its a bit confusing to understand.

Code:
6. How many bits are required to address a 4M x 32-bit main memory if
a. main memory is word-addressable?
b. main memory is byte-addressable?


Many thanks if you provide any help


Last edited by ChickenzRage0 on Mon Nov 17, 2014 5:09 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 08, 2014 6:29 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:46 pm
Posts: 2331
Location: *poof*
Title: The Mad Hacker
Google?
http://electronics.stackexchange.com/qu ... addressing

I don't have a best guess at what 4M means.

_________________
Image


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 09, 2014 9:41 am 
Offline
Kommunist
Kommunist
User avatar

Joined: Wed Oct 08, 2014 2:15 pm
Posts: 5
4M means 4 Mega which is 2^22 (2^2 * 2^20)


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 12, 2014 12:15 am 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
The math is pretty simple, actually. 4Mbit = 0x400000 bits. Divide by 8 to get the total number of bytes = 0x80000. Divide again by 4 to get the total number of words = 0x20000.
Now subtract 1 from each of these and count the number of set bits:

0x7FFFF = 19 bits for byte-addressable.
0x1FFFF = 17 bits for word-addressable.

In other words, the chip requires 19 address lines and 8 data lines (4M x 8) or 17 address lines and 32 data lines (4M x 32)

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 12, 2014 6:14 am 
Offline
Kommunist
Kommunist
User avatar

Joined: Wed Oct 08, 2014 2:15 pm
Posts: 5
Right, he posted the answers and they were different. Copy pasta doesn't really work so I'll just upload a pic.
Also apparently
Quote:
In a word-addressable system, a word is the smallest
addressable unit of storage.


Attachments:
Untitled.png
Untitled.png [ 13.52 KiB | Viewed 8564 times ]
Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 12, 2014 12:26 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
Nice! What I screwed up was dividing a pre-divided number. ;)

The full memory size for 4M x 32 is 128M (multiply: 4*32)
It's already word-addressable, so it has 0x3FFFFF = 22 address lines.
To make it byte-addressable, you have to multiply by 4: 0xFFFFFF = 24 address lines.

It makes perfect sense.

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 12, 2014 12:36 pm 
Offline
Kommunist
Kommunist
User avatar

Joined: Wed Oct 08, 2014 2:15 pm
Posts: 5
Alright, thanks I understand the question now. I however have not come across this notation yet
Quote:
0x3FFFFF
0xFFFFFF

Are these numbers in hex? And why is there a 0x at the beginning?


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 12, 2014 3:06 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
It is hexadecimal notation, yes. The 0x prefix is the common hex notation prefix. Though $ has also been used, primarily in old (DOS era) applications which had very little screen space.

Prepare yourself for ...

Parasyte's Number Representation Tutorial

Hex is just another number representation. Whereas decimal is base-10, and binary is base-2; hexadecimal is base-16. Converting between different number bases is just a matter of expressing each number as a polynomial equation, and working out the exponents. Here's an example using 222:

1. Polynomial expansion of a base-2 number

222 = 1*222 + 0*221 + 0*220 + 0*219 ... + 0*22 + 0*21 + 0*20

The final 20 can usually be discarded, since any positive number raised to an exponent of 0 is always equal to 1. And the penultimate exponent can also be discarded, because raising any positive number to an exponent of 1 is always equal to the original base. Simplify:

222 = 1*222 + 0*221 + 0*220 + 0*219 ... + 0*22 + 0*2 + 0

Of course, we can also simplify further by removing all the polynomial segments that are 0:

222 = 1*222

And multiplying by 1 is redundant, so we come full circle:

222 = 222

This example is rather boring, because only one digit is set. Things get a little more crazy when converting to base-10 and base-16. So here we go!

2. Polynomial expansion of a base-10 number

In base-2, each digit may have 2 possible values: 0 or 1. In base-10, each digit may have 10 possible values: 0 through 9. This property alone explains the number in the "base".

Let's take a base-10 number: 4194304 and expand this number as a polynomial expression:

4194304 = 4*106 + 1*105 + 9*104 + 4*103 + 3*102 + 0*101 + 4*100

Super easy; each digit in the base-10 number is simply multiplied by the polynomial. Simplify if you like:

4194304 = 4*106 + 1*105 + 9*104 + 4*103 + 3*102 + 4

3. Convert each sub-expression to base-2

4 = 22
3*102 = 300 = 256+32+8+4 = 28 + 25 + 23 + 22
4*103 = 4000 = 2048+1024+512+256+128+32 = 211 + 210 + 29 + 28 + 27 + 25
9*104 = 90000 = 65536+16384+4096+2048+1024+512+256+128+16 = 216 + 214 + 212 + 211 + 210 + 29 + 28 + 27 + 24
1*105 = 100000 = 65536+32768+1024+512+128+32 = 216 + 215 + 210 + 29 + 27 + 25
4*106 = 4000000 = 2097152+1048576+524288+262144+65536+2048+256 = 221 + 220 + 219 + 218 + 216 + 211 + 28

And add all of the expanded expressions together. This is made easier by grouping common exponents, and recursively solving for those. To add exponents, take each group of two common exponents and reduce by removing one expression, and increasing the exponent by 1. For example, there are two 22:

(22 + 22) = 23

So here's the full series, grouped, and followed by the solution for the first iteration:

221 + 220 + 219 + 218 + (216 + 216) + 216 + 215 + 214 + 212 + (211 + 211) + 211 + (210 + 210) + 210 + (29 + 29) + 29 + (28 + 28) + (28 + 28) + (27 + 27) + 27 + (25 + 25) + 25 + 24 + 23 + (22 + 22) =
221 + 220 + 219 + 218 + (217) + 216 + 215 + 214 + 212 + (212) + 211 + (211) + 210 + (210) + 29 + (29) + (29) + (28) + 27 + (26) + 25 + 24 + 23 + (23)

You'll notice the way I grouped these exponents is in groups of two. That's very important. Regroup, and solve again:

221 + 220 + 219 + 218 + 217 + 216 + 215 + 214 + (212 + 212) + (211 + 211) + (210 + 210) + (29 + 29) + 29 + 28 + 27 + 26 + 25 + 24 + (23 + 23) =
221 + 220 + 219 + 218 + 217 + 216 + 215 + 214 + (213) + (212) + (211) + (210) + 29 + 28 + 27 + 26 + 25 + 24 + (24)

And again: (Yay! Recursion!)

221 + 220 + 219 + 218 + 217 + 216 + 215 + 214 + 213 + 212 + 211 + 210 + 29 + 28 + 27 + 26 + 25 + (24 + 24) =
221 + 220 + 219 + 218 + 217 + 216 + 215 + 214 + 213 + 212 + 211 + 210 + 29 + 28 + 27 + 26 + 25 + (25)

... until there are no more common exponents ...

221 + 220 + 219 + 218 + 217 + 216 + 215 + 214 + 213 + 212 + 211 + 210 + 29 + 28 + 27 + 26 + (25 + 25) =
221 + 220 + 219 + 218 + 217 + 216 + 215 + 214 + 213 + 212 + 211 + 210 + 29 + 28 + 27 + 26 + (26)

The pattern at this point is pretty obvious. If we continue this iteration, we will eventually simplify to 222. :) This is just a long-hand explanation for how addition with carry works in binary.

4. What are those magic numbers?

There are some magic numbers in the equations above. Take for instance this line:

Quote:
3*102 = 300 = 256+32+8+4 = 28 + 25 + 23 + 22


The numbers 256, 32, 8, and 4 are "magic" numbers, because I didn't really explain how I got them. Obviously, they are the result of solving the exponents on the right side, but there's also no explanation for how I came up with these numbers, either. The answer is kind of depressing; it's just a matter of estimation. You need to answer the question, "what's the biggest power-of-two that fits into 300?" It turns out to be 256, because the next power-of-two is 512, which is greater than 300. Thus, 28 fits into 300, but 29 does not. Subtract the 256 from 300, and find the biggest power-of-two that fits into that result:

300 - 256 = 44
22 = 4
23 = 8
24 = 16
25 = 32
26 = 64

Therefore 32 fits into 44, and 25 is the next polynomial segment. Repeat until the number is solved. The same estimation steps can be used to convert the other way, as well. Which is what we'll see in the following section.

5. TL;DR: Onward to base-16

The biggest power-of-sixteen that fits into 222 is 165 = 220, because 20 is evenly divisible by 4. Why 4? It takes 4 bits to represent one hex digit. This is defined by 16 = 24

In fact, 165 fits into 222 exactly 4 times. So:

222 = 4*165

Which can also be written in hex notation as a 4 followed by 5 zeros: 0x400000.

Fin.

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 13, 2014 3:31 am 
Offline
Kommunist
Kommunist
User avatar

Joined: Wed Oct 08, 2014 2:15 pm
Posts: 5
Ah, yeah I didn't need that much of an explanation, I am already able to convert any base 10 number to any base. My mistake was thinking 0x400000 represented 22, (causing me to confuse myself) when it was actually 2^22. Now it makes perfect sense (and I feel stupid). And the 0x part is just a prefix to show that the number is in hex. Anyway thanks for posting such helpful info, Ill be learning assembly soon so I may be back. (I'm also learning java)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group