Boolean logic. Boolean Algebra. Introduction to Computer Yung-Yu Chuang NOT AND NOT

Similar documents
6. Combinational Circuits. Building Blocks. Digital Circuits. Wires. Q. What is a digital system? A. Digital: signals are 0 or 1.

Combinational Circuits

Combinational Circuits Digital Logic (Materials taken primarily from:

Chapter 3. Gate-Level Minimization. Outlines

Combinational Logic & Circuits

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

2/8/2017. SOP Form Gives Good Performance. ECE 120: Introduction to Computing. K-Maps Can Identify Single-Gate Functions

Gate Level Minimization

Gate Level Minimization Map Method

Gate-Level Minimization. BME208 Logic Circuits Yalçın İŞLER

There are only 16 possible 2-input gates Let s examine all of them. Some we already know, others are just silly.

CS8803: Advanced Digital Design for Embedded Hardware

Experiment 3: Logic Simplification

Logic Design (Part 2) Combinational Logic Circuits (Chapter 3)

Gate-Level Minimization

Arithmetic Logic Unit (ALU)

QUESTION BANK FOR TEST

Chapter 2. Boolean Expressions:

Gate-Level Minimization

Boolean Algebra and Logic Gates

University of Technology

Philadelphia University Faculty of Information Technology Department of Computer Science. Computer Logic Design. By Dareen Hamoudeh.

Review: Standard forms of expressions

Chapter 2 Combinational Logic Circuits

Experiment 4 Boolean Functions Implementation

Simplification of Boolean Functions

Department of Electrical Engineering McGill University ECSE 221 Introduction to Computer Engineering Assignment 2 Combinational Logic

Boolean Logic CS.352.F12


ELCT201: DIGITAL LOGIC DESIGN

Circuit analysis summary

Chapter 2: Combinational Systems

ENGIN 112 Intro to Electrical and Computer Engineering

Standard Forms of Expression. Minterms and Maxterms

01 Introduction to Digital Logic. ENGR 3410 Computer Architecture Mark L. Chang Fall 2008

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

1. Mark the correct statement(s)

Chapter 2 Boolean algebra and Logic Gates

Gate-Level Minimization

DKT 122/3 DIGITAL SYSTEM 1

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Chapter 3. Boolean Algebra and Digital Logic

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

Boolean Algebra. BME208 Logic Circuits Yalçın İŞLER

Incompletely Specified Functions with Don t Cares 2-Level Transformation Review Boolean Cube Karnaugh-Map Representation and Methods Examples

Menu. Algebraic Simplification - Boolean Algebra EEL3701 EEL3701. MSOP, MPOS, Simplification

Digital Logic Design (3)

Digital Logic Lecture 7 Gate Level Minimization

IT 201 Digital System Design Module II Notes

6: Combinational Circuits

Unit-IV Boolean Algebra

Chapter 2 Combinational

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali

2.1 Binary Logic and Gates

Gate-Level Minimization. section instructor: Ufuk Çelikcan

Digital Fundamentals

SWITCHING THEORY AND LOGIC CIRCUITS

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

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

Lecture (05) Boolean Algebra and Logic Gates

Simplification of Boolean Functions

Ch. 5 : Boolean Algebra &

Announcements. Chapter 2 - Part 1 1

Summary. Boolean Addition

Computer Science. Unit-4: Introduction to Boolean Algebra

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

X Y Z F=X+Y+Z

Combinational Logic Circuits

Module -7. Karnaugh Maps

2.6 BOOLEAN FUNCTIONS

S1 Teknik Telekomunikasi Fakultas Teknik Elektro FEH2H3 2016/2017

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

Lecture 10: Combinational Circuits

Switching Circuits & Logic Design

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

ELCT201: DIGITAL LOGIC DESIGN

CS470: Computer Architecture. AMD Quad Core

Computer Engineering Chapter 3 Boolean Algebra

Graduate Institute of Electronics Engineering, NTU. CH5 Karnaugh Maps. Lecturer: 吳安宇教授 Date:2006/10/20 ACCESS IC LAB

01 Introduction to Digital Logic. ENGR 3410 Computer Architecture Mark L. Chang Fall 2006

A B AB CD Objectives:

Code No: 07A3EC03 Set No. 1

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

UNIT 2 BOOLEAN ALGEBRA

Specifying logic functions

Chapter 2. Boolean Algebra and Logic Gates

Propositional Calculus. Math Foundations of Computer Science

Boolean algebra. June 17, Howard Huang 1

2008 The McGraw-Hill Companies, Inc. All rights reserved.

Variable, Complement, and Literal are terms used in Boolean Algebra.

數位系統 Digital Systems 朝陽科技大學資工系. Speaker: Fuw-Yi Yang 楊伏夷. 伏夷非征番, 道德經察政章 (Chapter 58) 伏者潛藏也道紀章 (Chapter 14) 道無形象, 視之不可見者曰夷

Combinational Logic Circuits Part III -Theoretical Foundations

Introduction to Boolean logic and Logical Gates

Digital Logic Design. Outline

7/25/2016. Example: Addition of Unsigned Bit Patterns. ECE 120: Introduction to Computing. Adding Two Non-Negative Patterns Can Overflow

Lecture 7 Logic Simplification

Lecture 4: Implementation AND, OR, NOT Gates and Complement

Combinational Logic Circuits

ece5745-pla-notes.txt

Transcription:

oolean lgebra oolean logic ased on symbolic logic, designed by George oole oolean variables take values as or. oolean expressions created from: NOT, ND, OR Introduction to Computer ung-u Chuang with slides by Sedgewick & Wayne (introcs.cs.princeton.edu), Nisan & Schocken (www.nand2tetris.org) and Harris & Harris (DDC) 2 NOT ND X X X X Digital gate diagram for NOT: Digital gate diagram for ND: NOT ND 3 4

OR Operator Precedence X+ Examples showing the order of operations: NOT > ND > OR Digital it gate diagram for OR: OR Use parentheses to avoid ambiguity 5 6 Defining a function Defining a function Description: square of x minus lgebraic form : x 2 - Enumeration: x f(x) 2 3 3 8 4 5 5 24 : : 7 Description: number of days of the x-th month of a non-leap pyear x f(x) lgebraic form:? 3 Enumeration: 2 28 3 3 4 3 5 3 6 3 7 3 8 3 9 3 3 3 2 3 8

Truth Table Truth table. Systematic method to describe oolean function. One row for each possible input combination. N inputs 2 N rows. Proving the equivalence of two functions Prove that x 2 -=(x+)(x-) Using algebra: (you need to follow some rules) (x+)(x-) = x 2 +x-x-= x 2 - x y x y ND truth table Using enumeration: x (x+)(x-) x 2-2 3 3 3 8 8 4 5 5 5 24 24 : : : 9 x + = x + = x x + x = x. = x x. = x.x = DeMorgan Law x.y = x + y Important laws x + y = y + x x + (y+z) = (x+y) + z x.y = y.x x.(y.z) = (x.y).z x.(y+z) = xy + xz Simplifying oolean Equations Example : = + Chapter 2 <2>

Simplifying oolean Equations Example : = + = ( + ) = () = Simplifying oolean Equations Example 2: = ( + C) Chapter 2 <3> Chapter 2 <4> Simplifying oolean Equations DeMorgan s Theorem Example 2: = ( + C) = (( + C)) = (()) = () = () = = = + = + = Chapter 2 <5> Chapter 2 <6>

ubble Pushing ubble Pushing ackward: ody changes dds bubbles to inputs What is the oolean expression for this circuit? Forward: ody changes dds bubble to output C D Chapter 2 <7> Chapter 2 <8> ubble Pushing What is the oolean expression for this circuit? C D = + CD ubble Pushing Rules egin at output, then work toward inputs Push bubbles on final output back Draw gates in a form so bubbles cancel C D Chapter 2 <9> Chapter 2 <2>

ubble Pushing Example ubble Pushing Example no output bubble C D C D Chapter 2 <2> Chapter 2 <22> ubble Pushing Example ubble Pushing Example no output bubble no output bubble C D C D bubble on input and output bubble on input and output C D C D no bubble on input and output C D = C + D Chapter 2 <23> Chapter 2 <24>

Truth Tables ( of 3) oolean function has one or more oolean inputs, and returns a single oolean output. truth table shows all the inputs and outputs of a oolean function Example: X Truth Tables (2 of 3) Example: X 25 26 Truth Tables (3 of 3) When s=, return x; otherwise, return y. Example: ( S) (X S) X S mux Z Two-input multiplexer Truth Table for Functions of 2 Variables Truth table. 6 oolean functions of 2 variables. every 4-bit value represents one x y ZERO ND x y XOR OR Truth table for all oolean functions of 2 variables x y NOR EQ y' x' NND Truth table for all oolean functions of 2 variables ONE 27 28

ll oolean functions of 2 variables Truth Table for Functions of 3 Variables Truth table. 6 oolean functions of 2 variables. 256 oolean functions of 3 variables. 2^(2^n) oolean functions of n variables! every 4-bit value represents one every 8-bit value represents one every 2 n -bit value represents one x y z ND OR MJ ODD some functions of 3 variables Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 29 3 Sum-of-Products Sum-of-products. Systematic procedure for representing a oolean function using ND, OR, NOT. Form ND term for each in oolean function. OR terms together. x y z MJ x'yz xy'z xyz' xyz expressing MJ using sum-of-products proves that { ND, OR, NOT } are universal x'yz + xy'z + xyz' + xyz Universality of ND, OR, NOT Fact. ny oolean function can be expressed using ND, OR, NOT. { ND, OR, NOT } are universal. Notation Ex: XOR(x,y) = xy' + x'y. x' NOT x x y x + y Expressing XOR Using ND, OR, NOT x y x' y' x'y xy' x'y + xy' x XOR y Exercise. Show {ND, NOT}, {OR, NOT}, {NND}, {NOR} are universal. Hint. DeMorgan's law: (x'y')' = x + y. Meaning x ND y x OR y 3 32

From Math to Real-World implementation We can implement any oolean function using NND gates only. Implementation of gates Fluid switch (http://www.cs.princeton.edu/introcs/lectures/fluid-computer.swf We talk about abstract oolean algebra (logic) so far. Is it possible to realize it in real world? The technology needs to permit switching and conducting. It can be built using magnetic, optical, biological, i l hydraulic and pneumatic mechanism. 33 Digital Circuits What is a digital system? nalog: signals vary continuously. Digital: signals are or. 3.3V 2.8V.5V Why digital systems?.v ccuracy and reliability. Staggeringly fast and cheap. asic abstractions. On, off. Wire: propagates on/off value. Switch: controls propagation p of on/off values through wires. Wires Wires. On (): connected to power. Off (): not connected to power. If a wire is connected to a wire that is on, that wire is also on. Typical drawing convention: "flow" from top, left to bottom, right. power connection 35 36

Controlled Switch Relay Controlled switch. [relay implementation] 3 connections: input, output, control. Magnetic force pulls on a contact that cuts electrical flow. Control wire affects output wire, but output does not affect control; establishes forward flow of information on over time. X X 37 38 Circuit natomy Logic Gates: Fundamental uilding locks 39 4

NOT NOT 4 42 OR Series relays = NOR 43 44

OR ND 45 46 ND Logic Gates: Fundamental uilding locks 47 48

What about parallel relays? =NND Can we implement ND/OR using parallel relays? Now we know how to implement ND,OR and NOT. We can just use them as black boxes without knowing how they were implemented. Principle of information hiding. 49 5 Multiway Gates Multiway gates. OR: if any input is ; otherwise. ND: if all inputs are ; otherwise. Generalized: negate some inputs. Multiway Gates Multiway gates. OR: if any input is ; otherwise. ND: if all inputs are ; otherwise. Generalized: negate some inputs. 5 52

Multiway Gates Multiway gates. Can also be built from 2-way ygates (less efficient but implementation independent) Example: build 4-way OR from 2-way ORs Translate oolean Formula to oolean Circuit Sum-of-products. XOR. 53 54 Translate oolean Formula to oolean Circuit Sum-of-products. XOR. Translate oolean Formula to oolean Circuit Sum-of-products. XOR. 55 56

Gate logic ODD Parity Circuit Interface a Xor b out ODD(x, y, z). if odd number of inputs are. otherwise. a b out a Implementation ti nd Not Or out b Not nd Xor(a,b) = Or(nd(a,Not(b)),nd(Not(a),b))) (b)) d(n ( ) b))) ODD Parity Circuit ODD(x, y, z). if odd number of inputs are. otherwise. ODD Parity Circuit ODD(x, y, z). if odd number of inputs are. otherwise. x y z ODD x'y'z x'yz' xy'z' xyz x'y'z+x'yz' y + xy'z' + xyz Expressing ODD using sum-of-products 59 6

