June 18, 2001Systems Architecture II1 Systems Architecture II Systems Architecture I Review * Jeremy R. Johnson June 18, 2001 * Most figures from Computer.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Chapter 2 Instructions: Language of the Computer
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Informationsteknologi Saturday, September 29, 2007 Computer Architecture I - Class 41 Today’s class More assembly language programming.
1 Chapter Five The Processor: Datapath and Control.
The Processor: Datapath & Control
MIPS Architecture CPSC 321 Computer Architecture Andreas Klappenecker.
1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
1  2004 Morgan Kaufmann Publishers Chapter Three.
Fall 2007 MIPS Datapath (Single Cycle and Multi-Cycle)
Computer Structure - The Instruction Set (2) Goal: Implement Functions in Assembly  When executing a procedure (function in C) the program must follow.
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Processor I CPSC 321 Andreas Klappenecker. Midterm 1 Thursday, October 7, during the regular class time Covers all material up to that point History MIPS.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
Computing Systems The Processor: Datapath and Control.
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
1  2004 Morgan Kaufmann Publishers Instructions: bne $t4,$t5,Label Next instruction is at Label if $t4≠$t5 beq $t4,$t5,Label Next instruction is at Label.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Lecture 4: MIPS Instruction Set
ECE 445 – Computer Organization
Oct. 25, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Alternative Instruction Sets * Jeremy R. Johnson Wed. Oct. 25, 2000.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
September 26, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 2: Implementation of a Simplified Computer Jeremy R. Johnson Wednesday,
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
1  2004 Morgan Kaufmann Publishers Chapter Five.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
Lec 11Systems Architecture1 Systems Architecture Lecture 11: Arithmetic for Computers Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
COMPUTER ORGANIZATION LECTURE 3: ISA YASSER MOHAMMAD.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
Jeremy R. Johnson William M. Mongan
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
May 2, 2001System Architecture I1 Systems Architecture I (CS ) Lecture 11: Arithmetic for Computers * Jeremy R. Johnson May 2, 2001 *This lecture.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
MIPS Assembly.
COMPUTER ARCHITECTURE & OPERATIONS I
ELEN 468 Advanced Logic Design
Systems Architecture I
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Processor (I).
Instructions - Type and Format
Computer Architecture & Operations I
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
Rocky K. C. Chang 6 November 2017
Systems Architecture I
The Processor Lecture 3.1: Introduction & Logic Design Conventions
Systems Architecture I
COMS 361 Computer Organization
Computer Instructions
Processor: Multi-Cycle Datapath & Control
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
Systems Architecture I
Presentation transcript:

June 18, 2001Systems Architecture II1 Systems Architecture II Systems Architecture I Review * Jeremy R. Johnson June 18, 2001 * Most figures from Computer Organization and Design: The Hardware/Software Approach, Second Edition, by David Patterson and John Hennessy, are copyrighted material (COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED).

June 18, 2001Systems Architecture II2 A Random Access Machine Control Unit AC Program Memory AC = accumulator register

June 18, 2001Systems Architecture II3 Instruction Set LDA X; Load the AC with the contents of memory address X LDI X; Load the AC indirectly with the contents of address X STA X; Store the contents of the AC at memory address X STI X; Store the contents of the AC indirectly at address X ADD X; Add the contents of address X to the contents of the AC SUB X; Subtract the contents of address X from the AC JMP X; Jump to the instruction labeled X JMZ X; Jump to the instruction labeled X if the AC contains 0 JMN X; Jump to the instruction labeled X if the contents of the AC ; is negative HLT ; Halt execution

June 18, 2001Systems Architecture II4 Sample RAM Program 1. LDI 3; get i-th entry from A 2. ADD 4; add offset to compute index j 3. STA 5; store index j 4. LDI 5; get j-th entry from B 5. JMZ 9; if entry 0, go to 9 6. LDA 3; if entry 1, get index i 7. STA 2; and store it at HLT ; stop execution 9. LDA 1; get constant STI 5; and store it in B 11. LDA 3; get index i 12. SUB 4; subtract limit 13. JMZ 8; if i = limit, stop 14. LDA 3; get index i again 15. ADD 1; increment I 16. STA 3; store new value of I 17. JMP 1; AC 1 Memory 1 constant 2 0answer 3 6Index i 4 9 Limit of A 5 0Index j A B

June 18, 2001Systems Architecture II5 MBR MAR AC ALU PC IR(C) IR(O) Memory MUX MUX t 9 t 8 t 7 t 6 t 5 t 4 t 3 t 2 t 1 t 0 q 9 q 8 q 7 q 6 q 5 q 4 q 3 q 2 q 1 q 0 x 13 x 12 x 11 x 10 x 9 x 8 x 7 x 6 x1x2x3x4x5x1x2x3x4x5 DecoderT s s s s LOAD LOAD AD READ/ WRITE INC CLEAR INC

June 18, 2001Systems Architecture II6 Building Blocks

