Author Topic: multiplication circuit by using only sumators  (Read 2284 times)

0 Members and 1 Guest are viewing this topic.

Offline spiniTopic starter

  • Newbie
  • Posts: 2
  • Country: pl
multiplication circuit by using only sumators
« on: January 24, 2021, 09:57:23 pm »
Hi,
how can I make for example a circuit which multiply a number by 10, only by using (built-in) sumators and simple logical gates? (I'm using cedar logic soft)

Thanks.
 

Offline MK14

  • Super Contributor
  • ***
  • Posts: 5385
  • Country: gb
Re: multiplication circuit by using only sumators
« Reply #1 on: January 24, 2021, 10:04:28 pm »
Hi,
how can I make for example a circuit which multiply a number by 10, only by using (built-in) sumators and simple logical gates? (I'm using cedar logic soft)

Thanks.

It might be a homework question, so I will give a hint, rather than a full answer.

If X is some number.

What is (X shifted to the left 3 bits) plus (using adders) (X shifted left just one bit) ?

Example:
17

17 = 10001 in binary

So 10001000 <shifted left 3 bits, so had 000 appended to it> + 100010 <shifted 1 bit>

10001000
00100010 + in binary

10101010 = binary
= 170
 
The following users thanked this post: spini

Offline spiniTopic starter

  • Newbie
  • Posts: 2
  • Country: pl
Re: multiplication circuit by using only sumators
« Reply #2 on: January 24, 2021, 10:27:15 pm »
Thanks for response,

how did U know that it must be shifted in this example (multiplication by 10) to the left 3 bits + shifted 1 bit?
I get it how to make circuit by Ur explanation but, I don't understand how did U invent it  :-//
 

Offline MK14

  • Super Contributor
  • ***
  • Posts: 5385
  • Country: gb
Re: multiplication circuit by using only sumators
« Reply #3 on: January 24, 2021, 10:31:09 pm »
Thanks for response,

how did U know that it must be shifted in this example (multiplication by 10) to the left 3 bits + shifted 1 bit?
I get it how to make circuit by Ur explanation but, I don't understand how did U invent it  :-//

There was some FPGA discussions on here, a while ago. It used that method, as a very high speed way of multiplying by 10.
If I am misremembering that, then it would have been something like programming in C, where that method was used, to speed up the program, as multiplication, tends to be a little bit slow. Especially on very old processors.
 
The following users thanked this post: spini

Offline JohnnyMalaria

  • Super Contributor
  • ***
  • Posts: 1154
  • Country: us
    • Enlighten Scientific LLC
Re: multiplication circuit by using only sumators
« Reply #4 on: January 24, 2021, 10:33:28 pm »
Think how you do it in decimal:

e.g., 23 x 7 = [(2 x 10) x 7] + [3 x 7]

Multiplying by 10 in decimal is equivalent to multiplying by 2 in binary - which is just a shift.

And in binary, multiplication is easily done with adders. So, in the binary case, the above can be achieved with just adders and shifters.

Search for "binary multiplier gate implementation"
 
The following users thanked this post: MK14, spini

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: multiplication circuit by using only sumators
« Reply #5 on: January 24, 2021, 10:57:17 pm »
Do you know long multiplication?  Binary multiplication works exactly like that.

If you want to multiply by some constant C, convert C to binary representation.  Ignore all zeros in the binary representation.  The ones represent the shifts (of the other multiplicand) you need to sum together.

For example, consider C = 6 = 1102 = 4 + 2.   To multiply any number X by C=6 we do
    6X = (4 + 2)X = 4X + 2X = (X << 2) + (X << 1)

Just remember that 1<<0=20=1, 1<<1=21=2, 1<<2=22=4, 1<<3=23=8, 1<<4=24=16, 1<<5=25=32, and so on.
 
The following users thanked this post: MK14, spini

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 4207
  • Country: us
Re: multiplication circuit by using only sumators
« Reply #6 on: January 24, 2021, 11:19:48 pm »
And don't forget the trick of implementing division with multiplication:

https://ridiculousfish.com/blog/posts/labor-of-division-episode-i.html

So now you can implement division by a constant with just adders.


 
The following users thanked this post: MK14, spini

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 10088
  • Country: us
Re: multiplication circuit by using only sumators
« Reply #7 on: January 25, 2021, 02:23:57 am »
23 = 8 so when we shift right 3 places we are multiplying by 8 so shift X left 3 places
21 = 2 so when we shift left   1 place   we are multiplying by 2 sp shift X left 1 place

Finally, 8 times X plus 2 times X => 10 times X
 
The following users thanked this post: spini

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 10088
  • Country: us
Re: multiplication circuit by using only sumators
« Reply #8 on: January 25, 2021, 02:31:14 am »
If we can't use shifts but only adders, we need a couple of temporary values, call them A + B
A = X + X  -> A := 2X
B = A + A  -> B := 4X   
ans = (B + B) + A  -> ans := 4X + 4X + 2X := 10X
 
The following users thanked this post: spini

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: multiplication circuit by using only sumators
« Reply #9 on: January 25, 2021, 03:08:02 am »
If we can't use shifts but only adders, we need a couple of temporary values, call them A + B
A = X + X  -> A := 2X
B = A + A  -> B := 4X   
ans = (B + B) + A  -> ans := 4X + 4X + 2X := 10X

It would be a very odd situation where you could not use a shift.  But then I think in terms of hardware where shifting is just a matter of how you connect things. 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: spini


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->