Starting Boolean Algebra

Similar documents
(Refer Slide Time 3:31)

Slide Set 5. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

(Refer Slide Time 6:48)

Combinational Circuits Digital Logic (Materials taken primarily from:

Introduction to Computer Architecture

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

IT 201 Digital System Design Module II Notes

Summary. Boolean Addition

Experiment 4 Boolean Functions Implementation

Learning Objectives: Topic Karnaugh Maps. At the end of this topic you will be able to;

(Refer Slide Time 5:19)

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

LSN 4 Boolean Algebra & Logic Simplification. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

(Refer Slide Time: 1:43)

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

CHAPTER-2 STRUCTURE OF BOOLEAN FUNCTION USING GATES, K-Map and Quine-McCluskey

Designing Computer Systems Boolean Algebra

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

COMP combinational logic 1 Jan. 18, 2016

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

SYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202)

Section 0.3 The Order of Operations

BOOLEAN ALGEBRA. Logic circuit: 1. From logic circuit to Boolean expression. Derive the Boolean expression for the following circuits.

6.001 Notes: Section 6.1

An Interesting Way to Combine Numbers

Combinational Logic & Circuits


Module -7. Karnaugh Maps

DKT 122/3 DIGITAL SYSTEM 1

9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

ELCT201: DIGITAL LOGIC DESIGN

Chapter 3. Boolean Algebra and Digital Logic

Chapter 2. Boolean Expressions:

Properties and Definitions

Contents. Chapter 3 Combinational Circuits Page 1 of 34

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

6.001 Notes: Section 8.1

How Computers Work. Processor and Main Memory. Roger Young

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Animations involving numbers

Chapter 3. Set Theory. 3.1 What is a Set?

Software Engineering 2DA4. Slides 2: Introduction to Logic Circuits

Excel Basics: Working with Spreadsheets

Points Addressed in this Lecture. Standard form of Boolean Expressions. Lecture 4: Logic Simplication & Karnaugh Map

ELCT201: DIGITAL LOGIC DESIGN

Lecture 1: Overview

Gate Level Minimization Map Method

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Grade 7/8 Math Circles Fall Nov.4/5 The Pythagorean Theorem

Skill 1: Multiplying Polynomials

Assignment (3-6) Boolean Algebra and Logic Simplification - General Questions

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Math Fundamentals for Statistics (Math 52) Unit 3: Addition and Subtraction. Scott Fallstrom and Brent Pickett The How and Whys Guys.

Chapter 2 Combinational Logic Circuits

Homework. Update on website issue Reading: Chapter 7 Homework: All exercises at end of Chapter 7 Due 9/26

Unit 4: Multiplication

4 KARNAUGH MAP MINIMIZATION

DeMorgan's Theorem. George Self. 1 Introduction

ENGIN 112 Intro to Electrical and Computer Engineering

JMC 2015 Teacher s notes Recap table

UNIT-4 BOOLEAN LOGIC. NOT Operator Operates on single variable. It gives the complement value of variable.

Divisibility Rules and Their Explanations

Introduction to Boolean Algebra

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

EECS 140 Laboratory Exercise 5 Prime Number Recognition

Binary, Hexadecimal and Octal number system

Circuit analysis summary

At this point in our study of digital circuits, we have two methods for representing combinational logic: schematics and truth tables.

If Statements, For Loops, Functions

Introduction to Boolean Algebra

6.001 Notes: Section 15.1

Digital Techniques. Lecture 1. 1 st Class

Specifying logic functions

Boolean relationships on Venn Diagrams

Chapter 2 Combinational

DIGITAL SYSTEM DESIGN

UNIT II. Circuit minimization

(Refer Slide Time: 01.26)

n! = 1 * 2 * 3 * 4 * * (n-1) * n

Intro. Scheme Basics. scm> 5 5. scm>

Combinational Devices and Boolean Algebra

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Mathematics Background

9/10/2016. The Dual Form Swaps 0/1 and AND/OR. ECE 120: Introduction to Computing. Every Boolean Expression Has a Dual Form

A point is pictured by a dot. While a dot must have some size, the point it represents has no size. Points are named by capital letters..

CS470: Computer Architecture. AMD Quad Core

