CSI-2111 Computer Architecture Ipage 2-1 2. Revision Objective : To examine basic concepts of:...

Post on 13-Jan-2016

215 views 0 download

Transcript of CSI-2111 Computer Architecture Ipage 2-1 2. Revision Objective : To examine basic concepts of:...

CSI-2111 Computer Architecture I page 2-1

2. Revision

Objective: To examine basic concepts of:

– 2.1 Numbering Systems– 2.2 Binary Numbers– 2.3 Boolean Algebra – 2.4 Logic Gates – 2.5 Adders– 2.6 Timing Diagram

CSI-2111 Computer Architecture I page 2-2

2.1 Number System (base B)

Number is represented in terms of Positional Weighting:

(N)B = dn-1 Bn-1 + dn-2 Bn-2+...+ d1 B1 + d0 B0 · d-1 B-1+...+ d-m B-m

Integral Part. Fractional Part• B = base• dk = digit in position k, -m ≤ k ≤ n-1• Bk = weight of position k, -m ≤ k ≤ n-1 • n = number of integral digits in N• m = number of fractional digits in N

CSI-2111 Computer Architecture I page 2-3

The most known systems

B = 10 (Decimal)• digits : (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

B = 2 (Binary)• digits: (0, 1)

B = 8 (Octal)• digits: (0, 1, 2, 3, 4, 5, 6, 7)

B = 16 (Hexadecimal)• digits: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D,

E, F)

CSI-2111 Computer Architecture I page 2-4

Conversions (I)

How to convert from one number system to the other (change of base B)?

Algorithm 1: – favorable for conversions to the

decimal system

(N1)A (N2)10

CSI-2111 Computer Architecture I page 2-5

Conversions (II)

Algorithm 2: Use of successive divisions and multiplications– favorable for conversions from the

decimal system

(N1)10 (N2)B

(34.625)10 (?)2

CSI-2111 Computer Architecture I page 2-6

Conversions (II) - Example

(34.625)10 (100010.101)2

Integral Part: Fractional Part:

34 ÷ 2 = 17 r 0 0.625 x 2 = 1 .2517 ÷ 2 = 8 r 1 0.25 x 2 = 0 .5 8 ÷ 2 = 4 r 0 0.5 x 2 = 1 4 ÷ 2 = 2 r 0 2 ÷ 2 = 1 r 0 1 ÷ 2 = 0 r 1

CSI-2111 Computer Architecture I page 2-7

Binary Hexadecimal

Binary Hexadecimal– Form groups of 4 bits starting at

binary point.– Each group of 4 bits represents a

hexadecimal digit.

Hexadecimal Binary– Convert each hexadecimal digit to its

binary equivalent (4 bits).

CSI-2111 Computer Architecture I page 2-8

Binary Octal

Binary Octal– Form groups of 3 bits starting at

binary point.– Each group of 3 bits represents an

octal digit.

Octal Binary– Convert each octal digit to its binary

equivalent (3 bits).

CSI-2111 Computer Architecture I page 2-9

2.2 Binary Numbers

Fixed Point Representation.

– (N)2 has an implicit binary point in a fixed position.

– Notion of complement:• Complement(d) = (Base - 1) - d

CSI-2111 Computer Architecture I page 2-10

Complements of Binary Numbers

1’s Complement : (1CF)

2’s Complement : (2CF)

2’s Complement of 1001011 = ?

CSI-2111 Computer Architecture I page 2-11

Unsigned Binary Integers (UBI)

N is represented in terms of positional weighting: 0 ≤ N ≤ 2n – 1

dn-1dn-2dn-3 ... d2d1d0

No sign

N = (00011010110)2(7.4) = (?)10– Word of 11 digits– Fixed point representation, with 4 digits for

the fractional part

CSI-2111 Computer Architecture I page 2-12

Signed Binary Integers

3 ways of representing ± N with n bits:

– Sign-Magnitude Form (SMF)

– 1’s Complement Form (1CF)

– 2’s Complement Form (2CF)

CSI-2111 Computer Architecture I page 2-13

Comparison of SMF, 1CF, and 2CF

Sign Magnitude / 2’s Complement / 1’s Complement(4 bits word length)

Binary SMF 2CF 1CF0111 +7 +7 +70110 +6 +6 +60101 +5 +5 +50100 +4 +4 +40011 +3 +3 +30010 +2 +2 +20001 +1 +1 +10000 +0 0 +01111 -7 -1 -01110 -6 -2 -11101 -5 -3 -21100 -4 -4 -31011 -3 -5 -41010 -2 -6 -51001 -1 -7 -61000 -0 -8 -7

CSI-2111 Computer Architecture I page 2-14

Binary Addition (by complement)

The bit sign is treated like any other bit (they are added!)

The subtraction is performed by addition; the negative numbers are treated like numbers to add.

