Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture CPSC 321 Andreas Klappenecker.

Similar presentations


Presentation on theme: "Computer Architecture CPSC 321 Andreas Klappenecker."— Presentation transcript:

1 Computer Architecture CPSC 321 Andreas Klappenecker

2 Early History One of the first calculation tools was the abacus, presumably invented sometime between 1000-500 B.C.

3 ENIAC All-electronic general purpose computer based on vacuum tubes Intended to calculate ballistic firing tables Designed by Presper Eckert and John Mauchly Designed and constructed during 1943-1946 Programming by rewiring 5000 additions per second, 357 multiplications per second, and 38 divisions per second Decimal, not binary! (photo courtesy of the U.S. army)

4 Key Inventions 1948 Brattain, Shockley and Bardeen invent the transistor (and receive the Nobel price in 1956) 1952 The ferrite core memory is invented and replaces the vacuum tube memories. 1957 Jack Kilby and Robert Noyce invent the silicon wafer. 1961 Steven Hofstein develops the Field Effect Transistor that will be used in the MOS integrated circuits

5 Intel 4004 The first microprocessor, the Intel 4004 with 2300 transistors and 3mmx4mm size, was introduced in 1971.

6 Intel Pentium 4 The Pentium 4 was introduced in 2000. It had 42 million transistors and a 1,400- 1,500MHz clock speed. The die size was 224mm 2

7 Some Observations The main conceptual ideas underlying the computer have not changed dramatically from Z3 or EDVAC to modern computers. The stored program concepts that was popularized by von Neumann is still is common to almost all the computers of our time. The technology underwent some dramatic changes that made the devices much more energy efficient and significantly smaller.

8 Computer Architecture Some people define computer architecture as the combination of the instruction set architecture (what the executable can see of the hardware, the functional interface) and the machine organization (how the hardware implements the instruction set architecture)

9 What is Computer Architecture ? I/O system Instr. Set Proc. Compiler Operating System Applications Digital Design Circuit Design Firmware Many levels of abstraction Datapath & Control Layout Instruction set architecture Machine organization

10 How does the course fit into the curriculum? ELEN 220 Intro to Digital Design ELEN 248 Intro to DGTL Sym Design CPSC 321 Computer Architecture CPSC 483 Computer Sys Design CPSC 4xx Algorithmic Aspects of Quantum Computing In computer science, you can take up to 3 graduate courses and get credit for it! Do that if you are bored!

11 What next? How does better technology help to improve performance? How can we quantify the gain? The MIPS architecture MIPS instructions First contact with assembly language programming

12 Performance Response time: time between start and finish of the task (aka execution time) Throughput: total amount of work done in a given time

13 Question Suppose that we replace the processor in a computer by a faster model Does this improve the response time? How about the throughput?

14 Question Suppose we add an additional processor to a system that uses separate processors for separate tasks. Does this improve the response time? Does this improve the throughput?

15 Performance Relative Performance (Absolute) Performance

16 Amdahl’s Law The execution time after making an improvement to the system is given by Exec time after improvement = I/A + E I = execution time affected by improvement A = amount of improvement E = execution time unaffected

17 Amdahl’s Law Suppose that program runs 100 seconds on a machine and multiplication instructions take 80% of the total time. How much do I have to improve the speed of multiplication if I want my program to run 5 times faster? 20 seconds = 80 seconds/n + 20 seconds => it is impossible!

18 MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker

19 MIPS Assembly Instructions add $t0, $t1, $t2 # $t0=$t1+$t2 sub $t0, $t1, $t2 # $t0=$t1-$t2 lw $t1, a_addr # $t1=Mem[a_addr] sw $s1, a_addr# Mem[a_addr]=$t1

20 Assembler directives.text assembly instructions follow.datadata follows.globlglobally visible label = symbolic address

21 Hello World!.text# code section.globl main main:li $v0, 4# system call for print string la $a0, str# load address of string to print syscall# print the string li $v0, 10# system call for exit syscall# exit.data str:.asciiz “Hello world!\n” # NUL terminated string, as in C

22 Addressing modes lw $s1, addr # load $s1 from addr lw $s1, 8($s0)# $s1 = Mem[$s0+8] register $s0 contains the base address access the address ($s0) possibly add an offset 8($s0)

