CS/COE0447 Computer Organization & Assembly Language

Slides:



Advertisements
Similar presentations
1 CS/COE0447 Computer Organization & Assembly Language Logic Design.
Advertisements

Appendix B Digital Logic. Irvine, Kip R. Assembly Language for Intel-Based Computers, NOT AND OR XOR NAND NOR Truth Tables Boolean Operators.
Chapter 11_1 (chap 10 ed 8) Digital Logic. Irvine, Kip R. Assembly Language for Intel-Based Computers, NOT AND OR XOR NAND NOR Truth Tables Boolean.
Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.
Relationship Between Basic Operation of Boolean and Basic Logic Gate The basic construction of a logical circuit is gates Gate is an electronic circuit.
1 Digital Logic
Computer ArchitectureFall 2008 © August 20 th, Introduction to Computer Architecture Lecture 2 – Digital Logic Design.
1 CSE 20: Lecture 7 Boolean Algebra CK Cheng 4/21/2011.
Introduction to Digital Logic Design Appendix A of CO&A Dr. Farag
Chapter 10_1 Digital Logic. Irvine, Kip R. Assembly Language for Intel-Based Computers, NOT AND OR XOR NAND NOR Truth Tables Boolean Operators.
Lecture 17: Digital Design Today’s topic –Intro to Boolean functions Reminders –HW 4 due Wednesday 10/8/2014 (extended) –HW 5 due Wednesday 10/15/2014.
Fall 2012: FCM 708 Foundation I Lecture 2 Prof. Shamik Sengupta
Apr. 3, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 3: Review of Digital Circuits and Logic Design Jeremy R. Johnson Mon. Apr.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /05/2013 Lecture 4: Basics of Logic Design Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
Logic Gates Shashidhara H S Dept. of ISE MSRIT. Basic Logic Design and Boolean Algebra GATES = basic digital building blocks which correspond to and perform.
Lecture 22: 11/19/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
מבנה מחשב תרגול 2. 2 Boolean AND Operation Truth Table Equivalent Gate Different notations:
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
Lecture 18: Hardware for Arithmetic Today’s topic –Intro to Boolean functions (Continued) –Designing an ALU 1.
CS/COE0447 Computer Organization & Assembly Language
Logic Design / Processor and Control Units Tony Diep.
Appendix C Basics of Digital Logic Part I. Florida A & M University - Department of Computer and Information Sciences Modern Computer Digital electronics.
Digital Logic Design Basics Combinational Circuits Sequential Circuits Pu-Jen Cheng Adapted from the slides prepared by S. Dandamudi for the book, Fundamentals.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
Gates AND, OR, NOT NAND, NOR Combinational logic No memory A set of inputs uniquely and unambiguously specifies.
ECE DIGITAL LOGIC LECTURE 6: BOOLEAN ALGEBRA Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 02/01/2016.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
BOOLEAN ALGEBRA LOGIC GATES. Introduction British mathematician George Boole( ) was successful in finding the link between logic and mathematics.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
LOGIC CIRCUITLOGIC CIRCUIT. Goal To understand how digital a computer can work, at the lowest level. To understand what is possible and the limitations.
1 CS/COE0447 Computer Organization & Assembly Language Logic Design Appendix C.
Appendix C Basics of Logic Design. Appendix C — Logic Basic — 2 Logic Design Basics §4.2 Logic Design Conventions Objective: To understand how to build.
Hoda Roodaki Boolean Algebra Hoda Roodaki
Computer Architecture & Operations I
Computer Architecture & Operations I
Boolean Algebra & Logic Gates
Morgan Kaufmann Publishers
Prof. Sin-Min Lee Department of Computer Science
DIGITAL LOGIC CIRCUITS
Lecture 11: Hardware for Arithmetic
מבנה מחשב תרגול 3.
Basics of digital systems
Jeremy R. Johnson Wed. Sept. 29, 1999
DIGITAL LOGIC CIRCUITS
Basics of Digital Logic Design Presentation D
XOR, XNOR, and Binary Adders
Reading: Hambley Chapters
Lecture 3 Boolean Algebra and Digital Logic Lecture Duration: 2 Hours
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Basics Combinational Circuits Sequential Circuits Ahmad Jawdat
Boolean Algebra and Digital Logic
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Fundamentals of Computer Science Part i2
Digital Logic Structures Logic gates & Boolean logic
CSE 370 – Winter Combinational Logic - 1
XOR, XNOR, & Binary Adders
Inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 23 – Representations of Combinatorial Logic Circuits TA/Punner.
Digital Logic.
Lecture 11: Hardware for Arithmetic
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Boolean Algebra.
CS/COE0447 Computer Organization & Assembly Language
Digital Logic.
COMS 361 Computer Organization
Logic Circuits I Lecture 3.
TA David “The Punner” Eitan Poll
XOR, XNOR, and Binary Adders
Digital Circuits and Logic
XOR, XNOR, and Binary Adders
Presentation transcript:

CS/COE0447 Computer Organization & Assembly Language Logic Design Appendix C

