Download presentation

Presentation is loading. Please wait.

Published byAlessandro Chance Modified over 3 years ago

1
CS1022 Computer Programming & Principles Lecture 9.2 Boolean Algebra (2)

2
Plan of lecture Simplifying Boolean expressions Karnaugh maps Logic circuits 2 CS1022

3
Simplifying Boolean expressions (1) Given a Boolean expression, can we find a “simpler” equivalent expression? – “Simpler” = “fewer symbols” Technique applied to disjunctive normal form (DNF) – Even though it might be more complex than original – Process: original expr. DNF simplified expr. Technique restricted to at most 3 Boolean variables – Extension to more variables is possible 3 CS1022

4
Simplifying Boolean expressions (2) To simplify, let’s suppress “ ” – Just like “ ” in algebra can be dropped (e.g., 2y = 2 y) – For instance, the expression in disjunctive normal form (p q r) (p q r) (p q r) Will be represented as pqr pqr pqr We can simplify the above expression as follows: 4 CS1022 pqr pqr pqr (prq prq) pqr Comm.& assoc. Laws pr(q q) pqr Distr. Law pr pqrSince q q = 1

5
Simplifying Boolean expressions (3) Compare pr pqr and pqr pqr pqr – They are equivalent – all changes done via a “law” – It is much simpler than original expression Very important: simplification can be automated – Each step in the process is an operation – Sequence of steps terminates at some point Notice: – First step puts together two minterms which differed by one symbol – Second step reduced two terms to one 5 CS1022

6
Karnaugh maps (1) Simplification done via a Karnaugh map – “Device” invented in the 1950s to help circuit design – Uses a visual display to indicate which pairs of minterms can be merged as a simpler expression For Boolean expressions with 3 variables (p, q and r) – Karnaugh map is a table with 2 rows and 4 columns – Columns labelled with all possible disjunctions of p and q and their negations – Rows labelled with r and r 6 CS1022 pq pqpqpqpq r r

7
Karnaugh maps (2) As we move from column to column precisely one change occurs in the column label Cells correspond to 8 different minterms stemming from 3 Boolean variables For a given Boolean expression, we write “1” in each cell whose row/column expression appears For instance, pqr pqr pqr has map 7 CS1022 pq pqpqpqpq r11 r 1

8
Karnaugh maps (3) Required simplification suggested by “clusters” of 1s – Shaded in green here There is only one such cluster in the example – Corresponds to terms we combined using the laws 8 CS1022 pq pqpqpqpq r11 r 1

9
Karnaugh maps (3) Relabelling columns preserves adjacency – Some clusters may be “hidden” – NB relabelling must be consistent with requirement that adjacent columns differ by one symbol only Example: Karnaugh map of pqr pqr pqr – Relabelling columns produces an alternative Karnaugh map and reveals a pair of adjacent minterms 9 CS1022 pq pqpqpqpq r11 r 1 pqpqpqpq r11 r 1

10
Karnaugh maps (4) Hence, 10 CS1022 pqpqpqpqpq r11 r 1 pqr pqr pqr pqr (pqr pqr) pqr pr(q q) pqr pr

11
Karnaugh maps (5) Let’s simplify pqr pqr pqr pqr pqr Karnaugh map: It contains a cluster of 4 (A) and a pair (B) – There are no hidden pairs – We must try relabelling exhaustively 11 CS1022 pq pqpqpqpq r11 r 111 pqr pqr pqr pqr (pqr pqr) pqr pr(q q) pqr pr

12
Karnaugh maps (6) Cluster (A) corresponds to 12 CS1022 pq pqpqpqpq r11 r 111 pqr pqr pqr pqr (p p)qr (p p)qr qr qr q(r r) q

13
Karnaugh maps (7) Cluster (B) corresponds to So, simplified expression is q pr 13 CS1022 pq pqpqpqpq r11 r 111 pqr pqr pr(q q) prpr

14
Logic circuits (1) One of the main application of Boolean algebra is the design of binary devices – They accept a (finite) number of inputs – They produce a (finite) number of outputs – Binary: only two possible values for each input & output Circuits as “black boxes”: 14 CS1022 ?... p1p1 p2p2 p3p3 pnpn q1q1 q2q2 q3q3 qmqm

15
Logic circuits (2) Devices are built of logic gates which perform basic Boolean operations ( , , and ) 15 CS1022 a b a b a b a b a a a b (a b) OR gate AND gate NOT gate NAND gate

16
Interconnecting gates produces a logical circuit A logical circuit evaluates a Boolean expression Example: What is the final output of this circuit? Logic circuits (3) 16 CS1022 4 3 2 1 p q r 5 6 7

17
4 3 2 1 p q r 5 6 7 Example: What is the final output of this circuit? Logic circuits (4) 17 CS1022 4 3 2 1 p q r 5 6 7 pq 4 3 2 1 p q r 5 6 7 4 3 2 1 p q r 5 6 7 pqr pqr pqr pqr pqr pqr

18
Solution: pqr pqr pqr Logic circuits (5) 18 CS1022 GateInputsOutput 1p, qpq 2 p, qpq 3pq, rpqr 4 pq, rpqr 5 pq, rpqr 6 pqr, pqrpqr pqr 7 pqr pqr, pqrpqr pqr pqr

19
Logic circuits can be simplified if we allow AND and OR gates to have more than 2 inputs More dramatic simplifications w/ Karnaugh maps – 2 clusters (one hidden) We can simplify things: – pqr pqr pq(r r) pq – pqr pqr (q q)pr pr That is, pqr pqr pqr pq pr – We can further simplify this as p(q r) Logic circuits (6) 19 CS1022 pq pqpqpqpq r11 r 1

20
With p(q r), we simplify previous circuit to obtain Logic circuits (7) 20 CS1022 p q r

21
Further reading R. Haggarty. “Discrete Mathematics for Computing”. Pearson Education Ltd. 2002. (Chapter 9) Wikipedia’s entry on Boolean algebra Wikibooks entry on Boolean algebra 21 CS1022

Similar presentations

OK

Karnaugh Maps The minimization method using Boolean Algebra, apart from being laborious and requiring the remembering all the laws, can lead to solutions.

Karnaugh Maps The minimization method using Boolean Algebra, apart from being laborious and requiring the remembering all the laws, can lead to solutions.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Run ppt on html editor Ppt on condition monitoring jobs Ppt on total parenteral nutrition nursing Ppt on testing of 3 phase induction motor Ppt on bond length of hbr Ppt on job rotation pros Ppt on network topology Ppt on statistics in maths pie Ppt on life and works of robert frost Ppt on teachers day free download