boolean algebra, gates and circuits - radboud universiteit · boolean algebra, gates and circuits...

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

Upload: others

Post on 25-Mar-2020

14 views

Category:

Documents


0 download

TRANSCRIPT

Boolean Algebra, Gates andCircuits

Kasper BrinkNovember 21, 2017

(Images taken from Tanenbaum, Structured Computer Organization,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Gates en Circuits

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

Gates

20

How are Gates Implemented?

NOT-gate NAND-gate NOR-gate

21

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

XOR

A B A⊕ B0 0 0

0 1 1

1 0 1

1 1 0

A⊕ B = AB+ AB

AB+ AB

23

Equivalence of Circuits

AB+ AC

A(B+ C)

24

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

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

Multiplexer with 8 inputs

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

Decoder

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

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

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

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

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