Implementing a function using an adder and a multiplier

In summary: X0 to X2 into the multiplier inputs Ma0 to Ma2 and Mb0 to Mb2.Now you can call the output of the multiplier X^2 or 2X^2 or 4X^2 or 8X^2 - or any combination.Input nodes X0 to X2. Output nodes Y0 to Y8. Y=10X^2.Now tie Ma3 and Mb3 to ground.And finally, on the third step:You want to get both 8x^2 and 2x^2 from the output of the multiplier.Here's the final hint: You want to get both 8x^2 and 2x^2 from the
  • #1
timnswede
101
0

Homework Statement


http://imgur.com/a/3Cn7c [/B]Z is an unsigned 9 bit number and X is an unsigned 3 bit number. The only available components are an 8 bit adder and a 4-bit x 4-bit multiplier.
c.) We have a single 8 bit adder and a single 4-bit x 4-bit multiplier. We would like to implement the function Z=kX^2 where k is a constant. What is the maximum possible for k that can be achieved?

Homework Equations


No equations

The Attempt at a Solution


My thinking was that with the multiplier we can get 4X^2 (X2 X1 X0 0)*(X2 X1 X0 0). Then with adder we can add that with itself to get 8X^2 so the largest value for k is 8? Is my logic correct?
 
Physics news on Phys.org
  • #2
X is a 3-bit number, so max(X) is 7, squared it 49.
Z is unsigned 9-bit, so max(Z) is 511.
511/49 is less than 11, so k cannot be greater than 10.

Can you think of a solution for Z=10X*X ?

Bear in mind that a multiply by a power of 2 is free. All you need to do is wire things up for a bit shift.
 
  • #3
.Scott said:
X is a 3-bit number, so max(X) is 7, squared it 49.
Z is unsigned 9-bit, so max(Z) is 511.
511/49 is less than 11, so k cannot be greater than 10.

Can you think of a solution for Z=10X*X ?

Bear in mind that a multiply by a power of 2 is free. All you need to do is wire things up for a bit shift.
Ok the logic for why the max is 10 makes total sense to me, but I'm not sure how I would implement that. Since I could either get 2x^2 or 4x^2 from the output. But I don't think I could get the 10x^2 required from the adder could I?
 
  • #4
Does the 8 bit adder have a carry output to go into a ninth bit? If not, what's the point in Z having 9 bits?
 
  • #5
rcgldr said:
Does the 8 bit adder have a carry output to go into a ninth bit? If not, what's the point in Z having 9 bits?
Yes I tried to put a picture, but it wouldn't show up. The 8 bit adder has a carry in and carry out as the 9th bit
 
  • #6
timnswede said:
Ok the logic for why the max is 10 makes total sense to me, but I'm not sure how I would implement that. Since I could either get 2x^2 or 4x^2 from the output. But I don't think I could get the 10x^2 required from the adder could I?
Here's the final hint: You want to get both 8x^2 and 2x^2 from the output of the multiplier.
 
  • #7
.Scott said:
Here's the final hint: You want to get both 8x^2 and 2x^2 from the output of the multiplier.
I can see getting 2x^2 or 4x^2 from the multiplier, but not 8x^2.
 
Last edited:
  • #8
rcgldr said:
I can see getting 2x^2 or 4x^2 from the multiplier, but not 8x^2. The adder will need to be used more than once to get 10x^2.
This isn't a software problem. It's an EE problem.
You aren't programming these things, you're wiring them into a circuit.

I said I wasn't going to give anymore hints, but I think the OP is past this point.
Lets say I have a 4-bit input, represented by nodes I0 to I3. And I want to generate a 20-bit output with a value of 1024 times the input value. The output is represented by nodes O0 to O19. So I start by wiring nodes O0 to O9 to ground. Then O14 to O19 to ground. Then I0 to I3 to O10 to O13, respectively.

Get the picture?

Oh yes, and please note that my gate count is zero.
 
  • #9
rcgldr said:
I can see getting 2x^2 or 4x^2 from the multiplier, but not 8x^2.

.Scott said:
You aren't programming these things, you're wiring them into a circuit.
OK, but the way I see this, the circuit isn't getting 8x^2 from the multiplier. Instead the two inputs to the adder could be x^2 "shifted left" 1 bit (2x^2) and x^2 "shifted left" 3 bits (8x^2), with the most significant bit of 8x^2 going to the carry input of the 8 bit adder.
 
Last edited:
  • #10
rcgldr said:
OK, but the way I see this, the circuit isn't getting 8x^2 from the multiplier. Instead the two inputs to the adder could be x^2 "shifted left" 1 bit (2x^2) and x^2 "shifted left" 3 bits (8x^2), with the most significant bit of 8x^2 going to the carry input of the 8 bit adder.
Here's how I see it:

Input nodes X0 to X2. Output nodes Y0 to Y8. Y=10X^2.

Well all agree on the first step:
Tie X0 to X2 into the multiplier inputs Ma0 to Ma2 and Mb0 to Mb2. Tie Ma3 and Mb3 to ground.

