CSc 256 Midterm 2 Spring 2012

Similar documents
CSc 256 Midterm 2 Fall 2011

CSc 256 Final Fall 2016

CSc 256 Midterm (green) Fall 2018

CSc 256 Final Spring 2011

MIPS Instruction Format

CSc 256 Midterm 1 Fall 2011

MIPS Instruction Reference

F. Appendix 6 MIPS Instruction Reference

ECE Exam I February 19 th, :00 pm 4:25pm

SPIM Instruction Set

TSK3000A - Generic Instructions

MIPS Reference Guide

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Computer Architecture. The Language of the Machine

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

Flow of Control -- Conditional branch instructions

Examples of branch instructions

Week 10: Assembly Programming

Q1: /30 Q2: /25 Q3: /45. Total: /100

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

MIPS Instruction Set

Midterm. Sticker winners: if you got >= 50 / 67

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

M2 Instruction Set Architecture

Reduced Instruction Set Computer (RISC)

Mips Code Examples Peter Rounce

The MIPS Instruction Set Architecture

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

The MIPS R2000 Instruction Set

Adventures in Assembly Land

MIPS Assembly Language Programming

MIPS Assembly Language

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

Reduced Instruction Set Computer (RISC)

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

Exam in Computer Engineering

Programming the processor

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

CPS311 - COMPUTER ORGANIZATION. A bit of history

CS 351 Exam 2 Mon. 11/2/2015

4. What is the average CPI of a 1.4 GHz machine that executes 12.5 million instructions in 12 seconds?

MIPS Assembly Language. Today s Lecture

Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Introduction to MIPS Processor

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

INSTRUCTION SET COMPARISONS

Assembly Programming

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

Lec 10: Assembler. Announcements

Kernel Registers 0 1. Global Data Pointer. Stack Pointer. Frame Pointer. Return Address.

ece4750-parc-isa.txt

Final Project: MIPS-like Microprocessor

Project Part A: Single Cycle Processor

CSEN 601: Computer System Architecture Summer 2014

EE108B Lecture 3. MIPS Assembly Language II

MIPS%Assembly% E155%

Review: Organization. CS152 Computer Architecture and Engineering Lecture 2. Review of MIPS ISA and Design Concepts

CS 4200/5200 Computer Architecture I

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015

Computer Architecture. MIPS Instruction Set Architecture

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ECE 15B Computer Organization Spring 2010

MIPS Coding Snippets. Prof. James L. Frankel Harvard University. Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved.

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

RTL Model of a Two-Stage MIPS Processor

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Midterm. CS64 Spring Midterm Exam

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 9 December 2015

Midterm Questions Overview

ECE260: Fundamentals of Computer Engineering

CS 61c: Great Ideas in Computer Architecture

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

Laboratory Exercise 6 Pipelined Processors 0.0

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016

ECE260: Fundamentals of Computer Engineering

Concocting an Instruction Set

We will study the MIPS assembly language as an exemplar of the concept.

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

CSEE W3827 Fundamentals of Computer Systems Homework Assignment 3 Solutions

MACHINE LANGUAGE. To work with the machine, we need a translator.

Computer Organization & Design

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

CS3350B Computer Architecture Quiz 3 March 15, 2018

CENG 3420 Lecture 06: Datapath

CMPE324 Computer Architecture Lecture 2

Transcription:

CSc 256 Midterm 2 Spring 2012 NAME: 1a) You are given this MIPS assembly language instruction (i.e., pseudo- instruction): ble $12, 0x20004880, there Translate this MIPS instruction to an efficient sequence of machine language instructions. You only have to show the text form of the machine language instructions; don't translate into binary. Leave the branch target as the label there; don t worry about calculating its address etc. ANS: lui $1, 0x2000 ori $1, $1, 0x4881 slt $1, $12, $1 bne $1, $0, there 1b) This is a memory location that contains a MIPS instruction: address [0x00400024] contents 0x00e28824 Translate it into the MIPS assembly language instruction (show the operation, operands, etc): (13 points) ANS: and $17, $7, $2

1c) You are given a MIPS branch instruction: x: beq $12, $0, y The address of the label "y" is 0x4006e4. The memory location at "x" contains: address contents?????? 000100 01100 00000 1111 1111 0011 0101... which represents the beq instruction. Find the address of the label x. (12 points) ANS: 0x400a0c [Work:] BTA = &branch + 4 + offset Offset = 1111 1111 1111 1111 1111 1100 1101 0100 0x4006e4 = &x + 4 + 0xfffffcd4 &x = 0x4006e4 0xffff fcd8 = 0x4006e4 + 0x328 = 0x400a0c

