Computer Organization and Architecture

70
Computer Organization and Architecture COMP 241 Henok Sahilu (M.sc computer science) Computing and infromatics building Office no 8 [email protected]

Transcript of Computer Organization and Architecture

Page 1: Computer Organization and Architecture

Computer Organization and ArchitectureCOMP 241

Henok Sahilu (M.sc computer science)

Computing and infromatics building Office no 8

[email protected]

Page 2: Computer Organization and Architecture

Chapter oneIntroduction to digital logic circuits

• What computers are?– Computers are programmable digital electronic devices.

• Digital information is presented by variables that take a limited number of discrete values.

• Discrete values are processed internally by components that contain a limited number of discrete states.– Decimal digits: 0, 1, 2,…..9 → 10 discrete values.– Binary number: 0, 1 -> 2 discrete values.

Page 3: Computer Organization and Architecture

• But, in digital systems, these discrete elements of information are represented by physical quantities called signals (electrical signals: current and voltage)

• These signals are characterized to have only two discrete values and are said to be binary .

• Digital computers use the binary number system which has two digits: 0 and 1.

• In these systems information is represented in in group of bits.

• By employing several coding methods these group of bits can be used to represent no only binary numbers but also other discrete symbols or information: digits, letters and can be used to develop complete sets of instructions for performing various types of computations.

Page 4: Computer Organization and Architecture

• For example : the binary number 1001011 represent a decimal number 75. but when using the binary code for the letters it represents the letter k. It is also possible for it to represent a control code for specifying some decision logic in a particular digital machine.

Page 5: Computer Organization and Architecture

• Generally speaking, Computers consist of hierarchical layers of hardware and software.– Hardware: All electronic components and electromechanical

devices that comprise the physical entity of device.– Software: Instructions and data that the computer

manipulates to perform various tasks.– Program: A sequence of instructions for the computer.

Page 6: Computer Organization and Architecture
Page 7: Computer Organization and Architecture

Architecture & Organization• Architecture is those attributes visible to the programmer-

those attributes that have a direct impact on the execution of a program.– Or is concerned with the specification of the various functional

modules. –Instruction set, number of bits used for data representation, I/O mechanisms, addressing techniques.

• Q: How many bits is a “typical” data in a processor?• A: It depends on the architecture

– 4-bit, 8-bit, 32-bit, etc. (usually powers of 2)• Organization is how features are implemented

– Is concerned with the way the hardware components operate and the way they are connected together to give rise to the computer system. In other words it is to investigate the organizational structure to verify that the computer parts operate as intended or expected.

it to mean the underlying implementation of the architecture.

Page 8: Computer Organization and Architecture

Why study computer organization and architecture?– Design better programs, including system software such as

compilers, operating systems, and device drivers.

– Optimize program behavior.

– Evaluate (benchmark) computer system performance.

– Understand time, space, and price tradeoffs.

Page 9: Computer Organization and Architecture

• Generally: the Principle of Computer Organization and Architecture answers the question "How do computers work ?"

• It examines the underlying components and the basic organizing principles in the construction of computer systems.

• By studying the fundamental organizing principles of computer systems, we are better able to understand, design, and implement complex systems.

Page 10: Computer Organization and Architecture

An example of abstraction

Page 11: Computer Organization and Architecture

• Logic gates– Binary logic deals with binary variables and with

operations that assumes a logical meaning. It is used to describe the manipulation of and processing of binary information.

• Digital Logic Circuits– electronic circuits that handle information encoded in

binary form (deal with signals that have only two values, 0 and 1).These circuits are called Logic gates.

– These gates are hardware that produce signals of binary 1 or 0 when input logic requirements are satisfied.

– Each gate has a distinct graphical expression and a truth table to represent the input –output relationship of the binary variables of each gate in a tabular form.

Page 12: Computer Organization and Architecture

Truth Tables and Boolean Notation

• Circuits with one input

– Buffer P = A– The buffer does not

produce any particular logic function since the binary value of the output is the same as the binary value of the input

– Not P = A

A P0 01 1

A P0 11 0

A P

A P

Page 13: Computer Organization and Architecture

Basic AND / OR

• Circuits with two Inputs

– AND P = A.B

– OR P=A+B