Now you can call the output of the multiplier X^2 or 2X^2 or 4X^2 or 8X^2 - or any combination.

I think we all agree, on the second step:
Tie multiplier outputs to adder inputs. M0 to M5 to Aa0 to Aa5 and Ab2 to Ab7. Tie all other adder inputs to ground.
Exactly how you describe the adder input and outputs is optional. I treated this as 8X^2+2X^2=10X^2. Equally valid would be 4X^2+X^2=5X^2.
In either case, you don't need to use the carry bit.
 
  • #11
.Scott said:
8X^2+2X^2=10X^2. Equally valid would be 4X^2+X^2=5X^2.
In either case, you don't need to use the carry bit.
Max value for X == 7 => X^2 == 49 => 8X^2 == 352, which will need the adder's carry (ninth) bit).
 
  • #12
rcgldr said:
Max value for X == 7 => X^2 == 49 => 8X^2 == 352, which will need the adder's carry (ninth) bit).
8X^2 ranges from 0 to 392, in steps of 8, so you need 6 bits. 2X^2 ranges from 0 to 98 in steps of 2, so you need 6 bits. Combined: 10X^2 ranges from 0 to 490 in steps of 2, so you need 8 bits (no carry), the units position is always 0.

I'm doing everything I can to avoid simply blurting out the answer.
 
  • #13
.Scott said:
Tie multiplier outputs to adder inputs. M0 to M5 to Aa0 to Aa5 and Ab2 to Ab7. Tie all other adder inputs to ground.
That will produce 5 X^2. I'm assuming the goal is to be produce 10 X^2 in the 9 bit combination of adder carry out and adder 8 bit sum.

rcgldr said:
most significant bit of 8x^2 going to the carry input of the 8 bit adder.
This was a mistake, I struck it out in my prior post.
 
Last edited:
  • #14
rcgldr said:
That will produce 5 X^2. I'm assuming the goal is to be produce 10 X^2 in the 9 bit combination of adder carry out and adder 8 bit sum.
There is no difference between 5X^2 and 10X^2. If you think that 5X^2 does not require the carry (which it does not), then you should easily see that the carry is not required for 10X^2. The only problem with using the carry is that is the question does not state that it is available.
 
  • #15
.Scott said:
The only problem with using the carry is that is the question does not state that it is available.

From the op, post #5:

timnswede said:
The 8 bit adder has a carry in and carry out as the 9th bit

.Scott said:
There is no difference between 5X^2 and 10X^2. If you think that 5X^2 does not require the carry (which it does not), then you should easily see that the carry is not required for 10X^2.
Based on post #5, I assume the 9 bit output is adder carry + adder 8 bit sum, and that shifting the output left 1 or more bits to get sum * power of 2 is not the goal. With this limitation, generating 8 X^2 isn't an issue, but I don't know about 10 X^2, with only a single multiply and single add allowed, even though 10 X^2 fits in 9 bits.
 
  • #16
rcgldr said:
From the op, post #5:
Based on post #5, I assume the 9 bit output is adder carry + adder 8 bit sum, and that shifting the output left 1 or more bits to get sum * power of 2 is not the goal. With this limitation, generating 8 X^2 isn't an issue, but I don't know about 10 X^2, with only a single multiply and single add allowed, even though 10 X^2 fits in 9 bits.
You have 9 output nodes O0 to O9. Tie O0 to ground.
 
  • #17
.Scott said:
You have 9 output nodes O0 to O9. Tie O0 to ground.
It wasn't clear to me if this would be allowed, or if the output had to be the carry bit and 8 bits from the adder sum.
 

1. What is an adder and a multiplier?

An adder is a digital circuit that performs addition operations on binary numbers, while a multiplier is a digital circuit that performs multiplication operations on binary numbers.

2. How do you implement a function using an adder and a multiplier?

To implement a function using an adder and a multiplier, you need to first break down the function into its individual steps, then use the adder and multiplier circuits to perform each step, and finally combine the results to get the final output.

3. What are the advantages of using an adder and a multiplier in function implementation?

The main advantage of using an adder and a multiplier is that they are basic building blocks of digital circuits and are readily available in most hardware. This makes them efficient and cost-effective for implementing functions.

4. Can an adder and a multiplier be used to implement any function?

No, an adder and a multiplier can only implement functions that involve addition and multiplication operations. They cannot be used to implement functions that involve other operations such as division or exponentiation.

5. Are there any limitations to using an adder and a multiplier in function implementation?

One limitation of using an adder and a multiplier is that they are sequential circuits, meaning that they can only perform one operation at a time. This can lead to slower execution of functions compared to other types of circuits.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
6
Views
17K
  • Programming and Computer Science
Replies
1
Views
671
  • Engineering and Comp Sci Homework Help
Replies
1
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
954
  • Engineering and Comp Sci Homework Help
Replies
7
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
876
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
Back
Top