45
MA251 Computer Organization and Architecture [3-0-0-6] Lecture 1: Introduction, Logic gates, Boolean algebra, Canonical Forms Spring 2011 Partha Sarathi Mandal

MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Embed Size (px)

Citation preview

Page 1: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

MA251 Computer Organization and Architecture [3-0-0-6]

Lecture 1: Introduction, Logic gates, Boolean algebra, Canonical Forms

Spring 2011Partha Sarathi Mandal

Page 2: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Time Table

Page 3: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Syllabus

• Number Systems: representations of numbers (binary, octal, decimal, and hexadecimal), arithmetic of signed and unsigned numbers;

• Boolean algebra and logic gates: gate level minimization of Boolean functions; Combinational logic circuits: design and analysis, some standard combinational circuits (encoders, decoders, multiplexers); Sample and hold Circuits, analog-to-digital converter, digital-to-analog converter.

• Synchronous sequential logic circuits: design and analysis; flip-flops, registers, counters;

• Finite state model: state tables and state diagram, state minimization; • Memory organization: hierarchical memory systems, cache memories, cache

coherence, virtual memory; • System buses: interconnection structures and bus interconnection, Arithmetic

Logic Unit. • Study of an existing CPU: architecture, instruction set and the addressing modes

supported; assembly language programming; • Control unit design: instruction interpretation, hardwired and microprogrammed

methods of design; RISC and CISC paradigms. I/O transfer techniques: programmed, interrupt-driven and DMA; I/O processors and channels, mapping of I/O addresses.

Page 4: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Tests and Marks distribution

• Marks distribution:

– Quizzes + Assignments: 30%– Mid Semester: 30%– End Semester: 40%

• There may be pop quizzes (without prior warning or announcement)in the classes.

• If any one fails to write any of the quizzes or the mid-semester examination then NO make-up examination will be conducted.

• The portion (syllabus) for Mid-semester examination will be in general from the first lecture to the last lecture just before the mid semester examination.

• The end-semester examination will cover all topics.

Page 5: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Reference Books

• M. Morris Mano, “Digital Logic and Computer Design”, 10th impression ,Pearson Education, Inc., 2008.

• M. M. Mano, “Digital Design”, 3rd Edition, Pearson Education Asia, 2002.

• D.A. Pattersonand J.L. Hennessey, "Computer Organization and Design: The Hardware/Software Interface", Morgan Kaufman

• J.L. Hennesseyand D.A. Patterson, "Computer Architecture: A Quantitative Approach ", Morgan Kaufman

Page 6: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Road Map

Logic Design

Computer Organization and Architecture

Oper. Sys

Page 7: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean Algebra & Digital Logic

Page 8: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean Algebra

In 1938, Shannon showed how the basic rules of logicfirst given by George Boole in his 1854 publication The Laws of Thought, can be used to design circuitsthat enables computer hardware to perform variousarithmetic and logical operation. These rules form thebasis of Boolean Algebra. These rules involve twoSymbols 1 and 0 (synonymous with true and false) and the operators AND, OR, NOT.

Page 9: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean Algebra

Page 10: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Electric Switches and Logical Networks

Page 11: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Electric Switches and Logical Networks

Page 12: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean Algebra

• Developed mid-1800’s by George Boole to formalize human thought– Ex: “I’ll go to lunch if Mary goes OR John goes, AND Sally

does not go.”• Let F represent my going to lunch (1 means I go, 0 I don’t go)• Likewise, m for Mary going, j for John, and s for Sally• Then F = (m OR j) AND NOT(s)

– Nice features• Formally evaluate

– m=1, j=0, s=1 --> F = (1 OR 0) AND NOT(1) = 1 AND 0 = 0

• Formally transform– F = (m and NOT(s)) OR (j and NOT(s))– Looks different, but same function

Page 13: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Evaluate the Boolean equation: F = (a AND b) OR (c AND d)

What is the value of F ?

1. when a=1, b=1, c=1, d=0.

2. when a=0, b=1, c=0, d=1.

Page 14: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

NOT/OR/AND Logic Gate Timing Diagrams

Page 15: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Building Circuits Using Gates

Motion-in-dark DetectorTurn on lamp (F=1) when motion sensed (a=1) and no light (b=0)F = a AND NOT(b)Build using logic gates, AND and NOT, as shown

