LC-3 Instruction Processing. (Textbook s Chapter 4)

Similar documents
LC-3 Instruction Processing

Chapter 5 The LC-3. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

EEL 5722C Field-Programmable Gate Array Design

Introduction to Computer Engineering. Chapter 5 The LC-3. Instruction Set Architecture

Computing Layers. Chapter 5 The LC-3

Instruction Set Architecture

CS 2461: Computer Architecture I

COSC121: Computer Systems: Review

COSC121: Computer Systems: Review

Special Microarchitecture based on a lecture by Sanjay Rajopadhye modified by Yashwant Malaiya

11/28/2016. ECE 120: Introduction to Computing. Register Loads Control Updates to Register Values. We Consider Five Groups of LC-3 Control Signals

LC3DataPath ECE2893. Lecture 9a. ECE2893 LC3DataPath Spring / 14

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

The LC-3 Instruction Set Architecture. ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path

LC-3 ISA - II. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 10 February 17, 2011

Chapter 5 - ISA. 1.The Von Neumann Model. The Stored Program Computer. Von Neumann Model. Memory

LC-3 Instruction Set Architecture

Chapter 4 The Von Neumann Model

Binghamton University. CS-120 Summer LC3 Memory. Text: Introduction to Computer Systems : Sections 5.1.1, 5.3

20/08/14. Computer Systems 1. Instruction Processing: FETCH. Instruction Processing: DECODE

Chapter 4 The Von Neumann Model

LC-3 Instruction Set Architecture. Textbook Chapter 5

Chapter 4 The Von Neumann Model

10/31/2016. The LC-3 ISA Has Three Kinds of Opcodes. ECE 120: Introduction to Computing. ADD and AND Have Two Addressing Modes

Computer Architecture. Lecture 5: Multi-Cycle and Microprogrammed Microarchitectures

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Annie Lin, Mohit Verma

Introduction to Computer Engineering. CS/ECE 252 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin Madison

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

( input = α output = λ move = L )

Chapter 8 Input/Output

Computer Architecture Lecture 6: Multi-Cycle and Microprogrammed Microarchitectures

Intro. to Computer Architecture Homework 4 CSE 240 Autumn 2005 DUE: Mon. 10 October 2005

Register Files. Single Bus Architecture. Register Files. Single Bus Processor. Term Project: using VHDL. Accumulator based architecture

ADD R3, R4, #5 LDR R3, R4, #5

CS 270 Fall 2013 Mock Final

Microprogrammed Control. ECE 238L μseq 2006 Page 1

The von Neumann Model

LC-3 Architecture. (Ch4 ish material)

Introduction to Computer. Chapter 5 The LC-3. Instruction Set Architecture

Load -- read data from memory to register. Store -- write data from register to memory. Load effective address -- compute address, save in register

Programming Studio #4 ECE 190

Fortunately not. In LC-3, there are a variety of addressing modes that deal with these concerns.

ETH, Design of Digital Circuits, SS17 Practice Exercises III

Memory Usage in Programs

LC-3. 3 bits for condition codes (more later) Fixed-length instructions, with 4-bit opcodes. IIT CS 350 S 18- Hale

UNIVERSITY OF WISCONSIN MADISON

Department of Electrical and Computer Engineering The University of Texas at Austin

10/30/2016. How Do We Write Instructions? ECE 120: Introduction to Computing. Put Bits into Memory, Then Execute the Bits

Department of Electrical and Computer Engineering The University of Texas at Austin

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Control Unit for Multiple Cycle Implementation

ECE 411 Exam 1. This exam has 5 problems. Make sure you have a complete exam before you begin.

Department of Electrical and Computer Engineering The University of Texas at Austin

LC-3 Subroutines and Traps. (Textbook Chapter 9)"

Microprogrammed Control Approach

Outcomes. Lecture 13 - Introduction to the Central Processing Unit (CPU) Central Processing UNIT (CPU) or Processor

MICROCOMPUTER OPERATION

Implement useq's FSM's --- Next-state function --- Output function. We know: Any function can be implemented in AND-OR

Inf2C - Computer Systems Lecture Processor Design Single Cycle

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CSE 2021 COMPUTER ORGANIZATION

The Stored Program Computer

Memory General R0 Registers R1 R2. Input Register 1. Input Register 2. Program Counter. Instruction Register

