From Algorithms to Architecture David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. lightning introduction.

Slides:



Advertisements
Similar presentations
Computer Architecture and the Fetch-Execute Cycle
Advertisements

Java Coding OOP David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Towards Event-driven programming &
Everyday Algorithms David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. lightning introduction to.
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Computer Systems. Computer System Components Computer Networks.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Java Coding 6 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Collections.
Java Coding 2 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Decisions, decisions…!
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Java Coding 3 David Davenport Computer Eng. Dept.,
Java Coding 8 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Object-Oriented Design Examples.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Review: OOP & Arrays David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. …from CS101.
Introduction to a Programming Environment
Java Coding David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey.
 Prof. Dr. M. H. Assal Introduction to Computer AS 26/10/2014.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Intro to CS – Honors I Introduction GEORGIOS PORTOKALIDIS
Java Coding 3 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Over & over again!
Chapter 3 Computer Hard ware
Topics Introduction Hardware and Software How Computers Store Data
There are different types of translator. An Interpreter Interpreters translate one instruction at a time from a high level language into machine code every.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Introduction Lecture 01.
Introduction to Computer Systems and the Java Programming Language.
Computational Algorithms David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. lightning introduction.
Computer Architecture And Organization UNIT-II Structured Organization.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
Chapter 5 Computing Components. 5-2 Chapter Goals List the components and their function in a von Neumann machine Describe the fetch-decode-execute cycle.
Java Coding David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Syntax for Variables & Constants Input,
Java Coding 6 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Collections.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
COMPUTER ORGANISATION I HIGHER STILL Computing Computer Systems Higher Marr College Computing Department 2002.
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 15, 2004 Lecture Number: 10.
Java Coding OOP_3 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Some important Java interfaces +
Stored Programs In today’s lesson, we will look at: what we mean by a stored program computer how computers store and run programs what we mean by the.
© GCSE Computing Candidates should be able to:  describe the characteristics of an assembler Slide 1.
Electronic Analog Computer Dr. Amin Danial Asham by.
From Algorithms to Architecture David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. lightning introduction.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
Java Coding 5 – Part 2 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. To object or not…
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Von Neumann Machines. 3 The Von Neumann Architecture Model for designing and building computers, based on the following three characteristics: 1)The.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Computer Architecture Adapted from CS10051 originally by Professor: Johnnie Baker Computer Science Department Kent State University von Neuman model.
Java Programming: From the Ground Up
Edexcel GCSE Computer Science Topic 15 - The Processor (CPU)
Java Coding 3 – part2 David Davenport Computer Eng. Dept.,
von Neumann Architecture CPU
CSCE 121: Simple Computer Model Spring 2015
Introduction to Computer Architecture
Topics Introduction Hardware and Software How Computers Store Data
Chapter 5: Computer Systems Organization
von Neumann Architecture CPU
MARIE: An Introduction to a Simple Computer
Java Coding 4 (part2) David Davenport Computer Eng. Dept.,
Java Coding 6_part3 David Davenport Computer Eng. Dept.,
Java Coding 6 David Davenport Computer Eng. Dept.,
Presentation transcript:

From Algorithms to Architecture David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. lightning introduction to computer architecture

IMPORTANT… Students… This presentation is designed to be used in class as part of a guided discovery sequence. It is not self- explanatory! Please use it only for revision purposes after having taken the class. Simply flicking through the slides will teach you nothing. You must be actively thinking, doing and questioning to learn! Instructors… You are free to use this presentation in your classes and to make any modifications to it that you wish. All I ask is an saying where and when it is/was used. I would also appreciate any suggestions you may have for improving it. thank you, David. David

Implementing Algorithms Now have a methodology for going from problem to program (program syntax coming soon!) First, develop a mental model of a device that might actually execute our algorithm, i.e. a computer!

Memory – Mental Model Information anything a number, letter, word, a report, book, picture, music, animation, a collection of books… written/drawn on a paper cannot be changed! Store in Box can hold only a single paper can examine/copy paper at will replacing paper destroys old always a paper in box! Some info on a piece of paper!

Computer Memory Set of memory locations To identify easily, number or name them To minimise bugs, restrict type of content today (date) salary (pos. real) username (string) address (string) holidaypics (set of images) age (int 0-150) Might also specify whether information can be changed or not i.e. are constant or variable SPEEDOFLIGHT (integer = 300) TAXRATE (real = 22.5) PI (real = 3.142)

Memory requirements The circle computer algorithm… 1. Print “Welcome to circle computer” 2. Ask for & get radius from user 3. Compute area as pi.radius.radius 4. Compute circumference as 2.pi.radius 5. Report area, circumference & radius Information flowing from one step to another must be stored & so needs a place in memory  What memory locations are needed?

Algorithm Trace (1) Envisage area/circumference algorithm in terms of computer memory model radius (positive integer) area (positive real) circumference (positive real) pi (constant 3.142) 2 (constant 2.0) ? ? ? ??

Algorithm Trace (2) Envisage area/circumference algorithm in terms of computer memory model radius (positive integer) area (positive real) circumference (positive real) pi (constant 3.142) 2 (constant 2.0) ? ? ? ?? Ask for & get radius from user 5

Algorithm Trace (3) Envisage area/circumference algorithm in terms of computer memory model radius (positive integer) area (positive real) circumference (positive real) pi (constant 3.142) 2 (constant 2.0) ? ? ? ?? Compute area as pi.radius.radius * 78.55

Algorithm Trace (4) Envisage area/circumference algorithm in terms of computer memory model radius (positive integer) area (positive real) circumference (positive real) pi (constant 3.142) 2 (constant 2.0) ? ? ? ?? Compute circumference as 2.pi.radius *

