diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-11-10 01:36:37 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-11-10 01:36:37 -0600 |
| commit | 0f89db514bd174def590645c30a7bd358ea6be93 (patch) | |
| tree | a9c39a599ac5adf66d1a15478360b5958e5b6296 /rtl/core/porch | |
| parent | bf82f69cbf7fa0900263236057174c421a28045c (diff) | |
Fix flush-stall relationship in porch
Diffstat (limited to 'rtl/core/porch')
| -rw-r--r-- | rtl/core/porch/porch.sv | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/rtl/core/porch/porch.sv b/rtl/core/porch/porch.sv index 2eec438..238da88 100644 --- a/rtl/core/porch/porch.sv +++ b/rtl/core/porch/porch.sv @@ -10,6 +10,7 @@ module core_porch input word fetch_insn, input ptr fetch_insn_pc, + fetch_head, input insn_decode fetch_dec, output word insn, @@ -18,16 +19,7 @@ module core_porch ); logic execute, conditional, undefined; - insn_decode nop, hold_dec; - - core_porch_conds conds - ( - .* - ); - - assign nop.ctrl.execute = 0; - assign nop.ctrl.undefined = 0; - assign nop.ctrl.conditional = 0; + insn_decode hold_dec; always_comb begin dec = hold_dec; @@ -36,17 +28,20 @@ module core_porch dec.ctrl.conditional = !flush && (dec.ctrl.conditional || conditional); end + core_porch_conds conds + ( + .* + ); + always_ff @(posedge clk or negedge rst_n) if(!rst_n) begin insn <= `NOP; insn_pc <= 0; - hold_dec <= nop; - end else if(!stall) begin - insn <= fetch_insn; + hold_dec <= {$bits(hold_dec){1'b0}}; + end else if(flush || !stall) begin + insn <= flush ? `NOP : fetch_insn; + insn_pc <= flush ? fetch_head : fetch_insn_pc; hold_dec <= fetch_dec; - - if(!flush) - insn_pc <= fetch_insn_pc; end endmodule |