ODD Parity Circuit ODD(x, y, z). if odd number of inputs are. otherwise. Expressing a oolean Function Using ND, OR, NOT Ingredients. ND gates. OR gates. NOT gates. Wire. Instructions. Step : represent input and output signals with oolean variables. Step 2: construct truth table to carry out computation. Step 3: derive (simplified) oolean expression using sum-of products. Step 4: transform oolean expression into circuit. 6 62 Translate oolean Formula to oolean Circuit Sum-of-products. Majority. Translate oolean Formula to oolean Circuit Sum-of-products. Majority. 63 64

Translate oolean Formula to oolean Circuit Sum-of-products. Majority. Translate oolean Formula to oolean Circuit Sum-of-products. Majority. 65 66 Simplification Using oolean lgebra Every function can be written as sum-of-product oolean expression simplification Karnaugh map Many possible circuits for each oolean function. Sum-of-products not necessarily optimal in: number of switches (space) depth of circuit (time) 67 68

Karnaugh Maps (K Maps) oolean expressions can be minimized by combining terms K maps minimize equations graphically P + P = P C C C C C C C C C C C K Map Circle s in adjacent squares In oolean expression, include only literals whose true and complement form are not in the circle C C = Chapter 2 <69> Chapter 2 <7> 3 Input K Map 3 Input K Map C C C C C C C C C C C C C C C C C C Truth Table C K-Map C Chapter 2 <7> Truth Table K-Map C C = + C Chapter 2 <72>