June 18, 2001Systems Architecture II7 Implementing Logic Gates with Transistors output gate +V ground A Transistor NOT Gate A NAND B A +V ground A Transistor NAND Gate B

June 18, 2001Systems Architecture II8 A Clocked Flip-Flop Q Q’ S R clock

June 18, 2001Systems Architecture II9 Memory Cell R Q S Q’ input read/write select output

June 18, 2001Systems Architecture II10 Memory

June 18, 2001Systems Architecture II11 MIPS Architecture Load/Store architecture General purpose register machine (32 registers) ALU operations have 3 register operands (2 source + 1 dest) 16 bit constants for immediate mode Simple instruction set –simple branch operations (beq, bne) –Use register to set condition (e.g. slt) –operations such as move built, li, blt from existing operations Uniform encoding –All instructions are 32-bits long –Opcode is always in the high-order 6 bits –3 types of instruction formats –register fields in the same place for all formats

June 18, 2001Systems Architecture II12 Design Principles Simplicity favors regularity –uniform instruction length –all ALU operations have 3 register operands –register addresses in the same location for all instruction formats Smaller is faster –register architecture –small number of registers Good design demands good compromises –fixed length instructions and only 16 bit constants –several instruction formats but consistent length Make common cases fast –immediate addressing –16 bit constants –only beq and bne

June 18, 2001Systems Architecture II13 MIPS Encoding All instructions are 32-bits long Opcode is always in the high-order 6 bits Only three instruction formats 32 registers implies 5 bit register addresses: –$zero R0 ; zero register always equal to 0 –$at R1 ; temporary register –$v0 - $v1 R2-R3 ; return registers –$a0 - $a3 R4-R7 ; argument registers –$t0 - $t7 R8-R15 ; temporary - not preserved across calls –$s0 - $s7 R16-R23 ; saved registers - preserved across calls –$t8 - $t9 R24-R25 ; temporary not preserved across calls –$k0 - $k1 R26-R27 ; reserved by OS kernel –$gp R28 ; global pointer –$sp R29 ; stack pointer –$fp R30 ; frame pointer –$ra R31 ; return address

June 18, 2001Systems Architecture II14 MIPS Instruction Set Arithmetic/Logical –add, sub, and, or –addi, andi, ori Data Transfer –lw, lb –sw, sb –lui Control –beq, bne –slt, slti –j, jal, jr

June 18, 2001Systems Architecture II15 MIPS Instruction Formats R format (register format - add, sub, …) I format (immediate format - lw, sw, …) J format (jump format – j, jal) op rs rt rd shamt func op rs rt address op 26-bit constant

June 18, 2001Systems Architecture II16 MIPS Addressing Modes Immediate Addressing –16 bit constant from low order bits of instruction –addi $t0, $s0, 4 Register Addressing –add $t0, $s0, $s1 Base Addressing (displacement addressing) –16-bit constant from low order bits of instruction plus base register –lw $t0, 16($sp) PC-Relative Addressing –(PC+4) + 16-bit address (word) from instruction –bne $s0, $s1, Target Pseudodirect Addressing –high order 4 bits of PC+4 concatenated with 26 bit word address - low order 26 bits from instruction shifted 2 bits to the left –j Address

June 18, 2001Systems Architecture II17 MIPS Memory Convention

June 18, 2001Systems Architecture II18 sub $sp,$sp,8 # push stack sw $ra,4($sp) # save return address sw $a0,0($sp) # save n slt $t0,$a0,1 # test n < 1 beq $t0,$zero,L1 # branch if n >= 1 add $v0,$zero,1 # return 1 add $sp,$sp,8 # pop stack jr $ra # return to calling procedure L1: sub $a0,$a0,1 # set parameter to n-1 jal fact # call fact(n-1) lw $a0,0($sp) # restore previous value of n lw $ra,4($sp) # restore previous return address mul $v0,$a0,$v0 # return n * fact(n-1) add $sp,$sp,8 # pop stack jr $ra # return to calling procedure

June 18, 2001Systems Architecture II19 Activation Records (Frames) and the Call Stack An activation record (frame) is a segment on the stack containing a procedure’s saved registers and local variables. Each time a procedure is called a frame ($fp: frame pointer register points to the current frame) is placed on the stack.

June 18, 2001Systems Architecture II20 Compiler Linker Loader Translation Hierarchy

June 18, 2001Systems Architecture II21 Bits have no inherent meaning — conventions define relationship between bits and numbers Binary numbers (base 2) decimal: n -1 Complications: numbers are finite (overflow) fractions and real numbers negative numbers –e.g., no MIPS subi instruction; addi can add a negative number) How do we represent negative numbers? –Which bit patterns will represent which numbers? Numbers

June 18, 2001Systems Architecture II22 Sign Magnitude: One's Complement Two's Complement 000 = = = = = = = = = = = = = = = = = = = = = = = = -1 Issues: balance, number of zeros, ease of operations Which one is best? Why? Possible Representations

