Lec02-CS110 Computational Engineering

Preview:

DESCRIPTION

A keynote on Problem Solving using Computers

Citation preview

CS110: Models of Computing

Lecture 2V. Kamakoti

3rd January 2008

• What IS a computer?• A computer is a machine• Something that operates mechanically• But it is a flexible machine• Its behaviour is controlled by a program• A program is like a spell cast on a machine• Programmers are like wizards• Programs reside in the memory of the

machine– Charles Babbage (1791-1871)– “The stored program concept”

Early Computing Hardware

The Slide rule The Chinese Abacus

The gear replaced the beads inearly mechanical calculators

“History of computing hardware”From Wikipedia, the free encyclopedia

Jaquard looms

Used punched cards to weave different patterns

The DifferenceEngine

The London Science Museum'sreplica Difference Engine, builtfrom Babbage's design.

Part of Babbage's differenceengine, assembled after hisdeath by Babbage's son, usingparts found in his laboratory.

The First ProgrammerAugusta Ada King, Countess ofLovelace (December 10, 1815 –November 27, 1852), born AugustaAda Byron, is mainly known forhaving written a description ofCharles Babbage's early mechanicalgeneral-purpose computer, theanalytical engine.

The programming language ADA is named after her.

ENIAC – the first electronic computerPhysically, ENIAC wasmassive compared to modernPC standards. It contained17,468 vacuum tubes, 7,200crystal diodes, 1,500 relays,70,000 resistors, 10,000capacitors and around 5million hand-soldered joints.It weighed 30 short tons (27 t),was roughly 8 feet (2.4 m) by3 feet (0.9 m) by 100 feet (30m), took up 1800 square feet(167 m²), and consumed 150kW of power.

2000: Intel Pentium 4 ProcessorClock speed: 1.5 GHz# Transistors: 42 millionTechnology: 0.18µm CMOS

High Level Prog.

Assembly Language

Operating Systems

Digital Hardware

Structured

Computer

Organization

A typical PC Specification fromtoday’s Newspaper

• Intel Core 2 Duo 6550 2.33GHz• 2x2MB L2 Cache/ 1333MHz FSB• Intel DG31PR Motherboard• 2GB DDR2 RAM 667MHz• 160GB SATA 3Gbps HDD• Onboard Intel Graphics Controller• Onboard 10/100Mbps Ethernet• Onboard Sound card• 19” Widescreen TFT Monitor (Viewsonic)• Logitech Keyboard and Optical Mouse• DVD Writer• Creative 2.0 Speakers• 500VA UPS

The computing machinePROCESSOR

The computer is made up of a processor and a memory. The memorycan be thought of as a series of locations to store information.

MEMORY

01234……. (say) 256 MEGABYTES

The computing machinePROCESSOR

The processor treats part of the information in memory as instructions,and a part of it as data. A program is a sequence of instructionsassembled for some given task. Most instructions operate on data. Someinstructions control the flow of the operations. It is even possible to treatprograms as data. By doing so a program could even modify itself.

MEMORY

01234……. 256 MEGABYTES

program data

Variables

• Each memory location is given a name.• The name is the variable that refers to the

data stored in that location.• Variables have types that define the

interpretation data.– e.g. integers (1, 14, 25649), or characters (a, f, G,

H)• All data is represented as binary strings. That

is, it is a sequence of 0’s and 1’s, of apredetermined size – “word”. A byte is madeof 8 bits.

Instructions

• Instructions take data stored in variables asarguments.

• Some instructions do some operation on thedata and store it back in some variable.

• The instruction “XX+1” on integer type saysthat “Take the integer stored in X, add 1 to it,and store it back in (location) X”..

• Other instructions tell the processor to dosomething. For example, “jump” to a particularinstruction next, or to exit

Programs• A program is a sequence of instructions.• Normally the processor works as follows,

– Step A: pick next instruction in the sequence -Program Counter

– Step B: Decode the instruction– Step C: get data for the instruction to operate upon– Step D: execute instruction on data (or “jump”)– Step E: store results in designated location

(variable)• Different parts of the processor are

responsible for the above steps.

Test Your Understanding -Please copy in your notebook

• Name at least 20 important electroniccircuitry/peripherals inside/connected toa PC.

• What are the four prominent levels in aStructured Computer Organization?

• What are the five steps taken by theprocessor to execute an instruction?

Test Your Understanding -Please copy in your notebook

• Suppose each stage takes onemillisecond, then each instruction takesfive milliseconds to complete execution.

• Then 10000 instructions shall take50000 milliseconds.

• Is there a way to improve this?

Answers

20 components

1) Motherboard2) Processor Chip3) Cache4) Bus5) Memory6) Printer7) USB pen drive8) External Disk

20 components

9) CD/DVD Drive10) Monitor11) Webcam12) Keyboard13) Mouse14) Graphics Card15) Speaker16) Mic

20 components

17) Network Card - Wired18) Wireless Network card19) Power Supply20) Floppy drive

Four levels: High level, Assembler lang. level,Operating Systems and Digital Hardware

Making it fast

Fetch + Inc. PC

Decode Instrn

Fetch Data

Execute Instrn

Store Data

10000 Instructions

No pipelining takes

50000 Units. Eachhardware isindependent.

With Pipelining

I1I2

I1

I3

I2

I1

I4

I3

I2

I1

I5

I4

I3

I2

I1

First Instructioncompletes at end of5th unit

Second instructionat end of 6th unit

10000th instructionat end of 10004units

The concept• Instruction Level Parallelism• You can use more than one CPU - Multicore

Creative Problem - 1• The Towers of Hanoi: Move from peg 1 to

peg 3, such that a larger disk is not on top ofa small one.

Src: wikipedia

One disk - one move

One disk - one move

Two disks - three moves

Two disks - Move 1

Two disks - Move 2

Two disks - Move 3

Three disks - 7 moves

Three disks - move 1

Three disks - move 2

Three disks - move 3

Three disks - move 4

Three disks - move 5

Three disks - move 6

Three disks - move 7

The problem

How many? Proveit.

n

73

32

11No. of MovesNo. of Disks

Thank You

• Monday– Lab starts on Monday

• RF-ID 1 to 60 - Monday batch• RF-ID 61 to 120 - Tuesday• RF-ID 121 to 180 - Wed• RF-ID 181 to 240 - Thurs• RF-ID 241 to 300 - Fri

– Lab details + solution to Towers of Hanoi