A B P0 0 00 1 01 0 01 1 1

AB P

A B P0 0 00 1 11 0 11 1 1

AB P

Page 14: Computer Organization and Architecture

Basic NAND / NOR

– NAND P = A.B

– NOR P=A+B

A B P0 0 10 1 11 0 11 1 0

AB P

A B P0 0 10 1 01 0 01 1 0

AB P

Page 15: Computer Organization and Architecture

Basic XOR (Exclusive OR) / XNOR (Exclusive NOR)

• Circuits with two Inputs:

– XOR P = A B

– XNOR P = A B

A B P0 0 00 1 11 0 11 1 0

A B P0 0 10 1 01 0 01 1 1

AB P

AB P

Page 16: Computer Organization and Architecture

• You should be aware that

A . Bnot A and not B

A . Bnot (A and B) equivalent to NAND

and

are different.

011

001

010

100

BA A.B

Page 17: Computer Organization and Architecture

• Any logic circuits can be built from the three basic building blocks: OR, AND, NOT– Example 1: x = A B + C– Example 2: x = (A+B)C

• Gates can have multiple inputs and more than one output.– A second output can be provided for the complement of the

operation.

Page 18: Computer Organization and Architecture

Examples 1,2

Page 19: Computer Organization and Architecture

Boolean Algebra • Boolean Algebra is used as a formal mathematical

tool that deals with binary variables and logic operations.

• Boolean expressions are created by performing operations on Boolean variables.

• A Boolean function has:• At least one Boolean variable, • At least one Boolean operator, and • At least one input from the set {0,1}.

• It produces an output that is also a member of the set {0,1}.

• And can be expressed using a truth table and diagrammatically using logic gates.

Page 20: Computer Organization and Architecture

21

3.2 Boolean Algebra• The truth table for the Boolean

function:

is shown at the right.

• To make evaluation of the Boolean function easier, the truth table contains extra (shaded) columns to hold evaluations of subparts of the function.

Page 21: Computer Organization and Architecture

22

3.2 Boolean Algebra• Digital computers contain circuits that implement Boolean

functions.• Hence the simpler that we can make a Boolean function, the

smaller the circuit that will result.– Simpler circuits are cheaper to build, consume less power, and run faster than

complex circuits.

• With this in mind, we always want to reduce our Boolean functions to their simplest form.

• Generally- the purpose of Boolean algebra is to facilitate the analysis and design of digital circuits. It provides a convenient tool to: – Express in algebraic form a truth table relationship between binary

variables.– Express in algebraic from the input –output relationship of logic

diagrams.– Find simple circuit for the same function.

• There are a number of Boolean identities\rules that help us to do this.

Page 22: Computer Organization and Architecture

The most basic identities of the Boolean Algebra

1) X.0 =0 null law

2) X. 1 =X identity law

3) X.X=X idempotent law

4) X.X’=0 inverse law

5) x+0=x identity law

6) x+1=1 null law

7) x+x=x idempotent law

8) x+x’=1 inverse law

9) (X’)’ = X double complement law

Page 23: Computer Organization and Architecture

Boolean Theorems (Multivariable)1) x+y = y+x2) X.Y = Y.X3) x+(y+z) = (x+y)+z=x+y+z4) x(yz)=(xy)z=xyz5) x(y+z)=xy+xz6) (w+x)(y+z)=wy+xy+wz+xz7) x+xy=x -> x(1 +y) = x.1=x8) x+x’y=x+y -> x + xy + x’y= x+ y(x+x’)= x+y since x+x’=19) x’+xy=x’+y -> x’+ x’y +xy = x’+y(x+x’)= x’+y

Page 24: Computer Organization and Architecture

DeMorgan’s Theorems• (x+y)’=x’y’• Implications and alternative symbol for NOR

function. Figure (b) is the alternative of the NOR gate.

Page 25: Computer Organization and Architecture

(xy)’=x’+y’Implications and alternative symbol for NAND function. Figure (b) is the alternative of the NAND gate.

Page 26: Computer Organization and Architecture

Alternate Logic-Gate Representation

Page 27: Computer Organization and Architecture

28

3.2 Boolean Algebra• Simplify

Page 28: Computer Organization and Architecture

Another example