Problem 2: a) Consider this digital logic circuit: Fill out an equivalent truth table for the circuit. (12 points) X2 X1 X0 Y 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1

b) Fill out a truth table for this digital logic circuit. (8 points) X1 X0 Y 0 0 1 0 1 0 1 0 1 1 1 1

Problem 3: Refer to the MIPS single-cycle datapath in the sheets provided. Show the control signals for the MIPS instructions, in the table below. Note that some of the control signals have new names. (30 points) Hint: ALUOp control bits are 00 (force ALU to add), 01 (force ALU to subtract), 10 (follow operation specified by bits 5-0 of instruction word) [SelA is ALUSrc, SelB is RegDst, SelC is branch, SelD is MemToReg] a) beq MemRead MemWrite SelA SelB SelC SelD ALUOp1 ALUOp0 RegWrite X 0 0 x 1 x 0 1 0 b) lw MemRead MemWrite SelA SelB SelC SelD ALUOp1 ALUOp0 RegWrite 1 0 1 0 0 1 0 0 1

Problem 4: For the MIPS single-cycle datapath given, suppose we build a new implementation using different technology. These are the latencies through the main components: Register Read Register Write ALU operation Memory Read Memory Write T R ps T R ps 300 ps 600 ps 600 ps a) We are given that the time taken for an R-type instruction to complete (i.e., the latency of the R-type instruction) is 1200 ps. Solve for T R. (8 points) 1200 ps = 600 + T R + 300 + T R 2 T R = 300 T R = 150 ps b) How much time does a lw take to complete? (6 points) lw latency = 600 + 150 + 300 + 600 + 150 = 1800 ps

c) What is the clock rate in MHz for this new MIPS implementation? You don t have to give the actual number as the answer; just show an equation that can be solved to get the clock rate in MHz. (Hint: 1 ps = 10^-12 seconds, 1 ns = 10^-9 seconds, 1 MHz = 10^6 Hz.) (6 points) ANS: Clock rate = 1 / (1800 * 10^-12) Hz = 10^12 / 1800 Hz = 10^6 / 1800 MHz

MIPS instructions op1, op2 are registers, op3 is register or constant cont[op1] means contents of op1 move op1, op2 cont[op1] = cont[op2] add op1, op2, op3 cont[op1] = cont[op2] + cont[op3] sub op1, op2, op3 cont[op1] = cont[op2] - cont[op3] mul op1, op2, op3 cont[op1] = cont[op2] * cont[op3] div op1, op2, op3 cont[op1] = cont[op2] / cont[op3] rem op1, op2, op3 cont[op1] = cont[op2] % cont[op3] not op1, op2 cont[op1] = not cont[op2] (bitwise) and op1, op2, op3 cont[op1] = cont[op2] and cont[op3] (bitwise) or op1, op2, op3 cont[op1] = cont[op2] or cont[op3] (bitwise) nand op1, op2, op3 cont[op1] = cont[op2] nand cont[op3] (bitwise) nor op1, op2, op3 cont[op1] = cont[op2] nor cont[op3] (bitwise) xor op1, op2, op3 cont[op1] = cont[op2] xor cont[op3] (bitwise) sll op1, op2, AMT cont[op1] = cont[op2] shift left logical by AMT bits srl op1, op2, AMT cont[op1] = cont[op2] shift right logical by AMT bits sra op1, op2, AMT cont[op1] = cont[op2] shift right arithmetic by AMT bits rol op1, op2, AMT cont[op1] = cont[op2] rotate left by AMT bits ror op1, op2, AMT cont[op1] = cont[op2] rotate right by AMT bits b label j label beq op1, op2, label bne op1, op2, label bgt op1, op2, label bge op1, op2, label blt op1, op2, label ble op1, op2, label beqz op1, label bnez op1, label bgtz op1, label bgez op1, label bltz op1, label blez op1, label la R, label li R, constant lw R,?? goto label goto label if (cont[op1]==cont[op2]) goto label if (cont[op1]!=cont[op2]) goto label if (cont[op1]>cont[op2]) goto label if (cont[op1]>=cont[op2]) goto label if (cont[op1]<cont[op2]) goto label if (cont[op1]<=cont[op2]) goto label if (cont[op1]==0) goto label if (cont[op1]!=0) goto label if (cont[op1]>0) goto label if (cont[op1]>=0) goto label if (cont[op1]<0) goto label if (cont[op1]<=0) goto label cont[r] = address of label cont[r] = constant cont[r] = M[ADDR]

