Digital Logic Design Alex Bronstein

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

Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
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
CPE 731 Advanced Computer Architecture Instruction Set Principles Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University of California,
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
VHDL Synthesis of a MIPS-32 Processor Bryan Allen Dave Chandler Nate Ransom.
CDA 3101 Fall 2012 Introduction to Computer Organization Instruction Set Architecture MIPS Instruction Format 04 Sept 2013.
83 Assembly Language Readings: Chapter 2 ( , 2.8, 2.9, 2.13, 2.15), Appendix A.10 Assembly language Simple, regular instructions – building blocks.
IT253: Computer Organization Lecture 5: Assembly Language and an Introduction to MIPS Tonga Institute of Higher Education.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
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,
Lecture 4: MIPS Instruction Set
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
MIPS Instructions Instructions: Language of the Machine
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
EEL5708/Bölöni Lec 3.1 Fall 2006 Sept 1, 2006 Lotzi Bölöni EEL 5708 High Performance Computer Architecture Lecture 3 Review: Instruction Sets.
CDA 3101 Spring 2016 Introduction to Computer Organization
MIPS Instruction Set Architecture Prof. Sirer CS 316 Cornell University.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
EEL5708/Bölöni Lec 3.1 Fall 2004 Sept 1, 2004 Lotzi Bölöni Fall 2004 EEL 5708 High Performance Computer Architecture Lecture 3 Review: Instruction Sets.
Pirouz Bazargan SabetDecember 2003 Effective Implementation of a 32-bit RISC Processor Pirouz Bazargan Sabet University of Paris 6 - LIP6 - ASIM
Instruction Set Architecture of MIPS Processor Presentation B
Instructor: Prof. Hany H Ammar, LCSEE, WVU
MIPS Assembly.
/ Computer Architecture and Design
Digital Logic Design Alex Bronstein
CS 230: Computer Organization and Assembly Language
Prof. Hsien-Hsin Sean Lee
Computer Architecture Instruction Set Architecture
Computer Organization and Design Instruction Sets - 2
Instructions: Language of the Computer
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
Computer Organization and Design Instruction Sets - 2
Computer skills CPU Jakub Yaghob.
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
32-bit MIPS ISA.
ENGR 3410 – Computer Architecture Mark L. Chang Fall 2006
Assembly Programming using MIPS R3000 CPU
Computer Organization and Design Instruction Sets
Designing MIPS Processor (Single-Cycle) Presentation G
ECE/CS 552: Instruction Sets – MIPS
Instructions - Type and Format
Appendix A Classifying Instruction Set Architecture
Lecture 4: MIPS Instruction Set
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
Today’s Lecture Quick Review of Last Lecture
Instruction encoding The ISA defines Format = Encoding
Lecture 5: Procedure Calls
Part II Instruction-Set Architecture
August 29 New address for Fang-Yi
/ Computer Architecture and Design
Computer Instructions
Flow of Control -- Conditional branch instructions
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
MIPS Instruction Set Architecture
Assembly Programming using MIPS R3000 CPU
Flow of Control -- Conditional branch instructions
CS352H Computer Systems Architecture
Reduced Instruction Set Computer (RISC)
MIPS Arithmetic and Logic Instructions
MIPS Assembly.
Presentation transcript:

Digital Logic Design 234262 Alex Bronstein Lecture 5: MIPS Instruction Set Architecture

Abstraction Hierarchy Application Software Operating System (threads, files, exceptions) Computer Architecture (instruction set) Micro-Architecture (execution pipeline) Logic (adders, multipliers, FSMs) Digital Circuits (gates) Analog Circuits (amplifiers) Process and Devices (MOS FET transistors) Physics (electrons, holes, tunneling, band gap)

Controller vs. Processor REG REG REG CTRL ROUTER CL CL CL Controllers discussed thus far were special purpose Processor (aka CPU) is programmable hardware that can implement various functions (Turing complete)

RISC vs. CISC Reduced Instruction Set Computer (RISC) Small structured and highly optimized instruction set Simple encoding, few addressing modes, load/store architecture More complicated compiler More efficient hardware Examples: ARM, MIPS, PowerPC, DEC Alpha, SPARC, Blackfin Complex Instruction Set Computer (CISC) Complicated and heterogenous instruction set More cumbersome hardware Examples: Intel x86, DEC PDP11/VAX

MIPS Architecture in a Nutshell The following interface is exposed to software: 32-bit bit instructions of 3 types: I,R and J 32 general purpose 32-bit integer registers 32 general purpose single-precision floating point registers (paired into 16 double-precision registers) 2 special registers (Lo/Hi) to store results of multiplication/division (not directly addressable) 32-bit addressable data memory 32-bit addressable instruction memory addressed by the dedicated 32-bit program counter register (PC)

Toolchain High-level program (C) Assembly language (MIPS) Compiler void swap(int v[], int k) { int temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } Assembly language (MIPS) swap: sll $t0, $a1, 2 add $t0, $a0, $t0 lw $t1, 0($t0) lw $t2, 4($t0) sw $t1, 4($t0) sw $t2, 0($t0) jr $ra Compiler Assembler Machine code (MIPS) 00054080 00884020 8d090000 8d0a0004 ad090004 ad0a0000 00000008

MIPS Memory Registers ×32 32-bit (4-byte) integer registers 32-bit program counter (PC, not directly addressable) (More stuff: FP registers, special Lo/Hi registers) Data memory 230 addressable 32-bit word space Each word address has two LSBs = 0 Instruction memory Each instruction is encoded in exactly 32-bit (no variable length) 230 word instruction memory space Memory is often practically implemented on the same physical RAM as modified Harvard architecture