• F= ABC + ABC’ +A’C =AB(C + C’) + A’C= AB + A’C

Page 29: Computer Organization and Architecture

30

Complement of a function • Sometimes it is more economical to build a circuit using

the complement of a function (and complementing its result) than it is to implement the function directly.

• DeMorgan’s law provides an easy way of finding the complement of a Boolean function.

• Recall DeMorgan’s law states:

Page 30: Computer Organization and Architecture

31

• DeMorgan’s law can be extended to any number of variables.

• Replace each variable by its complement and change all ANDs to ORs and all ORs to ANDs.

• Thus, the complement of:

can be:

Page 31: Computer Organization and Architecture

32

• Through our exercises in simplifying Boolean expressions, we see that there are numerous ways of stating the same Boolean expression.– These “synonymous” forms are logically equivalent.– Logically equivalent expressions have identical truth tables.

• In order to eliminate as much confusion as possible, designers express Boolean functions in standardized or canonical form.

• There are two canonical forms for Boolean expressions: • sum-of-products and product-of-sums.

• In the sum-of-products form, ANDed variables are ORed together.– For example:

• In the product-of-sums form, ORed variables are ANDed together:– For example:

Page 32: Computer Organization and Architecture

33

• It is easy to convert a function to sum-of-products form using its truth table.

• From the truth table locate the values of the variables that make the function true (=1).

• Then list the values of the variables that result in a true function value

• Each group of variables is then ORed together.

• Hence, the sum-of-products form for our function is:

• note that this function is not in simplest terms. Our aim is only to rewrite our function in canonical sum-of-products form.

Page 33: Computer Organization and Architecture

Karnaugh Map Method• Simplification of Boolean functions leads to simpler (and

usually faster) digital circuits.But• Simplifying Boolean functions using identities is time-

consuming and error-prone.• This special section presents an easy, systematic

method for reducing Boolean expressions.• K map method

– A graphical method of simplifying logic equations or truth tables. • Some Uses of K-Maps

– Finding optimum or near optimum• SOP and POS standard forms.

• Basically A K-map is a collection of squares–Each square represents a minterm- each combination of

the variables in a truth table is called minterm.

Page 34: Computer Organization and Architecture

• A Kmap has a cell for each minterm. This means that it has a cell for each line for the truth table of a function.

• The information contained in a truth table may be expressed in compact form by listing the decimal equivalent of the those minterms that produce a 1 for the function.

F= x + y’z

F(x,y,z)= 7,6,5,4,1

Page 35: Computer Organization and Architecture

• By convention, we represent the minterms of F by a "1" in the map and leave the other minterms blank or 0.

The truth table for the function F(x,y) = xy is shown at the right along with its corresponding Kmap.

Page 36: Computer Organization and Architecture

Each variable under brackets contains half of the square in the map where that variable appears unprimed – that is having a value of 1. That variable appears with a prime (Complemented ) in the remainder half of the square .The pattern from top to bottom and left to right must be in the form:

BAAB,B,A,BA

Page 37: Computer Organization and Architecture

38

• Groupings can contain only 1s.• Groups can be formed only at right angles; diagonal

groups are not allowed.• The number of 1s in a group must be a power of 2 –

even if it contains a single 1.• The groups must be made as large as possible.• Groups can overlap and wrap around the sides of

the K-map that is -Looping may also be wrapped between top, bottom, and sides.

• Each group of square represents an algebraic terms , and the OR of the those terms gives the simplified algebraic expression for the function in the sum-of-products form.

The rules of Kmap simplification are:

Page 38: Computer Organization and Architecture

Example • The Boolean algebraic expression is m = a'bc + ab'c + abc' + abc. • The minimization can done as follows.

m = a'bc + abc + ab'c + abc + abc' + abc = (a' + a)bc + a(b' + b)c + ab(c' + c)

= bc + ac + ab

Page 39: Computer Organization and Architecture

• The minimization is done by drawing circles around sets of adjacent 1s.

• We have circled two 1s. The fact that the circle spans the two possible values of a (0 and 1) means that the a term is eliminated from the Boolean expression corresponding to this circle.

• The bracket delimits the set of squares for which the variable has the value 1. We see that the two circled 1s are at the intersection of sets b and c, this means that the Boolean expression for this set is bc.

