ECE/CS 250 Computer Architecture

Similar documents
ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design Boolean Algebra, Logic Gates

ECE/CS 250: Computer Architecture. Basics of Logic Design: Boolean Algebra, Logic Gates. Benjamin Lee

CS/COE0447: Computer Organization and Assembly Language

Computer organization

CHAPTER1: Digital Logic Circuits Combination Circuits

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

Digital Logic. CS211 Computer Architecture. l Topics. l Transistors (Design & Types) l Logic Gates. l Combinational Circuits.

211: Computer Architecture Summer 2016

Binary addition example worked out

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

Floating Point Representation and Digital Logic. Lecture 11 CS301

University of Technology

CS61C : Machine Structures

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

CS61C : Machine Structures

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic

Hakim Weatherspoon CS 3410 Computer Science Cornell University

BOOLEAN ALGEBRA. Introduction. 1854: Logical algebra was published by George Boole known today as Boolean Algebra

CS/COE0447: Computer Organization

CS1800: Hex & Logic. Professor Kevin Gold

Boolean Algebra & Logic Gates. By : Ali Mustafa

Building a Computer Adder

EEE130 Digital Electronics I Lecture #4

Design of Sequential Circuits

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

Combinational Logic. By : Ali Mustafa

Intro To Digital Logic

Boolean algebra. Examples of these individual laws of Boolean, rules and theorems for Boolean algebra are given in the following table.

Fundamentals of Digital Design

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

CprE 281: Digital Logic

CS/COE0447: Computer Organization

CS/COE1541: Introduction to Computer Architecture. Logic Design Review. Sangyeun Cho. Computer Science Department University of Pittsburgh

CMP 334: Seventh Class

CMPE12 - Notes chapter 2. Digital Logic. (Textbook Chapters and 2.1)"

CSC9R6 Computer Design. Practical Digital Logic

Combina-onal Logic Chapter 4. Topics. Combina-on Circuit 10/13/10. EECE 256 Dr. Sidney Fels Steven Oldridge

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

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

Unit 8A Computer Organization. Boolean Logic and Gates

Adders, subtractors comparators, multipliers and other ALU elements

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

Combinational Logic Trainer Lab Manual

CMPE12 - Notes chapter 1. Digital Logic. (Textbook Chapter 3)

Every time has a value associated with it, not just some times. A variable can take on any value within a range

CSE140: Components and Design Techniques for Digital Systems. Decoders, adders, comparators, multipliers and other ALU elements. Tajana Simunic Rosing

Latches. October 13, 2003 Latches 1

E40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1

Logic Gates and Boolean Algebra

Computer Science. 19. Combinational Circuits. Computer Science COMPUTER SCIENCE. Section 6.1.

Hardware Design I Chap. 4 Representative combinational logic

Logic Design. Chapter 2: Introduction to Logic Circuits

1.10 (a) Function of AND, OR, NOT, NAND & NOR Logic gates and their input/output.

Lecture 22 Chapters 3 Logic Circuits Part 1

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

UNIT 8A Computer Circuitry: Layers of Abstraction. Boolean Logic & Truth Tables

Adders, subtractors comparators, multipliers and other ALU elements

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

Review for Test 1 : Ch1 5

Computer Organization: Boolean Logic

CPS 104 Computer Organization and Programming Lecture 11: Gates, Buses, Latches. Robert Wagner

Introduction to Digital Logic Missouri S&T University CPE 2210 Subtractors

ECE 545 Digital System Design with VHDL Lecture 1A. Digital Logic Refresher Part A Combinational Logic Building Blocks

Numbers and Arithmetic

Logic design? Transistor as a switch. Layered design approach. CS/COE1541: Introduction to Computer Architecture. Logic Design Review.

Review: Additional Boolean operations

1 Boolean Algebra Simplification

Lecture 2 Review on Digital Logic (Part 1)

COS 140: Foundations of Computer Science

S C F F F T T F T T S C B F F F F F T F T F F T T T F F T F T T T F T T T

COMBINATIONAL LOGIC FUNCTIONS

Digital Logic (2) Boolean Algebra

Switches: basic element of physical implementations

20. Combinational Circuits

Numbers and Arithmetic

SAMPLE ANSWERS MARKER COPY

EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits)

Systems I: Computer Organization and Architecture

Logic and Boolean algebra

10/14/2009. Reading: Hambley Chapters

CS61c: Representations of Combinational Logic Circuits

Logic Gate Level. Part 2

Outline. EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits) Combinational Logic (CL) Defined

CSE370: Introduction to Digital Design

Implementation of Boolean Logic by Digital Circuits