K Map Rules Every must be circled at least once Each circle must span a power of 2 (i.e., 2, 4) squares in each direction Each circle must be as large as possible circle may wrap around the edges don't care (X) is circled only if it helps minimize the equation 4 Input K Map C D CD Chapter 2 <73> Chapter 2 <74> 4 Input K Map 4 Input K Map C D CD C D CD = C + D + C + D Chapter 2 <75> Chapter 2 <76>

K Maps with Don t Cares K Maps with Don t Cares C D CD X X X X X X X C D X X X X X X X CD X X X X X X X Chapter 2 <77> Chapter 2 <78> K Maps with Don t Cares Example C D X X X X X X X CD X X X X X X X = + D + C xy z Chapter 2 <79> 8

Simplification Using oolean lgebra Many possible circuits for each oolean function. Sum-of-products not necessarily optimal in: number of switches (space) depth of circuit (time) MJ(x, y, z) = x'yz + xy'z + xyz' + xyz = xy + yz + xz. Layers of abstraction. Layers of bstraction uild a circuit from wires and switches. [implementation] Define a circuit by its inputs and outputs. [PI] To control complexity, encapsulate circuits. [DT] 8 82 Layers of bstraction Layers of abstraction. uild a circuit from wires and switches. [implementation] Define a circuit by its inputs and outputs. [PI] To control complexity, encapsulate circuits. [DT] Specification Step : identify input and output t Step 2: construct truth table Step 3: derive (simplified) oolean expression using sum-of products. Step 4: transform oolean expression into circuit/implement it using HDL. ou would like to test the gate before packaging. 83

