Question 1 (10 points):

Similar documents
Solutions. Solution The values of the signals are as follows:

Computer Organization and Components

Computer organization

Design of Digital Circuits (SS16)

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December :59

Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm

Review: MIPS Addressing Modes/Instruction Formats

Pipeline Hazards. Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by Arvind and Krste Asanovic

Central Processing Unit (CPU)

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Instruction Set Architecture

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern:

Reduced Instruction Set Computer (RISC)

CS352H: Computer Systems Architecture

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

A FPGA Implementation of a MIPS RISC Processor for Computer Architecture Education

(Refer Slide Time: 00:01:16 min)

CPU Organisation and Operation

OAMulator. Online One Address Machine emulator and OAMPL compiler.

Chapter 2 Logic Gates and Introduction to Computer Architecture

MICROPROCESSOR AND MICROCOMPUTER BASICS

Instruction Set Design

Systems I: Computer Organization and Architecture

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Computer Organization and Components

Typy danych. Data types: Literals:

PROBLEMS #20,R0,R1 #$3A,R2,R4

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway

MIPS Assembler and Simulator

Introducción. Diseño de sistemas digitales.1

WAR: Write After Read

Notes on Assembly Language

CHAPTER 11: Flip Flops

Summary of the MARIE Assembly Language

PROBLEMS (Cap. 4 - Istruzioni macchina)

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

CHAPTER 7: The CPU and Memory

PROBLEMS. which was discussed in Section

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1

Chapter 5 Instructor's Manual

CSE140 Homework #7 - Solution

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

EE282 Computer Architecture and Organization Midterm Exam February 13, (Total Time = 120 minutes, Total Points = 100)

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997

1 Classical Universal Computer 3

PART B QUESTIONS AND ANSWERS UNIT I

Instruction Set Architecture (ISA)

The Little Man Computer

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

CPU Organization and Assembly Language

PCSpim Tutorial. Nathan Goulding-Hotta v0.1

Execution Cycle. Pipelining. IF and ID Stages. Simple MIPS Instruction Formats

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Figure 1: Graphical example of a mergesort 1.

Microprocessor & Assembly Language

Design: a mod-8 Counter

Decimal Number (base 10) Binary Number (base 2)

A SystemC Transaction Level Model for the MIPS R3000 Processor

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Generating MIF files

Week 1 out-of-class notes, discussions and sample problems

VLIW Processors. VLIW Processors

Z80 Instruction Set. Z80 Assembly Language

CHAPTER IX REGISTER BLOCKS COUNTERS, SHIFT, AND ROTATE REGISTERS

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

Preface. Any questions from last time? A bit more motivation, information about me. A bit more about this class. Later: Will review 1st 22 slides

Chapter 9 Computer Design Basics!

EE361: Digital Computer Organization Course Syllabus

Lecture 8: Binary Multiplication & Division

EC 362 Problem Set #2

The 104 Duke_ACC Machine

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

Systems I: Computer Organization and Architecture

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

Introduction to MIPS Assembly Programming

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

A s we saw in Chapter 4, a CPU contains three main sections: the register section,

Basic Computer Organization

Instruction Set Architecture. Datapath & Control. Instruction. LC-3 Overview: Memory and Registers. CIT 595 Spring 2010

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Intel 8086 architecture

MACHINE ARCHITECTURE & LANGUAGE

The WIMP51: A Simple Processor and Visualization Tool to Introduce Undergraduates to Computer Organization

CSE 141L Computer Architecture Lab Fall Lecture 2

MACHINE INSTRUCTIONS AND PROGRAMS

CS 61C: Great Ideas in Computer Architecture Finite State Machines. Machine Interpreta4on

Translating C code to MIPS

Quiz for Chapter 1 Computer Abstractions and Technology 3.10

We will use the accumulator machine architecture to demonstrate pass1 and pass2.

CSE 141 Introduction to Computer Architecture Summer Session I, Lecture 1 Introduction. Pramod V. Argade June 27, 2005

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

LC-3 Assembly Language

Transcription:

Question 1 (10 points): Write a program that computes t0 t1 and leaves the result in register t2 You can use only the following instructions: addi, add, sub, sll, srl, nand, beq Do not worry about efficiency or following MIPS calling conventions Assume that before your program runs t0 and t1 contain the values you need to multiply Furthermore, you can assume that both t0 and t1 are positive integers Do not worry about overflow ADD $t2, $0, $0 # clear $t2 BEQ $t0, $0, finished # if either operand=0 multiplication gives 0 BEQ $t1, $0, finished loop: ADD $t2, $t2, $t0 # increment $t2 by $t0 ADDi $t1, $t1, -1 # decrement counter ($t1) BEQ $t1, $0, finished # finished if counter reach 0 BEQ $0, $0, loop # continue finished:

Question 2 (10 points): Write a program that computes t0 t1 and leaves the result in register t2 You can use only the following instructions: add, sub, sll, srl, nand, beq Do not worry about efficiency or following MIPS calling conventions Assume that before your program runs t0 and t1 contain the values you need to multiply Furthermore, you can assume that both t0 and t1 are positive integers Do not worry about overflow (Note this question is different than question 1) ADD $t2, $0, $0 # clear $t2 BEQ $t0, $0, finished # if either operand=0 multiplication gives 0 BEQ $t1, $0, finished NAND $t3, $0, $0 # $t3 gets all 1s SLL $3, $3, 31 # erase all higher bit 1s SRL $3, $3, 31 # 1 stored in $t3 loop: ADD $t2, $t2, $t0 # increment $t2 by $t0 SUB $t1, $t1, $t3 # decrement counter ($t1) BEQ $t1, $0, finished # finished if counter reach 0 BEQ $0, $0, loop # continue finished:

Question 3 (10 points): Write a program that computes t0 t1 and leaves the result in register t2 You can use only the following instructions: add, sll, srl, nand, beq Do not worry about efficiency or following MIPS calling conventions Assume that before your program runs t0 and t1 contain the values you need to multiply Furthermore, you can assume that both t0 and t1 are positive integers Do not worry about overflow (Note this question is different than question 2) ADD $t2, $0, $0 # clear $t2 BEQ $t0, $0, finished # if either operand=0 multiplication gives 0 BEQ $t1, $0, finished NAND $t3, $0, $0 # all 1s in reg is equivalent to -1 loop: ADD $t2, $t2, $t0 # increment $t2 by $t0 ADD $t1, $t1, $t3 # decrement counter ($t1) BEQ $t1, $0, finished # finished if counter reach 0 BEQ $0, $0, loop # continue finished:

Question 4 (10 points): Write a program that computes t0 t1 and leaves the result in register t2 You can use only the following instructions: add, sll, srl, nand Do not worry about efficiency or following MIPS calling conventions Assume that before your program runs t0 and t1 contain the values you need to multiply Furthermore, you can assume that both t0 and t1 are positive integers Do not worry about overflow (Note this question is different than question 3) ADD $t2, $0, $0 # $t2 = final result ADD $t5, $0, $0 # repeat 1 SLL $t3, $t1, 31 # get the lowest bit from $t1 SRL $t3, $t3, 31 NAND $t4, $t0, $t3 # 2 NANDs AND NAND $t4, $t4, $t4 ADD $t5, $t4, $t5 # repeat 2 SLL $t3, $t3, 1 NAND $t4, $t0, $t3 NAND $t4, $t4, $t4 ADD $t5, $t4, $t5 # repeat the above 32 times multiplication result of lowest bit of $t1 w/ entire $t0 ADD $t2, $t2, $t5 # update result reg w/ $t5 SLL $t0, $t0, 1 # go on to bit of $t1 need to shift $t0 SLL $t3, $t1, 30 # shift amount each iteration SRL $t3, $t3, 32 # repeat the above 32 repeats 32 times multiplication result of all bits of $t1 w/ entire $t2 eg 0101 $t0 X 101 $t1 0101 $t5: mult result of t1 s lowest bit w/ t0 (32 repeats b/c 32 bits in reg) 0000 second bit 0101 third bit 011001 $t2

Question 5 (20 points): Modify the following machine to support the following new instruction: JRLZ It stands for Jump-to-register if less than zero The instruction is used in assembly like (as an example): jrlz $t0, $t1 The result of the instruction is to cause the machine to branch to the address specified in $t0 if $t1 is less than zero components to add: [2:1] mux AND gate SLL component PC+4 addr and $t0 addr (after SLL by 2 to get actual inst addr) are selected through a mux and fed into the PC component as next instruction addr The mux-select bit is from an AND gate that ANDs the output of ALU (is $t1 < 0?) with instruction op (is inst JRLZ?)

Question 6 (20 points): The following diagram looks a lot like Lab 1, but is subtly different Explain how to make this processor support loads and stores Write the control signals required to do this and explain their operation It takes 2 cycles to carry out either LW or SW: 1 fetch instruction 2 execute instruction LW On Fetch PCWriteCond: 0 PCWrite: 1 MemRead: 1 MemWrite: 0 MemtoReg: 0 IRWrite: 1 PCSource: 0 ALUsrcB: 1 ALUsrcA: 0 RegWrite: 0 On Execute PCWrite: 0 MemRead: 1 MemWrite: 0 MemtoReg: 1 IRWrite: 0 ALUsrcB: 0 ALUsrcA: 1 RegWrite: 1 RegDst: 0 SW PCWriteCond: 0 PCWrite: 1 MemRead: 1 MemWrite: 0 MemtoReg: 0 IRWrite: 1 PCSource: 0 ALUsrcB: 1 ALUsrcA: 0 RegWrite: 0 PCWrite: 0 MemRead: 0 MemWrite: 1 MemtoReg: 0 IRWrite: 0 ALUsrcB: 0 ALUsrcA: 1 RegWrite: 0

Question 7 (20 points): Suppose the following instructions were fetched: add $t1, $t3, $t4 lw $t0, 0($t1) beq $t0, $t2, somewhere Suppose the lw instruction is in the memory stage Draw on the diagram where the beq and add instructions are (which stage) Label all forwarding networks that are being used in that clock cycle and indicate what data values are being forwarded It is possible you will have to modify the diagram to support your answer and make the processor properly execute If this is the case, draw these modifications too BEQ LW ADD Add a mux that outputs to the comparator: input = select between datamem output or regfile output mux-select bit = output from the forwarding unit that recognizes LW/BEQ dependence