LECTURE 2 An Introduction to Boolean Algebra

Algebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper.

Engineering Mechanics Prof. Siva Kumar Department of Civil Engineering Indian Institute of Technology, Madras Statics - 4.3

Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn

Exercise: Graphing and Least Squares Fitting in Quattro Pro

Using Basic Formulas 4

Lecture #21 March 31, 2004 Introduction to Gates and Circuits

Combinational Logic Circuits

Solution Guide for Chapter 20

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali

Transcription:

Boolean Algebra March 2, 27 Diagram for FunChip2 Here is a picture of FunChip2 that we created more or less randomly in class on /25 (used in various Activities): Starting Boolean Algebra Boolean algebra is a branch of mathematics that is well-suited to nicely describe circuits constructed using Not, Or, and And gates In addition to being a nice way to represent circuits and digital functions, we can do algebraic manipulation on a boolean expression, much like in ordinary algebra, which will allow us to sometimes produce circuits that are more efficient, in the sense that they use fewer gates Boolean algebra is such a useful tool that we will expend quite a bit of time becoming somewhat proficient at it In boolean algebra, letters represent input pins to a circuit or digital function, a b means a and b (and just like in ordinary algebra, we usually omit the and just write ab), a + b means a or b, and a means not a Much like in ordinary algebra, parentheses are used when needed to group operations and and has higher precedence than or For example, a(b + c) is different from ab + c, and in this latter expression we don t have to write (ab) + c The not operator is a little different from any operation in ordinary algebra, because it sort of provides its own parentheses, grouping together everything that function, actually) For example, we can write ab instead of (ab) is under it (like the to mean first And together a and b, and then flip the result, and a b means flip a and b separately, and then And together the results Note that the break in the overline is all that distinguishes these two expressions! CS 4 Spring 27 Page 4

Boolean Algebra March 2, 27 Converting Between Circuit Diagrams and Boolean Expressions Shortly we ll work directly with boolean algebra, but first let s motivate that work by seeing how easy it is to create a circuit diagram for a given boolean expression, and to create a boolean expression for a circuit diagram Activity 6 In your small groups, draw a circuit for a(ab + c + b) Activity 7 our task on this activity is to produce the boolean expression equivalent to the FunChip2 circuit To do this, simply figure out proceeding in a sensible order what boolean expression is produced on each wire For example, w 2 = b + c (oh, I gave it away, but I might be wrong!) Then the final answer is the boolean expression for f Two Ways to Create Any Function From And, Or, Not It turns out to be, in principle, easy to produce a boolean expression for any desired digital function table We will study this next, but note that this technique does not necessarily or even usually produce the most efficient expressions After learning these techniques, we will then do a lot of work on boolean algebra to learn how to work with boolean expressions, thus maybe obtaining circuits with fewer fundamental gates, and to learn how to use different gates Technique : Sum of Products Suppose you are given a digital function table, say: a b c f The first big idea here is to note that a boolean expression such as abc using each input variable unchanged or flipped, and then And ed together, has a very simple truth table it is simply CS 4 Spring 27 Page 5

Boolean Algebra March 2, 27 a b c abc where the only occurs in the only row that makes abc true, namely the row The second big idea is that if we have two digital functions and we Or them together, the resulting digital function has s anywhere either of the original functions has a So, it is obvious that a boolean expression for f is f = abc + abc + abc + abc Activity 8 In your small group, write down a boolean expression equivalent to this digital function: a b c f CS 4 Spring 27 Page 6

Boolean Algebra March 2, 27 Technique 2: product of sums The technique we have just learned is easier and produces simpler expressions if there are fewer s than s in the given digital function output column If there are more s than s, we can focus on how to make s, as follows For our earlier chart, consider the first in the f column, corresponding to a =, b =, and c = The only way to make a + b + c false is to have all three terms false In other words, note that the digital function for a + b + c is: a b c a + b + c Now we note that if we And together two digital functions, then we get wherever any one of them is, and get everywhere else So, with some deep thought, we see that another boolean expression for f is f = (a + b + c)(a + b + c)(a + b + c)(a + b + c) Activity 9 In your small group, write down a boolean expression equivalent to this digital function, in the form of a product of sums: a b c f CS 4 Spring 27 Page 7

Boolean Algebra March 2, 27 Exercise 7 Write down the truth table for ab and apply both techniques (sum of products and product of sums) to get two different boolean expressions for ab Do the same thing for a + b Getting Into Boolean Algebra Now we want to really get into boolean algebra so we will be able to manipulate boolean expressions in order to make them more efficient or use gates of our choice (specifically, we will build all the combinational circuits for our virtual computer using just Nand gates!) We begin by stating a convenient collection of axioms statements that are assumed to be true in a mathematical system Note that unlike in many branches of mathematics, all the axioms below can actually be proven by checking, using truth tables, whether they are true in all possible cases ie, for all possible values of the variables involved In this sense they are not axioms, just observations our only actual axioms, technically, are the +,, and tables Axioms of Boolean Algebra Note that we put in the operator here, for clarity, but usually we ll omit it For all possible values of the variables being used: a + b = b + a and a b = b a (the commutative laws) (a + b) + c = a + (b + c) and (a b) c = a (b c) (the associative laws) a (b + c) = a b + a c and a + (b c) = (a + b) (a + c) (the distributive laws) a + = a, a = a ( and are the additive and multiplicative identity elements) a = a + =, a a = a, a + a = a aa =, a + a =, a = a Activity As a whole group, discuss which of these axioms are familiar from ordinary algebra, and which are a little strange For the strange ones, let s try to see whether we believe them CS 4 Spring 27 Page 8

Boolean Algebra March 2, 27 Proving Theorems of Boolean Algebra Now we want to see how to do formal proofs of boolean algebra facts, and learn some useful facts along the way To prove that two boolean expressions are equal and hence that they have the same digital function charts we can write them in two separate columns, and in each column separately write down what each side is equal to, until at the bottom in both columns we have the same expression This shows, by properties of equality, that the original expressions are equal Often, we will start with one expression and transform it until we reach the other but it is okay to work on both sides and transform each to some common expression As we write these chains of equations, we don t have to write down why each equation is true, but we must be sure of each Example Proof Prove that a(a + b) = a: Working on the left side, we see that (reasons are included here, which is a good idea, but usually too easy to bother): a(a + b) = aa + ab distributive law = a + ab axiom: a a = a = a + ab axiom: a = a = a( + b) distributive law = a axiom: a + = plus commutativity = a axiom: a = Activity our small group will be assigned several of the following facts (they are referred to as theorems because they are often useful in simplifying other boolean expressions For each one, either prove it by chains of equalities, or, if that doesn t seem to be working, resort to computing the truth tables (a common albeit strange term for digital function chart ) for both sides and verifying that the two expressions produce the same output for all inputs If you are the primary group (hearts) for a theorem, be ready to write your proof on the board when we regather If you couldn t figure it out, tell us, and we ll make the secondary (clubs) or tertiary (spades) group report If you complete your assigned Theorems, do others the more practice, the better! By the way, we express these using uppercase letters to make it easier later to substitute different lowercase letters Theorem + = (done) CS 4 Spring 27 Page 9

Boolean Algebra March 2, 27 Theorem 2 + = + (hint: start by using Theorem on the first ) Theorem 3 + Z + = + Z (hint: multiply the on the left by in the form + ) Theorem 4 ( + ) = Theorem 5 ( + ) = Theorem 6 ( + )( + ) = Theorem 7 ( + )( + Z) = Z + Theorem 8 ( + )( + Z)( + Z) = ( + )( + Z) Theorem 9 = + (hint: check the truth tables) Theorem + = (hint: check the truth tables) Applying These Theorems Note that these theorems apply with any quantities substituted in for,, and Z It might be helpful to look at some of these theorems more vividly, using symbols that look more distinct from each other: Theorem + = Theorem 2 Theorem 3 + = + + + = + The Duality Principle The dual of a Boolean expression is obtained by replacing all And s by Or s, Or s by And s, s by s, and s by s If an equation involving Boolean expressions always holds, then so will its dual equation For example, Theorem says that for any and, The dual of this statement is that Excitingly, this statement is Theorem 4! + = ( + ) = Activity 2 Write down the dual statement for Theorem 2, and see that it is simply Theorem 5 Explore the duals of Theorems 6 and 7 and see if they are any other theorems CS 4 Spring 27 Page 2

Boolean Algebra March 2, 27 Exercise 8 Write down the dual statement for Theorem 3 and see if it is the same as any of the other Theorems Some Famous Fallacies People often think that things should be true which can t be fallacies: + can t be simplified, and it is certainly not + can t be simplified, and it is certainly not is not the same as + is not the same as + Here are some of these Some Examples of Simplifying Boolean Expressions Activity 3 In your small groups, prove the following equations (as time allows do the others on your own for practice) a + + + ( + ) = b + + + = + Z c = + Z d ( + )( + Z)( + Z ) = + e (W + + )(W + )( + ) = + W f W Z + + W + + W = W + g W Z + W Z + + W = Z + + W Z h ( + + Z)( + + Z)( + + Z ) = Z + Exercise 9 Starting from the left and applying various facts, show that + + + = + Z + CS 4 Spring 27 Page 2

Boolean Algebra March 2, 27 Another Proof of Theorem 8 As warm-up for out upcoming work (seeing how we can use Nand gates to implement target functions), let s prove Theorem 8 by demorgan s rules This doesn t seem possible, but we can do it by putting two negation bars over the starting expression Activity 4 Begin with ( + )( + Z)( + Z) = ( + )( + Z)( + Z) and use demorgan s laws to simplify until we get the desired result for Theorem 8 Gray Codes In an apparent digression (but something that is good to know, is fun and easy, hits an earlier topic, and is crucial for our next big topic), let s consider a different way of writing down all the binary sequences of a given size The goal is to write down all 2 n bit sequences of size n in such a way that the change from each one to the next occurs in just one bit including going around from the last one to the first one This is not true for the way we said to list them before, say for n = 2: Bit sequence transition okay? no changed 2 bits from last one okay no changed 2 bits okay Recall how we generated lists of all bit sequences of a given size: we repeatedly made two copies of the known bit sequences of a given size, and put s in front of all the sequences in the first group, and s in front of all in the second Creating a Gray code list is similar, but instead of just copying, we copy and reverse For example, all the bit sequences of size are To make a 2-bit Gray code, we copy these, and reverse the second list: CS 4 Spring 27 Page 22

Boolean Algebra March 2, 27 and then we put s in front the of the first half and s in front of the second half, obtaining: It is easy to check that this is a Gray code of size 2: Bit sequence transition okay? okay okay okay okay It is easy to see why this trick works First, we are guaranteed to get all the 2 n different n-bit sequences reversing the copy doesn t lose or gain anything, so it s much like before Second, reversing the copy guarantees that the bit sequences at the two places where the copies are touching are identical, so when we put s and s in, at those touchings, we have just one bit changing between and in the first position and inside the two halves, we aren t adding a bit change, because we have and or and Activity 5 Use this technique to produce Gray codes for 3-bit and 4-bit sequences Karnaugh Maps Now we want to explore a technique for analyzing and simplifying boolean expressions involving up to four variables (or more, but it is less effective the higher we go above 4) known as a Karnaugh map A Karnaugh map is just a clever way to write the truth table for a digital function that helps us to understand the structure of the expression However many variables there are in the boolean expression being studied, the idea is to divide them roughly in half, using rows for the first half, columns for the second half, and then to list a Gray code with with number of bits equal to the number of variables along the rows and columns medskip For example, if we have four variables, say A, B, C, and D, we create this chart: CS 4 Spring 27 Page 23

Boolean Algebra March 2, 27 Here is the crucial fact for the Karnaugh map: each cell corresponds to a row of an ordinary digital function chart (truth table), with the values of the row variables being given, in order, by the Gray code item for the row, and the values of the column variables being given, in order, by the Gray code item for the column For example, the cell in row 3, column 2, corresponds to the row of the truth table with A =, B =, C =, D = The truth table drawn as a Karnaugh map with a in this cell and s everywhere else, corresponds to the boolean expression Activity 6 Write in the boolean expression for the cells in the Karnaugh map below (the one in row 3, column 2 has been done alreadys) Fill them in randomly scattered around the grid until you totally understand how you could do them all: CS 4 Spring 27 Page 24

Boolean Algebra March 2, 27 Activity 7 Write the Karnaugh map below for this truth table: A B C D f Write down the sum of products boolean expression for this function (reading the terms to include from the Karnaugh map is easier than from the original truth table, note): CS 4 Spring 27 Page 25

Boolean Algebra March 2, 27 Activity 8 Figure out how to write a Karnaugh map with just two variables, and fill in its 4 cells for the Nor function Actually, usually we just write s and leave s blank, or even shade the squares that have s and leave the s unshaded A very important cleverness that makes the Karnaugh map work is that the row and column bit sequences are in a Gray code order This is done so that squares that are next to each other in a row only have one of their bits differing, and similarly for columns The idea of using the Karnaugh map is to first shade all the cells that have a in the truth table, and then to recognize algebraic terms that can be OR d together to produce those s To do this, we first have to understand the correspondence between algebraic terms that consist of one or more variables, perhaps negated, And d together Activity 9 Using the blank Karnaugh maps provided, shade or write s in the appropriate cells for each given boolean expression: So, with 4 variables, a product of four factors (a variable or not of a variable) gives cell(s) with s D B B CS 4 Spring 27 Page 26

Boolean Algebra March 2, 27 So, with 4 variables, a product of 3 factors gives cell(s) with s A D BC So, with 4 variables, a product of 2 factors gives cell(s) with s A D B So, with 4 variables, one factor gives cell(s) with s CS 4 Spring 27 Page 27

Boolean Algebra March 2, 27 Activity 2 In your small group, explore Karnaugh maps with 3 variables, say A, B, and C, similarly to how we explored 4 variable Karnaugh maps in Activity 9 We can do this in two ways, but let s all do it the way that has more columns than rows Operations on Karnaugh Maps It turns out to be easy to perform our basic operations And, Or, and Not on Karnaugh maps (or truth tables in any form, for that matter) To compute the Or of two Karnaugh maps, we just make a new one that has ones wherever either of the two given maps has a one To compute the And of two Karnaugh maps, we just put a wherever both given maps have s To compute the Not of a Karnaugh map, we just put a wherever the given map doesn t have a Karnaugh maps are great for representing sum of product expressions, but sometimes we have to deal with the other two operations (other than the way they occur in the sum of products form), and in that case, we need to do operations on Karnaugh maps Proving the Standard Distributive Axiom Using Karnaugh Maps Let s verify the axiom A(B + C) = + AC using Karnaugh maps To do this, we just fill in the Karnaugh maps below for A and B + C, and perform the And operation on these two maps, obtaining the Karnaugh map for A(B + C): A B + C A(B + C) A BC A BC = A BC Then we fill in the Karnaugh map for + AC, and note that the two sides do produce the same Karnaugh maps: + AC BC A CS 4 Spring 27 Page 28

Boolean Algebra March 2, 27 Activity 2 Fill in these Karnaugh maps to verify the other distributive axiom: A + B A + C (A + B)(A + C) A BC A BC = A BC A + BC BC A We can use Karnaugh maps to verify or prove any boolean equation (for more than 4 variables occurring in an equation, we would need to enlarge our Karnaugh map, say to 8 rows or columns for 3 variables, using an 8-bit Gray code) More importantly, doing these proofs will help us to get comfortable with Karnaugh maps, so we will be able to use them to simplify given boolean expressions Example: verify Theorem 7 with Karnaugh maps Recall Theorem 7: ( + )( + Z) = Z + We can easily verify this by filling in these Karnaugh maps and verifying that the And of the first two is the third (note that we can And the two maps and check against the third in our heads without writing down the map): + + Z Z +? = CS 4 Spring 27 Page 29

Boolean Algebra March 2, 27 Activity 22 In your small group, and continuing on your own as needed, verify all the theorems and exercises that we previously did using algebra (do as many of these as you need to in order to know that you could do anything similar the empty maps are provided for all, but that doesn t imply that you have to do them all but make sure you don t skip any because they look hard) Theorem + = + Theorem 2 + = + + + Theorem 3 + Z + = + Z + Z + + Z Theorem 4 ( + ) = ( + ) CS 4 Spring 27 Page 3

Boolean Algebra March 2, 27 Theorem 5 ( + ) = + Theorem 6 ( + )( + ) = + + Theorem 8 ( + )( + Z)( + Z) = ( + )( + Z) + + Z + Z Theorem 9 = + + CS 4 Spring 27 Page 3

Boolean Algebra March 2, 27 Theorem + = + + Activity 3 revisited a + + + ( + ) = + + + ( + ) b + + + = + Z + ++ + Z CS 4 Spring 27 Page 32

Boolean Algebra March 2, 27 c = + Z Z Z + Z d ( + )( + Z)( + Z ) = + + + Z + Z (+ )( +Z)( +Z ) + CS 4 Spring 27 Page 33

Boolean Algebra March 2, 27 e (W + + )(W + )( + ) = + W W + + W + + W W W (W ++)(W +)( + ) + W W W f W Z + + W + + W = W + W Z + +W ++W W + W W CS 4 Spring 27 Page 34

Boolean Algebra March 2, 27 g W Z + W Z + + W = Z + + W Z W Z+W Z+ +W Z + + W Z W W h ( + + Z)( + + Z)( + + Z ) = Z + + + Z + + Z + + Z (+ +Z)( + +Z)( + +Z ) Z + Exercise revisited + + + = + Z + ++ + + Z + CS 4 Spring 27 Page 35

Boolean Algebra March 2, 27 The Art of Using Karnaugh Maps to Get Nice Boolean Expressions Now we should have enough experience with Karnaugh maps to comfortably get to a main point of all that we have been doing Once we have a Karnaugh map for a desired truth table, we can use it to write nice boolean expressions for the truth table The point is that our earlier sum of products technique, say with 4 variables, leads to a term with 4 factors for each occurring in the truth table This approach, while easy to write down, is often way more complicated, and hence harder to implement as a circuit diagram, than it needs to be We could, of course, use our algebra skills to simplify the expression, but the Karnaugh map approach seems easier We can often make much simpler boolean expressions by finding rectangular blocks of s that have width and height as powers of 2 (, 2, 4) The cool thing is that larger rectangles correspond to terms with fewer factors, so we win in two ways we end up with fewer terms, and they are simpler Though there are algorithms to do this automatically, we will treat it as an art just examine the Karnaugh map, looking for nice rectangles that cover all the s We will only go up to at most 4 by 4 Karnaugh maps for 4 variables The art gets harder with 3 variables on a side, requiring 8 rows or columns, because the rectangles no longer have to have adjacent cells Remember that the rectangles can wrap around the edges of the diagram, and that it is okay to overlap rectangles it doesn t hurt to have a single produced by multiple terms Let s practice this art a little! Activity 23 To warm up a little, write down (in the convenient box at the top) the single term that produces each of these given rectangles: CS 4 Spring 27 Page 36

Boolean Algebra March 2, 27 Activity 24 For the Karnaugh map given below, write down two different but equally nice boolean expressions CS 4 Spring 27 Page 37

Boolean Algebra March 2, 27 Exercise For the Karnaugh map given below, write down a nice boolean expression that implements it Example: Designing a 7-Segment Digit Display Before starting our big project (you may have forgotten our goal: understand how to build a computer), let s do a simpler real-world design example, as a warm-up exercise Suppose we want to create a circuit with input bits giving, in binary, a decimal value between and 9, and we want to have 7 outputs sharing those inputs, one for each segment (an LED, say) of a single digit display like this: a f b g e c d In other words, the 7 outputs will each be connected to an LED for the corresponding segment, so that when 4 bits are fed to the DigitDisplay chip, corresponding to a decimal number from through 9, the correct LED s will light up, crudely drawing the digit (something like this this is pretty commonly done in lots of household devices like my watch, now that I look at it, in a bunch of different places where it wants to display a single digit) The digit is typically drawn with segments b and c turned on, rather than f and e The other digits are pretty obvious CS 4 Spring 27 Page 38

Boolean Algebra March 2, 27 The idea is that for each row corresponding to 4 bits that give a decimal digit of the truth table below, we want if the corresponding segment should be turned off, and if it should be turned on: Inputs Outputs Decimal Digit A B C D a b c d e f g 2 3 4 5 6 7 8 9 x x x x x x The s and s have been filled in for a, but not for the others Note that the last 6 rows of input should never happen, because there are only possible digits (we have to use 4 input wires to allow for digits, because 3 inputs would only give us 8 different cases), we write x to mean don t care To design the circuit for a, we now create the Karnaugh map for a: CS 4 Spring 27 Page 39

Boolean Algebra March 2, 27 a x x x x x x Now we use our Karnaugh map design idea, namely looking for big power of 2 sized rectangles of s and x s If we don t include any of the x s, we could cover the s with 4 one by two rectangles, obtaining A B D + A + A BD + C We could also use all the x s as s and note that the bottom two rows are covered by A, obtaining A + + A B D + A BD Activity 25 Complete the design of the 7-segment digit display by filling in s and s in the truth table, filling in the Karnaugh maps below for the remaining 6 outputs, finding nice boolean expressions for all 7 outputs, and drawing a sketch of the internals of the circuit diagram with these input/output pins: A B C D DigitDisplay a b c d e f g Here, for your convenience, are the empty Karnaugh maps you can use: CS 4 Spring 27 Page 4

Boolean Algebra March 2, 27 b c d e f g Write your final nicest boolean expressions here: a = b = c = d = e = f = g = CS 4 Spring 27 Page 4

Boolean Algebra March 2, 27 Exercise Implement your DigitDisplay circuit as an HDL file, as follows At the course web site, in folder HDLstuff, you will find a folder DigitDisplay that contains DigitDisplayhdl and DigitDisplaytst Download these files into a convenient folder on your computer The inputs and outputs have been written in DigitDisplayhdl, and output a has been implemented, using the formula discussed previously that leaves all the don t care rows at Be careful about uppercase and lowercase letters they are completely different symbols, and you must get them right since this example unfortunately uses both A and a Start up the hardware simulator and load the chip DigitDisplayhdl and the script DigitDisplaytst Run the script and then view DigitDisplayout in a text editor ou should see the truth table for a throught g, and the column for a should be correct, because it has already been implemented in DigitDisplayhdl Now, text edit DigitDisplayhdl and finish write parts to implement each of the outputs b through g Then, load the chip and run the test script again This time you should see the correct columns for all the outputs If not, fix your work (the error could be in any phase of what you ve done) Of course, if you are wise, you will implement and test the outputs one at a time, so as not to overwhelm yourself CS 4 Spring 27 Page 42

Boolean Algebra March 2, 27 Some Hints for Exercise The safest way to create an HDL file for a circuit and the approach we will definitely take with our upcoming work building a computer is to actually draw the circuit, labeling all the pins, wires, and parts We must make sure that each wire (which can have lots of connected, branching parts a wire is actually one electrically-connected piece of copper) has its own name, like w7 The approach we have taken with Karnaugh maps looking for 2 by 4, by 4, 2 by 2, or 2 by rectangles of adjacent (with wrapping) cells, and only using by rectangles when we have to leads to a sum of products circuit, where each term has one or more factors which is a variable or a variable with a bar over it To conveniently draw such a circuit, a common technique is to first produce wires with all the inputs, labeled like A, B, and so on, and then to produce the Not of all these in an obvious way, labeled like nota, notb, and so on Then further to the right we can put various And gates to produce the various products needed, and finally, further yet to the right, we put various Or gates to produce the sums we need To keep the circuit diagrams easier to read and write, we can create handy new gates like And3Way that takes three inputs and outputs the And of all three, and Or4Way that takes four inputs and outputs the Or of all four We just have to design and draw these circuits and then specify them in files And3Wayhdl and Or4Wayhdl that are in the same folder as DigitDisplayhdl On the next page we show a diagram for output a using these ideas Note that when we are drawing circuits we can take liberties with the physical arrangements of the input and output pins here for convenience we use a Not gate that has its input on top and its output on the bottom The HDL files are all about connections they have no concept of the geometry of things Another idea is to notice terms that appear in more than one of the output functions and after producing such a term, to branch its wire to all the places where it is appears CS 4 Spring 27 Page 43

Boolean Algebra March 2, 27 A A B B C C D D Not Not Not Not And3Way And3Way And3Way Or4Way a And3Way CS 4 Spring 27 Page 44