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

Similar documents
UNIVERSITY OF WISCONSIN MADISON

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

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

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

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

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

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

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

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

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

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

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

appendix a The LC-3 ISA A.1 Overview

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

CS 2461: Computer Architecture I

Trap Vector Table. Interrupt Vector Table. Operating System and Supervisor Stack. Available for User Programs. Device Register Addresses

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

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

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

CS/ECE 252 Introduction to Computer Engineering

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

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

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

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

LC-3 Instruction Set Architecture

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

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

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

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

EEL 5722C Field-Programmable Gate Array Design

Instruction Set Architecture

LC-3 Instruction Set Architecture. Textbook Chapter 5

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

COSC121: Computer Systems: Review

COSC121: Computer Systems: Review

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

Computing Layers. Chapter 5 The LC-3

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

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

Memory Usage in Programs

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

Logistics. IIT CS 350 S '17 - Hale

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

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

Chapter 4 The Von Neumann Model

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

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

Lab 1. Warm-up : discovering the target machine, LC-3

Review Topics. Midterm Exam Review Slides

Chapter 4 The Von Neumann Model

Review Topics. Midterm Exam Review Slides

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

Chapter 4 The Von Neumann Model

LC-3 Instruction Processing

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

Microprogrammed Control. ECE 238L μseq 2006 Page 1

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

UNIVERSITY OF WISCONSIN MADISON

LC-2 Programmer s Reference and User Guide

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

CS 135: Computer Architecture I

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

컴퓨터개념및실습. 기말고사 review

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

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

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

ECE/CS 252 Fall 2011 Homework 4 (25 points) // Due in Lecture Mon Oct. 17, 2011

Fill in your name, section, and username. DO NOT OPEN THIS TEST UNTIL YOU ARE TOLD TO DO SO.

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

11/29/2016. ECE 120: Introduction to Computing. Microinstruction Branch Conditions for LC-3. LC-3 State Transition Diagram Has Few Outgoing Arcs

Chapter 9 Computer Design Basics

That is, we branch to JUMP_HERE, do whatever we need to do, and then branch to JUMP_BACK, which is where we started.

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Review Topics. parameter passing, memory model)

LC-3 Architecture. (Ch4 ish material)

CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK

University of Toronto Mississauga. Flip to the back cover and write down your name and student number.

ECE 109 Sections 602 to 605 Final exam Fall December, 2007

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

EE 3170 Microcontroller Applications

Chapter 10 Computer Design Basics

DC57 COMPUTER ORGANIZATION JUNE 2013

ISA Instruction Operation

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

Chapter 5: The Processor: Datapath and Control

Midterm 2 Review Chapters 4-16 LC-3

Register-Level Design

SISTEMI EMBEDDED. Computer Organization Central Processing Unit (CPU) Federico Baronti Last version:

Major and Minor States

Mapping Control to Hardware

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Initial Representation Finite State Diagram. Logic Representation Logic Equations

Universiteit Leiden Opleiding Informatica

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

UNIVERSITY OF WISCONSIN MADISON

The Assembly Language of the Boz 5

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Inf2C - Computer Systems Lecture Processor Design Single Cycle

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

The LC3's micro-coded controller ("useq") is nothing more than a finite-state machine (FSM). It has these inputs:

Computer Architecture Programming the Basic Computer

Transcription:

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Instructor: Rahul Nayar TAs: Annie Lin, Mohit Verma Examination 2 In Class (50 minutes) Wednesday, March 8, 207 Weight: 7.5% NO: BOOK(S), NOTE(S), CALCULATORS OR ELECTRONIC DEVICES OF ANY SORT. The exam has ten pages. You must turn in the pages -9. Circle your final answers. Plan your time carefully since some problems are longer than others. Use the blank sides of the exam for scratch work. LAST NAME: FIRST NAME: ID#:

Problem Maximum Points Points Earned 4 2 6 3 3 4 5 5 4 6 2 7 4 8 5 9 5 Total 38 2

. Figure shows the output of a transistor-level circuit connected to the select line of a 2-input multiplexer. Figure Fill out the following truth table for the overall circuit. (Note: ~A means NOT(A)). Fill all 8 rows. (4 points) A B C S Y 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3

