Top Banner
Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc.)
33

Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Mar 25, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Boolean Algebra, Gates andCircuits

Kasper BrinkNovember 21, 2017

(Images taken from Tanenbaum, Structured Computer Organization,

Fifth Edition, (c) 2006 Pearson Education, Inc.)

Page 2: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Outline

Last week:

• Von Neumann architecture

• General structure of a CPU

This week and next week: “Digital Logic Level”

Today:

• Boolean algebra

• Rewriting Boolean expressions

• Gates and circuits

• Examples

2

Page 3: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Digital Logic

Digital computers process discrete information.

All information is represented by two logical values:logic 0 → e.g. voltage between 0.0 and 0.5 Vlogic 1 → e.g. voltage between 1.0 and 1.5 V

To design and analyze digital circuits we make use ofBoolean Algebra.

3

Page 4: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Boolean Values and Operators

Boolean values B = {0,1}Boolean variables x ∈ B

Boolean operatorcorresponds toLogic operator

x complement (NOT) ¬p negationx · y product (AND) p∧ q conjunctionx+ y sum (OR) p∨ q disjunction

x x0 11 0

x y xy0 0 00 1 01 0 01 1 1

x y x+ y0 0 00 1 11 0 11 1 1

4

Page 5: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Derived Operators

xy NAND

x+ y NOR

x⊕ y XOR (exclusive or)

x y xy x+ y x⊕ y0 0 1 1 0

0 1 1 0 1

1 0 1 0 1

1 1 0 0 0

5

Page 6: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Boolean Functions

Boolean function of degree n: f : Bn → B

We can describe each Boolean function by its truth table, forexample this function f : B3 → B

x y z f0 0 0 00 0 1 10 1 0 10 1 1 01 0 0 11 0 1 01 1 0 01 1 1 0

The function f is true iff exactly one of itsarguments is true.

How many distinct Boolean functions of degree n exist? 22n

6

Page 7: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Boolean Expressions

Boolean expression: expression using 0, 1, boolean variablesand operators.

Every Boolean expression represents a Boolean function.

Example: f (x, y) = x+ y

x y f (x, y)0 0 10 1 01 0 11 1 1

Conversely: can every Boolean function be written as aBoolean expression?

7

Page 8: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Deriving a Boolean Expression for a Function

Example: x y f (x, y)0 0 1 x y0 1 01 0 1 x y1 1 1 x y

This gives us f (x, y) = x y+ xy+ xy

Literal: xi or xiMinterm: product of literals where each variable occursexactly onceExpression for f : sum of the minterms where f = 1

This is called the (full) Disjunctive Normal Form (DNF), or the“sum of products” representation.

8

Page 9: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Equivalence of Boolean Expressions

Two Boolean expressions that represent the same Booleanfunction are called equivalent.

Example: x+ y = x y+ xy+ xy

You can prove this by showing that both expressions havethe same truth table.

Often more convenient: rewriting expressions using the lawsof Boolean algebra.

9

Page 10: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Laws of Boolean Algebra

Name Multiplicative form Additive form

Complement x = xIdentity x · 1 = x x+ 0 = xNull x · 0 = 0 x+ 1 = 1

Idempotent x x = x x+ x = xInverse x x = 0 x+ x = 1

Commutative xy = yx x+ y = y+ xAssociative x(yz) = (xy)z x+ (y+ z) = (x+ y) + zDistributive x(y+ z) = xy+ xz x+ yz = (x+ y)(x+ z)Absorption x(x+ y) = x x+ xy = xDe Morgan xy = x+ y x+ y = x y

See also Tanenbaum, figure 3-6 (p. 156).

10

Page 11: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Rewriting Expressions (1)

Example: rewrite the following expression to (full) DNF.

(x+ z)(x+ y ) = (x+ z)(x · y ) (de Morgan)

= xxy+ zxy (distributivity, double complement)

= 0+ zxy (inverse, null)

= xyz (identity, commutativity)

11

Page 12: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Rewriting Expressions (2)

Example: derive an expression for the following function,and simplify this.

x y z f0 0 0 00 0 1 00 1 0 10 1 1 01 0 0 11 0 1 01 1 0 11 1 1 0

f (x, y, z) = xyz + xy z + xyz (DNF)

= (xy+ xy+ xy)z (distributivity)

= (xy+ xy+ (xy+ xy))z (idempotent)

= (xy+ xy+ xy+ xy)z (commutativity)

= ((x+ x)y+ x(y+ y))z (distributivity)

= (y+ x)z (inverse & null)

= yz + xz (distributivity)

12

Page 13: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Karnaugh Maps

Karnaugh Map is a graphical method for simplifying aBoolean expression.

Basic idea:

• Two minterms that differ in exactly one literal can becombined into a simpler term:

ABCD+ A B C D −→ ABD