lb R,?? lbu R,?? sw R,?? sb R,?? cont[r] = m[addr], sign- extended cont[r] = m[addr], zero- extended M[ADDR] = cont[r] m[addr] = low 8- bits of cont[r] if?? is a label, ADDR = address of label if?? is (R), ADDR = cont[r] if?? is constant(r), ADDR = cont[r] + constant if?? is label(r), ADDR = cont[r] + address of label mtc0 op1, op2 contents of coprocessor 0 register op1 = contents of MIPS register op2 mfc0 op1, op2 contents of MIPS register op1 = contents of coprocessor 0 register op2 Syscall usage: print an int $v0=1, $a0=int to be printed print a string $v0=4, $a0=address of string to be printed read an int $v0=5, input int appears in $v0 exit $v0=10 MIPS register names: $0 $1 $2,$3 $v0,$v1 $4 - $7 $a0 - $a3 $8 - $15 $t0 - $t7 $16 - $23 $s0 - $s7 $24 - $25 $t8 - $t9 $26 - $27 $k0 - $k1 $28 $gp $29 $sp $30 $s8 $31 $ra

0000 00ss ssst tttt dddd d000 0010 0000 add rd,rs,rt 0000 00ss ssst tttt dddd d000 0010 0010 sub rd,rs,rt 0000 00ss ssst tttt 0000 0000 0001 1000 mult rs,rt 0000 00ss ssst tttt 0000 0000 0001 1010 div rs,rt 0000 00ss ssst tttt dddd d000 0010 0001 addu rd,rs,rt 0000 00ss ssst tttt dddd d000 0010 0011 subu rd,rs,rt 0000 00ss ssst tttt 0000 0000 0001 1001 multu rs,rt 0000 00ss ssst tttt 0000 0000 0001 1011 divu rs,rt 0000 0000 0000 0000 dddd d000 0001 0000 mfhi rd 0000 00ss sss0 0000 0000 0000 0001 0001 mthi rs 0000 0000 0000 0000 dddd d000 0001 0010 mflo rd 0000 00ss sss0 0000 0000 0000 0001 0011 mtlo rs 0000 00ss ssst tttt dddd d000 0010 0100 and rd,rs,rt 0000 00ss ssst tttt dddd d000 0010 0111 nor rd,rs,rt 0000 00ss ssst tttt dddd d000 0010 0101 or rd,rs,rt 0000 00ss ssst tttt dddd d000 0010 0110 xor rd,rs,rt 0000 00ss ssst tttt dddd d000 0000 0100 sllv rd,rt,rs 0000 00ss ssst tttt dddd d000 0000 0110 srlv rd,rt,rs 0000 00ss ssst tttt dddd d000 0000 0111 srav rd,rt,rs 0010 00ss ssst tttt iiii iiii iiii iiii addi rt,rs,i 0010 01ss ssst tttt iiii iiii iiii iiii addiu rt,rs,i 0011 00ss ssst tttt iiii iiii iiii iiii andi rt,rs,i 0011 1100 000t tttt iiii iiii iiii iiii lui rt,i 0011 01ss ssst tttt iiii iiii iiii iii ori rt,rs,i 0011 10ss ssst tttt iiii iiii iiii iiii xori rt,rs,i 0000 0000 000t tttt dddd diii ii00 0000 sll rd,rt,i 0000 0000 000t tttt dddd diii ii00 0010 srl rd,rt,i 0000 0000 000t tttt dddd diii ii00 0011 sra rd,rt,i 1000 11bb bbbt tttt iiii iiii iiii iiii lw rt,i(rb) 1000 00bb bbbt tttt iiii iiii iiii iiii lb rt,i(rb) 1001 00bb bbbt tttt iiii iiii iiii iiii lbu rt,i(rb) 1010 11bb bbbt tttt iiii iiii iiii iiii sw rt,i(rb) 1010 00bb bbbt tttt iiii iiii iiii iiii sb rt,i(rb) 0000 01ss sss0 0000 iiii iiii iiii iiii bltz rs,i 0000 01ss sss0 0001 iiii iiii iiii iiii bgez rs,i 0001 10ss sss0 0000 iiii iiii iiii iiii blez rs,i 0001 11ss sss0 0000 iiii iiii iiii iiii bgtz rs,i 0001 00ss ssst tttt iiii iiii iiii iiii beq rs,rt,i

0001 01ss ssst tttt iiii iiii iiii iiii bne rs,rt,i 0000 00ss ssst tttt dddd d000 0010 1010 slt rd,rs,rt 0010 10ss ssst tttt iiii iiii iiii iiii slti rt,rs,i 0000 10ii iiii iiii iiii iiii iiii iiii j I 0000 00ss sss0 0000 0000 0000 0000 1000 jr rs 0000 11ii iiii iiii iiii iiii iiii iiii jal I 0000 00ss sss0 0000 dddd d000 0000 1001 jalr rd,rs 0000 0000 0000 0000 0000 0000 0000 1100 syscall