23 Load and move instructions la $a0, addr# load address addr into $a0 li $a0, 12# load immediate $a0 = 12 lb $a0, c($s1)# load byte $a0 = Mem[$s1+c] lh $a0, c($s1) # load half word lw $a0, c($s1)# load word move $s0, $s1# $s0 = $s1

24 Control Structures Assembly language has very few control structures:  Branch instructions if cond then goto label  Jump instructions goto label We can build while loops, for loops, repeat-until loops, if-then-else structures from these primitives

25 Branch instructions beqz $s0, labelif $s0==0goto label bnez $s0, labelif $s0!=0 goto label bge $s0, $s1, labelif $s0>=$s1 goto label ble $s0, $s1, label if $s0<=$s1 goto label blt $s0, $s1, label if $s0<$s1 goto label beq $s0, $s1, label if $s0==$s1 goto label bgez $s0, $s1, label if $s0>=0 goto label

26 if-then-else structures if ($t0==$t1) then /* blockA */ else /* blockB */ beq $t0, $t1, blockA j blockB blockA: … instructions of then block … j exit blockB: … instructions of else block … exit:… subsequent instructions …

27 repeat-until loop repeat … until $t0>$t1 loop: … instructions of loop … ble $t0, $t1, loop # if $t0<=$t1 goto loop Other loop structures are similar… Exercise: Derive templates for various loop structures

28 System calls load argument registers load call code syscall li $a0, 10# load argument $a0=10 li $v0, 1# call code to print integer syscall# print $a0

29 SPIM system calls procedure code $v0 argument print int 1 $a0 contains number print float 2 $f12 contains number print double 3 $f12 contains number print string 4 $a0 address of string

30 SPIM system calls procedure code $v0 result read int 5res returned in $v0 read float 6res returned in $f0 read double 7res returned in $f0 read string 8

31 Example programs Loop printing integers 1 to 10 Increasing array elements by 5 123123 for(i=0; i<len; i++) { a[i] = a[i] + 5; }

32 main:li $s0, 1# $s0 = loop counter li $s1, 10# $s1 = upper bound of loop loop:move $a0, $s0# print loop counter $s0 li $v0, 1 syscall li $v0, 4# print “\n” la $a0, linebrk# linebrk:.asciiz “\n” syscall addi $s0, $s0, 1# increase counter by 1 ble $s0, $s1, loop# if ($s0<=$s1) goto loop li $v0, 10# exit syscall Print numbers 1 to 10

33 Increase array elements by 5.text.globl main main: la $t0, Aaddr # $t0 = pointer to array A lw $t1, len # $t1 = length (of array A) sll $t1, $t1, 2 # $t1 = 4*length add $t1, $t1, $t0 # $t1 = address(A)+4*length loop: lw $t2, 0($t0) # $t2 = A[i] addi $t2, $t2, 5 # $t2 = $t2 + 5 sw $t2, 0($t0) # A[i] = $t2 addi $t0, $t0, 4 # i = i+1 bne $t0, $t1, loop # if $t0<$t1 goto loop.data Aaddr:.word 0,2,1,4,5 # array with 5 elements len:.word 5

34 Increase array elements by 5.text.globl main main:la $t0, Aaddr# $t0 = pointer to array A lw $t1, len# $t1 = length (of array A) sll $t1, $t1, 2# $t1 = 4*length (byte addr.) add $t1, $t1, $t0# $t1 = beyond last elem. A

35 Increase array elements by 5 Loop:lw $t2, ($t0)# $t2 = A[i] addi $t2, $t2, 5# $t2 = $t2 + 5 sw $t2, ($t0)# A[i] = $t2 addi $t0, $t0, 4# i = i+1 bne $t0, $t1, loop# if $t0<$t1 goto loop li $v0, 10# exit syscall

36 Increase array elements by 5.data Aaddr:.word 0,2,1,4,5 len:.word 5 Idiosyncratic: Byte addressing => loop in steps of 4 Describe meaning of registers in your documentation!

37 Conclusion Read Chapter 2 in Patterson, Hennessy, 2 nd edition Lab 0 requires you to become familiar with the lab environment Do some exercises on your own! Read Appendix A in 2 nd edition


Download ppt "Computer Architecture CPSC 321 Andreas Klappenecker."

Similar presentations


Ads by Google