diff options
Diffstat (limited to 'rtl/core/porch')
| -rw-r--r-- | rtl/core/porch/conds.sv | 47 | ||||
| -rw-r--r-- | rtl/core/porch/porch.sv | 53 |
2 files changed, 100 insertions, 0 deletions
diff --git a/rtl/core/porch/conds.sv b/rtl/core/porch/conds.sv new file mode 100644 index 0000000..b8db1e7 --- /dev/null +++ b/rtl/core/porch/conds.sv @@ -0,0 +1,47 @@ +`include "core/decode/isa.sv" +`include "core/uarch.sv" + +module core_porch_conds +( + input word insn, + input psr_flags flags, + + output logic execute, + conditional, + undefined +); + + always_comb begin + undefined = 0; + conditional = 1; + + unique case(insn `FIELD_COND) + `COND_EQ: execute = flags.z; + `COND_NE: execute = ~flags.z; + `COND_HS: execute = flags.c; + `COND_LO: execute = ~flags.c; + `COND_MI: execute = flags.n; + `COND_PL: execute = ~flags.n; + `COND_VS: execute = flags.v; + `COND_VC: execute = ~flags.v; + `COND_HI: execute = flags.c & ~flags.z; + `COND_LS: execute = ~flags.c | flags.z; + `COND_GE: execute = flags.n ~^ flags.v; + `COND_LT: execute = flags.n ^ flags.v; + `COND_GT: execute = ~flags.z & (flags.n ~^ flags.v); + `COND_LE: execute = flags.z | (flags.n ^ flags.v); + + `COND_AL: begin + execute = 1; + conditional = 0; + end + + `COND_UD: begin + execute = 1'bx; + conditional = 1'bx; + undefined = 1; + end + endcase + end + +endmodule 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 |