UC Berkeley College of Engineering, EECS Department CS61C: Representations of Combinational Logic Circuits

Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit

CSE370 HW3 Solutions (Winter 2010)

Additional Gates COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

Boolean Algebra and Digital Logic

ALU A functional unit

UNIVERSITY OF WISCONSIN MADISON

COSC 243. Introduction to Logic And Combinatorial Logic. Lecture 4 - Introduction to Logic and Combinatorial Logic. COSC 243 (Computer Architecture)

Introduction to Computer Engineering. CS/ECE 252, Fall 2012 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

Menu. Binary Adder EEL3701 EEL3701. Add, Subtract, Compare, ALU

INF2270 Spring Philipp Häfliger. Lecture 8: Superscalar CPUs, Course Summary/Repetition (1/2)

Binary addition by hand. Adding two bits

Transcription:

ECE/CS 250 Computer Architecture Basics of Logic Design: Boolean Algebra, Logic Gates (Combinational Logic) Tyler Bletsch Duke University Slides are derived from work by Daniel J. Sorin (Duke), Alvy Lebeck (Duke), and Drew Hilton (Duke)

Reading Appendix B (parts 1,2,3,5,6,7,8,9,10) This material is covered in MUCH greater depth in ECE/CS 350 please take ECE/CS 350 if you want to learn enough digital design to build your own processor 2

What We ve Done, Where We re Going Top Down Application Operating System Software Compiler Firmware CPU Memory I/O system Digital Design Circuit Design Interface Between HW and SW Instruction Set Architecture, Memory, I/O Hardware (Almost) Bottom UP to CPU 3

Computer = Machine That Manipulates Bits Everything is in binary (bunches of 0s and 1s) Instructions, numbers, memory locations, etc. Computer is a machine that operates on bits Executing instructions operating on bits Computers physically made of transistors Electrically controlled switches We can use transistors to build logic E.g., if this bit is a 0 and that bit is a 1, then set some other bit to be a 1 E.g., if the first 5 bits of the instruction are 10010 then set this other bit to 1 (to tell the adder to subtract instead of add) 4

How Many Transistors Are We Talking About? Pentium III Processor Core 9.5 Million Transistors Total: 28 Million Transistors Pentium 4 Total: 42 Million Transistors Core2 Duo (two processor cores) Total: 290 Million Transistors Core2 Duo Extreme (4 processor cores, 8MB cache) Total: 590 Million Transistors Core i7 with 6-cores Total: 2.27 Billion Transistors How do they design such a thing? Carefully! 5

Abstraction! Use of abstraction (key to design of any large system) Put a few (2-8) transistors into a logic gate (or, and, xor, ) Combine gates into logical functions (add, select,.) Combine adders, shifters, etc., together into modules Units with well-defined interfaces for large tasks: e.g., decode Combine a dozen of those into a core Stick 4 cores on a chip 6

Boolean Algebra First step to logic: Boolean Algebra Manipulation of True / False (1/0) After all: everything is just 1s and 0s Given inputs (variables): A, B, C, P, Q Compute outputs using logical operators, such as: NOT:!A (= ~A = A) AND: A&B (= A B = A*B = AB = A B) = A&&B in C/C++ OR: A B (= A+B = A B) = A B in C/C++ XOR: A ^ B (= A B) NAND, NOR, XNOR, Etc. 7

Truth Tables Can represent as truth table: shows outputs for all inputs a NOT(a) 0 1 1 0 a b AND(a,b) 0 0 0 0 1 0 1 0 0 1 1 1 a b OR(a,b) 0 0 0 0 1 1 1 0 1 1 1 1 a b XOR(a,b) 0 0 0 0 1 1 1 0 1 1 1 0 a b XNOR(a,b) 0 0 1 0 1 0 1 0 0 1 1 1 a b NOR(a,b) 0 0 1 0 1 0 1 0 0 1 1 0 8

All possible two-input truth tables A B 0 A and B A and -B A -A and B B A xor B A or B 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 Two inputs Every possible sequence of 4 bits A B 1 A nand B -A or B -A A or -B -B A xnor B A nor B 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 0 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 9

Any Inputs, Any Outputs Can have any # of inputs, any # of outputs Can have arbitrary functions: a b c f 1 f 2 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 10

Let s Write a Truth Table for a Function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output A B C Output 11

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output A B C Output 0 0 0 Fill in Inputs Counting in Binary 12

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output A B C Output 0 0 0 0 0 1 Fill in Inputs Counting in Binary 13

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output Fill in Inputs Counting in Binary A B C Output 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 14

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output Fill in Inputs Counting in Binary Compute Output (0 & 0)!0 = 0 1 = 1 A B C Output 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 15

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output Fill in Inputs Counting in Binary Compute Output (0 & 0)!1 = 0 0 = 0 A B C Output 0 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 16

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output Fill in Inputs Counting in Binary Compute Output (0 & 1)!0 = 0 1 = 1 A B C Output 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 17

