Questin in review about Risc v

199 views
Skip to first unread message

223380...@gmail.com

unread,
Dec 14, 2020, 8:24:03 PM12/14/20
to cmpt-295-sfu
# Lecture Question
Week : final 
Slide deck name: RISC V  Branch and Jump type 
Question:

in the lecture vedio, the range of branch type is +-2^13 


in the quiz5 answer is +-2^10


and also why the range of Jar instruction, imm do not need to * 4?

if the range is +-2^18, do we wast 2 bit since the instruction are 4 byte and the last 2 bit is 0.  should it able to reach +-2^20^ if we * 4 to use all the bit?

223380...@gmail.com

unread,
Dec 14, 2020, 8:28:22 PM12/14/20
to cmpt-295-sfu
in the vedio :
Capture.PNG

in and the quiz 
Captu2re.PNG

ashrir...@gmail.com

unread,
Dec 15, 2020, 3:49:52 PM12/15/20
to cmpt-295-sfu
1) 2^11 in the video refers to 2 bytes (as program can be mix of compressed 2 byte or 4 byte instructions]; hence the branch offsets are specified in terms of 2 byte instructions.
In the quiz the program cannot use any compressed instructions so only 4 byte instructions. 



2) You can reach all -2%20-+2^20-1 addresses; it is just that not all addresses. Instructions are only stored at multiples of 4 (4 byte alighed)
The 2^18 refers to in terms of 4 byte instructions (not bytes).

Pay attention to  the metric it is either instructions, bytes, 2 bytes or 4 bytes. It varies from the video to the quiz.

zhilong

unread,
Dec 15, 2020, 5:26:27 PM12/15/20
to cmpt-295-sfu
maybe I misunderstand something. I assuming the imm in branch instruction it is going to be +-2^13 instuctions.
there are 12 bits for the imm and the left most bit for sign. so there are 11bits left. and since we all know it multiple of 4 so we assume the last 2 bit is 0 for saving them we putiply by 4
for example the imm is 000000000001 this is 12 bits original it should represent 1 but now since instruction are 4 byte then it should represent 4(* 4) 
if we have   000000000010 then is 8 byte(*4)  so instead of having +-2^11 we now able to have +-2^13

I thought this is what the video said 
am I right?

ashrir...@gmail.com

unread,
Dec 16, 2020, 3:11:03 PM12/16/20
to cmpt-295-sfu
Imm in branch is 12 bits so -2^11 to +2^11 values.
Instructions can start only even address. So branch imm is shifted by 2 before adding to PC
that specifies byte offset values in range 2^-12 - 2^12. This is either -2^11-+2^11 (2 byte instructions: i.e., Both compressed and uncompressed) or -2^10 - 2^10 offsets in terms of 4 byte (32 bit instructions).

The video says hypothetically. Assume that instructions can start only on addresses which are multiples of 4 (not 2 as previously), then the branch imm values -2^11 - 2^11 get shifted by 2 . -2^13 - 2^13 byte addresses. or -2^11 - 2^-11 (4 byte instructions). 2x more addressing range then previous

zhilong

unread,
Dec 16, 2020, 6:10:22 PM12/16/20
to cmpt-295-sfu
Thanks you 

some other question is in quiz7 how do we identify a conflict miss or capcity miss? 
Captur3e.PNG

since we only hold 4 block in cash after all 4 block is fill (the compulsory miss) all the below is capacity miss? the rest is conflict?

Arrvindh Shriraman

unread,
Dec 16, 2020, 7:49:50 PM12/16/20
to cmpt-295-sfu
Whatever is not capacity or compulsory is conflict
Conflict : run trace on fully associative same size cache. If miss occurs it’s conflict

zhilong

unread,
Dec 16, 2020, 8:16:13 PM12/16/20
to cmpt-295-sfu
" Conflict: run trace on fully associative same size cache. If miss occurs it’s conflict  "
 isn't it capacity? 
run in fully associative same size cash as long as there is a replacement it is capacity right
or how do we find capacity 

ashrir...@gmail.com

unread,
Dec 17, 2020, 1:26:03 AM12/17/20
to cmpt-295-sfu
Sorry; if miss occurs its capacity. if miss does not occur with fully-assoc. cache its conflict

ashrir...@gmail.com

unread,
Dec 17, 2020, 1:29:35 AM12/17/20
to cmpt-295-sfu
If you are talking about the quiz question; capacity is already given its 32B. Its just the organization that varies.  
See 1.1 https://www2.cs.sfu.ca/~ashriram/Courses/CS295/q-solutions/q6.pdf
Reply all
Reply to author
Forward
0 new messages