Docsity

Programmable Machines - Lecture Notes | COMP 411, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Programmable Machines - Lecture Notes | COMP 411 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

L15 – Programmable Machines

10/22/

Programmable Machines

In order to computeWe need onlyStorage, Data Paths,and ControlA General Purpose computerrequires one additional thingPROGRAMMABILITY

! Help

L15 – Programmable Machines

10/22/

One More Functional Unit

Thus far, our processing blocks units have focused on logical andarithmetic functions. We’ll also need functional units for storingintermediate results. By now, we are used to the notion of buildingwide registers.

DEN Q

DEN Q

DEN Q

DEN Q

DEN Q

D^1 0 S^ D Q Q

EN CLK

D Q

EN

An N-bit wideRegister with enable

L15 – Programmable Machines

10/22/

A Multi-Ported Register File

Multiple read ports by simply adding more output MUXs

D Q

EN^

D Q

EN^

D Q

EN

…^ …

0 1

N 2 -

Write Addr[N:0] Read Addr A[N:0]

0 1^ …^

N 2 -

Data in[B:0]
Data out A[B:0]
Write Enable
Clk

0 1

N 2 -

Read Addr B[N:0]
Data out B[B:0]

Din[B:0] WA[N:0]RA[N:0]WE DA[B:0] DB[B:0] RB[N:0]

L15 – Programmable Machines

10/22/

Let’s Build a Simple Computer Data path for computing N*(N-1)

EN^
EN

A^ *

B

N^0 1 -

0 1

ASEL^

BSEL BLE

ALE^ ANSWER

L15 – Programmable Machines

10/22/

A First Program

A^ ←^

1 A^ ←^

A * B B ← B - 1

B^ ←^

N

A^ ←^

A * B

SSN^

AN+1 sel BA sel^

Ble le

0 1 1 2 2 3 3 4 4 4 S0 S1 S2 S3 S

Once more,writing a controlprogram is nothing more thanfilling in a table

L15 – Programmable Machines

10/22/

An Optimized Program

A^ ←^

1 A^ ←^

A * B B ← B - 1

B^ ←^

N

A^ ←^

A * B

SSN^

AN+1 sel BA sel^

Ble le

0 1 1 2 2 3 3 3 S0 S1 S2 S

Some parts of the programcan be computed simultaneously.

L15 – Programmable Machines

10/22/

Program for Factorial

A^ ← B^ ←^ N A^ ←^1 A * BB ←^ B - 1

Z= Z=1 DONE

S0 S1 S

Z^ SN

S N+

A sel^ BAsel^

Ble le

Programmability, allows us to reusedata paths to solve new problems.What we need is a general purposedata path, that can be used to efficientlysolve most problems, aswell as a easier way to control it.^ -^00 11 1 -^2

L15 – Programmable Machines

10/22/

Computing Factorials

Z S^ |^ S’

Asel^ Bsel

Ale^ Ble ----+--------------------- -^0 | 1

1

0 1

1 A=1,

B=N

0 1^ |^1

0

1 1

1 A=A*B,

B=B-

1 1^ |^2

0

1 1

1

  • 2^ |^2 -^ -^0

0 done EN^

EN A^ *

B 1

N^01 - (^01) ControlFSM^

ASEL BSELALE BLE ASEL^

BSEL BLE ALE ANSWER

The same data paths could computeN*(N-1), Factorial, ..... only difference: information in control ROM

This computing machine does agreat job computing these specificfunctions, but is it general purposeenough?Can it compute

N?^ i ∑∑∑∑====i^1 A + B?^2 A?

L15 – Programmable Machines

10/22/

Computability vs. Programmability

Recall Church’s thesis (from last lecture)“Any discrete function computable byANY realizable machine is computable bysome Turing Machine”An Thusly, we’ve defined what it means toCOMPUTE (whatever a TM can compute)A Turing machine is nothing more that anFSM that receives inputs from, andoutputs onto, an infinite tape.Thus far, we’ve been designing a new Turingmachine FSM for each new function thatwe encounter.Wouldn’t it be nice if we could design a moregeneral purpose computing machine?

Alan Turing

1 S 1

0,(1,R)^ 1,(1,L)^ S^2 0,(1,L)^ 1,Halt

L15 – Programmable Machines

10/22/

Too many Turing machines!

(^0 1 1 0) FSM 0 0 1 0

0 Multiplication^0 1 1 0 FSM 0 0 1 0

0 Sorting

(^0 1 1 0) FSM 0 0 1 0

0 Factorization

(^0 1 1 0) FSM 0 0 1 0

0 Primality Test^ Is there analternative toad-hocTuring Machines?

L15 – Programmable Machines

10/22/

Fundamental Result: Universality^ Define "Universal Function“: U(x,y) = T

(y) for every x, y …X

Surprise!

U(x,y) IS COMPUTABLE

,

hence U(x,y) = T

(<x,y>) for some U.U

Universal Turing Machine (UTM):

"data" "program" "interpreter"

PARADIGM

T[<y,^ U^ for General-Purpose Computer!

z>] = T

[z]Y

INFINITELY many UTMs

...

Any one of them canevaluate any computablefunction by simulating/emulating/interpretingthe actions of Turingmachine given to itas an input.UNIVERSALITY:Basic requirementfor a general purposecomputer

L15 – Programmable Machines

10/22/

Demonstrating Universality

Suppose you've designed Turing Machine T

and want to show that its universal.K

APPROACH:1. Find some

known

universal machine, say T

.U

  1. Devise a program, P, to

simulate

Ton TU^

:K

T[<P,x>] = TK

[x] for all x.U

  1. Since T

[<y,z>] = TU

[z], it follows that, for all y and z.Y

CONCLUSION:

Armed with program

P, machine

Tcan mimic the behaviorK^

of an arbitrary machine

Toperating on an arbitrary input tape z.Y^

HENCE T

T can compute any function that can be computed by any TuringK Machine.

[<P,<y,z>>]K

=^ T

[<y,z>]U

=^ T

[z]Y

L15 – Programmable Machines

10/22/

Power of Interpretation

BIG IDEA: Manipulate

coded representations

of computing

machines, rather than the machines themselves.• PROGRAM as a behavioral description• SOFTWARE vs. HARDWARE• INTERPRETER as machine which takes program andmimics behavior it describes• LANGUAGE as interface between interpreter andprogram• COMPILER as translator between languages:INTELLECTUAL BENEFITS:• Programs as data -- mathematical objects• Combination, composition, generation,parameterization, etc.

L15 – Programmable Machines

10/22/

Anatomy of an Interpreter

ControlUnit

DataPaths Internal storage

controlstatus MEMORY

instructions
data

dest

asel fn

bsel Cc’s ALU

PC^

1101000111011

+1^ • INSTRUCTIONS coded as binary data• PROGRAM COUNTER or PC: Address ofnext instruction to be executed• logic to translate instructions intocontrol signals for data path

R1^ ←←←←R2+R

address
address