Electronic – How is unsigned integer max implemented in hardware

digital-logic

I'm working on a design that involves a lot of max functions (and max functions as arguments to other max functions).

In an effort to simplify the hardware design I was wondering how max is implemented in hardware?

Mathematically, Max(a,b) can be represented as [(a + b) + abs(b – a)]/2.

Is this how its implemented in hardware? (i.e. in stages; addition, bit shift division, etc.)

If so, how is the absolute of the difference calculated?

Best Answer

A very simple approach would be to implement (a>b)?a:b. a>b can be implemented by starting at the left and check each bit pair of (a,b):

  • both 0 or both 1 : continue to next lower pair
  • a is 1 : a is highest; b is 1 : b is highest

When you know which one is the highest you can select that one by a 2N->N mux.

With some clever tricking the checking of the bit pairs can be combined with the muxer for the same bit pair.

Related Topic