Welcome to Computer Organization and Design Logic CS 64: Computer Organization and Design Logic Lecture #1 Winter 2018

Similar documents
Welcome to Computer Organization and Design Logic

Welcome to Solving Problems with Computers I

MIPS and Basic Assembly Language CS 64: Computer Organization and Design Logic Lecture #4

Binary Arithmetic Intro to Assembly Language CS 64: Computer Organization and Design Logic Lecture #3

CS 64 Week 0 Lecture 1. Kyle Dewey

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

Chapter 1: Introduction to Computers and Programming

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

MIPS Assembly: More about MIPS Instructions Using Functions in MIPS CS 64: Computer Organization and Design Logic Lecture #8

Functions and the MIPS Calling Convention 2 CS 64: Computer Organization and Design Logic Lecture #11

Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

MIPS and Basic Assembly Language CS 64: Computer and Design Logic Lecture #4

Overloading Functions & Command Line Use in C++ CS 16: Solving Problems with Computers I Lecture #6

Call-by-Type Functions in C++ Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #5

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

Introduction. Arizona State University 1

An Introduction to Computer Science CS 8: Introduction to Computer Science Lecture #2

Using the MIPS Calling Convention. Recursive Functions in Assembly. CS 64: Computer Organization and Design Logic Lecture #10 Fall 2018

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Electricity: Voltage. Gate: A signal enters the gate at a certain voltage. The gate performs operations on it, and sends it out was a new signal.

Chapter 1: Why Program? Computers and Programming. Why Program?

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Chapter 1 Introduction to Computers and Programming

Binary Arithme-c CS 64: Computer Organiza-on and Design Logic Lecture #2

Information Science 1

COMP 122/L Lecture 1. Kyle Dewey

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Computer Fundamentals

CS 101, Mock Computer Architecture

MIPS Assembly: Practice Questions for Midterm 1 Saving to and Loading from Memory CS 64: Computer Organization and Design Logic Lecture #6

1a Computers, Problem Solving!

CSI31 Introduction to Computer Programming I. Dr. Sharon Persinger Fall

Function Calling Conventions 2 CS 64: Computer Organization and Design Logic Lecture #10

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

Binary Arithme-c 2 Intro to Assembly CS 64: Computer Organiza-on and Design Logic Lecture #3

Fundamentals of Programming Session 1

MIPS Assembly: More about Memory and Instructions CS 64: Computer Organization and Design Logic Lecture #7

Design and Debug: Essen.al Concepts Numerical Conversions CS 16: Solving Problems with Computers Lecture #7

SCSP Programming Technique C

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

History. 3rd Generation- Integrated Circuits, Transistors (Integrated Circuit form) for Memory ( memory is now volatile), Terminal/Keyboard for I/O

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Computer Organization and Programming

C H A P T E R 1. Introduction to Computers and Programming

Chapter 1 INTRODUCTION

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

Slide Set 1 (corrected)

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

Computer Principles and Components 1

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Lecture 19: Computers. Pay no attention to the man behind the curtain.

Reversing. Time to get with the program

Strings in Python: Cipher Applications CS 8: Introduction to Computer Science Lecture #7

User. Application program. Interfaces. Operating system. Hardware

HARDWARE. There are a number of factors that effect the speed of the processor. Explain how these factors affect the speed of the computer s CPU.

(0) introduction to the course. how to learn a programming language. (0) course structure

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

Computer Architecture 2/26/01 Lecture #

378: Machine Organization and Assembly Language

COMPUTER SYSTEM. COMPUTER SYSTEM IB DP Computer science Standard Level ICS3U. COMPUTER SYSTEM IB DP Computer science Standard Level ICS3U

Binary Representations and Arithmetic

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

Computer Architecture and Assembly Language. Spring

CHAPTER 1 Introduction to Computers and Java

CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm

CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session

CPS104 Computer Organization Lecture 1. CPS104: Computer Organization. Meat of the Course. Robert Wagner

Compiling C++ Programs Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3

Bits and Bytes. Here is a sort of glossary of computer buzzwords you will encounter in computer use:

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I

Memory Addressing, Binary, and Hexadecimal Review

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Fundamentals of Programming (Python) Basic Concepts. Ali Taheri Sharif University of Technology Spring 2018