appendix a The LC-3 ISA A.1 Overview

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Ch. 5: The LC-3. PC-Relative Addressing Mode. Data Movement Instructions. James Goodman!

Department of Electrical and Computer Engineering The University of Texas at Austin

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015

Logistics. IIT CS 350 S '17 - Hale

Midterm 2 Review Chapters 4-16 LC-3

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

Computer Architecture Review CS 595

Lec-memMapIOtrapJSR SYS_BUS

Block diagram view. Datapath = functional units + registers

CPE 335. Basic MIPS Architecture Part II

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Review Topics

LC-3 Assembly Language. (Textbook Chapter 7)"

Department of Electrical and Computer Engineering The University of Texas at Austin

REGISTER TRANSFER LANGUAGE

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

are Softw Instruction Set Architecture Microarchitecture are rdw

Department of Electrical and Computer Engineering The University of Texas at Austin

Department of Electrical and Computer Engineering The University of Texas at Austin

CS 135: Computer Architecture I

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

Unit 8 - Week 7: Organization and Optimization of Micro-programmed Controlled Control Unit

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Examining the complete instruction cycle for one instruction illustrates the operation of the P8 CPU. Assume the following conditions: C C C

Faculty of Engineering Systems & Biomedical Dept. First Year Cairo University Sheet 6 Computer I

Learning Outcomes. Spiral 3-3. Sorting: Software Implementation REVIEW

CC 311- Computer Architecture. The Processor - Control

Computer Organization. Structure of a Computer. Registers. Register Transfer. Register Files. Memories

Chapter 10 Computer Design Basics

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Basic Processing Unit: Some Fundamental Concepts, Execution of a. Complete Instruction, Multiple Bus Organization, Hard-wired Control,

Transcription:

LC-3 Instruction Processing (Textbook s Chapter 4)

Instruction Processing Fetch instruction from memory Decode instruction Evaluate address Fetch operands from memory Usually combine Execute operation Store result CMPE12 Winter 2009 Joel Ferguson 8-2

Phases of instruction processing Six basic phases of instruction processing: F D EA OP EX S NOTE: Not all phases are needed by every instruction All instructions will go through F and D at least Phases may take more than 1 machine cycle CMPE12 Winter 2009 Joel Ferguson 8-3

FETCH Load next instruction (at address stored in PC) from memory into Instruction Register (IR). Copy contents of PC into MAR. Send read signal to memory. Copy contents of MDR into IR. Then increment PC, so that it points to the next instruction in sequence. PC becomes PC+1. F D EA OP EX S CMPE12 Winter 2009 Joel Ferguson 8-4

DECODE First identify the opcode. In LC-3, this is always the first four bits of instruction. A 4-to-16 decoder asserts a control line corresponding to the desired opcode. F D Depending on opcode, identify other operands from the remaining bits. Example: for LDR, last six bits is offset for ADD, last three bits is second source operand EA OP EX S CMPE12 Winter 2009 Joel Ferguson 8-5

EVALUATE ADDRESS For instructions that require memory access, compute address used for access. F D Examples: add offset to base register (as in LDR) add offset to PC add offset to zero set source registers addresses EA OP EX S CMPE12 Winter 2009 Joel Ferguson 8-6

FETCH OPERANDS Obtain source operands needed to perform operation. F D Examples: load data from memory (LDR) read data from register file (ADD) EA OP EX S CMPE12 Winter 2009 Joel Ferguson 8-7

EXECUTE F Perform the operation, using the source operands. Examples: send operands to ALU and assert ADD signal do nothing (e.g., for loads and stores) D EA OP EX S CMPE12 Winter 2009 Joel Ferguson 8-8

STORE RESULT Write results to destination. (register or memory) Examples: result of ADD is placed in destination register result of memory load is placed in destination register for store instruction, data is stored to memory write address to MAR, data to MDR assert WRITE signal to memory F D EA OP EX S CMPE12 Winter 2009 Joel Ferguson 8-9

LC-3 Data Path Filled arrow = info to be processed. Unfilled arrow = control signal. CMPE12 Winter 2009 Joel Ferguson 8-10