Let s write a Truth Table for a function Example: (A & B)!C Start with Empty TT Column Per Input Column Per Output Fill in Inputs Counting in Binary Compute Output A B C Output 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 Logisim example basic_logic.circ : example1 18

You try one Try one yourself: (!A B) &!C Answer: A B C Output 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0 Logisim example basic_logic.circ : example2 19

Suppose I turn it around Given a Truth Table, find the formula? Hmmm.. A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 20

Suppose I turn it around Given a Truth Table, find the formula? Hmmm Could write down every true case Then OR together: (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A & B &!C) (A & B &C) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 21

Suppose I turn it around Given a Truth Table, find the formula? Hmmm.. Could write down every true case Then OR together: (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A & B &!C) (A & B &C) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 22

Suppose I turn it around Given a Truth Table, find the formula? Hmmm.. Could write down every true case Then OR together: (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A & B &!C) (A & B &C) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 23

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A & B &!C) (A & B &C) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 24

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A & B &!C) (A & B &C) Could just be (A & B) here? A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 25

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A&B) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 26

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B &!C) (!A &!B & C) (!A & B &!C) (A&B) Could just be (!A &!B) here A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 27

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B) (!A & B &!C) (A&B) Could just be (!A &!B) here A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 28

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B) (!A & B &!C) (A&B) Looks nicer Can we do better? A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 29

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!B) (!A & B &!C) (A&B) This has a lot in common:!a & (something) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 30

Suppose I turn it around This approach: sum of products Works every time Result is right But really ugly (!A &!(B & C)) (A & B) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 31

Just did some of these by intuition.. but Somewhat intuitive approach to simplifying This is math, so there are formal rules Just like regular algebra 32

Boolean Function Simplification Boolean expressions can be simplified by using the following rules (bitwise logical): A & A = A A A = A A & 0 = 0 A 0 = A A & 1 = A A 1 = 1 A &!A = 0 A!A = 1!!A = A & and are both commutative and associative & and can be distributed: A & (B C) = (A & B) (A & C) & and can be subsumed: A (A & B) = A 33

DeMorgan s Laws Two (less obvious) Laws of Boolean Algebra: Let s push negations inside, flipping & and!(a & B) = (!A) (!B)!(A B) = (!A) & (!B) You should try this at home build truth tables for both the left and right sides and see that they re the same 34

Suppose I turn it around One more simplification on early example: (!A &!(B & C)) (A & B) = (!A & (!B!C)) (A & B) A B C Output 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Logisim example basic_logic.circ : example3 35

! (!A!(A & (B C))) Simplification Example: DeMorgan s!!a &!! (A & (B C)) Double Negation Elimination A & (A & (B C)) (A & A) & (B C) A & (B C) Associativity of & A & A = A 36

You try this: Come up with a formula for this Truth Table Simplify as much as possible Sum of Products: (!A &!B &!C) (!A & B &!C) (A &!B & C) (A & B & C) Simplify this part A B C Output 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 37

You try this: Simplify: (!A &!B &!C) (!A & B &!C) Regroup (associative/commutative): ((!A &!C) &!B) ((!A &!C) & B) Un-distribute (factor): (!A &!C) & (!B B) OR identities: (!A &!C) & true = (!A &!C) 38

You try this: Come up with a formula for this Truth Table Simplify as much as possible Sum of Products: (!A &!C) (A &!B & C) (A & B & C) Result of simplifying You can simplify this part in the same way A B C Output 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 39

You try this: Come up with a formula for this Truth Table Simplify as much as possible Sum of Products: (!A &!C) (A & C) A B C Output 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 Logisim example basic_logic.circ : example4 40

Applying the Theory Lots of good theory Can reason about complex Boolean expressions But why is this useful? 41

Boolean Gates Gates are electronic devices that implement simple Boolean functions (building blocks of hardware) a AND(a,b) a OR(a,b) a XOR(a,b) b b b a NAND(a,b) a NOR(a,b) a XNOR(a,b) b b b a NOT(a) 42

Guide to Remembering your Gates This one looks like it just points its input where to go It just produces its input as its output Called a buffer a a A circle always means negate (invert) a NOT(a) Circle = NOT 43

Guide to Remembering your Gates a AND(a,b) a OR(a,b) a XOR(a,b) b b b Straight like an A Curved, like an O XOR looks like OR (curved line), but has two lines (like an X does) Circle means NOT a NAND(a,b) a NOR(a,b) a XNOR(a,b) b b b (XNOR is 1-bit equals by the way) a NOT(a) 44