HDL Example: uilding an nd gate a b nd out nd.cmp a b out Contract: When running your.hdl on our.tst, your.out should be the same as our.cmp. nd.hdl nd.tst CHIP nd load nd.hdl, { IN a, b; output-file nd.out, OUT out; compare-to nd.cmp, // implementation missing output-list a b out; } set a,set b,eval,output;, set a,set b,eval,output; set a,set b,eval,output; set a, set b, eval, output; Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 86 uilding an nd gate uilding an nd gate Interface: nd(a,b) = exactly when a=b= Implementation: nd(a,b) = Not(Nand(a,b)) a b nd out a b out nd.hdl CHIP nd { IN a, b; OUT out; // implementation missing } nd.hdl CHIP nd { IN a, b; OUT out; // implementation missing } Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 87 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 88

uilding an nd gate uilding an nd gate Implementation: nd(a,b) = Not(Nand(a,b)) Implementation: nd(a,b) = Not(Nand(a,b)) a b a b Nand out x in Not out out a a out NND x in NOT out b b out nd.hdl nd.hdl CHIP nd { IN a, b; OUT out; // implementation missing } CHIP nd { IN a, b; OUT out; Nand(a = a, b = b, out = x); Not(in = x, out = out) } Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 89 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 9 Hardware simulator (demonstrating Xor gate construction) Hardware simulator HDL program test script HDL program Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 9 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 92

Hardware simulator Project materials: www.nand2tetris.org Project web site HDL program output file nd.hdl, nd.tst, nd.cmp files Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 93 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 94 Project tips Gates for project # (asic Gates) Read the Introduction + Chapter of the book Download the book s software suite Go through the hardware simulator tutorial Do Project (optional) ou re in business. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 95 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 96

Gates for project # Gates for project # (Multi-bit version) Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 97 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 98 Gates for project # (Multi-way version) Gates for project # (Multi-way version) Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 99 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide

Gates for project # (Multi-way version) Gates for project # (Multi-way version) Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 2 Perspective Each oolean function has a canonical representation The canonical representation is expressed in terms of nd, Not, Or End notes: Canonical representation Whodunit story: Each suspect may or may not have an alibi (a), a motivation to commit the crime (m), and a relationship to the weapon found in the scene of the crime (w). The police decides to focus attention only on suspects for whom the proposition Not(a) nd (m Or w) is true. nd, Not, Or can be expressed in terms of Nand alone Ergo, every oolean function can be realized by a standard PLD consisting of Nand gates only Truth table of the "suspect" function s( a, m, w) a ( m w) Mass production a b c and Universal building blocks, unique topology. or f(a,b,c) Gates, neurons, atoms, and Canonical form: s( a, m, w) a m w a mw a mw Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 3 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 4

End notes: Canonical representation (cont.) End notes: Programmable Logic Device for 3-way functions a m w s( a, m, w) a ( m w) or and s s( a, m, w) a m w a mw a mw a b c 8 and terms connected to the same 3 inputs and. legend: active fuse blown fuse or f(a,b,c) a m w and and or s and single or term connected to the outputs of 8 and terms and _ PLD implementation of f(a,b,c)= a b c + a b c (the on/off states of the fuses determine which gates participate in the computation) Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 5 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 6 End notes: Programmable Logic Device for 3-way functions Two-level logic: NDs followed by ORs Example: = C + C + C C C minterm: C minterm: C minterm: C Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter : oolean Logic slide 7