Dr. Franklin
CS 64 - KICKOFF
Today’s Schedule•W
hy are you here?•R
oll / Waiting List •S
yllabus•I
ntroduction• History• Basic concepts• Counting to 1023 on your fingers!
Computer Systems
*Coordination across many levels (layers) of abstraction
I/O systemProcessor
CompilerOperating
System(Mac OSX)
Application (ex: browser)
Digital DesignCircuit Design
Datapath & Control
transistors
MemoryHardware
Software AssemblerCS
CE
EE
Why learn assembly language?•H
elp you write faster programs• Understand the efficiency of different programming constructs
•Assembly required for low-level programming (drivers) and performance-critical kernels
Design Efficient Software
Why learn digital design?•P
rocessor design is one career of computer scientists•T
he building blocks determine
• Power• Complexity• Functionality
•Dispel the Magic!
Design Efficient Hardware
Where do programs come from?
•Compilers • Translate high-level languages into a human readable version of the machine’s language (e.g. assembly language)
•Assembler • Translate assembly language into a binary representation (object files) readable by the computer
•Linkers • combine multiple object files into executable programs
•Loaders• Loads the program into active memory to execute
General Class Info•W
hen, where and who• Lecture: Phelps 1425 (HERE!)• Lab: Fridays, phelps 3525• Website: http://www.cs.ucsb.edu/~franklin/64/• Professor: Diana Franklin, [email protected]• TA: Weilong Cui, Asad Khalid
•Office Hours:• Franklin: TR 2-3:15• TA: M 1-2, W 2-3• Assignments generally due on Wednesday
General Class Info (2)•P
rerequisites• Engineering 3 or CS 16; and Mathematics 3C• Not open if you have received credit for ECE 15A• Not required if you are in the CS BA major.
•Textbooks• Randall Hyde: How to Write Great Code, Volume 1 (e-Book)
• Robert L. Britton: MIPS Assembly Language Programming
Grading Policy•G
rading• Homeworks / Programs : 25-28% • Labs: 2-5%• MiniExams: 10% each• Midterm: 20% • Final: 35%
•Plagiarism• You may discuss the design of programming assignments• You may not show or look at any assembly code other than buddy’s• Come to office hours!!!• Look at example code from class!!!• Ask questions on piazza! (no code)
• Plagiarism will result in an F in the class and reporting to Judicial Affairs for further action.
• Recording or selling course resources is strictly prohibited.
Grading
•Students should know where they stand• Individual tests and assignments curved
•Reward the behaviors that lead to success w/out penalizing those who attain success other ways•Up to 2% extra credit for participation•Mini-exam portion dropped if it is lower than midterms/final (only entire segment, not individual mini-exams)
•Attendance required for 4 labs. After that, it makes assignments worth less and labs worth more.
Participation•2
% extra credit•H
ow?•Ask or answer questions in lecture•Come to office hours with questions
•Why?• I want to learn your names (letters of rec)• I want you to take an active role in your learning (because it leads to learning, not for my sake)
Assignments•R
eleased each Friday, due the following Thursday
•Consists of• Questions directly related to book reading• Small assembly or C programming exercises• Digital design problems
Discussion group•P
iazza
• join this week
•Announcements will be made here
•Do not post code or partial solutions EVER, even to ask for help as to what is wrong
•Send those messages directly to me or the TA!
How to Succeed in CS 64
•Skim the relevant book section(s) prior to class
•Attend every lecture and complete all labs
•Attempt to solve all in-class examples
•Ask questions the instant you do not understand
•Begin your programming assignments early
•Study for all exams
Waiting List•W
e have plenty of space. Sign up at the end of class with your name, then e-mail me so I can forward the e-mail to Benji.
•If your friends want to add, they must attend Tuesday. No one is allowed to add if they didn’t attend today orTuesday.
Answering your family and friends’ questions in a half-way intelligent manner
Community Service Portion
Where is computing going?
Technology Trends: Memory Capacity (Single-Chip DRAM)
• Now 1.4X/yr, or 2X every 2 years.• 8000X since 1980!
Technology Trends: Microprocessor Complexity
Moore’s Law
2X transistors/chipEvery 1.5 years
Alpha 21264: 15 millionPentium Pro: 5.5 millionPowerPC 620: 6.9 millionAlpha 21164: 9.3 millionSparc Ultra: 5.2 million
Moore’s Law
Athlon (K7): 22 Million
Itanium 2: 41 Million
Technology Trends: Processor Performance
1.5X/yr
year
Moore’s Law
2X transistors/chipEvery 1.5 years
Technology Trends Summary•T
echnology trend•2
X
every 2.0 years in memory size;
every 1.0 year in disk capacity;
every 1.5 years in processor complexity (Moore’s Law)
More processors per chip each generation•M
emory Gap / Memory Wall
• Processors get faster• Memory gets denser / bigger, not faster
The Architecture Walls•M
emory Wall
•ILP Wall
•Power Wall
The Architecture Walls•M
emory Wall – Processor speed kept increasing, memory did not as quickly, so processor is often idle waiting for memory
•ILP Wall – There are not enough independent instructions for the processor to get real work done when one instruction needs to wait for another (or memory or whatever)
•Power Wall – Solving the above two walls requires too much power, and we don’t have cooling technology to dissipate that much heat.
Beginning of the multi-core era•M
ulti-core chips •Place multiple processors on a single die
•Because•They can communicate very quickly•Much higher potential throughput•Less power per area than accelerating single thread
•But•You need parallel programs (or multiple programs) to exploit
The next frontier•G
PU – Graphics processing unit• Specialized hardware for graphics• Optimized to run the same thing on many pieces of data (i.e. pixels)
•Because• They are mature technology, driven by gaming• Low power parallel processing
•Bug• Limited programming model• Not appropriate for a lot of programs (i.e. servers)
Representing Data
•Everything 1’s and 0’s
•Data (int, char, string, float)
•Programs (instructions)•control•arithmetic•memory
Let’s count to 1023 on our fingers!!•A
nd then we’ll do something efficient with that knowledge
How do we usually count on fingers?
Each finger has a value, and we add the values up!
11
11
1
1
11
1
1
How do we usually count on fingers?Sometimes we count this way to make bigger numbersBut this doesn’t match how we usually do numbers
Each finger has a value, and we add the values up!
11
11
1
10
1010
10
10
How numbers usually work•W
hat is the difference between:• 001• 010• 100
• Are they all the same number?
EVERY position is worth a different value!
NO!!!!!
Counting to 1023 –Give a different set of values!All possible values from 0 – 1023!
Each finger has a value, and we add the values up!
116
84
2
32
128256
512
64
Beyond the parlor trick Using binary to accelerate our programs
•Write out the decimal values of the following numbers:
•00101
•01010
•10100
•What can you conclude from this?
Beyond the parlor trick Using binary to accelerate our programs
•To multiply by 2, shift left by 1• x = y << 1;
•To divide by 2, shift right by 1• x = y >> 1;
•To multiply by 4, shift left by ?
•To divide by 16, shift right by ?
Beyond the parlor trick Using binary to accelerate our programs
•Is this number odd or even?• 1011010010100101101
•What happens in this case?• 00101 >> 1 =?• Ah ha!!! Now we know why division rounds down!
Bases•O
ctal – base 8 – digits 0-7•H
exadecimal – base 16 – digits 0-9, a-f•W
hat are the values of the different digits?•D
ecimal: 1, 10, 100, 1000, 10000, …•B
inary: 1, 2, 4, 8, 16, 32, …•O
ctal: 1, 8, ???•H
exadecimal: 1, 16, ???
Bases•W
hat are the decimal values of these numbers?•0
b1011•0
o132•0
x132•T
ranslate the decimal number 153 into hex, octal, binary•T
ranslate the binary number 0b101001101110010100101 into octal, hex, decimal
Negative Numbers•2
’s complement – simplest addition, subtraction implementation•A
ll we need to know is the relationship between a positive number and its negative equivalent – the negate operation
•To negate a number:• Flip all the bits• Add 1
•Works both directions – positive to negative and negative to positive
•Let’s try it: 5 -> -5 -> 5,
•What numbers are these? 1111, 1110, 1010, 1001, 1000• unsigned representation value:• signed (2’s complement) representation value:
You should:•S
kim chapter 1, 2.1-2.7•M
emorize Page 26•R
ead sections 2.3, 2.4
Next topics•b
itwise operators•a
ddition•n
egative numbers / negation – sign-bit, 1’s complement, 2’s complement
Goal: Inspect the bits of a number•B
itwise and, or, xor•A
ND: Both must be true for the result to be true (write truth table both ways)• 011010 & 101011 -> 001010• Mask – inspect only a particular part of a number (i.e. the smallest bit
to see if it is odd or even)• If we want to ignore a bit, and it with 0• If we want to inspect a bit, and it with 1• ABCDE & 00001 -> 0000E• if (ABCDE & 00001 == 0)
• printf(“This is even\n”);
•OR
•XOR
Goal: Inspect the bits of a number•B
itwise and, or, xor•O
R: Both must be false for the result to be false• 011010 | 101011 -> 111011• Mask – setting a particular bit to 1• If we want to not change a bit, or it with 0• If we want to set a bit to 1, or it with 1• ABCDE I 00101 -> AB1D1• To save space, you store many boolean values in one integer• This allows you direct access to a particular bit• if (variable & 00100 == 0) then something;