Outline Example to begin: let’s implement a MUX Gates, Truth Tables, and Logic Equations Combinatorial Logic Constructing an ALU Memory Elements: Flip-flops, Latches, and Registers

Logic Gates 2-input AND Y=A&B Y=A|B 2-input OR 2-input NAND Y=~(A&B) 2-input NOR Y=~(A|B) Y B

Multiplexor If S then C=B else C = A A C B 1 How many bits is S? S C B 1 How many bits is S? S 1, since it is choosing between 2 values Let’s see how to implement a 2-input MUX using gates. Hint: the answer uses AND gates, an OR gate, and one INVERTER Answer in lecture

Computers and Logic Digital electronics operate with only two voltage levels of interest: high and low voltage. All other voltage levels are temporary and occur while transitioning between values We’ll talk about them as signals that are Logically true; 1; asserted Logically false; 0, deasserted 0 and 1 are complements and inverses of each other

Combinational vs. Sequential Logic Combinational logic A function whose outputs depend only on the current input Sequential logic Memory elements, i.e., state elements Outputs are dependent on current input and current state Next state is also dependent on current input and current state

Combinational Logic … … inputs outputs

Sequential Logic … … inputs outputs next state current state clock

The next set of topics [until the sequential logic picture we just saw pops up again] will only be about combinatorial logic

Functions Implemented Using Gates … ? … inputs outputs Combinatorial logic blocks implement logical functions, mapping inputs to outputs

Describing a Function OutputA = F(Input0, Input1, …, InputN-1) OutputB = F’(Input0, Input1, …, InputN-1) OutputC = F’’(Input0, Input1, …, InputN-1) Methods Truth table (since combinatorial logic has no memory, it can be completely specified by a truth table) …[in a moment]

Truth Table Input Output A B Cin S Cout 1

Truth Tables In a truth table, there is one row for every possible combination of values of the inputs Specifically, if there are N inputs, the possible combinations are the binary numbers 0 through 2EN - 1. For example: 3 bits (0-7): 000 through 111 4 bits (0-15): 0000 through 1111 5 bits (0-31): 00000 through 11111 While we could always use a truth table, they quickly grow in size and become hard to understand and work with Boolean logic equations are more succinct

Describing a Function OutputA = F(Input0, Input1, …, InputN-1) OutputB = F’(Input0, Input1, …, InputN-1) OutputC = F’’(Input0, Input1, …, InputN-1) Methods Truth table Boolean logic equations Sum of products Products of sums

Truth Table and Equations Input Output A B Cin S Cout 1 S = A’B’Cin+A’BCin’+AB’Cin’+ABCin Cout = A’BCin+AB’Cin+ABCin’+ABCin Each output has its own…? Column in the truth table And its own Boolean equation

Truth Tables and Equations All functions specified by truth tables can also be specified by Boolean formulas [and vice versa] So, let’s look more closely at Boolean algebra

Boolean Algebra Boole, George (1815~1864): mathematician and philosopher; inventor of Boolean Algebra, the basis of all computer arithmetic Binary values: 0, 1 Two binary operations: AND (/), OR () AND is also called the logical product since its result is 1 only if both operands are 1 OR is also called the logical sum since its result is 1 if either operand is 1 One unary operation: NOT (~)

Laws of Boolean Algebra Identity, Zero, and One laws aa = a+a = a a1 =a; a+0 = a [“copy” operations] a0 =0; a+1 = 1 [deassert by ANDing with 0; assert by ORing with 1] Inverse aa = 0; a+a = 1 Commutative ab = ba a+b = b+a Associative a(bc) = (ab)c a+(b+c) = (a+b)+c Distributive a(b+c) = ab + ac a+(bc) = (a+b)(a+c)

Laws of Boolean Algebra De Morgan’s laws ~(a+b) = ~a~b ~(ab) = ~a+~b More… a+(ab) = a a(a+b) = a ~~a=a You’ll see this again in CS441 and CS1502

Examples To get used to Boolean equations To see the relationships among Truth Tables, Boolean Equations, and hardware implementations in gates To see that a “sum of products” formula can always be derived from a truth table To see that equations can often be simplified

Example equation E = (A’ B C) + (A B’ C) + (A B C’) What is the value of the equation if A = 1, B = 0 and C = 0? E = (1’ 0 0) + (1 0’ 0) + (1 0 0’) E = (0 0 0) + (1 1 0) + (1 0 1) = 0 What is the value of the equation if A = 0, B = 1, and C = 1? E = (0’ 1 1) + (0 1’ 1) + (0 1 1’) E = (1 1 1) + (0 0 1) + (0 1 0) = 1

Truth Table for E A B C D E F 1 You can read our equation for E right from the truth table: E = (A’ B C) + (A B’ C) + (A B C’) These are the three cases when E is 1. Now, give a Boolean equation for F: F = A B C

Give a Boolean Equation for D C D E F 1 D = (A’ B’ C) + (A’ B C’) + (A’ B C) + (A B’ C’) + (A B’ C) + (A B C’) + (A B C) There are many logically equivalent equations (in general) D = (A’ B’ C’)’ [D is true in all cases except A=0 B=0 C=0.] Apply DeMorgan’s law: D = A’’ + B’’ + C’’ = A + B + C