Page 40: Computer Organization and Architecture

• The left bottom circle is the term ac. Note that the circle spans the two possible values of b, thus eliminating the b term. Another way to think of it is that the set of squares in the circle contains the same squares as the set a intersected with the set c.

• The other circle (lower right) corresponds to the term ab. Thus the expression reduces to bc + ac + ab

Page 41: Computer Organization and Architecture

4-input K-map

01 11

1

0

0

1

0

0

1

101

1

1

1

1

0

0

0

1

11

10

00

00

10AB

CD

Y

0

C D0 00 11 01 1

B0000

0 00 11 01 1

1111

1

110111

YA00000000

0 00 11 01 1

0000

0 00 11 01 1

1111

11111111

11

100000

Page 42: Computer Organization and Architecture

4-input K-map

01 11

1

0

0

1

0

0

1

101

1

1

1

1

0

0

0

1

11

10

00

00

10AB

CD

Y

Y = AC + ABD + ABC + BD

0

C D0 00 11 01 1

B0000

0 00 11 01 1

1111

1

110111

YA00000000

0 00 11 01 1

0000

0 00 11 01 1

1111

11111111

11

100000

Page 43: Computer Organization and Architecture

Product of sum simplification • It is sometimes convenient to obtain the algebraic

expression for the function in a product-of-sums form.• The sum are OR terms and the product denotes the

ANDing of these terms.• the method is

– The squares not marked by 1 represent the minitersm that produce 0 for the function.

– Marking the empty squares with 0’s and combining them into groups of adjacent squares will give the complement of the function F’.

– Taking the complement of F’ (using the double complement rule) produce the expression of F in the product of sum form.

Page 44: Computer Organization and Architecture

• Simplify the following Boolean function in both sum-of-products form and product-of-sums form:

F(A, B, C, D) = ∑ (0, 1, 2, 5, 8, 9,10) • Combining the squares, the figure, with 1's gives the simplified function in sum-of-

products form: F = B'D' + B'C' + A'C'D • Again If the squares marked with 0's are combined, we obtain the simplified

complemented function: F'=AB+CD+BD‘.• Hence Taking the complement of F', we obtain the simplified function in product-

