NivaarExam PrepOfficial exam papers ↗

22-Elec-A4 Digital Systems and Computers · May 2015

Question 3 of 6: Two-bit subtractor

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

Paper format. National Exams, May 2015 — 07-Elec-A4 Digital Systems & Computers. Three hours, closed book, one approved Casio or Sharp calculator. Six questions are printed and five constitute a complete exam; every question is worth 12 marks, with the per-part split printed in the marking scheme on page 1. A flip-flop excitation table and a Boolean-identity sheet are attached to the paper. All six questions are solved below, so that the set works as a complete study resource.

Reference texts.

Question 3 (12 marks) — Two-bit subtractor

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given. Two 2-bit unsigned operands, $N_1=AB$ with $A$ the most significant bit and $N_2=CD$ with $C$ the most significant bit; the difference is reported as a three-bit two's-complement word $XYZ$ with $X$ the sign bit. One half-subtractor and one full-subtractor block are supplied, each with the pin names listed in the question.

Find. (a) the 16-row truth table for $X$, $Y$ and $Z$; (b) minimal sum-of-products expressions for all three; (c) the wiring that produces $XYZ$ from the two supplied blocks.

Approach. Evaluate $N_1-N_2$ for all sixteen input combinations, encode each signed result in three-bit two's complement, then minimise on 4-variable K-maps in $ABCD$ and finally recognise the resulting expressions as the standard borrow-ripple structure so the block diagram wires itself.

  1. Establish the range and the encoding. With $0\le N_1\le 3$ and $0\le N_2\le 3$, the difference lies in $-3\le N_1-N_2\le 3$, which three-bit two's complement covers exactly (its range is $-4$ to $+3$). The encoding is $N_1-N_2=-4X+2Y+Z$, so $X$ is the sign bit and is 1 precisely when the subtraction borrows out of the most significant stage.
  2. Build the truth table (part a). Enumerating the sixteen combinations gives the table below; each row was computed as $N_1-N_2$ and then masked to three bits.
Question 3(a) — truth table for the two-bit subtractor. The difference is shown both as a signed decimal value and as the three-bit two's-complement word $XYZ$.
$m$$A$$B$$C$$D$$N_1$$N_2$$N_1-N_2$$X$$Y$$Z$
0000000+0000
1000101-1111
2001002-2110
3001103-3101
4010010+1001
5010111+0000
6011012-1111
7011113-2110
8100020+2010
9100121+1001
10101022+0000
11101123-1111
12110030+3011
13110131+2010
14111032+1001
15111133+0000
  1. Extract the minterm lists. Indexing minterms as $m=8A+4B+2C+D$, the tables give $X=\sum m(1,2,3,6,7,11)$, $Y=\sum m(1,2,6,7,8,11,12,13)$ and $Z=\sum m(1,3,4,6,9,11,12,14)$.
  2. Minimise $X$ (part b). The map for $X$ has one four-cell group and two two-cell groups, giving $\boxed{X=\overline{A}C+\overline{A}\,\overline{B}D+\overline{B}CD}$ — the classic borrow-out expression for a two-bit subtraction.
ABCD00011110000111100m01m11m21m30m40m51m61m70m80m90m101m110m120m130m140m15A'CA'B'DB'CDX (sign bit)
Question 3(b) — K-map for the sign bit $X$: three prime implicants, six minterms.
  1. Minimise $Z$. The $Z$ map splits cleanly into two four-cell groups, $\boxed{Z=\overline{B}D+B\overline{D}}$, which is just $Z=B\oplus D$ — the difference bit of the least significant stage, independent of $A$ and $C$ as it must be.
ABCD00011110000111100m01m10m21m31m40m51m60m70m81m90m101m111m120m131m140m15B'DBD'Z (LSB)
Question 3(b) — K-map for $Z$, two four-cell groups forming an exclusive-OR.
  1. Minimise $Y$. $Y$ is the middle bit, and it is an exclusive-OR of three quantities, so it resists grouping: no two of its eight minterms that would merge into a large cube share a common product. A minimum cover needs six product terms, $$Y=\overline{A}\,\overline{B}\,\overline{C}D+\overline{A}C\overline{D}+\overline{A}BC+A\overline{C}\,\overline{D}+A\overline{B}CD+AB\overline{C}.$$ The compact equivalent, and the form worth quoting alongside, is $\boxed{Y=A\oplus C\oplus(\overline{B}D)}$, where $\overline{B}D$ is the borrow generated by the least significant stage.
ABCD00011110000111100m01m11m20m30m40m51m61m71m80m90m101m111m121m130m140m15A'CD'A'BCABC'AC'D'A'B'C'DAB'CDY (middle bit)
Question 3(b) — K-map for $Y$. The checkerboard pattern of an exclusive-OR is why six product terms are needed.
  1. Wire the blocks (part c). The compact forms name the connections directly. The least significant stage subtracts $B-D$, which is exactly a half-subtractor: $\mathrm{M}=B$, $\mathrm{S}=D$, so $\mathrm{Diff}=B\oplus D=Z$ and $\mathrm{B_{out}}=\overline{B}D$. That borrow feeds the full-subtractor's $\mathrm{B_{in}}$, and the full-subtractor takes $\mathrm{M}=A$, $\mathrm{S}=C$, giving $\mathrm{Diff}=A\oplus C\oplus\mathrm{B_{in}}=Y$. Finally the full-subtractor's own borrow-out is the sign bit, $\mathrm{B_{out}}=\overline{A}C+\overline{A}\mathrm{B_{in}}+C\,\mathrm{B_{in}}=X$.
  2. Confirm the sign convention. A borrow out of the top stage means $N_1<N_2$, and in two's complement a negative result has its sign bit set — so tying $X$ directly to $\mathrm{B_{out}}$ is correct with no inverter. Checking one row, $N_1=00$, $N_2=01$ gives $Z=1$, $\mathrm{B_{out(HS)}}=1$, $Y=0\oplus0\oplus1=1$ and $X=1$, i.e. $111_2=-1$, as required.
ABCDHSMSDiffBoutFSMSBinDiffBoutBDACborrowX (sign)YZ (LSB)
Question 3(c) — completed connections. The half-subtractor handles the least significant bits, its borrow ripples into the full-subtractor, and the full-subtractor's borrow-out is the two's-complement sign bit.
Question 3 — final results
OutputMinimal sum of productsCompact formSource in part (c)
$X$ (sign)$\overline{A}C+\overline{A}\,\overline{B}D+\overline{B}CD$borrow-out of the FSFS $\mathrm{B_{out}}$
$Y$$\overline{A}\,\overline{B}\,\overline{C}D+\overline{A}C\overline{D}+\overline{A}BC+A\overline{C}\,\overline{D}+A\overline{B}CD+AB\overline{C}$$A\oplus C\oplus\overline{B}D$FS $\mathrm{Diff}$
$Z$ (LSB)$\overline{B}D+B\overline{D}$$B\oplus D$HS $\mathrm{Diff}$
HS borrow$\overline{B}D$—drives FS $\mathrm{B_{in}}$