Page 16: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Which circuit corresponds to the Boolean Equation: F = a AND NOT( b OR NOT(c) )

Page 17: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Example: Seat Belt Warning Light System

Page 18: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Basic Logic Gates

Page 19: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Circuits to Equations

Page 20: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Circuits to Equations

Page 21: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Equations to Circuits

Page 22: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Implementing XOR

Page 23: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean function

An n-variable Boolean function f : {0.1}n⟶ {0,1}

It can be expressed as a truth table.

Page 24: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean Algebra Properties

Ex 1: Show x+x’.zequivalent to x+z.

• x+x’.z = (x+x’).(x+z)= 1.(x+z)= x+z

Ex 2: Can xx’+xy(x’+y’) ever evaluate to 1?

• xx’+xy(x’+y’)=xx’+xyx’+xyy’=xx’+yxx’+xyy’=0+y.0+x.0=0+0+0=0

• Commutative– A+B = B+A– A.B=B.A

• Distributive– A.(B+C)=A.B+A.C– A+(B.C)=(A+B).(A+C)

• Associative– (A+B)+C=A+(B+C)– (A.B).C=A.(B.C)

• Identity– 0+A=A+0=A– 1.A=A.1=A

• Complement– A+A’ = 1– A.A’=0

Page 25: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Boolean Algebra Properties

Ex 1: Show x+x.z equivalent to x.• x+x.z = x.1+x.z as x=x.1

= x.(1+z) distributive law= x.1 as A+1=1= x Identity

Dual of the above equation: x.(x+z)=x-Every Boolean eq. has a dual, which is found by interchanging AND and OR operators and replacing 0's by 1's and 1's by 0's.

• x.(x+z) = x.x+x.z = x+ x.z =x

Note that the brackets are added to maintain the evaluation order.

• Null elements– A+1= 1– A.0=0

• Idempotent Law– A+A=A– A.A=A

• Involution– (A’)’=A

• DeMorgan’s Law– (A+B)’=A’.B’– (A.B)’=A’+B’

• Complement– A+A’ = 1– A.A’=0

Page 26: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

The principle of Duality

• Any algebraic equality derived from the axioms of Boolean algebra remains true when the operators (.) and (+) are interchanged and the identity elements 0 and 1 are interchanged.

• For example: x +1=1 --> x.0 = 0 (Dual)

Page 27: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Examples