Example: boolean equation of a circuit First add the boolean equations at the output for each AND gate A B Y C A•B B•C

Example: Next add the Boolean equations at the output for the OR gate The Boolean equation for the complete logic circuit is: Y = (A•B)+(B•C) A B Y C A•B (A•B) + (B•C) B•C

Example: Truth Table Y = (A•B)+(B•C) 1 Reading an equation from the Table: Y = (A’ B C) + (A B C’) + (A B C) The equations are logically equivalent: one way to see this is to consider each row in the truth table. If the two equations have the same outputs for each input, then they are logically equivalent.

Example: MUX (A S’) A (A S’) + (B S) C B (B S) S If the equation below were implemented directly: four (3-input) AND gates and one (4-input) OR gate would be needed (B S) S A B S C 1 Again, the two formulas are equivalent [next slide] C = (A’ B S) + (A B’ S’) + (A B S’) + (A B S) Equation read from the Table:

Example: MUX BS C = (A S’) + (B S) C = (A’ B S) + (A B’ S’) + (A B S’) + (A B S) AS’ If B ==0: (AS’) + 0 If B == 1: 0 + (AS’) So, this is the same as AS’ Methods perform such simplifications automatically You can see they are equivalent by comparing values for each row A B S C 1

Expressive Power Any Boolean algebra function can be constructed using AND gates, OR gates, and Inverters [For your interest: NAND and NOR are both universal: any logic function can be built with just that one gate type] There are “canonical forms” for Boolean functions: all equations can be expressed in these forms This made it possible to create translation programs that, given a logic equation or truth table as input, can automatically design a circuit that implements it

Outline Example to begin: let’s implement a MUX! Gates, Truth Tables, and Logic Equations Combinatorial Logic Constructing an ALU Memory Elements: Flip-flops, Latches, and Registers

Since we were talking about MUXs… How are larger MUXs implemented Wider inputs than 1 bit More choices

A 32-bit wide 2-to-1 Multiplexor 1-bit input to to all 32 MUXs Choosing between 2 32-bit wide buses Bus: collection of data lines treated as a single value. E.g., MUX controlled by MemtoReg. Each MUX is the same; just like the one we saw earlier

Use a Decoder to build a MUX with more choices     Decoder n bit input value and 2^n outputs   1 This is a 2-to-4 decoder Appendix C shows the truth table for a 3-to-8 decoder

Decoder: implementation with gates    Decoder n bit input value and 2^n outputs A = X • Y B = X • Y C = X • Y D = X • Y X Y A B C D 1 X A Y B C C D

N input MUX using a decoder Example in lecture

Implementing Combinatorial Logic PLA (Programming Logic Array) A direct implementation of sum of products form pla.html (thanks to: www.cs.umd.edu/class/spring2003/cmsc311/Notes/Comb/pla.html) ROM (Read Only Memory) Interpret the truth table as fixed values stored in memory Using logic gate chips (74LS…)

74LS Series Chips contain several logic gates 2-input OR gate SN 74LS04 Hex inverter gate SN 74LS08 Quad 2-input AND gate SN 74LS32 Quad 2-input OR gate

ALU Symbol Note that it’s combinational logic

Building a 1-bit ALU ALU = Arithmetic Logic Unit

Building a 1-bit Adder S = A’B’Cin+A’BCin’+AB’Cin’+ABCin Input Output A B Cin S Cout 1 S = A’B’Cin+A’BCin’+AB’Cin’+ABCin Cout = AB+BCin+ACin (after simplification) E.g., build a pla

Building a 32-bit ALU

Implementing “SUB”

Implementing “NAND”/”NOR”

Implementing “SLT”

Implementing “SLT”, cont’d

4-bit datapath “Operation” same for all “Binvert” same for all “Ainvert” same for all Bit 0 Bit 1 Bit 3 Bit 2

Supporting “BEQ”/”BNE” Need a “zero-detector”

ALU Symbol Note that it’s a combinational logic

Sequential Logic … … inputs outputs next state current state clock

RS Latch Note that there are feedbacks!

RS Latch, cont’d 1 1 1 When R=0, S=1

RS Latch, cont’d 1 1 1 When R=1, S=0

RS Latch, cont’d 1 1 When R=0, S=0, and Q was 0

RS Latch, cont’d 1 1 When R=0, S=0, and Q was 1

RS Latch, cont’d 1 1 What happens if R=S=1?

D Latch Note that we have an R-S latch as a back-end

D Latch, cont’d R S Note that S, R inputs always get D and inverted input of D when C=1 When C=0, S=R=0, remembering the previous value

D Latch, cont’d R C D Q(t) Q(t-1) 1 S

D Latch, cont’d D Q D Latch C Q’

D Flip-Flop (D-FF) Two D latches are cascaded, with opposite clock

D Flip-Flop, cont’d D Q D-FF C Q’