Brief Interlude: Building An Inverter a NOT(a) Vdd = power = 1 P-type: switch is on if input is 0 a NOT(a) N-type: switch is on if input is 1 ground= 0 45

Boolean Functions, Gates and Circuits Circuits are made from a network of gates. (!A &!C) (A & C) A C Out Logisim example basic_logic.circ : example5 46

A few more words about gates Gates have inputs and outputs If you try to hook up two outputs, bad things happen (your processor catches fire) a b c d BAD! If you don t hook up an input, it behaves kind of randomly (also not good, but not set-your-chip-on-fire bad) 47

Let s Make a Useful Circuit Pick between 2 inputs (called 2-to-1 MUX) Short for multiplexor What might we do first? Make a truth table? S is selector: S=0, pick A S=1, pick B Next: sum-of-products (!A & B & S) (A &!B &!S) (A & B &!S ) (A & B & S) Simplify (A &!S) (B & S) A B S Output 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 48

Circuit Example: 2x1 MUX Draw it in gates: A AND MUX(A, B, S) = (A &!S) (B & S) OR output B AND S So common, we give it its own symbol: a b output Logisim example basic_logic.circ : mux-2x1 s 49

Example 4x1 MUX a b a 0 c d out b c d 1 2 3 y 2 s 0 s 1 S The / 2 on the wire means 2 bits Logisim example basic_logic.circ : mux-4x1 50

Arithmetic and Logical Operations in ISA What operations are there? How do we implement them? Consider a 1-bit Adder 51

Designing a 1-bit adder What boolean function describes the low bit? XOR What boolean function describes the high bit? AND 0 + 0 = 00 0 + 1 = 01 1 + 0 = 01 1 + 1 = 10 52

Designing a 1-bit adder Remember how we did binary addition: Add the two bits Do we have a carry-in for this bit? Do we have to carry-out to the next bit? 01101100 01101101 +00101100 10011001 53

Designing a 1-bit adder So we ll need to add three bits (including carry-in) Two-bit output is the carry-out and the sum a b C in 0 + 0 + 0 = 00 0 + 0 + 1 = 01 0 + 1 + 0 = 01 0 + 1 + 1 = 10 1 + 0 + 0 = 01 1 + 0 + 1 = 10 1 + 1 + 0 = 10 1 + 1 + 1 = 11 Turn into expression, simplify, circuit-ify, yadda yadda yadda 54

A 1-bit Full Adder a b Cin Sum 01101100 01101101 +00101100 10011001 Cout a b C in Sum C out 0 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 Logisim example basic_logic.circ : full-adder 55

Example: 4-bit adder S3 S2 S1 S0 C out Full Adder Full Adder Full Adder Full Adder a3 b3 a2 b2 a1 b1 a0 b0 Logisim example basic_logic.circ : 4bit-adder 56

Subtraction How do we perform integer subtraction? What is the hardware? Recall: hardware was why 2 s complement was good idea Remember: Subtraction is just addition X Y = X + (-Y) = X + (~Y +1) 57

Example: Adder/Subtractor S3 S2 S1 S0 C out Full Adder Full Adder Full Adder Full Adder Add/Sub a3 b3 a2 b2 a1 b1 a0 b0 Logisim example basic_logic.circ : 4bit-addsub 58

Overflow We can detect unsigned overflow by looking at CO How would we detect signed overflow? If adding positive numbers and result is negative If adding negative numbers and result is positive At most significant bit of adder, check if CI!= CO Can check with XOR gate 59

Add/Subtract With Overflow Detection Overflow S n- 1 S n- 2 S 1 S 0 Full Adder Full Adder Full Adder Full Adder Add/Sub b n- 1 a n- 1 b n- 2 a n- 2 b 1 a 1 b 0 a 0 Logisim example basic_logic.circ : 4bit-addsub2 60

ALU Slice C in a b 3 2 1 Q A F Q 0 0 a + b 1 0 a - b - 1 NOT b - 2 a OR b - 3 a AND b Add/sub 0 2 C ou t Add/sub F Logisim example basic_logic.circ : alu-slice 61

The ALU Overflow Is non-zero? Q n-1 Q n-2 Q 1 Q 0 ALU Slice ALU Slice ALU Slice ALU Slice ALU control b n-1 a n-1 b n-2 a n-2 b 1 a 1 b 0 a 0 Logisim example basic_logic.circ : alu 62

Summary Boolean Algebra & functions Logic gates (AND, OR, NOT, etc) Multiplexors Adder Arithmetic Logic Unit (ALU) 63