CSc 256 Midterm 2 Fall 2011

Similar documents
CSc 256 Midterm 2 Spring 2012

CSc 256 Midterm (green) Fall 2018

CSc 256 Final Fall 2016

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

MIPS Reference Guide

TSK3000A - Generic Instructions

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

Computer Architecture. The Language of the Machine

Examples of branch instructions

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

Flow of Control -- Conditional branch instructions

MIPS Instruction Set

M2 Instruction Set Architecture

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

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

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

The MIPS Instruction Set Architecture

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

Week 10: Assembly Programming

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

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

Reduced Instruction Set Computer (RISC)

Mips Code Examples Peter Rounce

CS 351 Exam 2 Mon. 11/2/2015

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

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

Reduced Instruction Set Computer (RISC)

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

Adventures in Assembly Land

MIPS Assembly Language Programming

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

MIPS Assembly Language. Today s Lecture

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 One 22 September Your Name (please print clearly) Signed.

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

Exam in Computer Engineering

MIPS Assembly Language

The MIPS R2000 Instruction Set

CPS311 - COMPUTER ORGANIZATION. A bit of history

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

INSTRUCTION SET COMPARISONS

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

Introduction to MIPS Processor

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

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

Programming the processor

EE108B Lecture 3. MIPS Assembly Language II

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

Laboratory Exercise 6 Pipelined Processors 0.0

Final Project: MIPS-like Microprocessor

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

Assembly Programming

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

Project Part A: Single Cycle Processor

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

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

Midterm Questions Overview

Lec 10: Assembler. Announcements

MIPS%Assembly% E155%

ece4750-parc-isa.txt

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

CSEN 601: Computer System Architecture Summer 2014

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

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

CS 4200/5200 Computer Architecture I

ECE260: Fundamentals of Computer Engineering

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

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

Computer Architecture. MIPS Instruction Set Architecture

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

ECE260: Fundamentals of Computer Engineering

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

Concocting an Instruction Set

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 Spring problems, 8 pages Final Exam 29 April 2015

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

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

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

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

Midterm Questions Overview

Concocting an Instruction Set

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

CENG 3420 Lecture 06: Datapath

RTL Model of a Two-Stage MIPS Processor

IMPLEMENTATION MICROPROCCESSOR MIPS IN VHDL LAZARIDIS DIMITRIS.

CS 61c: Great Ideas in Computer Architecture

ECE 15B Computer Organization Spring 2010

Midterm. CS64 Spring Midterm Exam

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

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

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

CMPE324 Computer Architecture Lecture 2

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Transcription:

CSc 256 Midterm 2 Fall 2011 NAME: 1a) You are given a MIPS branch instruction: x: beq $12, $0, y The address of the label "y" is 0x400468. The memory location at "x" contains: address contents 0x40049c 000100 01100 00000????????????????... which represents the beq instruction. Find the 16- bit constant indicated by the????. (12 points) ANS: BTA = &beq + 4 + offset 0x400468 = 0x4004a0 + 4 + offset offset = 0x400468 0x4004a4 = 0x400468 + 0xffbf fb60 = 0xffff ffc8 = 1111 1111 1111 1111 1111 1111 1100 1000 16- bit constant = 1111 1111 1111 0010 1b) You are given this MIPS assembly language instruction (i.e., pseudo- instruction): lb $23, 0x10010014($11) 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. ANS: Lui $1, 0x1001 Add $1, $1, $11 Lb $23, 0x14($1)

1c) This is a memory location that contains a MIPS instruction: address [0x00400024] contents 0x0067a820 Translate it into the MIPS assembly language instruction (show the operation, operands, etc): (13 points) ANS: add $21, $3, $7 0x0067a820 = 0000 0000 0110 0111 1010 1000 0010 0000 opcode = 0 (R- format) rs = 00011 rt = 00111 rd = 10101 FUNC code: add

Problem 2: Consider this digital logic circuit:

a) Fill out an equivalent truth table for the circuit. (14 points) X2 X1 X0 Y 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 0 b) Write an equivalent logic expression for output y, in sum of products form. (6 points) y = ~x2~x1x0 + ~x2x1x0 + x2~x1~x0 + x2~x1x0

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) [SelE: branch, SelF: RegDst, SelG: AlUSrc, SelH: MemToReg] a) sw SelE SelF SelG SelH MemRead MemWrite RegWrite ALUOp1 ALUOp0 0 x 1 x 0 1 0 0 0 b) R-format SelE SelF SelG SelH MemRead MemWrite RegWrite ALUOp1 ALUOp0 0 1 0 0 x 0 1 1 0

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 250 ps 250 ps T A ps 400 ps 400 ps a) We are given that the time taken for a sw to complete (i.e., the latency of the sw) is 1250 ps. Solve for T A. (8 points) 1250 = 400 (IF) + 250 (ID) + T A (EX) + 400 (MEM) = 1050 + T A T A = 1250 = 1050 = 200 ps b) How much time does a lw take to complete? (6 points) latency for lw = 400 (IF) + 250 (ID) + 200 (EX) + 400 (MEM) + 250 (WB) = 1500 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 in Hz = 1 / 1500 ps = 10^12 / 1500 Hz Clock rate in MHz = 10^-6 * 10^12 / 1500 = 10^6/1500 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