An Introduc+on to Computers and Java CSC 121 Spring 2017 Howard Rosenthal

Call- by- Reference Func0ons Procedural Abstrac0ons Numerical Conversions CS 16: Solving Problems with Computers I Lecture #9

Numerical Conversions Intro to Strings in C/C++ CS 16: Solving Problems with Computers I Lecture #8

CPS104 Computer Organization Lecture 1

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

WELCOME TO CS 16! Enrollment status: 117/ Problem Solving with Computers-I

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

Basic Computer Programming for ISNE. Santi Phithakkitnukoon ผศ.ดร.ส นต พ ท กษ ก จน ก ร

Programming 1 - Honors

Information Science 1

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

Design and Debug: Essen.al Concepts CS 16: Solving Problems with Computers I Lecture #8

(More) Fun with Pointers and Linked Lists! CS 16: Solving Problems with Computers I Lecture #17

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

CS101 Lecture 25: The Machinery of Computation: Computer Architecture. John Magee 29 July 2013 Some material copyright Jones and Bartlett

IB Computer Science Topic.2-

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

Lecture 2: Variables & Assignments

Transcription:

Welcome to Computer Organization and Design Logic CS 64: Computer Organization and Design Logic Lecture #1 Winter 2018 Ziad Matni Dept. of Computer Science, UCSB

A Word About Registration for CS64 FOR THOSE OF YOU NOT YET REGISTERED: This class is currently FULL No one else is getting into this class, unless others drop it L If you want to add this class, see me after lecture I will resolve all reg.s by NO LATER THAN tomorrow 4/3/18 Matni, CS16, Sp18 2

Your Instructor Your instructor: Ziad Matni (zee-ahd mat-knee) Email: zmatni@cs.ucsb.edu My office hours: Mondays 12:00 PM 1:00 PM, at SMSS 4409 (or by appointment) 4/3/18 Matni, CS16, Sp18 3

Your TAs All labs will take place in PHELPS 3525 All TA office hours will take place in Open Lab Time in PHELPS 3525 LAB TAs Bay-Yuan Hsu Fatih Bakir GRADER Zimu Yang 4/3/18 Matni, CS16, Sp18 4

YOUR LABS ARE HERE PROF S OFFICE IS HERE 4/3/18 Matni, CS16, Sp18 5 YOUR LECTURES ARE HERE

You! With a show of hands, tell me how many of you A. Are Freshmen? Sophomores? Juniors? Seniors? B. Are CS majors? Other? C. Know: C, C++, Java, Python, JavaScript, PERL, Bash programming? D. Have NOT used a Linux or UNIX system before? E. Have seen actual assembly code before? F. Programmed in assembly before? G. Written/seen code for firmware? H. Understand basic binary logic (i.e. OR, AND, NOT)? I. Designed a digital circuit before? 4/3/18 Matni, CS64, Sp18 6

This Class This is an introductory course in low-level programming and computer hardware. Two separate but very intertwined areas What happens between your C/C++/Java/Python command: int a = 3, b =4, c = a+b; and the actual digital mechanisms in the CPU that process this simple command? This class will move fast so please prepare accordingly. 4/3/18 Matni, CS64, Sp18 7

Lecture Etiquette! I need you INVOLVED and ACTIVE! Phones OFF! and laptops/tablets are for NOTES only No tweeting, texting, FB-ing, surfing, gaming, Snapchatting, spitting, etc.! I will ask you to leave class if you do not follow this policy. Especially if you are disrupting others. To succeed in this class, you need to take thorough notes I ll provide my slides, but not class notes Studies show that written notes are superior to typing them into a laptop! 4/3/18 Matni, COMM88, Sp18 8

Class Website Website: https://ucsb-cs64-s18.github.io On there, I will keep: Latest syllabus Class assignments Lecture slides (after I ve given them) Interesting handouts and articles 4/3/18 Matni, CS64, Sp18 9

Just in Case 4/3/18 Matni, CS64, Sp18 10

So let s take a look at that syllabus Electronic version found at: http://cs.ucsb.edu/~zmatni/syllabi/cs64s18_syllabus.pdf 4/3/18 Matni, CS64, Sp18 11

4/3/18 Matni, CS64, Sp18 12

