Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 136 Lab 1 Outline Go through the CD attached to the textbook. Homework Hints 135 Review.

Similar presentations


Presentation on theme: "CSCI 136 Lab 1 Outline Go through the CD attached to the textbook. Homework Hints 135 Review."— Presentation transcript:

1

2 CSCI 136 Lab 1

3 Outline Go through the CD attached to the textbook. Homework Hints 135 Review

4 Prob 1.46 Magnetic disk: –On average, needs ½ revolution time for the disk to spin under the read/write head. For 7200 RPM, what is 1 revolution time? How about 10000 RPM?

5 Prob 1.51 Cost per wafer: $6000 1 wafer produces 1500 dies, where 50% are valid dies. –How many valid dies per wafer? –Cost per valid die? Chip = 1 die + package + test Cost for package + test : $10 Test yield: 90% –Cost per valid chip? Retail Price = Cost per valid chip * (1 + 40%). Invest: $500,000 –How many valid chips have to be sold to break even?

6 Prob 1.52 CISC vs. RISC –CISC needs fewer instructions to perform a task compared with RISC. –RISC instructions take less time. For a certain task –P CISC instructions vs. 2P RISC instructions –8T ns per CISC instr. vs. 2T ns per RISC instr. Which one is better?

7 Prob 1.54 Multiplication operation: 10 ns Subtraction operation: 1 ns d = a*b – a*c –How long time? How to optimize the equation to take less time?

8 Some Requirements Make the homework solutions clear –Handwriting & Content Prepare before coming the lab –Read the homework problems To be added…

9 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) The following 8 slides are from UCB CS61C

10 Numbers: positional notation Number Base B  B symbols per digit: –Base 10 (Decimal):0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 2 (Binary):0, 1 Number representation: –d 31 d 30... d 1 d 0 is a 32 digit number –value = d 31  B 31 + d 30  B 30 +... + d 1  B 1 + d 0  B 0 Binary:0,1 (In binary digits called “bits”) –0b11010 = 1  2 4 + 1  2 3 + 0  2 2 + 1  2 1 + 0  2 0 = 16 + 8 + 2 = 26 –Here 5 digit binary # turns into a 2 digit decimal # –Can we find a base that converts to binary easily? #s often written 0b…

11 Hexadecimal Numbers: Base 16 Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F –Normal digits + 6 more from the alphabet –In C, written as 0x… (e.g., 0xFAB5) Conversion: Binary  Hex –1 hex digit represents 16 decimal values –4 binary digits represent 16 decimal values  1 hex digit replaces 4 binary digits One hex digit is a “nibble”. Two is a “byte” Example: –1010 1100 0011 (binary) = 0x_____ ?

12 Decimal vs. Hexadecimal vs. Binary 00 00000 0110001 02 20010 0330011 04 40100 0550101 06 60110 0770111 08 81000 0991001 10 A1010 11B1011 12 C1100 13D1101 14 E1110 15F1111 MEMORIZE! Examples: 1010 1100 0011 (binary) = 0xAC3 10111 (binary) = 0001 0111 (binary) = 0x17 0x3F9 = 11 1111 1001 (binary) How do we convert between hex and Decimal?

13 Which base do we use? Decimal: great for humans, especially when doing arithmetic Hex: if human looking at long strings of binary numbers, its much easier to convert to hex and look 4 bits/symbol –Terrible for arithmetic on paper Binary: what computers use; you will learn how computers do +, -, *, / –To a computer, numbers always binary –Regardless of how number is written: 32 ten == 32 10 == 0x20 == 100000 2 == 0b100000 –Use subscripts “ten”, “hex”, “two” in book, slides when might be confusing

14 BIG IDEA: Bits can represent anything!! Characters? –26 letters  5 bits (2 5 = 32) –upper/lower case + punctuation  7 bits (in 8) (“ASCII”) –standard code to cover all the world’s languages  8,16,32 bits (“Unicode”) www.unicode.com www.unicode.com Logical values? –0  False, 1  True colors ? Ex: locations / addresses? commands? MEMORIZE: N bits  at most 2 N things Red (100)Green (010)Blue (001)

15 How to Represent Negative Numbers? So far, unsigned numbers Obvious solution: define leftmost bit to be sign! –0  +, 1  - –Rest of bits can be numerical value of number Representation called sign and magnitude MIPS uses 32-bit integers. +1 ten would be: 0000 0000 0000 0000 0000 0000 0000 0001 And - 1 ten in sign and magnitude would be: 1000 0000 0000 0000 0000 0000 0000 0001

