# Homework Help: Binary multiplication

1. Apr 17, 2013

### ProPatto16

1. The problem statement, all variables and given/known data

i have an 8 bit input, and i need to represent 0-359 in decimal on 3 7-seg displays

3. The attempt at a solution

with 8 bits there is only 256 possibilities so the input would have to be multiplied by 1.4 to get an even spread over 259 degrees.
but you cant multiply a binary number by a floating number and then if you have a result of say 345 how do you represent it with 8 bits.

so i need to find a way to take 8 bits and represent numbers from 0-359. doesnt need to be every degree .
and have to simulate it in multisim so cant use binary rate multipliers.

any ideas? just somehwere to start looking.

2. Apr 17, 2013

### oli4

Hi ProPatto16
You could multiply by 14 and divide by 10 :)
You are going to use BCD I guess, in any case you will need 2 bytes that would allow you to display up to 4 digits
So pretend you have 4 digits and whatever number you have to itself 13 times, and carry up to the second byte
At the end, you just ignore your last digits (the second nibble of your first byte)
Cheers...

3. Apr 17, 2013

### ProPatto16

Good idea!! Thanks,
Just another issue, multisim has no binary multiplier so I'm gonna have to make one out of JKs which is fine, but what other ICs would I need to get from the original 8-bit input to the 3 displays? Cause ill need to design them from scratch too. But that'll get me on the right track

4. Apr 17, 2013

### oli4

Hi, sorry I don't know about ICs, I am not into electronics, I just have some memories about it but they are quite old :)
Anyway, multiplication is hard, I think you can avoid it by just doing addition, you just need to do 13 additions, it should be fast.
Once the additions are done, you convert to BCD if it is easy enough, I remember it is a standard way to work and there are plenty of ready to use algorithms / ICs to go from BCD to 7 segs displays
you should find yourself with 2 bytes encoding in BCD a 4 digits number, (the 4 nibbles) you just discard the last nibble and wire everything else and it should do the trick
Cheers...

5. Apr 17, 2013

### rcgldr

To do this exactly, you need to multiply by 45, then divide by 32 (shift right 5 bits). You could create a translation table (like a rom), using the 8 bit input shifted left 2 bits to index the table to get 32 bits, using 21 bits of that for the three 7 segment displays.

6. Apr 17, 2013

### ProPatto16

Yeah I gave up on the multiplier and made an 8x8 adder. It's a beast. I just can't get the 9th bit to work when I add 2 large 8 bits and get a 9th bit to make a number over 255. I thought I just put the last carry out as the 9th bit so when there's carry it'll be high ?

7. Apr 17, 2013

### rcgldr

Why not make a 14 bit adder? This will be large enough to multiply by 45. Then you need a second register to hold intermediate sums. Assuming the original value O is in X and using A... for the intermediate sums:

Code (Text):

A = X + X    (A = 2 O)
A = A + A    (A = 4 O)
X = A + X    (X = 5 O)
A = X + X    (A = 10 O)
A = A + X    (A = 15 O)
X = A + A    (X = 30 O)
X = A + X    (X = 45 O)
X = X + 16   (round X before shifting)
X >>= 5      (use upper 9 bits of X)

You've still got the problem that you now have to convert this to decimal for the three 7 segment displays. As mentioned before, you could just create a 256 entry by 12 or 21 bit table and let multisim figure it out.

Last edited: Apr 17, 2013
8. Apr 18, 2013

### ProPatto16

Doesn't need to be perfect. Just gonna round the decimal off and show whole numbers so it'll go like 0,1,3,4,5,7,8,9,11,12,14 type thing

9. Apr 27, 2013

### SymDog

Did you ever resolve this? I have to do a multiplication as well, but am a little overwhelmed by the complexities of it all.

10. Apr 27, 2013

### ProPatto16

I figured out the multiplier but havnt done the division. If you look at how binary numbers are multiplied and then add those combinations. Whatever your multiplicand is like 2 bits 3 bits 4 bits, then youll need one less adders. So for 4 bits you need 3 adders. Go do some multiplication the long way and you'll see if you multiply by a 4 bit number you'll get 4 additions before the last result. Put those 4 additions through adders

11. Apr 27, 2013