June 18, 2001Systems Architecture II23 32 bit signed numbers: two = 0 ten two = + 1 ten two = + 2 ten two = + 2,147,483,646 ten two = + 2,147,483,647 ten two = – 2,147,483,648 ten two = – 2,147,483,647 ten two = – 2,147,483,646 ten two = – 3 ten two = – 2 ten two = – 1 ten maxint minint MIPS

June 18, 2001Systems Architecture II24 Negating a two's complement number: invert all bits and add 1 –remember: “negate” and “invert” are quite different! Converting n bit numbers into numbers with more than n bits: –MIPS 16 bit immediate gets converted to 32 bits for arithmetic –copy the most significant bit (the sign bit) into the other bits > > –"sign extension" (lbu vs. lb) Two's Complement Operations

June 18, 2001Systems Architecture II25 Just like in grade school (carry/borrow 1s) Two's complement operations easy –subtraction using addition of negative numbers Overflow (result too large for finite computer word): –e.g., adding two n-bit numbers does not yield an n-bit number note that overflow term is somewhat misleading, 1000 it does not mean a carry “overflowed” Addition & Subtraction

June 18, 2001Systems Architecture II26 No overflow when adding a positive and a negative number No overflow when signs are the same for subtraction Overflow occurs when the value affects the sign: Detecting Overflow

June 18, 2001Systems Architecture II27 Addition and Subtraction Carry-ripple adder

June 18, 2001Systems Architecture II28 Logical Operations Shift left << sll Shift right >> srl Shift right arithmetic sra Bitwise and & and, andi Bitwise or | or, ori Bitwise complement (not) ~ not (pseudo) Exclusive or ^ xor, xori

June 18, 2001Systems Architecture II29 Representation of Shift Instruction Example sll$t2, $s0, 8 # $t2 = $s0 << 8 $t2 = $8, $s0 = $ op rs rt rd shamt func

June 18, 2001Systems Architecture II30 MIPS ALU

June 18, 2001Systems Architecture II31 Distribution of Floating Point Numbers 3 bit mantissa exponent {-1,0,1} 01 23

June 18, 2001Systems Architecture II32 Representation of Floating Point Numbers IEEE 754 single precision SignBiased exponentNormalized Mantissa (implicit 24th bit) (-1) s  F  2 E-127

June 18, 2001Systems Architecture II33 Representation of Floating Point Numbers IEEE 754 double precision SignBiased exponentNormalized Mantissa (implicit 53rd bit) (-1) s  F  2 E-1023

June 18, 2001Systems Architecture II34 Floating Point Addition Hardware

June 18, 2001Systems Architecture II35 Single Cycle Datapath & Control Implementation of MIPS Simplified to contain only: –memory-reference instructions: lw, sw –arithmetic-logical instructions: add, sub, and, or, slt –control flow instructions: beq, j Generic Implementation: –use the program counter (PC) to supply instruction address –get the instruction from memory –read registers –use the instruction to decide exactly what to do

June 18, 2001Systems Architecture II36 Timing Clocks used in synchronous logic – when should an element that contains state be updated? Edge-triggered timing cycle time rising edge falling edge

June 18, 2001Systems Architecture II37 Edge Triggered Timing State updated at clock edge read contents of some state elements, send values through some combinational logic write results to one or more state elements

June 18, 2001Systems Architecture II38 Components for Simple Implementation Functional Units needed for each instruction

June 18, 2001Systems Architecture II39 Datapath with Control

June 18, 2001Systems Architecture II40 Multicycle Implementation of MIPS Break up the instructions into steps, each step takes a cycle –balance the amount of work to be done –restrict each cycle to use only one major functional unit –Functional units: memory, register file, and ALU At the end of a cycle –Use internal registers to store results between steps

June 18, 2001Systems Architecture II41 Execution Steps 1Instruction fetch –IR = Memory[PC]; –PC = PC + 4; 2Instruction decode and register fetch –A = Reg[IR[25-21]]; –B = Reg[IR[20-16]]; –ALUOut = PC + (sign-extend (IR[15-0]) << 2);

June 18, 2001Systems Architecture II42 Execution Steps 3Execution, memory address computation, or branch completion –Memory reference ALUOut = A + sign-extend (IR[15-0]); –Arithmetic-logical instruction (R-type) ALUOut = A op B; –Branch if (A == B) PC = ALUOut; –Jump PC = PC [31-28] || (IR[25-0]<<2)

June 18, 2001Systems Architecture II43 Execution Steps 4Memory access or R-type instruction completion –memory reference MDR = Memory [ALUOut]; –or Memory [ALUOut] = B; –R-type completion Reg [IR[15-11]] = ALUOut; 5Memory read completion –Reg [IR[20-16]] = MDR;

June 18, 2001Systems Architecture II44 Finite State Machine Set of states Next function determined by input and current state Output determined by current state and possibly input Moore machine (output determined only by current state)

June 18, 2001Systems Architecture II45 Multicycle Datapath with Exception Support

June 18, 2001Systems Architecture II46 Multicycle Control with Exceptions

June 18, 2001Systems Architecture II47 Implementation