Docsity

Week 7 Disucssion notes, Lecture notes of Electrical and Electronics Engineering

Partial preview of the text

Download Week 7 Disucssion notes and more Lecture notes Electrical and Electronics Engineering in PDF only on Docsity!

1 1 1 1 1

+

7 − 5 = 0111 + 1010 + 1 → keep 4 bits: 0010

EECS 31 · Introduction to Digital Systems

Subtractors and BCD

Discussion · Week 7 — half and full subtractors, subtracting with

an adder, BCD and excess-3, the BCD adder

Reading: Section 5.2.2 (Subtraction) · BCD step by step: Suggested Study 7

UC Irvine · Samueli School of Engineering · Fall 2026

TODAY

Plan for the next 50 minutes

1

Half subtractor

x − y with a borrow · its circuit and delay 6 min

2

Full subtractor

Practice 1 · truth table, K-maps, delay, compare with the full adder 9 min

3

Subtracting with an adder

A − B = A + B̅ + 1 · what Cout means · Practice 2 11 min

4

BCD and excess-

Codes · a BCD → excess-3 converter with don't-cares 11 min

5

Binary → BCD

0–15 as two decimal digits 2 min

6

BCD adder

Add 6 when the sum is over 9 · Practice 3 9 min

7

Wrap-up

Common mistakes, cheat sheet, questions 2 min

PART 1 · HALF SUBTRACTOR

The circuit and its delay

How we count (as in Week 6)

1

NOT, AND, OR: 1 gate delay

each, any fan-in.

2

No XOR gate: in a circuit XOR is

NOT → AND → OR (3).

3

Inputs ready at 0, true form only:

a bar costs a NOT.

4

Delay = most gates on any path

from an input.

Two-level half subtractor (gold = ready at)

vs. the half adder: same D = S (NOT → AND → OR = 3). The carry xy is ready at 1, but the borrow x̅y needs a 

NOT: ready at 2.

PART 2 · FULL SUBTRACTOR

Practice 1: the full subtractor

TRY IT · 5 MIN

Problem

Design a full-subtractor circuit with three

inputs x, y, Bin and two outputs D and B.

The circuit subtracts x − y − Bin, where

Bin is the input borrow, B is the output

borrow, and D is the difference.

Hint: if x − y − Bin < 0, borrow: add 2 and

set the borrow out to 1.

x y D

(a)

Fill in the truth table.

(b)

Draw the K-maps of D and Bout

and write minimal two-level

equations.

(c)

Delay of the two-level circuit: D?

Bout? From Bin to Bout?

(d)

Fast finishers: compare with Week

6's full adder. What is the same?

Name: we write the output borrow as Bout (the problem calls it B) so it can't be confused with an input.

PART 2 · FULL SUBTRACTOR

Solutions (c)(d): delay, and the full adder

SOLUTIONS

(c) two-level full subtractor

(c)

D: NOT → AND → OR = 3

Bout: needs x̅ → also 3 

From Bin: Bout 2 , D 3

(d) vs. the full adder

D = S. Bout = Cout with x̅ in place of A 

: 1 when two

or more of x̅, y, Bin are 1. 

PART 3 · SUBTRACTING WITH AN ADDER

A − B = A + B̅  + 1

Two's complement

invert every bit, then add 1

The +1 goes in through the adder's carry in : no extra

adder needed.

Example 2: 7 − 5 in 4 bits

carries 1 1 1 1 1

A 0 1 1 1

= 7

B̅ 1 0 1 0

(B = 0101 = 5)

1 0 0 1 0

Keep 4 bits: 0010 = 2 carry out = 1

gold row: carries (carry in = 1 on the right)

Last year: A − B = A + ( B̅ + 1) = A + B̅ + 1 “by associativity” — that one line is why every computer subtracts with its

adder.

PART 3 · PRACTICE

Practice 2: subtract with the adder

TRY IT · 5 MIN

Hint: B̅ is ready at 1; the carry in is a constant 1,

ready at 0. Week 6: a two-level full adder is carry in

→ carry out 2, carry in → sum 3.

(e)

1001 − 0011: write B̅, add, give the 4-bit result and Cout. In

decimal?

(f)

0011 − 1001: same questions. What does Cout tell you?

What is the answer in decimal?

(g)

The adder is four two-level full adders (Week 6). Delay of the

subtractor, and which output is last?

(h)

Fast finishers: a chain of four full subtractors (Practice 1), Bin

= 0. Faster or slower?

Remember: 4 bits only — the carry out is a separate output, not a fifth bit of the answer.

PART 3 · PRACTICE

Solutions (e)(f)

SOLUTIONS

(e) 1001 − 0011 (9 − 3)

carries 1 0 0 1 1

A 1 0 0 1

= 9

B̅ 1 1 0 0

(B = 0011 = 3)

1 0 1 1 0

Cout = 1: no borrow. 0110 = 6

borrow out of bits 3…0: 0 1 1 0 = NOT carry out of each bit

(f) 0011 − 1001 (3 − 9)

carries 0 1 1 1 1

A 0 0 1 1

= 3

B̅ 0 1 1 0

(B = 1001 = 9)

0 1 0 1 0

Cout = 0: borrow. 1010 − 16 = 10 − 16 = −

borrow out of bits 3…0: 1 0 0 0 = NOT carry out of each bit

Check: 9 − 3 = 6 and 3 − 9 = −6. Cout = 0 means we borrowed 16: the answer is the 4-bit result − 16.

PART 4 · BCD AND EXCESS-

Binary-coded decimal (BCD)

One digit = 4 bits (8 4 2 1)

0

1

2

3

4

5

6

7

8

9

Not used: 1010 1011 1100 1101 1110 1111

More digits: digit by digit

2026

2

0

2

6

BCD: 16 bits

binary: 11 bits

BCD ≠ binary: 15 is 0001 0101 in BCD, but 1111 in binary. A 4-bit group above 1001 is not a BCD digit.

PART 4 · BCD AND EXCESS-

Excess-3: each digit + 3

Digit · BCD · excess-

digit BCD excess-

Self-complementing

2 = 0101 invert → 1010 = 7 = 9 − 2

The 9's complement (9 − digit) is just NOT on every bit — true for all

ten digits.

Next: a code converter

Inputs: a BCD digit A B C D (A = 8). Outputs: its excess-3 code w x y

z. The inputs 1010–1111 never happen.

PART 4 · BCD AND EXCESS-

K-maps with don't-cares

Wrap-around: the left and right columns are neighbours, and so are the top and bottom rows (x's B̅C and B̅D, z's D̅).

PART 4 · BCD AND EXCESS-

Two circuits for the same converter

Two-level (K-maps) delay 3 · 13 gates Multi-level: share C + D (last year) delay 4 · 11 gates

PART 5 · BCD ADDER

BCD digits: add 6 when the sum is over 9

sum

0–9: binary = BCD, nothing to fix (C = 0)

Fix it when the sum ≥ 10

K: sums 16–19. Z

8

Z

4

, Z

8

Z

2

: Z = 1010–1111.

Why add 6?

The digit should be sum − 10. In 4 bits, −10 =

+6 (16 − 10). Adding 0110 skips the six unused

codes and makes the carry the decimal carry.

PART 5 · BCD ADDER

The BCD adder: two binary adders and a correction

binary: K Z = 1 0001

K = 1 → C = 1

answer: 1 0111 = 17

5 + 7 (the bottom carry (1) is ignored)

binary: K Z = 0 1100

Z

8

Z

4

= 1 → C = 1

answer: 1 0010 = 12