Addition by 1CF Addition by 2CF

CSI-2111 Computer Architecture I page 2-15

Overflow

An overflow occurs when the operands have the same sign and the result has a sign different from that of the operands.

Ex. 7 + 3; 4 bits word; SMF

+7 0 111+3 0 011(-2) 1 010

CSI-2111 Computer Architecture I page 2-16

2.3 Boolean Algebra

Two elements: 0 and 1 Elementary operators:

{AND, OR, NOT} Representation and algebraic

simplification of Boolean functions and their realization using logic gates will be studied.

CSI-2111 Computer Architecture I page 2-17

Boolean Functions & Truth Tables

Any Boolean function defined over n variables, each taking a Boolean constant value (0 or 1).

The Truth Table represents the function f, with all 2n combinations of 1’s and 0’s of its variables.

Each Boolean function is defined by its truth table and is represented by inter-connected logic gates.

CSI-2111 Computer Architecture I page 2-18

Functions and Logic GatesNom Symbole Fonction algébrique Table de vérité

ET(AND) F = A • B

A B F0 0 00 1 01 0 01 1 1

OU(OR) F = A + B

A B F0 0 00 1 11 0 11 1 1

NON(NOT) F = A’

A F0 11 0

Délai(Buffer) F = A

A F0 01 1

NON-ET(NAND) F = (A • B)’

A B F0 0 10 1 11 0 11 1 0

NON-OU(NOR) F = (A + B)’

A B F0 0 10 1 01 0 01 1 0

OU-Exclusif(XOR)

F = A B, ou encoreF = (A•B’) + (A’•B)

A B F0 0 00 1 11 0 11 1 0

Équivalence(XNOR)

F = A B, ou encoreF = (A’•B’) + (A•B)

A B F0 0 10 1 01 0 01 1 1

CSI-2111 Computer Architecture I page 2-19

Laws of Boolean Algebra

Together with – Postulates (or axioms)– Theorems

Manipulations (proof)– Algebraic– Tabular

Simplifications– Algebraic

CSI-2111 Computer Architecture I page 2-20

Proofs and Simplifications

Algebraic Proofs

Tabular Proofs

Algebraic Simplifications

CSI-2111 Computer Architecture I page 2-21

Examples *

Algebraic Proof:(A • B’) + B = A + B

= B + (A • B’) (Commutative, OR)= (B + A) • (B + B’) (Distributive, OR)= (B + A) • (1) (Complementation, OR)

= (B + A) (Identity Element, AND)

= A + B (Commutative, OR)

CSI-2111 Computer Architecture I page 2-22

Examples *

Proof by Truth Table:(A • B’) + B = A + B

A B (A • B’) + B A + B0 0 0 00 1 1 11 0 1 11 1 1 1

CSI-2111 Computer Architecture I page 2-23

Examples *

Algebraic Simplification

Example: f(ABC) = AC’ + A’B + A’B’C’ = ?

= AC’ + A’B + A’BC’ + A’B’C’ (Absorption, OR)= AC’ + A’B + A’C’ (B + B’) (Distributive, AND)= AC’ + A’B + A’C’ (1) (Complementation, OR)= AC’ + A’B + A’C’ (Identity Element, AND)= A’B + AC’ + A’C’ (Commutative, OR)= A’B + C’A + C’A’ (Commutative, AND (2 times))= A’B + C’ (A+A’) (Distributive, AND)= A’B + C’ (1) (Complimentation, OR)= A’B + C’ (Identity Element, AND)

CSI-2111 Computer Architecture I page 2-24

Representation: Canonical Forms

Canonical Sum of Products Form (CSOP or m)– Sum of mintermes – Ex.: f (A, B) = (A’•B) + (A•B) = m(1, 3 )

Canonical Product of Sums Form (CPOS or M)

– Product of maxtermes – Ex.: f (A, B) = (A+B’) • (A’+B) = M(1, 2)

CSI-2111 Computer Architecture I page 2-25

Examples of Canonical Forms

According to De Morgan’s law:Mi' = mi and mi' = Mi

Say f(A, B, C) defined by: A B C f 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1

CSI-2111 Computer Architecture I page 2-26

Examples of Canonical Forms *

f(A, B, C) defined by:A B C f0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 11 1 1 1

= A’B’C + AB’C’ + AB’C + ABC’ + ABC= m (1, 4, 5, 6, 7) is the CSOP form

of f

CSI-2111 Computer Architecture I page 2-27

Examples of Canonical Forms *

f(A, B, C) defined by: A B C f 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1

= (A+B+C) • (A+B’+C)• (A+B’+C’)= M (0, 2, 3) is the CPOS form of f.

CSI-2111 Computer Architecture I page 2-28

Equivalence of Canonical Forms*

f(A, B, C) = m (0, 4, 5, 7) = M (?)

