MicroComputer Engineering BranchProcCall page 1 3 + 5 + 7 Addiu$t1 $r0 3 Addiu$t1 $t1 5 Addiu$t1 $t1 7 Example.

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

ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
1  1998 Morgan Kaufmann Publishers We will be reusing functional units –ALU used to compute address and to increment PC –Memory used for instruction and.
ELEN 468 Advanced Logic Design
The Processor: Datapath & Control
CSCE 212 Quiz 8 – 3/23/11 1.What type of element is the ALU (combinational or state) and what does it mean for an element to be that type? 2.What is the.
331 Lec 14.1Fall 2002 Review: Abstract Implementation View  Split memory (Harvard) model - single cycle operation  Simplified to contain only the instructions:
Copyright 1998 Morgan Kaufmann Publishers, Inc. All rights reserved. Digital Architectures1 Machine instructions execution steps (1) FETCH = Read the instruction.
Pentium Addressing Modes
Computer Engineering AddSub page 1 Basic Building Blocks Multiplexer + Demultiplexer Adder.
Fall EE 333 Lillevik 333f06-l7 University of Portland School of Engineering Computer Organization Lecture 7 ALU design MIPS data path.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
MicroComputer Engineering IntroLab1 page 1 Introduction Lab1  A crash course in assembler programming  Learn how a processor works!  Decode a coded.
CDA 3101 Fall 2013 Introduction to Computer Organization
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
W.S Computer System Design Lecture 4 Wannarat Suntiamorntut.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
1. Building A CPU  We’ve built a small ALU l Add, Subtract, SLT, And, Or l Could figure out Multiply and Divide  What about the rest l How do.
EE 3755 Datapath Presented by Dr. Alexander Skavantzos.
CS61C L20 Datapath © UC Regents 1 Microprocessor James Tan Adapted from D. Patterson’s CS61C Copyright 2000.
By Wannarat Computer System Design Lecture 4 Wannarat Suntiamorntut.
PC Instruction Memory Address Instr. [31-0] 4 Fig 4.6 p 309 Instruction Fetch.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
MIPS Processor.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Single-cycle CPU Control
Access the Instruction from Memory
Electrical and Computer Engineering University of Cyprus
Single Cycle CPU.
CS 230: Computer Organization and Assembly Language
Prof. Hsien-Hsin Sean Lee
Single-Cycle Datapath and Control
Example Addiu $t1 $r0 3 Addiu $t1 $t1 5 Addiu $t1 $t1 7.
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
MIPS Processor.
ADITI SHINDE CHIDAMBARAM ALAGAPPAN
Designing MIPS Processor (Single-Cycle) Presentation G
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
CSCE 212 Chapter 5 The Processor: Datapath and Control
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
MIPS Processor.
MIPS Instructions.
MIPS Instruction Encoding
Topic 5: Processor Architecture Implementation Methodology
Instruction encoding The ISA defines Format = Encoding
The Processor Lecture 3.2: Building a Datapath with Control
Topic 5: Processor Architecture
COMS 361 Computer Organization
Basic Building Blocks Multiplexer Demultiplexer Adder +
Access the Instruction from Memory
The branch instruction
Review Fig 4.15 page 320 / Fig page 322
Reading and writing to data memory
Basic Building Blocks Multiplexer Demultiplexer Adder +
Datapath and Control Exceptions
CS/COE0447 Computer Organization & Assembly Language
The Processor: Datapath & Control.
COMS 361 Computer Organization
MIPS Processor.
Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

MicroComputer Engineering BranchProcCall page Addiu$t1 $r0 3 Addiu$t1 $t1 5 Addiu$t1 $t1 7 Example

MicroComputer Engineering BranchProcCall page 2 La$t0 tal Lw$t1 0($t0) Lw$t2 4($t0) Lw$t3 8($t0) Addu $t4 $t1 $t2 Addu $t4 $t4 $t3 Sw$t4 12($t0) tal Example 2

MicroComputer Engineering BranchProcCall page 3 The Branch Instruction B label “label” is an instruction address. Instruction addresses are 32 bits. But branch instructions are immediate format, ONLY 16 BITS !?

MicroComputer Engineering BranchProcCall page 4 How It’s Done! xBzx, y, z all have y !absolute values. ! !But the quantity z!z - y is an offset !(a relative value). If the offset z - y can be represented in 16 bits, then it will fit.

