A primer on Computers and Programs

Slides:



Advertisements
Similar presentations
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 2: Overview of Computer Organization Partially adapted from Computer Organization and.
Advertisements

Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
ECE 232 L2 Basics.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 2 Computer.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Computer Organization
1 CS/COE0447 Computer Organization & Assembly Language Pre-Chapter 2.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
Computer Systems 1 Fundamentals of Computing The CPU & Von Neumann.
Invitation to Computer Science 5th Edition
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Computer Science 210 Computer Organization The von Neumann Architecture.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Chapter 4 The Von Neumann Model
CPU How It Works. 2 Generic Block Diagram CPU MemoryInputOutput Address Bus Data Bus.
Invitation to Computer Science 6th Edition Chapter 5 Computer Systems Organization.
Introduction to Computer Engineering CS/ECE 252, Fall 2009 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
General Concepts of Computer Organization Overview of Microcomputer.
Computer Architecture And Organization UNIT-II General System Architecture.
Intro MIPS Computer Organization I 1 September 2009 © McQuain, Feng & Ribbens The Stored Program Computer 1945: John von Neumann – Wrote a.
Computer Science 101 Computer Systems Organization.
Introduction to Microprocessors
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
Computer Architecture 2 nd year (computer and Information Sc.)
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
1 chapter 1 Computer Architecture and Design ECE4480/5480 Computer Architecture and Design Department of Electrical and Computer Engineering University.
Von Neumann Model Computer Organization I 1 September 2009 © McQuain, Feng & Ribbens The Stored Program Computer 1945: John von Neumann –
Von Neumann Computers Article Authors: Rudolf Eigenman & David Lilja
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
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.
Chapter 4 The Von Neumann Model
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Chapter 5: Computer Systems Organization Invitation to Computer Science,
Computer Architecture Adapted from CS10051 originally by Professor: Johnnie Baker Computer Science Department Kent State University von Neuman model.
Computer Organization and Architecture Lecture 1 : Introduction
Software Development Environment
Rocky K. C. Chang, 12 September 2017 Version 0.1
The Stored Program Computer
Edexcel GCSE Computer Science Topic 15 - The Processor (CPU)
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Chapter 4 The Von Neumann Model
Computer Design & Organization
Computer Science 210 Computer Organization
Chapter 4 The Von Neumann Model
Introduction to Computer Engineering
Computer Organization & Assembly language
Chapter 4 The Von Neumann Model
Chapter 4 The Von Neumann Model
Computer Science I CSC 135.
Computer Science 210 Computer Organization
Introduction to Computer Engineering
The Von Neumann Model Basic components Instruction processing
Rocky K. C. Chang 6 November 2017
Chapter 5: Computer Systems Organization
CS/COE0447 Computer Organization & Assembly Language
Computer Architecture
Chapter 4 The Von Neumann Model
The Von Neumann Architecture
Introduction to Microprocessor Programming
The Stored Program Computer
Computer Architecture
Computer Systems An Introducton.
Introduction to Computer Engineering
Chapter 0 Introduction Introduction Chapter 0.
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 4 The Von Neumann Model
Presentation transcript:

A primer on Computers and Programs Rocky K. C. Chang 4 September 2018 Python Programming, 2/e

Objectives To understand the basic design of a modern computer. To understand the form and function of computer programming languages.

Hardware and software: which is more important? Source: http://www.cloudproviderusa.com/whats-more-important-hardware-software/abr0137l/

0 and 1 conquer the world! Bit: binary digit Byte Binary number system Binary arithmetic (Gottfried Wilhelm von LEIBNIZ (1646-1716))

Why only two values? Source: Charles Dierbach. 2013. Introduction to Computer Science Using Python. Wiley.

The binary number system Source: Charles Dierbach. 2013. Introduction to Computer Science Using Python. Wiley.

Raspberry Pi

Morgan Kaufmann Publishers January 12, 2019 Below Your Program Application software Written in high-level language (HLL) System software Compiler: translates HLL code to machine code Operating System: service code Handling input/output Managing memory and storage Scheduling tasks & sharing resources Hardware Processor, memory, I/O controllers Chapter 1 — Computer Abstractions and Technology