Input Keyboard Mouse Microphone Scanner --or-- From a Program A Simplified View of Modern Computer Architecture The 5 Main Components of a Computer: 1. Processor 2. Memory 3. Input 4. Output 5. Secondary Data Storage CPU Processing for calculations, etc RAM and ROM Memory for instructions, etc Secondary Data Storage HDD and SSD CD-ROM Mini Flash Drive Tape Drive a.k.a von Neumann Architecture Display screen Speakers Printer --or-- To a Program Output 4/3/18 13

Computer Memory Usually organized in two parts: Address: Where can I find my data? Data (payload): What is my data? The smallest representation of the data A binary bit ( 0 s and 1 s) A common collection of bits is a byte 8 bits = 1 byte What is a nibble? 4 bits = 1 nibble not used as often What is the minimum number of bits needed to convey an alphanumeric character? And WHY? 4/3/18 Matni, CS64, Sp18 14

What is the Most Basic Form of Binary a.k.a Base-2 Computer Language? Expressing data AND instructions in either 1 or 0 So, 01010101 01000011 01010011 01000010 00100001 00100001 could mean an instruction to calculate 2 + 3 Or it could mean an integer number ( 856,783,663,333) Or it could mean a string of 6 characters ( UCSB!! ) Or other things! 4/3/18 Matni, CS64, Sp18 15

So Like What Processes Stuff In A Computer? The Central Processing Unit (CPU) Executes program instructions Typical capabilities of CPU include: Add Subtract Multiply Divide Move data from location to location You can do just about anything with a computer with just these simple instructions! 4/3/18 Matni, CS64, Sp18 16

Parts of the CPU The CPU is made up of 2 main parts: The Arithmetic Logic Unit (ALU) The Control Unit (CU) The ALU does the calculations in binary using registers (small RAM) and logic circuits The CU handles breaking down instructions into control codes for the ALU and memory Image from wikimedia.org 4/3/18 Matni, CS64, Sp18 17

The CPU s Fetch-Execute Cycle Fetch the next instruction Decode the instruction Get data if needed Execute the instruction Why is it a cycle??? This is what happens inside a computer interacting with a program at the lowest level 4/3/18 Matni, CS64, Sp18 18

Computer Languages and the F-E Cycle Instructions get executed in the CPU in machine language (i.e. all in 1 s and 0 s) Even small instructions, like add 2 to 3 then multiply by 4, need multiple cycles of the CPU to get executed fully But THAT S OK! Because, typically, CPUs can run many millions of instructions per second 4/3/18 Matni, CS64, Sp18 19

Computer Languages and the F-E Cycle But THAT S OK! Because, typically, CPUs can run many millions of instructions per second In low-level languages, you need to spell those cycles out In high-level languages, you don t 1 HLL statement, like x = c*(a + b) is enough to get the job done This would translate into multiple statements in LLLs 4/3/18 Matni, CS64, Sp18 20

high level vs. low level Programming High Level computer languages, like C++ or Java, are A LOT simpler to use! Uses syntax that resembles human language Easy to read and understand: x = c*(a + b) vs. 101000111010111 But, still the CPU NEEDS machine language to do what it s supposed to do! So SOMETHING has to translate high level code into machine language 4/3/18 Matni, CS64, Sp18 21

Compilers SOMETHING has to translate high level code into machine language Compilers are programs that do this Compilers are language-specific 4/3/18 Matni, CS64, Sp18 22

Machine vs. Assembly Language Machine language is the actual 1s and 0s Example: 1011110111011100000101010101000 Assembly language is one step above Instructions are given mnemonic codes but still displayed one step at a time Advantage? Better human readability Example: lw $t0, 4($gp) # fetch N mult $t0, $t0, $t0 # multiply N by itself # and store the result in N 4/3/18 Matni, CS64, Sp18 23

int main(int argc, char** argv) {... } 4/3/18 Matni, CS64, Sp18 24

int main(int argc, char** argv) {... In reality à } 4/3/18 Matni, CS64, Sp18 25

int main(int argc, char** argv) {... With a more efficient algorithm à } 4/3/18 Matni, CS64, Sp18 26

Why Can Programs be Slow? After all, isn t just as simple as 1. getting an instruction, 2. finding the value in memory, 3. and doing stuff to it??? Yes except for the simple part Ordering the instructions matters Where in memory the value is matters How instructions get broken down matters What order these get pipelined matters 4/3/18 Matni, CS64, Sp18 27

