diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-01-21 06:23:46 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-02-20 11:11:17 -0600 |
| commit | f3b18ead59ae02f95dabbf0a1dea40873a816975 (patch) | |
| tree | 8979e50f2a37f66a4cd27e937b480efe60d72cf7 /rtl/core/core_porch.sv | |
| parent | a8bc5a353ea997f73209b39377ee15a73e471237 (diff) | |
rtl: refactor filenames and directory hierarchy
Diffstat (limited to 'rtl/core/core_porch.sv')
| -rw-r--r-- | rtl/core/core_porch.sv | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/rtl/core/core_porch.sv b/rtl/core/core_porch.sv new file mode 100644 index 0000000..060ab91 --- /dev/null +++ b/rtl/core/core_porch.sv @@ -0,0 +1,57 @@ +`include "core/uarch.sv" + +module core_porch +( + input logic clk, + rst_n, + flush, + stall, + input psr_flags flags, + + input word fetch_insn, + input logic fetch_nop, + fetch_abort, + input ptr fetch_insn_pc, + fetch_head, + input insn_decode fetch_dec, + + output word insn, + output ptr insn_pc, + output insn_decode dec, + output logic abort +); + + logic execute, conditional, undefined, nop; + insn_decode hold_dec; + + //FIXME: User mode puede hacer msr o mcr y saltare cualquier lĂmite de seguridad + + always_comb begin + dec = hold_dec; + dec.ctrl.nop = nop; + dec.ctrl.execute = !flush && dec.ctrl.execute && execute && !nop && !abort; + dec.ctrl.undefined = !flush && (dec.ctrl.undefined || undefined); + 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 + nop <= 0; // Even though it is a NOP + insn <= `NOP; + abort <= 0; + insn_pc <= 0; + hold_dec <= {$bits(hold_dec){1'b0}}; + end else if(flush || !stall) begin + nop <= flush ? 1 : fetch_nop; + insn <= flush ? `NOP : fetch_insn; + abort <= flush ? 0 : fetch_abort; + insn_pc <= flush ? fetch_head : fetch_insn_pc; + hold_dec <= fetch_dec; + end + +endmodule |