MIPS Registers Except for $0, all registers have the same status. The following convention is common for cross-compatibility of assemblers and compilers: Register Alias Conventional use $0 zero value 0 $1 $at assembler temporary reserved by the assembler $2-$3 $v0-$v1 values from expression evaluation & function results $4-$7 $a0-$a3 arguments – first four arguments of a function $8-$15 $t0-$t7 temporaries $16-$23 $s0-$s7 saved values $24-$25 $t8-$t9 temporaries $26-$27 $k0-$k1 reserved by interrupt handler $28 $gp global pointer $29 $sp stack pointer $30 $s8/$fp saved value/frame pointer $31 $ra return address

MIPS Instruction Set Architecture (ISA) Arithmetic/Logic (works on registers only) Integer Floating point Memory access (moves data between registers and RAM) Load/store Control (affects program counter) Jump Conditional branch Function call/return

MIPS Instructions Instructions are read in order from address pointed by the PC and executed Every instruction is encoded in exactly 32-bit (no exceptions) Every instruction in the ISA is characterized by Syntax – how the instruction is written in assembly language Semantics – what the instruction does Binary coding – the way the processor sees it Implementation-specific details – cycle count, delay slots, other limitations

MIPS Instruction Encoding Register (R) type instructions accept three registers Immediate (I) type instructions accept two registers and one fixed value (immediate) Jump (J) type instructions receive a fixed (immediate) address 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 OP [5 bit] s t d shamnt func 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 OP [5 bit] s t IM [16 bit] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 OP [5 bit] XI [26 bit]

MIPS R-type Instruction Encoding Integer addition Mnemonics: add rd, rs, rt Semantics: rd ← rs+rt Encoding: s,t,d = 5-bit register address (0..31) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 s t d 3210

MIPS I-type Instruction Encoding Integer add immediate Mnemonics: addi rt, rs, IM Semantics: rt ← rs+IM Encoding: s,t,d = 5-bit register address (0..31) IM = 16-bit immediate value coded into instruction 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 810 s t IM

MIPS I-type Instruction Encoding Load word Mnemonics: lw rt, IM(rs) Semantics: rt ← MEM[rs+IM] Encoding: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 3510 s t IM Store word Mnemonics: sw rt, IM(rs) Semantics: MEM[rs+IM] ← rt Encoding: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 4310 s t IM

MIPS I-type Instruction Encoding Branch on equal Mnemonics: beq rs, rt, ADDRESS Semantics: if (rs==rt): PC ← PC+(IM<<2) Encoding: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 410 s t IM

MIPS J-type Instruction Encoding Jump Mnemonics: j ADDR Semantics: PC ← (PC&F000000016)|(XI<<2) Encoding: XIM = 26-bit extended immediate value containing new absolute address to jump to 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 810 XI

MIPS Integer Arithmetic/Logic Instructions Addition: add (R) • addu (R) • addi (I) • addiu (I) Subtraction: sub (R) • subu (R) • subi (I) • subiu (I) Logic: or (R) • xor (R) • nor (R) • and (R) ori (I) • xori (I) • nori (I) • andi (I) Shift: sll (R) • srl (R) • sra (R) • sllv (R) • srlv (R) • srav (R) Other: slt (R) • sltu (R) • slti (I) • sltui (I) • lui (I) Mult/Div: mult (R) • multu (R) • div (R) • divu (R)

MIPS Memory Access Instructions Load: lw (R) • lb (R) Store: sw (R) • sb (R)

MIPS Jump Instructions Unconditional: j (J) • jr (R) • jal (J) • jalr (R) Conditional: bltz (I) • bgez (I) • bltzal (I) • bgezal (I) beq (I) • bne (I) • blez (I) • bgez (I)

MIPS Instructions Instruction reads at most two registers (rs, rt) Instruction modifies at most one register R-type might change rd I-type might change rt RAM-related instructions (lw/sw) do not perform calculations

MIPS Datapath Building Blocks Register file Arithmetic-Logic Unit (ALU) Memory (MEM) Program Counter (PC) These building blocks are present in all implementation Other implementations may have additional building blocks

Abstract MIPS Datapath PC+4+4IM Next PC PC+4 + 4 + MEM out new reg value ALU out Instruction Memory ADDR INSTR immediate Register File DATA ADDR1 Data Memory ADDR DATA rs PC REG1 ALU rs rt rt REG2 ADDR2 rd ADDR3 rt immediate

+ + Instruction Memory Register File Data Memory PC ALU CTRL Branch Zero 4 + + Instruction Memory ADDR INSTR Register File DATA ADDR1 Data Memory ADDR DATA PC REG1 ALU REG2 ADDR2 ADDR3 RegWR ALUOP MemRD MemWR CTRL

Abstract MIPS Datapath add rd, rs, rt PC+4 PC+4 + 4 + rs+rt rs+rt Instruction Memory ADDR INSTR Register File DATA ADDR1 Data Memory ADDR DATA rs PC REG1 ALU rs rt rt REG2 ADDR2 rd ADDR3

Abstract MIPS Datapath addi rd, rs, IM rs rd rs+IM IM PC+4 + 4 + Instruction Memory ADDR INSTR Register File DATA ADDR1 Data Memory ADDR DATA PC REG1 ALU REG2 ADDR2 ADDR3

Abstract MIPS Datapath lw rt, IM(rs) rs rt MEM[rs+IM] IM rs+IM PC+4 + 4 + MEM[rs+IM] Instruction Memory ADDR INSTR Register File DATA ADDR1 Data Memory ADDR DATA PC REG1 ALU REG2 ADDR2 ADDR3

Abstract MIPS Datapath sw rt, IM(rs) rs rt IM PC+4 + 4 + Instruction Memory ADDR INSTR Register File DATA ADDR1 Data Memory ADDR DATA rs+IM PC REG1 ALU rt REG2 ADDR2 ADDR3 rt