Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Lecture Goals
! Review course logistics
n n n n
Assignments Policies Organization Grading Criteria Role of Abstraction Software versus Hardware Universal Computing Devices Layered Model of Computing
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Logistics
! Lectures: Tue and Thu from 9:30-10:45 in Glover 130 ! Recitations: Tue 11:00-11:50, 1:00-1:50, Wed 11:00-11:50 in CSB 215 ! Exams:
n
One midterm in class (1 page notes, no calculator, no electronic aid) final on Wednesday May 9 6:20-8:20 in class (same rules) http://www.cs.colostate.edu/~cs270 http://ramct.colostate.edu
CS270 Spring 2012 - Colorado State University 3
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Name cards
! Fold your card LENGTHWISE so that it can be placed on your desk ! Neatly write your name (how you want to be addressed) in BIG, BOLD LETTERS, using the markers that are circulating ! Prop it up on your desk so that it can be seen from the front of the classroom
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Instructor
! Name: Sanjay Rajopadhye ! Pronunciation (optional): In Indian names, a is almost always pronounced as a short u sound as in gun, fun, etc., or a long aa sound as in calm, bard, etc. ! Sanjay is pronounced as Sun-juy ! Rajopadhye Raaj-Oh-paath-yay (in the paath make the t sound like a d). Dont worry if you dont get it right, its almost always mispronounced, even in India). ! These pronunciation rules are used in many parts of Asia, e.g., pronounce Bagdad? ! Interesting fact: Everyone in my family was born in a different country
CS270 Spring 2012 - Colorado State University 5
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TeachingAssistant
! Name: Nirmal Prajapati ! Call me: Nirmal (like normal, but with an i) ! Pronunciation (optional): nearly normal Nirmal ! Major: Computer Science (Ph.D., 1st year) ! Interesting fact:
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Assignments
Assignments and quizzes are posted on RamCT: ! Weekly assignments combination of written and programming assignments ! Written (hardcopy) assignments are due Thursday at 9:30 pm (start of class) ! Programming assignments are submitted in electronic form Mondays at 5:00 PM. ! Reading Quizzes are online, the due date is Monday at 11:59pm
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Policies
! Grading Criteria
n n n n n
Homework Assignments (45%) Reading Quizzes (5%) Recitations (5%) Midterm Exam (20%) Final Exam (25%) Accepted up to 48 hours after posted date with 10% penalty per 24 hrs delay Not accepted after 48 hr delay http://www.cs.colostate.edu/~info/student-info.html Be smart about Spring 2012 - Colorado State University CS270 Internet resources
! Late Policy
n
! Academic Integrity
n n 8
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Organization
! 1/3 computer hardware: numbers and bits, transistors, gates, digital logic, state machines, von Neumann model, instruction sets, LC-3 architecture ! 1/3 assembly code: instruction formats, branching, control, LC-3 programming, I/O, subroutines, memory model ! 1/3 C programming: data types, language syntax, variables and operators, control structures, functions, pointers and arrays, memory model, recursion, I/O, data structures
CS270 Spring 2012 - Colorado State University 9
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Grading Criteria
How to be successful in this class: 1) Attend all classes and recitations, information will presented that you cant get anywhere else. 2) Do all the homework assignments, ask questions (early!) if you run into trouble. 3) Read the textbook, take the quizzes, work through the end of chapter problems. 4) Use office hours
10
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
NO! Electronic idiot! Does exactly what we tell it to, nothing more. You will be able to understand how computers are built, and write programs in C and understand what s going on underneath. Build understanding from the bottom up. Bits Transistors Gates Logic Processor Instructions Assembly Code C Programming
CS270 Spring 2012 - Colorado State University 12
! Approach:
n n
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Productivity enhancer dont need to worry about details Can drive a car without knowing how the internal combustion engine works. until something goes wrong! Where s the dipstick? What s a spark plug? Important to understand the components and how they work together.
CS270 Spring 2012 - Colorado State University 13
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
It s not either/or both are components of a computer system that cooperate. Even if you specialize in one, you should understand capabilities and limitations of both. The best programmers understand the computer systems which run their programs. Computers are an entire ecosystem with multiple levels of abstraction.
14
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
=
PDA Workstation
=
Supercomputer
15
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Turing Machine
! Mathematical model of a device that can perform any computation Alan Turing (1937)
n n
ability to read/write symbols on an infinite tape state transitions, based on current state and symbol
Tadd
a+b
a,b
Tmul
ab
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
c(a+b)
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
time
! weather forecast, next frame of animation, ...
cost
! cell phone, automotive engine controller, ...
power
! cell phone, handheld video game, ...
CS270 Spring 2012 - Colorado State University 18
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Software Design: choose algorithms and data structures Algorithm Programming: use language to express design Program
Instr Set Architecture
10
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Processor Design: choose structures to implement ISA Microarch Logic/Circuit Design: gates and low-level circuits to implement components Process Engineering & Fabrication: develop and manufacture lowest-level components
CS270 Spring 2012 - Colorado State University 21
Circuits
Devices
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
stated using "natural language" may be ambiguous, imprecise step-by-step procedure, guaranteed to finish definiteness, effective computability, finiteness express the algorithm using a computer language high-level language, low-level language specifies the set of instructions the computer can perform data types, addressing mode
CS270 Spring 2012 - Colorado State University 22
! Algorithm
n n
! Program
n n
11
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
detailed organization of a processor implementation different implementations of a single ISA combine basic operations to realize microarchitecture many different ways to implement a single function (e.g., addition) properties of materials, manufacturability
! Logic Circuits
n n
! Devices
n
23
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
12
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Book Outline
! Bits and Bytes
n
How do we represent information using electrical signals? How do we build circuits to process information? How do we build a processor out of logic elements? What operations (instructions) will we implement? How do we use processor instructions to implement algorithms? How do we write modular, reusable code? (subroutines) How does processor communicate with outside world? How do we write programs in C?
CS270 Spring 2012 - Colorado State University 25
! Digital Logic
n
! C Programming
n
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
You already know how to program in Java Learning C will be much faster than the book s speed (Ch 11-13) Digital Logic Processor & Instruction Set Assembly Language Programming I/O, Traps, Interrupts Functions, procedures, activations/frames, etc. Reinforcement of ideas Second look at the same ideas
26
13
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Yeah right!!! BUT ITS TRUE ABOUT THIS CLASS 30 mins Quiz 4 hrs contact hours 30 mins review class notes (15 x 2) 8-11 hrs assignments
CS270 Spring 2012 - Colorado State University 27
3) Time management:
1) 2) 3) 4)
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
http://www.cs.colostate.edu/~cs270/.Spring12/Notes/ NumberSystems.pdf
28
14
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
!
n
Could base state on value of voltage, but control and detection circuits more complex.
compare turning on a light switch to measuring or regulating voltage
CS270 Spring 2012 - Colorado State University 30
15
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
! Basic unit of information is the binary digit, or bit. ! Values with >2 states require multiple bits.
n
A collection of two bits has four possible states: 00, 01, 10, 11 A collection of three bits has eight possible states: 000, 001, 010, 011, 100, 101, 110, 111 A collection of n bits has 2n possible states.
CS270 Spring 2012 - Colorado State University 31
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Numbers signed, unsigned, integers, floating point, complex, rational, irrational, Text characters, strings, Logical true, false Images pixels, colors, shapes, Sound waveforms Instructions representation and operations within the computer
! Data type:
n
16
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Unsigned Integers
! Non-positional notation
n
could represent a number ( 5 ) with a string of ones ( 11111 ) problems? like decimal numbers: 329 3 is worth 300, because of its position, while 9 is only worth 9
329
102 101 100
3x100 + 2x10 + 9x1 = 329
most significant
101
21
least significant
22
20
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
34
17
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1111 + 1 10000
18
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Signed Integers
! With n bits, we have 2n distinct values.
n n n
assign about half to positive integers (1 through 2n-1) assign about half to negative (- 2n-1 through -1) that leaves two values: one for 0, and one extra just like unsigned zero in most significant (MS) bit 00101 = 5 sign-magnitude set sign bit to show negative 10101 = -5 one s complement flip every bit to represent negative 11010 = -5 in either case, MS bit indicates sign: 0=pos., 1=neg.
CS270 Spring 2012 - Colorado State University 37
! Positive integers
n
! Negative integers
n
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Two s Complement
! Problems with sign-magnitude, 1 s complement
n n
two representations of zero (+0 and 0) arithmetic circuits are complex ! How to add two sign-magnitude numbers?
n
38
19
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Two s Complement
! Two s complement representation developed to make circuits easy for arithmetic.
n
for each positive number (X), assign value to its negative (-X), such that X + (-X) = 0 with normal addition, ignoring carry out
01001 (9) +
(-9) 00000 (0)
39
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
normal binary representation, zeroes in upper bit(s) start with positive number flip every bit (i.e., take the one s complement) then add one
! If number is negative,
n n n
01001 (9)
(1 s comp)
1
(-9)
40
20
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
copy bits from right to left until (and including) first 1 flip remaining bits to the left
011010000
(1 s comp) (flip) (copy)
100110000
41
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
-23 0 0 0 0 0 0 0 0
21
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
n 2n
0 1 2 3 4 5 6 7 8 9 10 1 2 4 8 16 32 64 128 256 512 1024
22