• Put all minterms in a table, ordered such thatneighboring cells differ in exactly one literal.

• Visually locate blocks of minterms that can be combined,which are as large as possible.

13

Page 14: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Karnaugh Maps: Example

A B C D F0 0 0 0 00 0 0 1 10 0 1 0 00 0 1 1 10 1 0 0 00 1 0 1 10 1 1 0 00 1 1 1 11 0 0 0 11 0 0 1 11 0 1 0 11 0 1 1 01 1 0 0 01 1 0 1 11 1 1 0 01 1 1 1 0

CD

AB

00 01 11 10

00

01

11

10

1 1

1 1

1 1 1

1

0 0

0 0

0

0 00

F = AD + CD + A B D

14

Page 15: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Karnaugh Maps: Rules

• Choose blocks to cover all the ones, but none of the zeros.

• Blocks are allowed to overlap.

• Blocks must:– be rectangular– have lengths of 1, 2 or 4– be as large as possible

• Use as few blocks as possible.

• Wrap around: top – bottom, left – right, corners

15

Page 16: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Karnaugh Maps: Example 2

A B C F0 0 0 10 0 1 10 1 0 00 1 1 11 0 0 11 0 1 11 1 0 11 1 1 0

BC

A

00 01 11 10

0

1

1 1 1

1 1 1

0

0

F = B + AC + AC

16

Page 17: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Functional Completeness

• Every Boolean function can be expressed as a sum ofproducts of literals (DNF).

→ The set of operators { , ·,+} is functionally complete.

• The sets { , ·} and { ,+} are also functionally complete.

• The operators NAND (xy) and NOR (x+ y) are eachfunctionally complete on their own.

17

Page 18: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Gates en Circuits

Page 19: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Digital Circuits

Physical implementation of digital logic:

Boolean values → signals in electronic circuitBoolean operators → gates

Completeness: every Boolean function can be expressedwith the help of a complete set of operators, for example{ , ·,+} or {NAND}.

Therefore: every Boolean function can be implemented as acircuit by connecting gates from a complete set together!

19

Page 20: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Gates

20

Page 21: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

How are Gates Implemented?

NOT-gate NAND-gate NOR-gate

21

Page 22: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Combinational and Sequential Logic

Combinational circuit

• output of circuit only depends on input (at the current time)

• implements a Boolean function

• acyclic circuit (mostly)

Sequential circuit

• output of circuit depends on input and internal state

• implements a finite state machine

• cyclic circuit: feedback

• “circuit with memory”

22

Page 23: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

XOR

A B A⊕ B0 0 0

0 1 1

1 0 1

1 1 0

A⊕ B = AB+ AB

AB+ AB

23

Page 24: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Equivalence of Circuits

AB+ AC

A(B+ C)

24

Page 25: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Majority

A B C M0 0 0 00 0 1 00 1 0 00 1 1 11 0 0 01 0 1 11 1 0 11 1 1 1

Page 26: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Multiplexer

Circuit with data inputs D0 en D1 and control input S.If S = 0, the signal from D0 is passed to the output, else D1 is.

Output X = S ·D0 + S ·D1

D0

S

D1

X

26

Page 27: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Multiplexer with 8 inputs

Page 28: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

General Multiplexer

In general: a multiplexer with n control inputs selects one ofthe input signals D0, . . . , D2n−1 and passes this to the output.

28

Page 29: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Decoder

The binary number on the n inputs determines which of the2n outputs will become active (output a “1”).

Page 30: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Half Adder

Adding two 1-bit numbers A en B:

A 0B 0

00+

10

01+

01

01+

11

10+

Sum = A⊕ BCarry = AB

30

Page 31: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Full Adder

Adding 1-bit numbers with carry-in.

A B Cin S Cout0 0 0 0 0

0 0 1 1 0

0 1 0 1 0

0 1 1 0 1

1 0 0 1 0

1 0 1 0 1

1 1 0 0 1

1 1 1 1 1

Sum = A⊕ B⊕ CinCarry = AB+ (A⊕ B) · Cin

31

Page 32: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Hades

• Practical assignment will be done in Hades,the Hamburg Design System.

• “Framework for interactive simulation”• Can be downloaded from

https://tams.informatik.uni-hamburg.de/applets/hades/

32

Page 33: Boolean Algebra, Gates and Circuits - Radboud Universiteit · Boolean Algebra, Gates and Circuits Kasper Brink November 21, 2017 (Images taken from Tanenbaum, Structured Computer

Summary

Boolean Algebra• Boolean functions and expressions• Disjunctive normal form• Laws of Boolean algebra• Karnaugh maps• Functional completeness

Gates and circuits• Physical implementation of digital logic• Combinational and sequential circuits• Gate symbols• Circuits: xor, majority, multiplexer, decoder,

half adder, full adder.

In preparation for Monday’s practical session:Download Hades, install a JRE if necessary.

33