The Point If you really want performance, you need to know how the magic works If you want to write a naive compiler (CS 160), you need to know some low-level details of how the CPU does stuff If you want to write a fast compiler, you need to know tons of low-level details 4/3/18 Matni, CS64, Sp18 28

So Why Digital Design? Because that s where the magic happens Logical decisions are made with 1s and 0s Physically (engineering-ly?), this comes from electrical currents switching one way or the other These currents modify semiconducting material that obeys the laws of electromagnetism that is physics 4/3/18 Matni, CS64, Sp18 29

So Why Digital Design? 4/3/18 Matni, CS64, Sp18 30

Digital Design in this Course We will not go into deep dives with digital design in this course For that, check out CS 154 (Computer Architecture) and also courses in ECE We will, however, delve deep enough to understand the fundamental workings of digital circuits and how they are used for computing purposes. 4/3/18 Matni, CS64, Sp18 31

4/3/18 Matni, CS64, Sp18 32

2 4/3/18 Matni, CS64, Sp18 33

Counting Numbers in Different Bases We normally count in 10s Base 10: decimal numbers We use 10 numerical symbols in Base 10: 0 thru 9 Computers count in 2s Base 2: binary numbers We use 2 numerical symbols in Base 2: 0 and 1 Represented with 1 bit (2 1 = 2) 4/3/18 Matni, CS64, Sp18 34

Counting Numbers in Different Bases Other convenient bases in computer architecture: Base 8: octal numbers Number symbols are 0 thru 7 Represented with 3 bits (2 3 = 8) Base 16: hexadecimal numbers Number symbols are 0 thru F: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15 Represented with 4 bits (2 4 = 16) Why are 4 bit representations convenient??? 4/3/18 Matni, CS64, Sp18 35

What s in a Number? 642 What is that??? Well, what NUMERICAL BASE are you expressing it in? 4/3/18 Matni, CS64, Sp18 36

Decimal Numbers Counting 642 as 600 + 40 + 2 is counting in TENS (aka BASE 10) --- what we re used to There are 6 HUNDREDS 6 x 100 There are 4 TENS 4 x 10 There are 2 ONES 2 x 1 6 4 2 100 10 1 642 = 600 + 40 + 2 4/3/18 Matni, CS64, Sp18 37

Positional Notation in Decimal Continuing with our example 642 in base 10 positional notation is: 6 x 10 2 + 4 x 10 1 + 2 x 10 0 = 6 x 100 = 600 = 4 x 10 = 40 = 2 x 1 = 2 = 642 in base 10 6 4 2 100 10 1 642 (base 10) = 600 + 40 + 2 4/3/18 Matni, CS64, Sp18 38

Numerical Bases and Their Symbols How many symbols or digits do we use in Decimal (Base 10)? Base 2 (Binary)? Base 16 (Hexadecimal)? Base N? 4/3/18 Matni, CS64, Sp18 39

Positional Notation This is how you convert any base number into decimal! What if 642 is expressed in the base of 13? 6 x 13 2 = 6 x 169 = 1014 + 4 x 13 1 = 4 x 13 = 52 + 2 x 13º = 2 x 1 = 2 6 4 2 13 2 13 1 13 0 642 (base 13) = 1014 + 52 + 2 = 1068 (base 10) 4/3/18 Matni, CS64, Sp18 40

Positional Notation in Binary 11101 in base 2 positional notation is: 1 x 2 4 = 1 x 16 = 16 + 1 x 2 3 = 1 x 8 = 8 + 1 x 2 2 = 1 x 4 = 4 + 0 x 2 1 = 1 x 2 = 0 + 1 x 2 0 = 1 x 1 = 1 So, 11101 in base 2 is 16 + 8 + 4+ 0 + 1 = 29 in base 10 4/3/18 Matni, CS64, Sp18 41

YOUR TO-DOs Read Handout #1 Assignment #1 Meet up in the lab on Monday Do the lab assignment: setting up CSIL + exercises You have to submit it using turnin Due on Friday, 4/13, by 11:59 PM 4/3/18 Matni, CS64, Sp18 42

4/3/18 Matni, CS64, Sp18 43