1 / 28

CSCI 136 Lab 1

CSCI 136 Lab 1. Outline. Go through the CD attached to the textbook. Homework Hints 135 Review. 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?. Prob 1.51.

jiro
Download Presentation

CSCI 136 Lab 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 136 Lab 1

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

  3. 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?

  4. 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?

  5. 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?

  6. 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?

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

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

  9. Numbers: positional notation • Number Base B  B symbols per digit: • Base 10 (Decimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9Base 2 (Binary): 0, 1 • Number representation: • d31d30 ... d1d0is a32 digit number • value = d31 B31 + d30 B30 + ... + d1 B1 + d0 B0 • Binary: 0,1 (In binary digits called “bits”) • 0b11010= 124 + 123 + 022 + 121 + 020 = 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 written0b…

  10. 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_____ ?

  11. MEMORIZE! Decimal vs. Hexadecimal vs. Binary 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? 00 0 000001 1 000102 2 001003 3 001104 4 010005 5 010106 6 011007 7 011108 8 100009 9 100110 A 101011 B 101112 C 110013 D 110114 E 111015 F 1111

  12. 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: 32ten == 3210 == 0x20 == 1000002 == 0b100000 • Use subscripts “ten”, “hex”, “two” in book, slides when might be confusing

  13. BIG IDEA: Bits can represent anything!! • Characters? • 26 letters  5 bits (25 = 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 • Logical values? • 0  False, 1  True • colors ? Ex: • locations / addresses? commands? • MEMORIZE: N bits  at most 2N things Red (100) Green (010) Blue (001)

  14. 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. +1ten would be: 0000 0000 0000 0000 0000 0000 0000 0001 • And - 1ten in sign and magnitude would be: 1000 0000 0000 0000 0000 0000 0000 0001

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

  16. 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?

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

  18. 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 0s) then the shift is called “Logical”variety of shift

  19. 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?

  20. 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?

  21. Byte Ordering Assume 32 bit word: Big Endian vs. Little Endian 00000000 00000000 00000100 00000001 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.

  22. 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!

  23. 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

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

  25. 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?

  26. 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 Class CPI Freq Load Word 8 31% Store Word 7 21% ALU (R format) 6 41% Branch 5 5% Jump 2 2%

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

  28. .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 "

More Related