## FP Implementation Examples used in LSU EE 4720 ## ## 17 April 2020 -- Floating point code execution examples. ## 20 April 2020 -- Live solution to 2016 Final Exam Problem 2c ## Illustration of a stall to avoid a WF structural hazard. # # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 mul.d f0, f2, f4 IF ID M1 M2 M3 M4 M5 M6 WF addi r1, r2, 3 IF ID EX ME WB add.d f6, f8, f10 IF ID -> A1 A2 A3 A4 WF # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ## Example showing non-dependent multiplications overlap (those writing f0, f6) ## and a dependent multiply stall (the one writing f10). # # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 mul.d f0, f2, f4 IF ID M1 M2 M3 M4 M5 M6 WF mul.d f6, f2, f8 IF ID M1 M2 M3 M4 M5 M6 WF mul.d f10, f6, f8 IF ID -------------> M1 M2 M3 M4 M5 M6 WF addi r1, r1, 8 IF -------------> ID EX ME WB # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ## Examples showing how to manage out-of-order writes. # # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 add.d f0, f2, f4 IF ID A1 A2 A3 A4 WF mul.d f6, f8, f10 IF ID M1 M2 M3 M4 M5 M6 WF add.d f6, f2, f4 IF ID A1 A2 A3 A4 WF ## THIS WRITE NOT RIGHT! # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # ## Option: Stall to avoid out-of-write of f6. # # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 add.d f0, f2, f4 IF ID A1 A2 A3 A4 WF mul.d f6, f8, f10 IF ID M1 M2 M3 M4 M5 M6 WF add.d f6, f2, f4 IF ID ----> A1 A2 A3 A4 WF # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # ## Option squash earlier instructions. # # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 add.d f0, f2, f4 IF ID A1 A2 A3 A4 WF mul.d f6, f8, f10 IF ID M1x # <--- Squashed! add.d f6, f2, f4 IF ID A1 A2 A3 A4 WF # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # # ISA might forbid this since we would never know if the mul.d raised # an exception. One might argue that no one cares whether the mul.d # raised an exception because the result, f6, is never used. But, # someone, call him Yawnoc, might have installed a FP exception # handler and expected that to be called when f8 and f10, say, were # large enough to cause a multiply overflow. If the exception handler # were not called Yawnoc's program would not work properly. Sounds # crazy? People can write code like that, that's life. Better to # clearly spell things out precisely in the ISA than to make # judgments about reasonableness when deciding what an implementation # should do. # ## Option: (We'll get to this on Monday.) ## 20 April 2020, 9:11:32 CDT # Spring 2016 Final Exam Problem 2c # https://www.ece.lsu.edu/ee4720/2016/fe.pdf # https://www.ece.lsu.edu/ee4720/2016/fe_sol.pdf # Cycle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 add.s f2, f3, f4 IF ID A1 A2 A3 A4 WF swc1 f1, 0(r7) IF ID EX ME WF ## <- Me first swc1 f2, 4(r8) IF ID ----> EX ME WF # Live solution to hardware part of problem: # :