• The dual of (x . 1 ).(0 + x') = 0 is

(x + 0)+(1 . x') = 1

• dual of (x + y).(y + z) = x.z + y is

x.y + y.z = (x + z).y

Page 28: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Representation of Boolean Functions

• A function can be represented in different ways– Here are seven representations of the same function using four

different methods: English, Equation, Circuit, and Truth Table

Page 29: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Truth Table Representation of Boolean Functions

• Define value of F for each possible combination of input values– 2-input function: 4 rows– 3-input function: 8 rows– 4-input function: 16 rows

Page 30: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Converting among Representations

• Can convert from any representation to any other• Common conversions

– Equation to circuit (we did this earlier)– Truth table to equation (which we can convert to circuit)

• Easy -- just OR each input term that should output 1

– Equation to truth table• Easy -- just evaluate equation for each input combination(row)• Creating intermediate columns helps

Q: Convert to equation

ab’cabc’abc

Page 31: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Standard Representation: Truth Table

• How can we determine if two functions are the same ?– Is f = c’(hp + hp’ + h’) the same as

g = hc’ + h’pc’?• Use algebraic methods• But if we failed, does that prove

not equal? – No.

• Solution: Convert to truth tables– Only ONE truth table

representation of a given function• Standard representation – for

given function, only one version in standard form exists.

– But, truth tables too big for numerous inputs

f = c’(hp + hp’ + h’)f = c’( h(p + p’) + h’ )f = c’( h + h’ )f = c’So…are they equal ?Q: Determine if F=ab+a’ is same function as F=a’b’+a’b+ab, by converting each to truth table first

Page 32: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Canonical Forms

Page 33: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Canonical Forms

• A canonical form is a standard way of writing an equation—a shape or form of equation.

• Canonical forms are useful for example in algorithms for logic gates such as logic minimization and checking if booleanexpressions are equal.

Page 34: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Canonical Forms-Minterms

• One common canonical form is a sum of minterms.

• Minterms: A minterm is simply a product term (i.e., a conjunction) containing each input variable appearing exactly once, in true or complemented form: eg (for 3 variables A, B, C): ABC, AB’C’, A’BC, ABC’ but not B’C’

Page 35: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Canonical Form - Sum of Minterms

Q: Determine if F(a,b)=ab+a’ is same function as F(a,b)=a’b’+a’b+ab, by converting first equation to canonical form (second already in canonical form)

F = ab+a’ (already sum of products)

F = ab + a’(b+b’) (expanding term)

F = ab + a’b + a’b’ (SAME -- same three terms as other equation)

Page 36: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

The canonical form derived from truth table

• One advantage of the canonical form is that it directly represents the truth table.

Consider the minterm: A’BC

– This has value 1 iff A=0, B=1 and C=1.

– So a minterm in the canonical form corresponds to a row in the truth table which has an output of 1

Page 37: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Example: The majority voter

(Returns 1 iff the majority of the inputs is 1)

So X = A’BC + AB’C + ABC’ + ABC

Page 38: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

The canonical form derived from eqs.

• The canonical form can also be found from

equations by a process known as augmentation.

• Consider X = BC + A’BC’

• We know that (A+A') = 1 and so we can write

• X = (A+A’)BC + A’BC’

• X = ABC+A’BC + A’BC’

Page 39: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

derived from eqs. Contd..

• The canonical form is simply a sum of minterms(ie a disjunction of conjuncts) also known as sum of products (SOP):

X1 = ABC + AB’C’ + A’BC

Note that, for example

X2 = BC + B’ + A’BC is a valid Boolean equation, but is not in canonical form.

Convert R2 to a canonical form

Page 40: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Canonical Forms-Maxterms

• Any boolean expression may be expressed in terms maxterms.

• A maxterm is the sum of N distinct literals where each literal occurs exactly once (where a mintermis the product of N distinct literals where each literal occurs exactly once)– Also known as products of sum (POS)

• Example: F= (x+y+z)(x+y+z’)(x+y’+z)(x’+y+z)

• Note: sum of mintrems also known as sum of products (SOP)

Page 41: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Canonical Forms-Minterm/Maxterms

• For a three-variable expression, the mintermsand maxterms are as follows

X Y Z Minterm Designation Maxterm Designation

0 0 0 X'.Y'.Z' m0 X+Y+Z M0

0 0 1 X'.Y'.Z m1 X+Y+Z' M1

0 1 0 X'.Y.Z' m2 X+Y'+Z M2

0 1 1 X'.Y.Z m3 X+Y'+Z' M3

1 0 0 X.Y'.Z' m4 X'+Y+Z M4

1 0 1 X.Y'.Z m5 X'+Y+Z' M5

1 1 0 X.Y.Z' m6 X'+Y'+Z M6

1 1 1 X.Y.Z m7 X'+Y'+Z' M7

Page 42: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Short Notation

• Mintrem

– F = A’BC’ + A’BC + ABC

– F(A,B,C)=(2,3,7)

• Maxterm

– F= (x+y+z)(x+y+z’)(x+y’+z)(x’+y+z)

– F(x,y,z)=(0,1,2,4)

Page 43: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Product of maxterms from truth table

• Now consider complement of a Boolean function i.e., products a 0 in the function and then ORing those termsF’1=x’y’z’+x’y’z+x’yz’+xy’z’=m0+m1+m2+m4

• Now take complement of F’1

F1 =(x+y+z)(x+y+z’)(x+y’+z)(x’+y+z)=M0M1M2M4

• Any Boolean function can be expressed as a product of maxterms (i) directly or (ii) complementing SOP.

• Try for F2 function

x y z F1 F2

0 0 0 0 1

0 0 1 0 1

0 1 0 0 0

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 0

Page 44: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

Exercises

1. Express Boolean function F=x+y’z in a sum of mintrms (SOP).

– Ans:f=x(y+y’)+y’z(x+x’)=….

=x’y’z+xy’z’+xy’z+xyz’+xyz

2. Express F=xy+x’z in a product of maxterms(POS).

– Ans: xy+x’z=(xy+x’)(xy+z)=()(x+z)(y+z)=()()(y+z+xx’)

=()()(x+y+z)(x’+y+z)

Page 45: MA251 Computer Organization and Architecture [3-0-0-6] · • Control unit design: instruction interpretation, hardwired and microprogrammed ... •M. Morris Mano,

16 possible Boolean algebraic functions for 2 variables