2

I need to implement a datapath for the following problem: "Design a combinational logic device that will take as input three unsigned numbers x, y, and z, and output the sum of the largest of the two. You may use any of our combinational datapath components in your design: MUXes, decoders, adder/subtractors, comparators, and individual logic gates as the need arises. Do not use sequential logic devices such as registers or flip flops."

I am having trouble with this because I feel like no matter which way I compare I will get the largest of the three twice and the answer will be wrong. For instance if x = 1, y = 3, and z = 2, then the sum should be 5 because 3 and 2 are the largest two. But if we use a comparator to get x and y, we will get 3 since 3 is larger, and if we use another comparator to compare y and z, we will also get 3 which gives us 6 as our total sum. Do we need to compare x and z as well to get the second largest? In that case we will get the largest integer twice and the second largest once. so we will get 3, 3, and 2. Should I use another comparator then and compare 3 and 3 and just pass through 3, but also have another comparator that checks to see which number is LESS than the other? So for instance we already have one 3 passing through, so compare the other 3 with the 2 and since 2 is less than 3, pass 2 through and add the remaining 3 and 2? Along with these comparators we will have MUX's that will let the appropriate input pass through based on the select input from the comparator.

Here is what I have:enter image description here

Is this correct?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
GenericUser01
  • 337
  • 3
  • 11
  • 27

1 Answers1

0

For your answer, where is the sel bit on the bottom left coming from? What determines if it uses the A=B or the A

The easiest and most self-justifyable way to do it is to compute all three possible answers (x+y, x+z, y+z), and compute logic to determine the smallest of the three numbers. Once you have that, you can simply select the sum of the larger two. It may use more total gates than the more selection heavy solution you propose, but it should have a lower delay because it is more parallelized.

Your way, it does become quite difficult to keep things clear when duplicate enter the mix.

Circuit Design

The above circuit functions for 4 bit unsigned numbers (computing a 5 bit unsigned answer), but it is easy to extend it to any size numbers.

Mshnik
  • 7,032
  • 1
  • 25
  • 38