2. Consider the logic equation Z = NOT(A OR NOT (B AND NOT (NOT A AND NOT C))) a) Using DeMorgan s law, simplify the logic equation for Z to reduce the number of NOT gates to one. Show your work for full credit. (Solutions using more than one NOT gate will receive only partial credit.) (3 points) Z = NOT (A OR NOT (B AND (A OR C) ) ) = NOT (A) AND B AND (A OR C) = (NOT (A) AND B AND C ) OR (NOT (A) AND B AND A) = NOT (A) AND B AND C (because NOT (A) AND A = 0 and 0 OR X = X ) b) Fill out the following truth table for Z. (2 points) A B C Z 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c) Draw the logic gate diagram for the simplified equation obtained in part a) above using NOT and AND gates only. You can use AND gates with any number of inputs. ( point) 4

3. a) An architecture has the following format for a 6-bit ISA. Given that all the fields are of equal length, what is the maximum number of Opcodes the ISA can represent? ( point) Opcode Destination Register Source Register Source Register 2 6/4 = 4. So 2^4 = 6 opcodes b) The PC-relative load instruction of a certain LC-3 like 6-bit ISA has the following format: Load Opcode (4 bits) Destination Register (3-bits) PC-offset (9-bits) If this instruction resides in memory at location 0x3000, what is the range of memory locations that can it can address when it is executed? Assume 2 s complement representation. (2 points) PC = x3000 + x = x300 Offset = 9 bits. So, 52 max locations can be represented. 2 s complement => -256 to +255 So, from 0x2F0 to 0x300 4. Answer the short answer questions below. a) In LC3, what is the difference between a jump and a branch instruction? Describe at least one way that they are the same and one way that they are different. ( point) They are both control instructions that can change the PC value, but jumps are unconditional and branches generally have conditions attached to them. b) True or false: a single LD instruction can be used to load from a memory location that is 00 locations away from the current PC. ( point) True 5

c) Match each of the descriptions below to the appropriate terms. Each definition will have only one answer. Possible terms: IR, ALU, Fetch Instruction, MDR, Execute Operation, Decode Instruction, Driver, Algorithm, Abstraction (2 points) MDR Decode Fetch Driver Register that contains the data to write to memory or read from memory Instruction processing state that identifies the opcode and other operands PC is always incremented in this instruction processing state Program that controls access to a device d) A decoder has 024 outputs. How many inputs does it have? ( point) Log 2 (024) = 0 inputs 5. In the von Neumann model, the control unit orchestrates execution of a program Figure 2 a) What do IR and PC stand for? What do they do? (2 points) IR (instruction register): contains the current instruction PC (program counter): contains address of next instruction to be executed b) Given the six steps of instruction processing, put them into the correct order. Write the numbers -6 next to the appropriate instructions, with being the first and 6 being the last. (2 points) Fetch instruction from memory 4 Fetch operands from memory 6 Store result 5 Execute operation 2 Decode instruction 3 Evaluate address 6

6. Figure 3 shows a -bit half adder, and a 2-to-4 decoder with the same inputs A and B. You have one 3-input OR gate, and one 2-input AND gate. Label the inputs of the given OR and AND gates in terms of the output of the decoder (C, D, E or F), to realize a -bit half adder. Clearly label the outputs of the two gates to show which gate outputs Sum and which gate outputs C out. (Note: You can also use the signals 0 and as any input, if needed). (2 points) Figure 3 C or 0 D E Sum F C out 7. a) An R-S latch is shown in Figure 4. Given that out is initially set to 0, fill out the following table. (2 points) Time 0 2 3 4 5 6 R NONE 0 0 S NONE 0 OUT 0 0 0 0 0 0 Figure 4 7

b) A gated D-latch adds two inputs, D and WE, to an RS-latch to decide when to set or keep memory. Describe how do we combine multiple gated D-latches to make a register? (2 points) Registers are a collection of gated D-latches that are controlled by a common WE. Each D-latch stores bit, and when WE =, an n-bit D-value is written to the register 8. Figure 5 shows the steps required to execute a certain LC-3 instruction. Figure 5 a) What is the instruction (ex. ADD, LD)? ( point) STR b) Suppose that we know A has a value of xfffd, B holds a value of x234, and C has a value of x2345. Is it possible to write out the instruction in its LC-3 6-bit binary format? If yes, write the instruction. If not, explain why. ( point) No because LC-3 requires you to know the register numbers but that information is not provided. 0 XXX XXX 0 c) Using the values from part (b), what are the final values stored in D, E, and F? Write your answers in hex. Explain your answers for full credit. (3 points) D = A + C 0 + 000 00 000 00 --------------------- 000 00 000 000 E = 0x234 (same as B because we re copying the data stored in that register) F = 0x234 (same as E because we moved the data in there) 8

