diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-11-08 13:00:40 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-11-08 13:29:23 -0600 |
| commit | f6929f9a4703e3eee9d7bd9752de055729cdd498 (patch) | |
| tree | 770acb4f96fd16e0f12bec2c5ed5cfdfa5a4c315 /rtl/core/porch/porch.sv | |
| parent | 89a8edd4bb96787c69118dd5f549345015b2d480 (diff) | |
Register decode output in a new porch stage
Diffstat (limited to 'rtl/core/porch/porch.sv')
| -rw-r--r-- | rtl/core/porch/porch.sv | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/rtl/core/porch/porch.sv b/rtl/core/porch/porch.sv new file mode 100644 index 0000000..6f5caf7 --- /dev/null +++ b/rtl/core/porch/porch.sv @@ -0,0 +1,53 @@ +`include "core/uarch.sv" + +module core_porch +( + input logic clk, + flush, + stall, + input psr_flags flags, + + input word fetch_insn, + input ptr fetch_insn_pc, + input insn_decode fetch_dec, + + output word insn, + output ptr insn_pc, + output insn_decode dec +); + + 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; + + always_comb begin + dec = hold_dec; + dec.ctrl.execute = !flush && dec.ctrl.execute && execute; + dec.ctrl.undefined = !flush && (dec.ctrl.undefined || undefined); + dec.ctrl.conditional = !flush && (dec.ctrl.conditional || conditional); + end + + always @(posedge clk) + if(!stall) begin + insn <= fetch_insn; + hold_dec <= fetch_dec; + + if(!flush) + insn_pc <= fetch_insn_pc; + end + + initial begin + insn = `NOP; + insn_pc = 0; + hold_dec = nop; + end + +endmodule |