Algorithm Trace (5) Envisage area/circumference algorithm in terms of computer memory model radius (positive integer) area (positive real) circumference (positive real) pi (constant 3.142) 2 (constant 2.0) ? ? ? ?? Report area, circumference & radius The area of a circle of radius and its circumference is is

COMPUTER ARCHITECTURE

Data flow Only three sorts of instructions input - from external world to memory output - from memory to world assignment - from memory to memory memory outputinput ALU Arithmetic & Logic Unit

Control flow (1) Control mechanism implements algorithm sets up the data paths in appropriate sequence memory outputinput ALU Control First computing devices had control mechanisms that were hardwired (fixed) or at best “pluggable” e.g ENIAC Changing the function of the machine required literally changing its wiring!

memory How it works… input output ALU Switches control data flow into and out of memory. Sequence of switch settings determines function

How it works… Switches control data flow into and out of memory. Sequence of switch settings determines function memory input output ALU

Control flow (2) Recognising only three forms of control sequence required (sequence, decision & repetition) & instructions can be encoded in memory like data allows general control mechanism to be implemented Control memory outputinput ALU Instructions & hence the machine’s function can be changed quickly & easily. Limitation: may be out of program memory, yet have free data memory or vice versa! Program memory PC

Control flow (3) Finally realise that program & data can share same memory Instructions stored in sequentially numbered locations in memory. Current position in program held in program counter. Control fetches current instruction, decodes & executes it (by setting data paths), increments PC, then fetches next instruction, and so on. Memory now holds both program & data Control memory outputinput ALU PC Fetch Execute cycle

Spaghetti Code? “go to” programming… 1.Read first number 2.If first number > 10 then go to 4 3.go to 1 4.Read second number 5.If second number <= first number goto 8 6.Print “Well done” 7.go to 10 8.Print “sorry, no good!” 9.go to 4 10.Print “finished.” Default is next instruction

Von Neumann Architecture Stored-program computer architecture Credited to John von Neumann, circa 1946 Today % of all computers still work like this! Control memory outputinput ALU PC CPU – Central Processing Unit (note: ALU may be considered part of it too.)

THE MEMORY HEIRARCHY Practicalities…

Practical Considerations Memory crucial to system speed! Memory technology Non-volatile, cheap, so plentiful, but slow! Optical & Magnetic Disks, tapes & CDROMs High-speed, volatile, expensive, so limited. Semiconductor RAM, ROM Speed differential >10,000x

Memory Hierarchy Result of today’s technological limitations only! Control Primary memory outputinput ALU PC Secondary memory (disks) Boot ROM Primary memory also called RAM – Random Access Memory

THE LANGUAGE HEIRARCHY Practicalities…

From problem to execution From requirements to algorithm From algorithm to program (something “understandable” to machine) Ultimately need machine code (1’s & 0’s representing switch patterns) but how do we get it…? Directly write machine code Write assembly & translate Write high-level & translate Translation is a symbol manipulation task!

Language Hierarchy (1) Machine code Patterns of 1’s & 0’s ~ machine instruction Usually restricted, e.g. no real numbers Difficult & error-prone writing by hand! Note: machine dependent, same operation may require different pattern of 1’s & 0’s on different machines. Computer designer/manufacturer defines machine code :

Language Hierarchy (2) Assembly language Each machine instruction has mnemonic Easier to remember & understand so slightly less error-prone, but still difficult to do even simple things! One-to-one mapping so translation to machine code is trivial Use program to do translation (assembler) Like machine code, assembly language is machine dependent and low-level MOV #5, R1 ADD R1, R2 :

Language Hierarchy (3) High-level language Much more “natural”, e.g. has real numbers! Much easier to understand & write Language standards, so machine independent Translation to machine code is complex, use program to do it! This program takes a “program” as input (data) and outputs a “program”! input A Z = A * 3 + 1; print( “Z=“. Z); : Two approaches Interpret Compile

Interpreters Translate & immediately execute each instruction in turn Source code (stored in file) 10 rem Sum two numbers 20 input “enter first number”, $a 30 input “enter second number”, $b 50 output “sum is “. $s interpreter … machine code (generated & executed, never stored) 40 $s = $a + $b

Compilers Translate all instructions to machine code, save & execute as needed Source code (stored in file) 10 rem Sum two numbers 20 input “enter first number”, $a 30 input “enter second number”, $b 40 $s = $a + $b 50 output “sum is “. $s compiler machine code (generated once & stored in file) … Stored machine code executed by OS as many times as required!

Java – compile & interpret Compile & save to bytecode (machine independent) Execute by interpreting bytecode // Program MyProg // David, Oct 2002 import java.io.*; Import cs1.JRobo; public class MyProg { public static void mai System.out.println( JRobo robby = new J robby.f(100); robby.rect( 150, 50); } Source code (stored in file) … Java compiler (javac) bytecode (stored in file) Java interpreter (java) … machine code (generated & executed, never stored) Also known as the Java Virtual Machine (JVM) MyProg.class MyProg.java

Java language levels…

Programs across Internet Java Applets – run anywhere safely! // Program MyApplet // David, Oct 2002 import java.io.*; Import cs1.JRobo; public class MyApplet extends Applet { public void paint( JRobo robby = new J robby.f(100); robby.rect( 150, 50) } Source code (stored in file) … Java compiler (javac) bytecode (stored in file) JVM in webbrowser creates machine code for client MyApplet.class MyApplet.java html webpage containing applet (stored in file) My WebPage Look at this applet… WebBrowser – Netscape Welcome to MyApplet Java interpreter (java) … INTERNET Mypage.html