MicroComputer Engineering BranchProcCall page 5 But There’s One More Trick.... z and y are valid byte addresses, both word aligned! That means that: z = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx00 y = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx00 so z - y = xxxxxxxxxxxxxx00 Why waste space representing two bits which are always zero?

MicroComputer Engineering BranchProcCall page 6 But there’s one more trick.... So, shift the difference (z - y) right two bits. That way, if (z - y) fits in 18 bits we can save the offset in 16 bits!

MicroComputer Engineering BranchProcCall page 7 How does the structure work? xBzWhen we fetch B z, y !the program counter !contains the value x. ! z!That means y = PC + 4. ! Since offset = (z - y), then PC offset = y + z - y, an absolute address!

MicroComputer Engineering BranchProcCall page 8 To calculate the branch address Program counter Instruction memory B Imm z - y shifted right twice Imm 00 Restore the two zeroes 18 bits Sign extend to 32 bits 4 + Absolute branch address PC + 4

MicroComputer Engineering BranchProcCall page 9 Branch logic Sgn/Ze extend Zero ext. B label ALU A B

MicroComputer Engineering BranchProcCall page 10 Branch logic Sgn/Ze extend Zero ext. B label ALU A B

MicroComputer Engineering BranchProcCall page 11 Branch logic Sgn/Ze extend Zero ext. B label ALU A B

MicroComputer Engineering BranchProcCall page 12 Branch logic Sgn/Ze extend Zero ext. Beq rs rt label ALU A B

MicroComputer Engineering BranchProcCall page 13 Branch logic Sgn/Ze extend Zero ext. Beq rs rt label ALU A B

MicroComputer Engineering BranchProcCall page 14 Branch logic Sgn/Ze extend Zero ext. Beq rs rt label ALU A B

MicroComputer Engineering BranchProcCall page 15 Branch logic Sgn/Ze extend Zero ext. Beq rs rt label ALU A B ?

MicroComputer Engineering BranchProcCall page 16 Procedure call Suppose we have a program that “rings the bell” at 10 different locations in the code. This sort of thing is usually complicated! many, many instructions..... That’s a waste of space can’t we write the “bell code” once and share it?

MicroComputer Engineering BranchProcCall page 17 Procedure call Bbell back! ! BbellProblem: The back!return address! Bell! !Branch is not !enough. Bback

MicroComputer Engineering BranchProcCall page 18 Return address A We need to tell the subroutine where it should branch back to, –i.e., the return address, each time we call it! That means: The return address must be changeable.

MicroComputer Engineering BranchProcCall page 19 Return address B We can’t use B x; X is not changeable –we can’t write to the instruction memory... But we can write to: –register file –data memory So we can write the return address there.

MicroComputer Engineering BranchProcCall page 20 Return address C Suppose we use $31 for example: Bell! ! Jr$31 Jump register $31: –Read the register file and stores the value into the PC

MicroComputer Engineering BranchProcCall page 21 Branch logic Sgn/Ze extend Zero ext. Jr $31 ALU A B

MicroComputer Engineering BranchProcCall page 22 Branch logic Sgn/Ze extend Zero ext. Jr $31 ALU A B

MicroComputer Engineering BranchProcCall page 23 This works (not the best way): !bell:!! La$31 x! Bbell! x:!Jr$31 ! La$31 y Bbell y:! !

MicroComputer Engineering BranchProcCall page 24 What’s done?? La$31 x2 instructions B bell1 instruction x:need a label We just want to get the address following the “call” into $31.

MicroComputer Engineering BranchProcCall page 25 save return address in reg $31 Branch logic Sgn/Ze extend Zero ext. La $31 x B bell x: ALU A B Return address when B bell is fetched

MicroComputer Engineering BranchProcCall page 26 The return address The “call” is at “PC”. So, the return address must be PC + 4. But we compute PC + 4. Can we cause PC + 4 to be written to the register file ($31). Yes. Use BALbell (branch and link).

MicroComputer Engineering BranchProcCall page 27 Branch logic Sgn/Ze extend Zero ext. Bal label ALU A B

MicroComputer Engineering BranchProcCall page 28 Branch logic Sgn/Ze extend Zero ext. Bal label ALU A B

MicroComputer Engineering BranchProcCall page 29 Branch logic Sgn/Ze extend Zero ext. Bal label ALU A B

MicroComputer Engineering BranchProcCall page 30 Branch logic Sgn/Ze extend Zero ext. Bal label ALU A B

MicroComputer Engineering BranchProcCall page 31 Branch logic Sgn/Ze extend Zero ext. B label … next instr ALU A B