Global bus Data Path Components (1) special set of wires that carry a 16-bit signal to many components inputs to the bus are tri-state devices, that only place a signal on the bus when they are enabled only one device speaks on the bus at any given time control unit decides which signal drives the bus any number of components can read the bus Memory the control unit write-enables the destination device Control and data registers for memory and I/O devices memory: MAR, MDR (also control signal for read/write) CMPE12 Winter 2009 Joel Ferguson 8-11

LC-3 Data Path Memory Components: Memory Mem. Address Reg. Mem. Data Reg. Mem Enable, R, W CMPE12 Winter 2009 Joel Ferguson 8-12

ALU Data Path Components (2) Accepts inputs from register file and from sign-extended bits from IR (immediate field). Output goes to bus, and is used by condition code logic, register file, memory Register File Two read addresses (SR1, SR2), one write address (DR) Input from bus result of ALU operation or memory read Two 16-bit outputs used by ALU, PC, memory address data for store instructions passes through ALU CMPE12 Winter 2009 Joel Ferguson 8-13

LC-3 Data Path Register File Registers R0-R7 16 bits Data in 2 x 16 bits Data out 10 control bits ALU and SR2MUX Data: 3 16-bit words Control: 2 bits for ALU and 1 bit for MUX CMPE12 Winter 2009 Joel Ferguson 8-14

Data Path Components (3) PC and PCMUX There are three inputs to PC, controlled by PCMUX 1. PC+1 FETCH stage 2. Address adder BR, JMP 3. bus TRAP (discussed later) MAR and MARMUX There are two inputs to MAR, controlled by MARMUX 1. Address adder LD/ST, LDR/STR 2. Zero-extended IR[7:0] -- TRAP (discussed later) CMPE12 Winter 2009 Joel Ferguson 8-15

LC-3 Data Path PC; PCMUX; incrementer PC gets data from 1 of 8 sources. Which instructions use which? MAR and MARMUX MAR gets data from how many sources? CMPE12 Winter 2009 Joel Ferguson 8-16

Data Path Components (4) Condition Code Logic Looks at value on bus and generates N, Z, P signals Registers set only when control unit enables them (LD.CC) only certain instructions set the codes (ADD, AND, NOT, LD, LDI, LDR, LEA) Control Unit Finite State Machine On each machine cycle, changes control signals for next phase of instruction processing who drives the bus? (GatePC, GateALU, ) which registers are write enabled? (LD.IR, LD.REG, ) which operation should ALU perform? (ALUK) Logic includes decoder for opcode, etc. CMPE12 Winter 2009 Joel Ferguson 8-17

LC-3 Data Path Condition Code Logic Sets codes when LD.CC allows. Control Unit Is an FSM Controls everything based on instruction. CMPE12 Winter 2009 Joel Ferguson 8-18

Data Path Components (5) Effective Address Mux and Adder Computes addresses for PC and MAR Used for most instructions that affect the PC or access memory (BRA, JMP, LD, ST, JSR, etc.) CMPE12 Winter 2009 Joel Ferguson 8-19

LC-3 Data Path Effective Address Computation Units: For almost all PC and MAR computations. CMPE12 Winter 2009 Joel Ferguson 8-20

Example 1: x30a2 add R2,R0,R1 R0 = x0230 R1 = x1111 R2 = x2222 x30a2 1) Fetch 1 st step(from mem) x1401 CMPE12 Winter 2009 Joel Ferguson 8-21

Example 1: x30a2 add R2,R0,R1 R0 = x0230 R1 = x1111 R2 = x2222 1) Fetch 2 nd step CMPE12 Winter 2009 Joel Ferguson 8-22

Example 1: x30a2 add R2,R0,R1 R0 = x0230 R1 = x1111 R2 = x2222 2) Decode x1401 CMPE12 Winter 2009 Joel Ferguson 8-23

Example 1: x30a2 add R2,R0,R1 R0 = x0230 R1 = x1111 R2 = x2222 x1111 x0230 3) Evaluate Address and Fetch Operands x1341 CMPE12 Winter 2009 Joel Ferguson 8-24

Example 1: x1341 x30a2 add R2,R0,R1 R0 = x0230 R1 = x1111 R2 = x2222 5) Execute CMPE12 Winter 2009 Joel Ferguson 8-25

Example 1: x30a2 add R2,R0,R1 R0 = x0230 R1 = x1111 R2 = x1341 6) Store Results CMPE12 Winter 2009 Joel Ferguson 8-26

