Kodewerx http://www.kodewerx.org/forum/ 

[solved] http://www.kodewerx.org/forum/viewtopic.php?f=24&t=11447 
Page 1 of 1 
Author:  ChickenzRage0 [ Wed Oct 08, 2014 2:21 pm ] 
Post subject:  [solved] 
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 32bit main memory if a. main memory is wordaddressable? b. main memory is byteaddressable? Many thanks if you provide any help 
Author:  James0x57 [ Wed Oct 08, 2014 6:29 pm ] 
Post subject:  Re: 4Mx32bit main memory? 
Google? http://electronics.stackexchange.com/qu ... addressing I don't have a best guess at what 4M means. 
Author:  ChickenzRage0 [ Thu Oct 09, 2014 9:41 am ] 
Post subject:  Re: 4Mx32bit main memory? 
4M means 4 Mega which is 2^22 (2^2 * 2^20) 
Author:  Parasyte [ Sun Oct 12, 2014 12:15 am ] 
Post subject:  Re: 4Mx32bit main memory? 
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 byteaddressable. 0x1FFFF = 17 bits for wordaddressable. 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) 
Author:  ChickenzRage0 [ Sun Oct 12, 2014 6:14 am ]  
Post subject:  Re: 4Mx32bit main memory?  
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 wordaddressable system, a word is the smallest
addressable unit of storage.