of- sums form as F= (A' + B')(C' + D')(B' + D)

Page 45: Computer Organization and Architecture

Don't-Care Conditions• There are occasions when it does not matter if the function produces

0 or 1 for a given minterm. • Since the function maybe either 0 or 1, we say that we don't care

what the function output is to be for this minterm. • Such kinds of Minterms in the function are said to be don't-care

conditions and are marked with an x in the map. • These don't-care conditions can be used to provide further

simplification of the algebraic expression. • When choosing adjacent squares for the function in the map, the x's

may be assumed to be either 0 or 1, whichever gives the simplest expression.

• In addition, an x need not be used at all if it does not contribute to the simplification of the function.

• In each case, the choice depends only on the simplification that can be achieved

Page 46: Computer Organization and Architecture

• Consider the following Boolean function together with the don't-care minterms: F(A, B, C) = ∑ (0,2,6) d(A,B,C) = ∑ (1,3,5)

• The 1's and x's can be combined in any convenient manner so as to enclose the maximum number of adjacent squares.

• It is not necessary to include all or any of the x's, but all the 1's must be included.• By including the don't-care minterms 1 and 3 with the 1's in the first row we obtain

the term A'. • The remaining 1 for minterm 6 is combined with minterm 2 to obtain the term BC'.

The simplified expression is F=A'+BC‘. • Note that don't-care minterm 5 was not included because it does not contribute

to the simplification of the expression

Page 47: Computer Organization and Architecture

•But if don't-care minterms 1 and 3 were not included with the 1's, the

simplified expression for F would have been: F=A'C' + BC' . Minterterm

0 and minterm 2 are combined and produce the term A’C’. Minterm 2

and minterm 6 will combine and produce the term BC’.

This would require two AND gates and one OR gate, as compared to

the expression obtained previously, which requires only one AND and

one OR gate

Page 48: Computer Organization and Architecture

Combinational and sequential circuits• There are two types of circuits in digital circuits:

combinational and sequential.• Combinational Circuits

– A combinational circuit is a connected arrangement of logic gates with a set of inputs and outputs.

– At any given time, the binary values of the outputs are a

function of the binary combination of the inputs.• Combinational circuits are employed in digital computers

for generating binary control decisions and for providing digital components required for data processing

Page 49: Computer Organization and Architecture

Combinational Circuits

Page 50: Computer Organization and Architecture

• A combinational circuit can also be specified with m Boolean functions, one for each output variable. Each output function is expressed in terms of the n input variables.

• The design of combinational circuits starts from the verbal outline of the problem and ends in a logic circuit diagram. The procedure involves the following steps:

1. The problem is stated. 2. The input and output variables are assigned letter

symbols. 3. The truth table that defines the relationship between

inputs and outputs is derived. 4. The simplified Boolean functions for each output are

obtained. 5. The logic diagram is drawn. With connected logic gates

Page 51: Computer Organization and Architecture

52

Half-Adder The most basic digital arithmetic circuit is the addition of two binary digits. A combinational circuit that performs the arithmetic addition of two bits is called a half-adderAs we see, the sum can be found using the XOR operation and the carry using the AND operation.

Page 52: Computer Organization and Architecture

Hence form the truth table the Boolean expression are for the output and the carry

Page 53: Computer Organization and Architecture

• Full-Adder – A full-adder is a combinational circuit that forms the arithmetic

sum of three input bits. It consists of three inputs and two outputs.

– Two of the input variables, denoted by x and y, represent the two significant bits to be added.

– The third input, z (carry in), represents the carry from the previous lower significant position.

•The two outputs are designated by the symbols S (for sum) and C (for carry out). •The binary variable S gives the value of the least significant bit of the sum. The binary variable C gives the output carry.

Page 54: Computer Organization and Architecture

•From the truth table it is clear that the output S is 1 when an odd number of inputs are 1, S is an odd function and represents the exclusive-OR relation of the variables.•The squares with 1 ‘s for the C out put may be combined in a variety of ways.

Page 55: Computer Organization and Architecture

•Hence the Boolean expression for he full adder is:

The full-adder circuit consists of two half-adders and an OR

gate.

Page 56: Computer Organization and Architecture

Binary adder• Binary adder that produces the arithmetic sum of

binary numbers can be constructed with full adders connected in cascade, with the output carry from each full adder connected to the input carry of the next full adder in the chain.

• Note that the input carry C0 in the least significant position must be 0.

Page 57: Computer Organization and Architecture

• For example to add A= 1011 and B= 0011 subscript i: 3 2 1 0 Input carry: 0 1 1 0 Ci

Augend: 1 0 1 1 Ai

Addend: 0 0 1 1 Bi -------------------------------- Sum: 1 1 1 0 Si

Output carry: 0 0 1 1 Ci+1

Page 58: Computer Organization and Architecture

• Although every digital system is likely to have a combinational circuit, most systems encountered in practice also include storage element, which require that the system be described in terms of sequential circuits.

• Synchronous circuits employ signals that affect the storage elements only at discrete instants of time.

• Synchronization is achieved by a timing device called a clock pulse generator that produces a periodic train of clock pulses.

Page 59: Computer Organization and Architecture

Sequential circuit concepts

•The addition of a memory device to a combinational circuit allows the output to be fed back into the input:

circuit

memory

Input(s) Output(s)

Page 60: Computer Organization and Architecture

The storage elements employed in clocked sequential circuits are called flip-flops.

A flip-flop is a binary cell capable of storing one bit of information. It has two outputs, one for the normal value and one for the complement value of the bit stored in it. Two outputs designated Q and Q-Not that are always opposite or complimentary.

When referring to the state of a flip flop, we refer to the state of the Q outputA flip-flop maintains a binary state until directed by a clock pulse to switch states. That is a clocked flip flop changes state only when permitted by the clock signal.SR Flip-FlopIt has three inputs, labeled S (for set), R (for reset), and C (for clock).

Page 61: Computer Organization and Architecture

S

R Q

Q

R

S

Q

Q

CircuitDiagram

Function Table

R S Qn+1

0 0 Qn

0 1 11 0 01 1 ?

Q

QS

R

n+1 represents output at some future time

n represents current output.

• A NOR implementation of the S-R flip flop.

Page 62: Computer Organization and Architecture

• The operation is as follows – If there is no signal at the clock input C, the out put of

the circuit cannot change irrespective of the values at the inputs S and R - that means there will not be a change in the SR flip flop.

– But when the clock changes form 0 to 1 – goes high or enabled that the out put of the circuit can be affected according to the values in inputs S and R. Hence when C changes from 0 to 1

• If S=1 and R=0 , then Q is set to 1.• If S=0 and R=1 then output Q is cleared to 0. • If S=1 ,R=1 then the out put is unpredictable and SR flip flop

should not be pulsed since it produces an indeterminate next step.

Page 63: Computer Organization and Architecture

• Assume some previous operation has Q as a 1• Assume R and S are initially inactive (both 0) and the clock is

high.

S = 0

R = 0Q = 1

Q = 0

Circuit

R S Qn+1

0 0 Qn

0 1 11 0 01 1 ?

Now assume R goes first to 1 then returns to 0, what happens:

Page 64: Computer Organization and Architecture

•When R goes active 1, the output from the first gate must be 0.

S = 0

R = 1Q = 0

~Q = 1This 0 feeds back to gate 2

Since both inputs are 0 the output is forced to 1

The output ~Q is fed back to gate 1, both inputs being 1 the output Q stays at 0.

S = 0

R = 1Q = 0

~Q = 1

Page 65: Computer Organization and Architecture

•When R now goes in-active 0, the feedback from ~Q (still 1), holds Q at 0.

S = 0

R = 0Q = 0

~Q = 1The “pulse” in R has changed the output as shown in the function table:

R S Qn+1

0 0 Qn

0 1 11 0 01 1 ?

We went from here

To hereAnd back again

In that process, Q changed from 1 to 0. Further signals on R will have no effect.

Page 66: Computer Organization and Architecture

•Similar sequences can be followed to show that setting S to 1 then 0 – activating S – will set Q to a 1 stable state.•However, When R and S are activated simultaneously both outputs will go to a 0. note: Q’ was 1 and Q is 0 from the previous state (previous slide).

S = 1

R = 1Q = 0

~Q = 0

•When R and S now go inactive 0, both inputs at both gates are 0 and both gates output a 1. note: both outputs were 0 from the previous state. •This 1 fedback to the inputs drives the outputs to 0, again both inputs are 0 and so on and so on and so on and so on.•If implemented in electronic circuits the oscillation continues indefinitely

S = 0

R = 0Q = 1

~Q = 1

Page 67: Computer Organization and Architecture

The Clocked SR Flip-flop• In some cases it is necessary to disable the inputs to a flip flop• This can be achieved by adding a control or clock input to the

flip –flop circuit. – In the circuit diagram below When C = 0 R and S inputs cannot reach the

flip flop, irrespective of their values. • Holds its stored value

– In the circuit diagram below When C = 1 R and S inputs connected to the flip flop

• Functions as before

S

RQ

Q

C

Page 68: Computer Organization and Architecture

Clocked SR Flip-flop

R S C Qn+1

X X 0 Qn Hold0 0 1 Qn Hold0 1 1 1 Set1 0 1 0 Reset1 1 1 ? Unused

S

R Q

Q

Q

Q

R

S

C C

Page 69: Computer Organization and Architecture

Clocked D Flip-flop• Simplest clocked Flip-flop of practical importance is

the Clocked D Flip-flop

• In D Flip-flop

• Both active 1 inputs at R and S can’t occur.

• Notice we’ve reversed the two inputs (that is they are complement of each other )so when D is 1 Q is 1.

Page 70: Computer Organization and Architecture

• It removes the undefined behavior of the SR Flip Flop• Often used as a basic memory element

• A D Flip Flop has a single data input– the previous output is held when the clock input is a zero (disabled) – the input is copied to the output when the clock input is a one (enabled)– That means As long as the clock pulse remains 1,any changes in the data input will

change the state of the flip-flop. The flip-flop is transparent, since its input value can be seen from the output.

D C Qn+1

X 0 Qn Hold0 1 0 Reset1 1 1 Set

Circuit

DC

QQ

Symbol Function Table

S

R

Q

Q

Q

Q

C C

D