9. a) Draw a finite state machine (FSM) that has four states (00, 0, 0, and ) and a -bit input. It should have the following transitions: (3 points) i) Input of 0 changes state from 00 to 0. ii) Input of at state 00 does not change the state. iii) Input of changes state from 0 to 0. iv) Input of 0 at state 0 does not change the state. v) Input of changes state from 0 to. vi) Input of 0 changes state from to 0. 00 0 0 00 0 0 0 0 An alternative solution is to have the transition from 0 to on an input of 0, instead of the transition to from 0 to 0 on input of 0, as shown above. b) Add extra transitions in your FSM above to satisfy the following condition: Given that the start state is 00, your FSM should finish at state at the end of ALL the following bit sequences: (2 points) i) 0, 0, 0. ii) 0, 000, 00000. Clearly indicate the additional lines you added in step b). ßTransitions in red 9

LC-3 Instruction Set (Entered by Mark D. Hill on 03/4/2007; last update 03/5/2007) PC : incremented PC. setcc(): set condition codes N, Z, and P. mem[a]:memory contents at address A. SEXT(immediate): sign-extend immediate to 6 bits. ZEXT(immediate): zero-extend immediate to 6 bits. 5 4 3 2 0 9 8 7 6 5 4 3 2 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ ADD DR, SR, SR2 ; Addition 0 0 0 DR SR 0 0 0 SR2 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß SR + SR2 also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ ADD DR, SR, imm5 ; Addition with Immediate 0 0 0 DR SR imm5 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß SR + SEXT(imm5) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ AND DR, SR, SR2 ; Bit-wise AND 0 0 DR SR 0 0 0 SR2 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß SR AND SR2 also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ AND DR,SR,imm5 ; Bit-wise AND with Immediate 0 0 DR SR imm5 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß SR AND SEXT(imm5) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ BRx,label (where x={n,z,p,zp,np,nz,nzp}); Branch 0 0 0 0 n z p PCoffset9 GO ß ((n and N) OR (z AND Z) OR (p AND P)) +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ if(go is true) then PCßPC + SEXT(PCoffset9) +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ JMP BaseR ; Jump 0 0 0 0 0 BaseR 0 0 0 0 0 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ PC ß BaseR +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ JSR label ; Jump to Subroutine 0 0 0 PCoffset +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ R7 ß PC, PC ß PC + SEXT(PCoffset) +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ JSRR BaseR ; Jump to Subroutine in Register 0 0 0 0 0 0 BaseR 0 0 0 0 0 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ temp ß PC, PC ß BaseR, R7 ß temp +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LD DR, label ; Load PC-Relative 0 0 0 DR PCoffset9 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß mem[pc + SEXT(PCoffset9)] also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LDI DR, label ; Load Indirect 0 0 DR PCoffset9 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DRßmem[mem[PC +SEXT(PCoffset9)]] also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LDR DR, BaseR, offset6 ; Load Base+Offset 0 0 DR BaseR offset6 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß mem[baser + SEXT(offset6)] also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ LEA, DR, label ; Load Effective Address 0 DR PCoffset9 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß PC + SEXT(PCoffset9) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ NOT DR, SR ; Bit-wise Complement 0 0 DR SR +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ DR ß NOT(SR) also setcc() +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ RET ; Return from Subroutine 0 0 0 0 0 0 0 0 0 0 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ PC ß R7 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ RTI ; Return from Interrupt 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ See textbook (2 nd Ed. page 537). +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ ST SR, label ; Store PC-Relative 0 0 SR PCoffset9 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ mem[pc + SEXT(PCoffset9)] ß SR +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ STI, SR, label ; Store Indirect 0 SR PCoffset9 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ mem[mem[pc + SEXT(PCoffset9)]] ß SR +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ STR SR, BaseR, offset6 ; Store Base+Offset 0 SR BaseR offset6 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ mem[baser + SEXT(offset6)] ß SR +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ TRAP ; System Call 0 0 0 0 trapvect8 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ R7 ß PC, PC ß mem[zext(trapvect8)] +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ ; Unused Opcode 0 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Initiate illegal opcode exception 5 4 3 2 0 9 8 7 6 5 4 3 2 0 0