16 Shortcomings of sign and magnitude? Arithmetic circuit complicated –Special steps depending whether signs are the same or not Also, two zeros – 0x00000000 = +0 ten – 0x80000000 = -0 ten –What would two 0s mean for programming? Therefore sign and magnitude abandoned

17 2’s Complement Numbers As with sign and magnitude, leading 0s  positive, leading 1s  negative –000000...xxx is ≥ 0, 111111...xxx is < 0 –except 1…1111 is -1, not -0 (as in sign & mag.) To get negative number from a positive.. Invert all digits and add 1. To get a positive number from a negative… Invert all digits and add 1. Assume 8 bit word. What is -57 in 2’s complement notation?

18 2’s Complement Number “line”: N = 5 2 N-1 non- negatives 2 N-1 negatives one zero how many positives? 00000 00001 00010 11111 11110 10000 01111 10001 0 1 2 -2 -15 -16 15............ -3 11101 -4 11100 000000000101111... 111111111010000...

19 Sign Extension Sign extension can be used when you shift a register right… the sign bit is repeated to keep a negative number negative… This is referred to as “Arithmetic” variety of shift If the sign bit isn’t extended.. (i.e. empty spots filled with 0 s) then the shift is called “Logical” variety of shift

20 Assume 8 bit words… What is result of logical right shifting -12 by 2? assembly: srl (shift right logical) srlv (shift right logical variable) What is result of arithmetic right shift -12 by 2? assembly: sra (shift right arithmetic) srav (shift right arithmetic variable) What is result of rotate right -12 by 2? assembly: ror (rotate right) What is the assembly code to do this?

21 What is result of rotating left -12 by 2? assembly: rol (rotate left) What is the result of logical shift left -12 by 2? assembly: sll (shift left logical) sllv (shift left logical variable) What is the assembly code to do this? Why isn’t there a sla (shift left arithmetic) assembly instruction?

22 Byte Ordering Assume 32 bit word: Big Endian vs. Little Endian In a big-endian system, the most significant value in the sequence is stored at the lowest storage address (i.e., first). In a little-endian system, the least significant value in the sequence is stored first. 00000000 00000000 00000100 00000001 Address Big-Endian representation of 1025 Little-Endian representation of 1025 00 01 02 03 00000000 00000000 00000100 00000001 00000001 00000100 00000000 00000000

23 Byte Ordering Computer designers can’t seem to agree on whether to use Big Endian or Little Endian. Neither design is really superior to the other. What kind of Endian are Intel PCs? What kind of Endian are Macs? Sun SPARC Stations can be set in either mode… (but Solaris OS requires Big Endian). Most of the time.. you probably won’t notice Endianness. But SPIM simulator uses the “Endianness” of the machine you run it on!

24 Load Immediate (li) What does the following instruction do? li $t0, 0x40044005 What does the following sequence of instructions do? lui $t0, 4004 ori $t0, $t0, 4005

25 li (load immediate) instruction is really “pseudocode” When the assembler sees an li instruction it substitutes: lui (load upper immediate) followed by an ori (or immediate) In the place of the li (load immediate)

26 Time Units How long is a microsecond? How long is a nanosecond? How long is a picosecond? If a clock runs at 450MHZ how long is a clock cycle? If a clock runs at 1.2GHZ how long is clock cycle?

27 Cycles Per Instruction Different Instructions may take different numbers of clock cycles to execute. CPI (Cycles Per Instruction) refers to number of clock cycles an instruction takes in a design What is average CPI of the following 600 MHZ machine? What is the MIPS rating? Instruction ClassCPIFreq Load Word831% Store Word721% ALU (R format)641% Branch55% Jump22%

28 PCSPIM A software simulator for the MIPS32 architecture. Load assembly file. Run in the software.

29 .text.globl main main: move $t6, $0 move $t7, $0 loop: addu $t7, $t7, $t6 addu $t6, $t6, 1 ble $t6, 100, loop li $v0, 4 la $a0, str syscall li $v0, 1 move $a0, $t7 syscall.data str:.asciiz "The sum from 0.. 100 is "


Download ppt "CSCI 136 Lab 1 Outline Go through the CD attached to the textbook. Homework Hints 135 Review."

Similar presentations


Ads by Google