Electronic – Muxes, Adders, Comparators, and Gates

addercomparatordigital-logicpcb-designphysical-design

This question is actually from one of my previous discussions, which I still don't understand how to implement. The goal is to use abstraction to design a circuit, which converts two-digit ASCII decimal numbers into 2’s complement representation.

"Recall that characters in ASCII are represented with seven bits and that the decimal digits are 0x30 (the digit 0) through 0x39 (the digit 9)."

Comparator and adder.

In addition to the comparator and adder, one or more zero extention units, one or more muxes, and gates and wires are to be used.

Basically, what are the key steps and concepts which I must know to arrive at a solution to this design problem? I'm sort of aware of how an adder works, as I've done some bit-slice problems with control units to implement different functions, but I don't know how to put all of this together.

Best Answer

The steps I usually follow to find the solution are explained here. (Disclaimer:I am not an expert here.)

1. Derive the input-out relationship

The first step is to understand and express the input-output relationship in some form. You can express this relation in a convenient form. Some of the standard forms are

  • mathematical expression
  • truth table
  • logical expression
  • any combination of above

Taking your question as an example,

If 011xxxx and 011yyyy be the input digits. The last four bits of these digits represent their binary values. So xxxxyyyy is the BCD representation of the number. Converting this BCD to binary is the required operation here. And this can be done by adding lower BCD digit with ten times the upper digit. ie,

$$\mathtt{output = 1010\times xxxx + yyyy}$$

So we have obtained the input output relation here. But we don't have a multiplier to implement this relationship.

2. Re-formulate the relation in terms of available hardware

Multiplying with \$1010\$ can be done by shifting and adding as given below:

$$\mathtt{1010\times xxxx = xxxx000 + xxxx0}$$

OR

$$\mathtt{output = xxxx000 + xxxx0 + yyyy}$$

So here we have obtained the input output relationship in terms of available hardware. A 7-bit adder can do the addition. zero extension units can do the zero-padding.

Pad a zero in front of answer to make it in 2's complement form.

3. Circuit diagram/ block diagram

Once we have the input-output relation, then replacing the operators in the expression with the corresponding block/module will give you the circuit diagram.