









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Open book, open notes. No laptops, PDAs, cell phones, etc. (calculators are ok). Questions vary in difficulty; it is strongly recommended that you do not spend too much time on any one question. For questions where a box is provided, please put your final answer in the box.
The rules of the Honor Code of the University of Michigan - College of Engineering apply for this exam. Honor code pledge: “I have neither given nor received aid on this examination, nor have I concealed any violations of the Honor Code”.
Signature: ________________________________ (Exams without a signed pledge will not be graded)
Question Score/Point value
Short questions
Design questions
1. Cache design options [3 pts]
Given a program, SearchIt , with the following characteristics:
40% lw, 10% sw, 30% R-type, 20% beq lw’s have high spatial locality but low temporal locality sw’s have low spatial locality but high temporal locality
Ignoring cost and cycle time, which of the following cache design choices would likely lead to
the highest cache hit rate for SearchIt? For each row, circle the best choice of parameter.
Associativity Direct mapped^ Fully associative Not enough info
Block size Large block size^ Small block size Not enough info
Write policy Write through Write back Not enough info
2. Processor performance ranking [4 pts]
Rank order the three LC2k processor design choices (SC = single cycle, MC = multicycle, and P = pipelined) for the cases below. If there is a tie, list multiple choices on the appropriate segment.
CPI: Lowest ____ SC __________ Middle _____ P __________ Highest ______ MC _____
Expected clock rate (hz): Fastest ____ MC,P (tie) _______ Middle ___________ Slowest ______ SC _______
Datapath implementation cost: Cheapest ___ MC ________ Middle _____ SC __________ Costliest _____ P _______
Run a program consisting of 100 branches with a 50% mispredict rate on 100 MHz implementations of each processor:
Fastest _____ SC _________ Middle _____ P _________ Slowest _____ MC _______
5. Memory alignments [4 pts]
SHOW YOUR WORK FOR CREDIT. Consider the following code: struct { char a; struct { char b; struct { char c; double d; } e; } f; } g; Assuming that the first available memory location is at address 100, at which location does:
6. Floating point [4 pts]
SHOW YOUR WORK FOR CREDIT. We designed a new floating point representation, minyFloats. It uses uses only 16 bits assigned as follows: ‐ Sign: 1 bit ‐ Exponent: 6 bits with bias 31 ‐ Mantissa: 9 bits Everything else works exactly as the IEEE floating point format discussed in class. Convert the following floating point value into decimal:
Sign bit is 1, so it is a negative number. Mantissa is 01101, exponent is 100011 (35). -1.01101 * 2 ^ (35-31) = -1.01101 * 2^4 = -10110.1 = -(16 + 4 +2 + 0.5) = -22.
Answer: __________-22.5________________
7. Hard disks [4 pts]
While writing this exam question, Drew found a deal on newegg for a 2TB hard disk drive. The drive is a Seagate Barracuda LP ST32000542AS 2TB 5900 RPM and, according to the spec sheet, it has the following characteristics:
Interface SATA Capacity 2TB RPM 5900 RPM Heads 8 Wait time 5.1ms Seek time 1ms Read rate 3,000 KB/s
On average, how long does it take to read a 30KByte (30*2 10 B) file whose sectors are located contiguously on a same track of the disk? SHOW YOUR WORK FOR CREDIT
5.1ms + 1ms + 30 KB / ( 3000 KB/s * 0.001 s/ms ) = 5.1ms + 1ms + 10ms = 16.1ms
Answer: __________________________
9. Instruction set architecture [7 pts]
A new processor, TinyC, optimized for low energy consumption, has recently been designed. It has two major differences in comparison to the LC2K ISA you studied in EECS 370: The 8 LC2k registers are replaced with a single register called the Accumulator or ACC Instructions are reduced to be 16-bits long
There are three instruction format types in TinyC’s instruction set, with the following format: U-type: bits [15-13] opcode, bits [12-0] unsigned immediate (0 to 4095) S-type: bits [15-13] opcode, bits [12-0] signed immediate (-2048 to 2047) N-type: bits [15-13] opcode, bits [12-0] unused
Below if the complete instruction set definition for TinyC: Instruction Format Opcode Semantics add uval U-type 000 ACC = ACC + MEM[uval] sub uval U-type 001 ACC = ACC - MEM[uval] lw uval U-type 010 ACC = MEM[uval] sw uval U-type 011 MEM[uval] = ACC beqz sval S-type 100 If ACC == 0, branch to PC+1+sval setacc sval S-type 101 ACC = sval halt N-type 110 Increment the PC, then halt the processor
a) What is the machine code encoding in hex for: beqz -3? 0x___ 9FFD ___________
b) What does the following assembly code compute? Provide your answer in C using the template on the right. Assume variable a is stored at location 100, b at 101, c at 102, and the ACC register initially contains 0. Assembly code C code lw 100 sub 101 beqz 4 add 102 sw 100 setacc 0 beqz 2 lw 100 sw 102 halt
int a, b, c;
if (_ a == b__/ or (a-b) == 0 / _______)
__ a = a – b + c __________________;
else ___ c = a _________________;
/* halt */
c) On average, would you expect LC2k programs to be longer or shorter than TinyC programs, in terms of number of instructions? Briefly explain.
Shorter because LC2k has 8 registers, whereas TinyC only has 1 register, and the overhead of bringing values into and out of the ACC is large.
10. Linking object files [8 pts]
Consider the object code files below generated by compiling files scott.c and valeria.c. Note that
the machine instructions shown in the text segments are pseudo-codes. Your job is to first complete the variable declarations in the corresponding source code files shown at the bottom of
the page. Then, indicate all the instructions in the two object files that must be updated by the
linker with a checkmark in the corresponding “Update?” column.
Name scott.o Text Size 0x030 Data Size 0x04 valeria.o Text Size 0x024 Data Size 0x
Text Segment Address^ Instruction^ Update?^ Address^ Instruction^ Update? 0x0 load title with “teaching” √ 0x0 load vanum with 0 √ 0x4 load sum with 0 √ 0x4 branch if k>=20 to 0x1C 0x8 branch to 0x28 if tf=0 0x8 jump to printf() √ 0xC load i with 0 0xC k=k+ 0x10 jump to printf() √ 0x10 temp= k+vanum √ 0x14 i=i+1; 0x14 sum=sum+temp √ 0x18 branch to 0x10 if i<10 0x18 jump to 0x 0x1C jump to va() √ 0x1C jump to sc() √ 0x20 scnum=sum+i √ 0x20 return 0x24 jump to 0x2C 0x28 jump to printf() √ 0x2C return 1
Data Segment
0x0 title 0x0 sum 0x4 vanum Symbol Table
sc() va() title sum sum vanum printf() title va() sc() printf()
*char title ;
int sc(char tf) { int i; int scnum;
title = "teaching"; sum = 0; if (tf) { for (i=0 ; i<10 ; i++) { printf("%s %d",title,i); } va(i); scnum =sum+i; } else printf ("prizes!"); return scnum; }
int sum; int vanum;
void va(int k) {
vanum=0; while (k<20) { printf("%s %d",title,k++) ; sum=sum+k+vanum; } sc(1) ; return; }
12. Processor performance [17 pts] As an up and coming entrepreneur, you decide to design a new processor that will be used in an embedded system application, namely the MPod (developed by UofM alumni). You decide to use the knowledge you gained in EECS370 to design the new processor, based on the LC2K ISA.
After extensive testing and oscilloscope measurements, you collect the data below:
Component Time Component Time Register file read/write 2ns Memory access (read/write) 12ns ALU operations 3ns Other operations (those circuits classes paid off!) 0ns
We also know that the average music software has the following instruction breakdown: 20% ADD 15% NAND 35% BEQ 15% LW 15% SW Branches are always predicted not taken and 75% of the branches are taken. 30% of all LW are followed by a dependent instruction.
You will be analyzing three different processors. The specs for the processors are given below: Processor A Processor B Processor C Single cycle as described in class
Multi-cycle with a few changes from the one studied in class:
Pipeline processor with one change from the one studied in class:
Your job is to analyze each of the three processors for the three questions listed below. Please use the table at the bottom of the next page to fill in your answers and use the space provided to show your work. Round all answers to the hundredths place.
Work for Processor A (single-cycle)
SingleCycle CPI==1, its always 1. Clock Frequency = Mem(fetch) + reg read +Alu + mem(lw) + reg write = 12+2+3+12+2=31ns 1/(3110‐^9 )= 32,258,064.5161 Hz =32.26 Mhz Time = 11000003110^‐ 9 = 0.0031sec = 3.1ms
Work for Processor B (multi-cycle)
MultiCycle CPI= NAND/ADD/BEQ all take 5 cycles now SW takes 6 LW takes 7 (0.2+0.15+0.35)5+0.157+0.156 = 5. Clock Frequency = Longest path is through LW which is the mem access which is 12ns. 1/12ns = 83,333,333.33Hz = 83.33MHz Time = 5.4512*10‐^9 *100000 = 6.54ms
Work for Processor C (pipeline)
Pipeline
CPI = 1+0.150.31+0.350.753=1.
Clock Frequency = Mem stage takes the longest. 12ns + 2ns (read problem description) = 14ns
1/14ns = 71,428,571.4286 Hz = 71.43 MHz
Time = 1.831410‐^9 *100000= 0.002562 sec = 2.56 ms
Clock frequency (MHz)
Execution time (ms)
Processor A (single-cycle)
1 32.26 3.
Processor B (multi-cycle)
5.45 83.33 6.
Processor C (pipeline)
1.83 71.43 2.
14. New pipeline feature [10 pts]
The five stage pipeline from lecture is reproduced in the next page. Your task is to add a multiply accumulate “mac” instruction to it. The semantic of the mac instruction is:
mac regA regB regC // regC = regC + (regA*regB)
Implement the mac instruction by adding components as needed to the square boxes and wire names to the rectangular boxes in the picture on the next page. To get you started, a third read port has been already added to the register file, which takes 1 cycle to read. Keep in mind that the original 370 pipeline CANNOT perform multiplications. You can ignore forwarding logic.
For each square box , you have the choice of leaving it blank or using one of the following components: Component Symbol Delay
Multiplier 1 cycle
Adder 0.5 cycles
Mux 0.5 cycles
AND gate 0.1 cycles
Wire 0 cycles
In addition, each hardware box has one output on its right side and three choices for wiring inputs. One is always provided for you in the diagram, either from the previous pipeline stage or from the output of another square box. The other two must be selected by you from the list below or left blank:
Wire Name Description PC output of the PC register IDregA regA output from register file IDregB regB output from register file IDregC regC output from register file IDEXregA regA from IDEX pipeline register IDEXregB regB from IDEX pipeline register IDEXregC regC from IDEX pipeline register EXMEMregA regA from EXMEM pipeline register EXMEMregB regB from EXMEM pipeline register EXMEMregC regC from EXMEM pipeline register MEMWBregA regA from MEMWB pipeline register
This is an example of how you may fill one of the square boxes and its input rectangular boxes.
Data memory
+
+
M U X
0- 16-
Fetch Decode Execute Memory Writeback
M U X
Sign extend
M U X M U X C A
Reg file
re gB
re gA
re gC
IDregA
*^ +
Now suppose that we decide to organize the page table system into three levels. All other parameters and information remain the same from the previous part, including the 12-bit virtual address space. The one exception is that the number of bits dedicated to the virtual page number for each level is now unknown, and potentially different from the previous part.
The processor accesses an instruction by reading from address 0xAE8. The virtual address translation process is reported below: it includes the physical address accessed and the value read in the corresponding page table entry at each level. You need to use this information to derive the organization of the virtual memory system. 1010 1110 1000
Physical Address Accessed Value Read (Superpage entry) 0x05 0x (Level 2 page entry) 0x52 0x2D (Level 3 page entry) 0x33 7
b) What is the complete physical address access for this read request?
16 byte pages -> 4 page offset bits. Combining the page offset bits with the physical page number (7) yields 0x78. Answer: _______0x78___________________
c) How many virtual address bits are assigned to each page table level?
PROVIDE JUSTIFICATIONS FOR CREDIT.
Level Number of virtual address bits Superpage 3 Level 2 2 Level 3 3
Bits to access superpage - justification for your selection:
We have an index of 0x05, which corresponds with 101 in binary, so there must be 3 bits in the
superpage address field. Sure enough, 101 happens to be the first three bits of 0xAE8.
Bits to access level 2 page - justification for your selection:
The offset for the level 2 virtual page is 0x01, which matches with the next two bits in 0xAE (0b01). Note that 0b1 was also a possibility, but the bit pattern given does not allow for this.
Therefore there are two bits in the level 2 virtual page field.
Bits to access level 3 page- justification for your selection:
Notice that 0x33 is accessed for the level 3 page entry. This is an index of 0x06 relative to
0x2D, so the level 3 field must have been 0x06, or 110 in binary. This corresponds to the final
three bits that are left before the page offset.
16. Virtual memory [10 pts]
The TLB, cache contents, and a snippet of the single level page table are shown below for a system that uses byte addressable memory with a 64 byte page size. The system has a 16 byte 2- way set associative cache with a 2 byte block size and a fully associative TLB with 8 entries. Virtual addresses are 12 bits and physical addresses are 10 bits. Page Table TLB 2-way cache
a) The processor reads one byte from virtual address 0x71A and the cache is physically indexed. Indicate what happens during the address translation process and the cache access by filling in the table provided. All numeric answers should be given in hexadecimal. Virtual page number: 0x1C Physical address: 0x39A Page offset: 0x1A Cache block offset: 0x TLB tag: 0x1C Cache set index: 0x TLB hit (yes/no): no Cache tag: 0x Page fault (yes/no): no Cache byte returned or MISS : 0x
b) Now assume that the cache is virtually indexed and the processor reads from virtual address 0x45F. Indicate what happens during the address translation process and the cache access by filling in the table below. All numeric answers should be given in hexadecimal. Virtual page number: 0x Physical address: 0x21F
Page offset: (^) 0x1F Cache block offset: (^) 0x
TLB tag: 0x Cache set index: 0x TLB hit (yes/no): Yes Cache tag: 0x8B Page fault (yes/no): No Cache byte returned or MISS : 0x MISS
VPN PPN Valid VPN PPN Valid Tag PPN Valid Index Tag Valid Byte0 Byte 0x010 A 1 0x018 F 0 0x05 E 1 0 0x77 1 0xDE 0xAD 0x011 2 1 0x019 A 1 0x1F A 0 0x1A 0 0x12 0xB 0x012 7 0 0x01A 4 1 0x00 1 1 1 0x26 0 0x0A 0xC 0x013 C 0 0x01B 8 0 0x17 4 1 0x73 1 0x99 0x1F 0x014 9 1 0x01C E 1 0x11 8 1 2 0x9C 1 0x84 0x 0x015 0 0 0x01D 1 0 0x1F 0 1 0x00 1 0xBE 0xEF 0x016 2 1 0x01E 6 1 0x0D E 1 3 0x11 1 0xCC 0xA 0x017 4 0 0x01F B 0 0x02 2 0 0xFA 1 0x45 0x