M (1, 2, 3, 6)

f(A, B, C, D) = M (2, 3, 5, 6, 7) = m (?)

m (0, 1, 4) ???m (0, 1, 4, 8, 9, 10, 11, 12, 13, 14,

15) !!!

CSI-2111 Computer Architecture I page 2-29

Canonical Forms (encore!)

A function f is not necessarily represented in a canonical form.

f(A, B, C) = A’B’C + AB’+ BC’

How to obtain the canonical forms of such functions?– Algebraic method

CSI-2111 Computer Architecture I page 2-30

Algebraic Method*

f(A, B, C) = A’B + C’ + ABC=A’B(C+C’) + C’(A+A’)(B+B’) +ABC=A’BC + A’BC’ + ABC’ + AB’C’ +

A’BC’ +A’B’C’ + ABC

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

= m(3, 2, 6, 4, 0, 7)

CSI-2111 Computer Architecture I page 2-31

Remarks on Boolean Functions

Single representation (POS or SOP).

Logical equivalence.

How many possible functions for N Boolean variable?

Functions with 2 Boolean variables

CSI-2111 Computer Architecture I page 2-32

Functionally Complete Sets

Together of operators being able to represent all the functions

{AND, NOT, OR}, {NOR}, {NAND}

POS form with {NOR} SOP form with {NAND}

CSI-2111 Computer Architecture I page 2-33

2.4 Logic Gates

The logic gates implement the switching functions

A gate with N inputs represents a function with N Boolean variables

One comes across OR, AND, NOR, and NAND gates with N inputs

CSI-2111 Computer Architecture I page 2-34

Synthesis with Logic Gates

To implement a switching function with logic gates

f(A, B, C) = (A + (BC)')'

BC

A f

CSI-2111 Computer Architecture I page 2-35

Analysis with Logic Gates

To find the functionality of the circuit made up of logic gates

f(A, B, C) = (A + (BC)')'

BC

A f

CSI-2111 Computer Architecture I page 2-36

Synthesis with Single Gates

More economical than {AND, OR, NOT}

SOP form with {NAND}

POS form with {NOR}– Similar to SOP.

AB A+B

A1

B1

A+B

CSI-2111 Computer Architecture I page 2-37

Return to NOR-NAND *

f(A, B, C, D) = AB’ +A’C + D To implement with NAND ( ) only:

= ((AB’ +A’C + D)’)’= ((AB’)’ . (A’C)’ . (D)’)’= (AB’)’ (A’C)’ (D)’= (AB’) (A’ C) (D)’

CSI-2111 Computer Architecture I page 2-38

Return to NOR-NAND *

f(A, B, C, D) = AB’ +A’C + D To implement with NOR ( only:

= ((AB’)’)’ + ((A’C)’)’ + D= (A’+B)’ + (A+C’)’ + D= (A’B) +(AC’) + D= (((A’B) +(AC’) + D)’)’= ((A’B) (AC’) D)’= ((A’B) (AC’) D) 0

CSI-2111 Computer Architecture I page 2-39

Return to NOR-NAND *

g(A, B, C, D) = (A+B’).(A’+C) . D Implement with NAND ( ) only:

= ((A+B’)’)’. ((A’+C)’)’ . D= (A’B)’ . (AC’)’ . D= (A’B) . (AC’) . D= (((A’B) . (AC’) . D)’)’= ((A’B) (AC’) D)’= ((A’B) (AC’) D)

CSI-2111 Computer Architecture I page 2-40

Return to NOR-NAND *

g(A, B, C, D) = (A+B’).(A’+C) . D Implement with NOR ( only:

= (((A+B’).(A’+C).D)’)’= ((A+B’)’ + (A’+C)’ + D’)’= (A+B’)’ (A’+C)’ D’= (AB’) (A’ C) D’

CSI-2111 Computer Architecture I page 2-41

2.5 Adders

Classic combinational circuits Various common circuits

– Half-Adders– Elementary adder– Parallel full-adder– Elementary subtracter– Adder-substracter

CSI-2111 Computer Architecture I page 2-42

Adding words of several bits?

Parallel full-adder of 4 bits EA = Elementary Adder

EA

B4 A4

C4

S4

EA

B3 A3

C3

S3

EA

B2 A2

C2

S2

EA

B1 A1

C1

S1

R5

CSI-2111 Computer Architecture I page 2-43

2.6 Logic Timing Diagram

CSI-2111 Computer Architecture I page 2-44

Complementary Reading

In Mano and Kime– Sections 1.2 and 1.3

• Numbers and binary arithmetic

– Sections 2.1, 2.2, 2.3, 2.6 and 2.7• Boolean algebra, logic gates, canonical forms

– Section 3.8, except « Carry Lookahead Adder »

• Adders

– Sections 3.9 and 3.10• Subtracters