Example 2: X3117 LDR R3,R5,xB R3 = x3451 R5 = x8800 x3117 1) Fetch 1 st step x674b CMPE12 Winter 2009 Joel Ferguson 8-27

Example 2: X3117 LDR R3,R5,xB R3 = x3451 R5 = x8800 1) Fetch 2 nd step x674b CMPE12 Winter 2009 Joel Ferguson 8-28

Example 2: X3117 LDR R3,R5,xB R3 = x3451 R5 = x8800 2) Decode x674b CMPE12 Winter 2009 Joel Ferguson 8-29

Example 2: X3117 LDR R3,R5,xB R3 = x3451 R5 = x8800 x000b x880b x8800 4) Evaluate Address x880b CMPE12 Winter 2009 Joel Ferguson 8-30

Example 2: x???? X3117 LDR R3,R5,xB R3 = x3451 R5 = x8800 x???? 4) Fetch Operands x880b X???? CMPE12 Winter 2009 Joel Ferguson 8-31

Example 2: x???? X3117 LDR R3,R5,xB R3 = x3451 R5 = x8800 x???? 5) Execute CMPE12 Winter 2009 Joel Ferguson 8-32

Example 2: x???? X3117 LDR R3,R5,xB R3 = mem[x880b] R5 = x8800 x???? 6) Store Results CMPE12 Winter 2009 Joel Ferguson 8-33

Example 3: x3040 BRZ EndLoop EndLoop = x3030 Therefore mem[x3040] = x05ef x3041 x3040 1) Fetch 1 st step x05ef CMPE12 Winter 2009 Joel Ferguson 8-34

Example 3: x3141 x3040 BRZ EndLoop EndLoop = x3030 1) Fetch 2 nd step x05ef CMPE12 Winter 2009 Joel Ferguson 8-35

Example 3: x3040 BRZ EndLoop x05ef 2) Decode CMPE12 Winter 2009 Joel Ferguson 8-36

Example 3: x3030 x3040 BRZ EndLoop x3041 xffef (16bits) x1ef (9bits) 3) Evaluate Address CMPE12 Winter 2009 Joel Ferguson 8-37

Example 3: x3030 x3040 BRZ EndLoop x3041 xffef (16bits) (no operand fetch) 5) Execute CMPE12 Winter 2009 Joel Ferguson 8-38

Example 3: x3030 x3040 BRZ EndLoop 6) Store Results (none) CMPE12 Winter 2009 Joel Ferguson 8-39

Example 4: X3317 STR R3,R5,xB R3 = x3451 R5 = x8800 x3317 1) Fetch 1 st step x774b CMPE12 Winter 2009 Joel Ferguson 8-40

Example 4: X3117 STR R3,R5,xB R3 = x3451 R5 = x8800 1) Fetch 2 nd step x774b CMPE12 Winter 2009 Joel Ferguson 8-41

Example 4: X3117 STR R3,R5,xB R3 = x3451 R5 = x8800 2) Decode x774b CMPE12 Winter 2009 Joel Ferguson 8-42

Example 4: X3117 STR R3,R5,xB R3 = x3451 R5 = x8800 x000b x880b x8800 4) Evaluate Address x774b x880b CMPE12 Winter 2009 Joel Ferguson 8-43

Example 4: X3117 STR R3,R5,xB R3 = x3451 R5 = x8800 x3451 ALU told to AND. AND(x3451,x3451) = x3451 4) Fetch Operands x3451 x880b CMPE12 Winter 2009 Joel Ferguson 8-44

Example 4: X3117 STR R3,R5,xB R3 = x3451 R5 = x8800 5) Execute (none) x3451 CMPE12 Winter 2009 Joel Ferguson 8-45

Example 4: X3117 STR R3,R5,xB R3 = x3451 R5 = x8800 mem[x880b]<-x3451 6) Store Results x3451 CMPE12 Winter 2009 Joel Ferguson 8-46

Recommended and Homework exercises: Ex 4.8, 4.10 Ex 4.13 and 4.16 (a little bit more advanced) To Turn in Feb 11: For the instruction LD R1, NAME, show the Evaluate Address phase of the instruction by showing the inputs and outputs of the Effective Address Computation Units. Instruction at x3010 NAME at x3025 CMPE12 Winter 2009 Joel Ferguson 8-47