Author:  Parasyte [ Sun Oct 12, 2014 12:26 pm ] 
Post subject:  Re: 4Mx32bit main memory? 
Nice! What I screwed up was dividing a predivided number. The full memory size for 4M x 32 is 128M (multiply: 4*32) It's already wordaddressable, so it has 0x3FFFFF = 22 address lines. To make it byteaddressable, you have to multiply by 4: 0xFFFFFF = 24 address lines. It makes perfect sense. 
Author:  ChickenzRage0 [ Sun Oct 12, 2014 12:36 pm ] 
Post subject:  Re: 4Mx32bit main memory? 
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? 
Author:  Parasyte [ Sun Oct 12, 2014 3:06 pm ] 
Post subject:  Re: 4Mx32bit main memory? 
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 base10, and binary is base2; hexadecimal is base16. 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 2^{22}: 1. Polynomial expansion of a base2 number 2^{22} = 1*2^{22} + 0*2^{21} + 0*2^{20} + 0*2^{19} ... + 0*2^{2} + 0*2^{1} + 0*2^{0} The final 2^{0} 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: 2^{22} = 1*2^{22} + 0*2^{21} + 0*2^{20} + 0*2^{19} ... + 0*2^{2} + 0*2 + 0 Of course, we can also simplify further by removing all the polynomial segments that are 0: 2^{22} = 1*2^{22} And multiplying by 1 is redundant, so we come full circle: 2^{22} = 2^{22} This example is rather boring, because only one digit is set. Things get a little more crazy when converting to base10 and base16. So here we go! 2. Polynomial expansion of a base10 number In base2, each digit may have 2 possible values: 0 or 1. In base10, each digit may have 10 possible values: 0 through 9. This property alone explains the number in the "base". Let's take a base10 number: 4194304 and expand this number as a polynomial expression: 4194304 = 4*10^{6} + 1*10^{5} + 9*10^{4} + 4*10^{3} + 3*10^{2} + 0*10^{1} + 4*10^{0} Super easy; each digit in the base10 number is simply multiplied by the polynomial. Simplify if you like: 4194304 = 4*10^{6} + 1*10^{5} + 9*10^{4} + 4*10^{3} + 3*10^{2} + 4 3. Convert each subexpression to base2 4 = 2^{2} 3*10^{2} = 300 = 256+32+8+4 = 2^{8} + 2^{5} + 2^{3} + 2^{2} 4*10^{3} = 4000 = 2048+1024+512+256+128+32 = 2^{11} + 2^{10} + 2^{9} + 2^{8} + 2^{7} + 2^{5} 9*10^{4} = 90000 = 65536+16384+4096+2048+1024+512+256+128+16 = 2^{16} + 2^{14} + 2^{12} + 2^{11} + 2^{10} + 2^{9} + 2^{8} + 2^{7} + 2^{4} 1*10^{5} = 100000 = 65536+32768+1024+512+128+32 = 2^{16} + 2^{15} + 2^{10} + 2^{9} + 2^{7} + 2^{5} 4*10^{6} = 4000000 = 2097152+1048576+524288+262144+65536+2048+256 = 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{16} + 2^{11} + 2^{8} 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 2^{2}: (2^{2} + 2^{2}) = 2^{3} So here's the full series, grouped, and followed by the solution for the first iteration: 2^{21} + 2^{20} + 2^{19} + 2^{18} + (2^{16} + 2^{16}) + 2^{16} + 2^{15} + 2^{14} + 2^{12} + (2^{11} + 2^{11}) + 2^{11} + (2^{10} + 2^{10}) + 2^{10} + (2^{9} + 2^{9}) + 2^{9} + (2^{8} + 2^{8}) + (2^{8} + 2^{8}) + (2^{7} + 2^{7}) + 2^{7} + (2^{5} + 2^{5}) + 2^{5} + 2^{4} + 2^{3} + (2^{2} + 2^{2}) = 2^{21} + 2^{20} + 2^{19} + 2^{18} + (2^{17}) + 2^{16} + 2^{15} + 2^{14} + 2^{12} + (2^{12}) + 2^{11} + (2^{11}) + 2^{10} + (2^{10}) + 2^{9} + (2^{9}) + (2^{9}) + (2^{8}) + 2^{7} + (2^{6}) + 2^{5} + 2^{4} + 2^{3} + (2^{3}) You'll notice the way I grouped these exponents is in groups of two. That's very important. Regroup, and solve again: 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{17} + 2^{16} + 2^{15} + 2^{14} + (2^{12} + 2^{12}) + (2^{11} + 2^{11}) + (2^{10} + 2^{10}) + (2^{9} + 2^{9}) + 2^{9} + 2^{8} + 2^{7} + 2^{6} + 2^{5} + 2^{4} + (2^{3} + 2^{3}) = 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{17} + 2^{16} + 2^{15} + 2^{14} + (2^{13}) + (2^{12}) + (2^{11}) + (2^{10}) + 2^{9} + 2^{8} + 2^{7} + 2^{6} + 2^{5} + 2^{4} + (2^{4}) And again: (Yay! Recursion!) 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{17} + 2^{16} + 2^{15} + 2^{14} + 2^{13} + 2^{12} + 2^{11} + 2^{10} + 2^{9} + 2^{8} + 2^{7} + 2^{6} + 2^{5} + (2^{4} + 2^{4}) = 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{17} + 2^{16} + 2^{15} + 2^{14} + 2^{13} + 2^{12} + 2^{11} + 2^{10} + 2^{9} + 2^{8} + 2^{7} + 2^{6} + 2^{5} + (2^{5}) ... until there are no more common exponents ... 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{17} + 2^{16} + 2^{15} + 2^{14} + 2^{13} + 2^{12} + 2^{11} + 2^{10} + 2^{9} + 2^{8} + 2^{7} + 2^{6} + (2^{5} + 2^{5}) = 2^{21} + 2^{20} + 2^{19} + 2^{18} + 2^{17} + 2^{16} + 2^{15} + 2^{14} + 2^{13} + 2^{12} + 2^{11} + 2^{10} + 2^{9} + 2^{8} + 2^{7} + 2^{6} + (2^{6}) The pattern at this point is pretty obvious. If we continue this iteration, we will eventually simplify to 2^{22}. This is just a longhand 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*10^{2} = 300 = 256+32+8+4 = 2^{8} + 2^{5} + 2^{3} + 2^{2} 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 poweroftwo that fits into 300?" It turns out to be 256, because the next poweroftwo is 512, which is greater than 300. Thus, 2^{8} fits into 300, but 2^{9} does not. Subtract the 256 from 300, and find the biggest poweroftwo that fits into that result: 300  256 = 44 2^{2} = 4 2^{3} = 8 2^{4} = 16 2^{5} = 32 2^{6} = 64 Therefore 32 fits into 44, and 2^{5} 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 base16 The biggest powerofsixteen that fits into 2^{22} is 16^{5} = 2^{20}, because 20 is evenly divisible by 4. Why 4? It takes 4 bits to represent one hex digit. This is defined by 16 = 2^{4} In fact, 16^{5} fits into 2^{22} exactly 4 times. So: 2^{22} = 4*16^{5} Which can also be written in hex notation as a 4 followed by 5 zeros: 0x400000. Fin. 
Author:  ChickenzRage0 [ Mon Oct 13, 2014 3:31 am ] 
Post subject:  Re: 4Mx32bit main memory? 
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) 
Page 1 of 1  All times are UTC  8 hours [ DST ] 
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ 