Documente Academic
Documente Profesional
Documente Cultură
Name:AII51Ker
Key
ECE411 Exam 1
This exam has 6 problems. Make sure you have a complete exam before you begin.
Write your name on every page in case pages become separated during grading.
You will have three hours to complete this exam.
Write all of your answers on the exam itself. If you need more space to answer a given problem,
continue on the back of the page, but clearly indicate that you have done so.
This exam is closed-book. You may use one sheet of notes.
You may use a calculator.
Do not do anything that might be perceived as cheating. The minimum penalty for cheating will
be a grade of zero.
Show all of your work on all problems. Correct answers that do not include work demonstrating
how they were generated may not receive full credit, and answers that show no work cannot receive
partial credit.
The exam is meant to test your understanding. Ample time has been provided. So be patient and
read the questions/problems carefully before you answer.
Good luck!
Question
Points
MPO /Debugging
11
MP1/Testing
11
ISA
21
Cache
18
16
DRAM
11
Total:
88
Score
Name:._ _ _ _ _ _ _ _ _ _ _ _ __
LDR
LDR
AND
ADD
R1,
R2,
R3,
R4,
RO,
RO,
R1,
R1,
SEVEN
MINUSTEN
R2
R3
HALT:
BRnzp HALT
;Data
DATA2 4x0007
SEVEN:
MINUSTEN: DATA2 4xFFF6
Joe loads the code into memory and tests his design in ModelSim. The first 400 ns of the generated
waveform is shown below.
elk
LrJlrlnJtrtnrlru
mem.resp J
L__j''l__j
t.n.r.r~n . nnnn.rt. rl . .
rr
... LJT'
, ... ,
~~"~~r!...._.n~~~---~J~...............~....~.~.~'..n.....-~
mem.Jead
mem_wrilet
'
<
-,,..,.,._....,.,.,=,
.._,,,., ....w.-.......-.-.vu~,"~~~~.........................,~,"~T-,
,,,, 2oons
300 ns
"".-...w.--w-..w.w"~~
400 ns
(a) (4 points) Joe thinks that there is a bug in his implementation. Circle all the values in the waveform that are wrong.
(b) (2 points) For each circled value, write the correct value next to it.
(c) (5 points) Provide a brief description (1-2 sentences) of a possible implementation bug in Joe's
SystemVerilog code. Justify your answer.
Io
S_o..f\J
St"o..te, ~JI,{)pcode.=
o..lvop.-<1..JJ.
-OR-
Page2
Nrume:._____________________________
ORIGIN 4x0000
SEGMENT CodeSegment:
LEA RO,DataSegment
LDI R1,RO,PTR2
HALT:
BRnzp HALT
SEGMENT
PTR1:
PTR2:
PTR3:
VALl:
VAL2:
VAL3:
DataSegment:
DATA2 VAL2
DATA2 VAL3
DATA2 VALl
DATA2 4x0003
DATA2 4x05ff
DATA2 4x0404
(a) (6 points) The following waveform shows the ldi instruction executing for the above code. Fill
in the values that should be in the waveform at the places labeled A, B, C, and D.
elk!
L'Lr--
'
memJesp
m&rnJead - m~
mem_write
MAR
MDR
[7]
[6]
[5)
.!R
'E
'~0>
!!!
[2]
[1]
(b) (5 points) What aspect of the LDI is not tested in the given code? Assume that all the registers
values shown in the trace are set correctly (including the ones you filled in).
1"
LPI
f'ets the.
... 0 I'-
Page3
co11J;..:v"
co Jes .
Name:
---------------------------
j,'AeJ : 11LRM
-t
-
\xv(o.ble: '1-.~b
4--
eD-S/ ~ I &.ecocle
b1~
\ CArtj"'
:.>
ze
SJ?'\~If b'VIOJ'(S'ZR,
comj~e~ 1~
YNYe
/ ~ecoJe
~ev;),/e
(b) (6 points) Write the program that does C = A-Busing the following 4 kinds of machines. You
SU13/
poP c
ii. Accumulator
Ll)
5T
~urs
c,
13
1-\
1-0 J<l;A ; LD R2 8 ;
I
(c) (3 points) Discuss the tradeoffs of supporting 9 registers instead of 8 in LC3b ISA? (instruction
t
Mcr...-e regs tef to ~ 1 (0-V\
~Ye cJ~t~
length is still16bits)
ho lo\
;"'
re,>t~>
c.A:t
()..
+/llA-e
(d) (4 points)
rectly to memory), what could go wrong if you run a test cod1 which contains both read and
write?
f(lfJJA.. 1ssu.~ : lt C\_ lru~
I"> ivt (.:\.eke. , U.11.J..
rt D
-\0
~~ ~t'~K<'rj
+k liiAe
correcffy
u.~ltfd.
(e) (4 points) How would you fix the issue in part d? (with minimal effort) Youranswershouldnot
be more than one sentence.
to
\lite
(I<\
YJ\e'ftC ~"-)
CQc~e
Oll\
~ u.e (Are.
tbt l't~e. .
Name:
-----------------------------
explo;t
DRAI'\
ok)
(b) (4 points) Ben is examining a 384-byte set associative cache that has following characteristics.
Byte addressable.
16-bit memory address.
8 cache lines per way. 16 bytes of data per cache line.
Read/write allocate. Write back policy. True LRU replacement policy.
Lf
3
9
offset bits
indexbits
tagbits
set associativity
Name:
----------------------------
(c) (6 points) (Use the cache configuration from part b) Below is a sequence of hex memory address
in the order they are used to reference memory. They are generated by an iteration of a loop.
Assume the cache is initially empty. For each reference, write down tag and index bits in binary
and identify if the reference is a hit or miss.
Access Type
Write
Read
Write
Write
Write
Read
Read
Read
Memory Address
Ox2DB2
Ox06FC
Ox5AB8
Ox773E
Ox4BB6
OxSABC
Ox2DB6
Ox4BB2
Tag
Index
001011011
Hit/Miss
Off
"-:s
oo ooouo1
1f1
01Dt10f01
Of1
"f'fOfffO
OfOOIOtf1
011
i )5
M;H
01/
f1
0 f(JI(D fD1
DO!Oif0f1
OfiJOiiJfff
_f11, l i
f"''
iSf
011
1-u'f
01f
Mlf>
011
hit
(d) (6 points) (Use the cache configuration from part b) Suppose access to cache takes 10 cycles,
and when a miss happens, access to DRAM takes an additional150 cycles. Calculate the cycles
taken to run the loop two rounds. Here is a spare table to work on the question.
Access Type
Write
Read
Write
Write
Write
Read
Read
Read
r:-,
ftr.;t
R01111:J
Memory Address
Ox2DB2
Ox06FC
Ox5AB8
Ox773E
Ox4BB6
Ox5ABC
Ox2DB6
Ox4BB2
Tag
hit-
h/t
.~
~ i<s
hir
tr1i >s
hi I-
10
W"f";H
1SO
b(hcks
f50
10
Hit- :;
tllftO.J-~10.:= 1jCf0
Tro#IJ ~ T1 f ia:::
10
I 0 '1 c b s
4:. ;l];:(()
Hit/Miss
h; "t-
h'"-
1 ''1 br ~"~'ssesI ~
1
fA
Index
~lOO
ECE 411 Exam 1
Page6
-:::
3:ZO cycles
1Jo cycle 5
Name:
--------------------------
bt
-NJ
f(SfCc,..\t
(c) (4 points) The virtual memory system specifies the page size as 4KB. Ben would like to provide
a 128KB data cache. He would also like to designed it as a Physical-Indexed-Physical-Tagged
cache, what is the minimum associativity so that virtual address translation and cache look-up
can be done in parallel? (Hint: line size should not matter.)
( 1) Lf f\ B
pc...~C
re(v ,rt..5
p.
~J;t~
fo '(
c;'\11
h11.v<
"-ddrts 5 9-rrAIIs/t*J-:, 1
o.~~d
l"'{e. o-fF-set,
.t-1, ~~.
wl
c "\ch C
t~ ;~
fhq_
c~hc.
12-M'f- r,-e.fJ
look -uf
Ill
Page?
/lCf.J
~0
fh #\.T
In'*-.~
B/
/w~y.
J'ii=3:t ~y
fro.rts>.
Name:
------------------------------
(d) (5 points) Given a 2KB direct-mapped cache, with 8 bytes per line. The computer system also
supports VM with page size of 2KB and 1 entry TLB. Ben is running two dimensional histogramming of a matrix of characters (1 Byte per character) on a computer with the above configuration. Ben finds the code runs unacceptably slow.
return myHistogram;
}
Calculate the hit rate of the cache and the TLB of the code. Please ignore the hit or miss of
accessing unordered_map when you do the calculation since a hash table is difficult to trace.
(t 5)
i5'
(;tt;)
'5
().
.%..
Page8
..
Natne:
-----------------------------
(e) (3 points) Could you modify the code to make it faster? Calculate the hit rate of the cache and
the TLB of your modified code.
~~~=r~(~~~~~ll=~}~;~i;J;{;~~===
(1)
~~~!l~~l2_~-~i~~0!~~fY~1!};__
}
return myHistogram;
}
7-
TLB
,,~:- (11\.te-
J..041
Page9
Name:
----------------------------
V6\Ti)
~;tt.f. v
of dock
OV...Qv
rtcr-s)
(b) (2 points) What is the maximal memory bandwidth that can be supported by one interface
(channel)?
b4- kt.s
htfe s
~-
=-
<if , I ~ tJ
(c) (4 points) What is the minimal number of banks required to achieve an actual transfer rate
equal to the channel (interface) bandwidth?
Ci;v.q
l tAt_ 1'\
~ Li
4 -
!J
h~Lf ~Jd{}
t:: Lily
U.S<
t 4-,
8' B' 2
.~1;.,.h
::=
~~ rl_.
~s
b~J..,~
(d) (3 points) What is the number of channels neede to equip a CPU with 48 G Bytes/sec memory
bandwidth?
48- 4
:g.
I 6 6lg
J.
lo
~....")Ls~t.;t