From C programs to execution temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; High Level Language Program (e.g., C) Compiler lw $t0, 0($2) lw $t1, 4($2) sw $t1, 0($2) sw $t0, 4($2) Anything can be represented as a number, i.e., data or instructions Assembly Language Program (e.g., MIPS) Assembler 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 Machine Language Program (MIPS) Machine Interpretation Hardware Architecture Description (e.g., block diagrams) Architecture Implementation Logic Circuit Description (Circuit Schematic Diagrams) Source: Slides by K. Asanovic & V. Stojanovic for CS61C at UC/Berlekey

From C programs to execution Compiler: Source code  assembly language (may be skipped)  machine code Assembler: Assembly code  machine code Machine code consists of instructions understood by the CPU Each instruction is executed by CPU Data processing (arithmetic, logic) Data storage Data movement Control/management

An example temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; lw $t0, 0($2) sw $t1, 0($2) sw $t0, 4($2) 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111

The Stored Program Computer 1943: ENIAC Presper Eckert and John Mauchly -- first general electronic computer. Hard-wired program -- settings of dials and switches. 1944: Beginnings of EDVAC Among other improvements, includes program stored in memory 1945: John von Neumann wrote a report on the stored program concept, known as the First Draft of a Report on EDVAC The basic structure proposed in the draft became known as the “von Neumann machine” (or model). a memory, containing instructions and data a processing unit, for performing arithmetic and logical operations a control unit, for interpreting instructions

Stored-Program Computer Instructions represented in binary, just like data Instructions and data stored in memory Programs can operate on programs e.g., compilers, linkers, … Binary compatibility allows compiled programs to work on different computers Standardized ISAs Source: David Patterson and John Hennessy, Computer Organization and Design, 5th edition, Morgan Kaufman, 2014.

Everything is now addressable Since all instructions and data are stored in memory, everything has a memory address: instructions, data words both branches and jumps use these C pointers are just memory addresses: they can point to anything in memory Unconstrained use of addresses can lead to nasty bugs; up to you in C; limited in Java by language design One register keeps address of instruction being executed: Program Counter (PC)

The von Neumann model

Flow of Information The parts are connected to one another by a collection of wires called a bus.

The three elements Memory: Store and retrieve instructions and data. Processor: Houses two separate components: The control unit: repeating the three tasks: Fetch an instruction from memory Decode the instruction Execute the instruction The arithmetic/logic unit (ALU): Perform mathematical and logical operations. Input/Output (I/O) Units: Handle communication with the outside world. Source: M. Schneider and J. Gersting, Invitation to Computer Science, 5th edition, Course Technology, 2010.

Memory Subsystem Memory, also called RAM (Random Access Memory) Consist of many memory cells (storage units) of a fixed size. Each cell has an address associated with it: 0, 1, … All accesses to memory are to a specified address. A cell is the minimum unit of access (fetch/store a complete cell). The time it takes to fetch/store a cell is the same for all cells. When the computer is running, both Program Data (variables) are stored in the memory.

RAM Need to distinguish between the address of a memory cell and the content of a memory cell Memory width (W): How many bits is each memory cell, typically one byte (=8 bits) Address width (N): How many bits used to represent each address, determines the maximum memory size = address space. If address width is N-bits, then address space is 2N (0,1,...,2N-1). N 0000000000000001 1 bit 1 2 ... 2N 2N-1 W

The fetch-decode-execute cycle

Programming Languages High-level computer languages Designed to be used and understood by humans Low-level language Computer hardware can only understand a very low level language known as machine language

Source: https://sherifelmahdi.wordpress.com/2012/02/

An example Source: https://sherifelmahdi.wordpress.com/2012/02/

Compiling vs interpreting Compiling the source code to machine code Source: http://www.aboutdebian.com/compile.htm

Compiling vs interpreting Source: http://www.circuitstoday.com/compilers-vs-interpreters-an-overview-of-the-differences

Compiling vs. Interpreting Once program is compiled, it can be executed over and over without the source code or compiler. If it is interpreted, the source code and interpreter are needed each time the program runs. Compiled programs generally run faster since the translation of the source code happens only once.

For Python Source: http://trizpug.org/Members/cbc/wyntkap/img/interpreter.png

Why Python?

END “Better is a little with righteousness than great revenues with injustice.” (Proverbs 16:8) “收入少而有公義,勝過收入多卻毫無正義。” (箴言 16:8)