Home › Practice › RTL Design › Load-use hazard detector
Load-use hazard detector
EasyRTLcombinationalarchitecture
A load instruction fetches a number from memory. The very next instruction wants to use that number, but it is not back yet.
Concept first. A load gets its data from memory one stage later than an ALU result is ready, so even forwarding cannot deliver it to the instruction right behind it in time. This is a load-use hazard. The fix is to stall for one cycle: freeze the Fetch and Decode stages, and put a bubble (a do-nothing slot) into Execute by flushing it. The hazard exists when the instruction in Execute is a load (the signal memtoreg_e says so) and its destination register is one of the two source registers of the instruction in Decode. The detector's three outputs all fire together.
What to build.
- Inputs:
rs_d[2:0]andrt_d[2:0](the two source registers of the instruction in Decode),rt_e[2:0](the destination register of the instruction in Execute),memtoreg_e(1 if that instruction is a load). - Outputs:
stall_f,stall_dandflush_e. All three are 1 whenmemtoreg_eis 1 andrt_eequalsrs_dorrt_d; otherwise all three are 0. - No clock.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.