Decimal <-> Binary, multiple digits?

Thread Starter

Shiwayari

Joined Feb 28, 2009
3
I recently started learning about logic circuits. I'm mainly researching because of my own interest and don't know much yet, so go easy on me :)

So, the question:
Let's say I have a 10-bit adder and want to Input decimals and also want to get back decimals.
I found some explanations on how to encode/decode to/from binary, but none mentioned what I do with 'carrys' in the decimal numbers.
I know how to encode for example decimal 9 to binary: I'll get a 4digit binary number and make a truth table to get my functions.
But what do I do if I want to encode decimal 10 to binary? Do I just have to make an insanely huge truth table and get huge functions or is there a better way?
The same applies for decoding: I can decode 1001 to 9 easily, but how do I get 10 out of 1010?

For the 10-bit adder, I could have a decoder with 10 bit input and 1024 outputs for each single decimal number, but that can't be it, right? So how do I get the single digits of a decimal out of or into a decimal number?
I think I would get 40 outputs, 4 decimal digits with 10 bits (for 0,1,2,..,9) =?

I hope that was understandable, english is not my main language and I don't know many scientific words =/
 
Last edited:

beenthere

Joined Apr 20, 2004
15,819
You are working in Binary Coded Decimal (BCD), as opposed to binary. In BCD, only the values of 0 - 9 are valid. Here is a link to a BDC adder - http://tams-www.informatik.uni-hamb...bdemos/20-arithmetic/10-adders/bcd-adder.html.

Your binary value 1001 is BCD 9. As the remaining states are also valid, we can use Hexidecimal, that uses the letters A, B, C, D, E and F to represent them;

Bin Dec Hex
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 X A
1011 X B
1100 X C
1101 X D
1110 X E
1111 X F
 

Thread Starter

Shiwayari

Joined Feb 28, 2009
3
Thanks, that was exactly what I was looking for.

I think I understood what a BCD adder does now. However, the link beenthere posted only shows how to add one-digit decimals with a two-digit output, where the second digit can only be 0 or 1.
I thought it was pretty similar to a half adder and tried to design a 'BCD full adder' on my own. This is what I got: http://img13.imageshack.us/img13/5945/bcdfulladder.jpg

I think it should work like that, but I'd like someone more experienced to confirm it.

Btw. Can I somehow use this Hades editor used in the link posted by beenthere to design my own circuits?


Edit: ((Forgot that I still need a Decimal to Binary encoder..
I have 20 2-bit Inputs, 2 digits and 1 bit for each decimal number.
So how do I get for example an output of 1100 in binary if the Input is 12 in decimal?
Inputting decimal 12 would mean that bit#2 of the first digit is 1 and bit#1 of the second digit is 1, and all other are 0.))

Edit2: Forget what I said about needing an encoder, I just realized I don't need to input bigger decimals than 9 into the BCD :rolleyes:
I'd still like a confirmation of my multiple-digit-BCD Adder design. Does it work like that, or did I overlook something? Or is there an easier way?
 
Last edited:

italo

Joined Nov 20, 2005
205
001 is one right suppose you have 0000001001 what you have is 9 You need to learn about decimal BCD hex and octal grouping The number do not change it remains the same just different way of rapresenting the number.
take decimal 9 octal 1 001 group of 3 hex 1001 group of 4 Finaly 1lsb=decimal 1 2nd lsb=0 decimal 0p 3rd lsb =0 decimal 0 4th lsb =1 =decimal 8 so 1+8=9
To find decimal 1111= to 1+2+4+8= decimal 15
 

Thread Starter

Shiwayari

Joined Feb 28, 2009
3
Yeah I already know about how to convert from and to different number systems, and of course that they do not represent different numbers. I don't really see what your post has to do with my question though :confused:

I was only asking if someone experienced could look over the 'Full BCD Adder' (Don't know if it's called that) I designed and tell me if it's ok like that. You can see an image of it here: http://img13.imageshack.us/img13/5945/bcdfulladder.jpg
And forget what I said about encoders, I realized that was a stupid question.




Oh and.., some more punctuation and format in your post would have helped; it was really hard to read and took a while to understand what you meant.
 
Top