Computer Architecture CPSC 321 Andreas Klappenecker.

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
CS/COE0447 Computer Organization & Assembly Language
Lecture 9: MIPS Instruction Set
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
SPIM Tutorial CSE 410 Computer Systems. Introduction SPIM: MIPS simulator –Reads/executes assembly source programs Does not execute binaries Download.
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
ELEN 468 Advanced Logic Design
CS3350B Computer Architecture Winter 2015 Lecture 4
Systems Architecture Lecture 5: MIPS Instruction Set
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
MIPS Function Continued
MIPS Assembly Language Programming
Assembly Language Working with the CPU.
MIPS Assembly Language
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
Chapter 01 Introduction Chapter 0 Introduction. Chapter 02 History of Computing - Early Computers Abacus (ancient orient, still in use) Slide rule (17C,
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
CPSC CPSC 3615 Computer Architecture Chapter 3 Instructions and Addressing (Text Book: Chapter 5)
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
Review for Midterm 1 CPSC 321 Computer Architecture Andreas Klappenecker.
Computer Architecture - The Instruction Set The Course’s Goals  To be interesting and fun. An interested student learns more.  To answer questions that.
Review CPSC 321 Andreas Klappenecker. Administrative Issues Midterm is on October 12 Allen Parish’s help session Friday 10:15-12:15.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
Lecture 5: Procedures. Function call book-keeping in C main() { int i,j,k,m;... i = mult(j,k);... m = mult(i,i);... } /* really dumb mult function */
MIPS Instruction Set Advantages
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
Gary MarsdenSlide 1University of Cape Town Computer Architecture – Introduction Andrew Hutchinson & Gary Marsden (me) ( ) 2005.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Architecture CPSC 350
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
CHAPTER 6 Instruction Set Architecture 12/7/
Chapter 2 Decision-Making Instructions (Instructions: Language of the Computer Part V)
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Computer Architecture CSCE 350 Rabi Mahapatra Spring 2015.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Computer Architecture
Computer Organization IS F242. Course Objective It aims at understanding and appreciating the computing system’s functional components, their characteristics,
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
MIPS Coding. Exercise – the bubble sort 7/9/2016week04-3.ppt2.
CS 312 Computer Architecture & Organization
MIPS Assembly.
MIPS Instruction Set Advantages
CS2100 Computer Organisation
MIPS Coding Continued.
ELEN 468 Advanced Logic Design
Computer Architecture CSCE 350
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
MIPS coding.
Instructions - Type and Format
CS170 Computer Organization and Architecture I
Systems Architecture Lecture 5: MIPS Instruction Set
September 24 Test 1 review More programming
MIPS coding.
MIPS Coding.
3.
COMS 361 Computer Organization
COMS 361 Computer Organization
MIPS Coding Continued.
MIPS coding.
MIPS Assembly Language Programming Computer Architecture
9/27: Lecture Topics Memory Data transfer instructions
Instruction Set Architecture
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
MIPS instructions.
Conditional Branching (beq)
Presentation transcript:

Computer Architecture CPSC 321 Andreas Klappenecker

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

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 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)

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 Jack Kilby and Robert Noyce invent the silicon wafer Steven Hofstein develops the Field Effect Transistor that will be used in the MOS integrated circuits

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

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

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.

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)

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

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!

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

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

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

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?

Performance Relative Performance (Absolute) Performance

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

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!

MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker

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

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

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

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)

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

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

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

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 …

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

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

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

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

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

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

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

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

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

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!

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