diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-12-11 14:48:08 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-12-16 16:27:20 -0600 |
| commit | ff71bcd0c5425c168f111b8f4a92d0a90a6c9c31 (patch) | |
| tree | 41190239b9220db09d8849afb6d6f6dbbc03f59b /rtl/core/control/exception.sv | |
| parent | 6fee344b754464b1fd17f7c0429e6597e51dc74d (diff) | |
Implement data aborts
Diffstat (limited to '')
| -rw-r--r-- | rtl/core/control/exception.sv | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/rtl/core/control/exception.sv b/rtl/core/control/exception.sv index 3965114..2d12c0a 100644 --- a/rtl/core/control/exception.sv +++ b/rtl/core/control/exception.sv @@ -2,24 +2,42 @@ module core_control_exception ( - input logic clk, - rst_n, - - input logic undefined, - high_vectors, - - output word vector, - output logic exception + input logic clk, + rst_n, + + input ctrl_cycle next_cycle, + input logic high_vectors, + undefined, + mem_fault, + + output logic exception, + exception_offset_pc, + output psr_mode exception_mode, + output word exception_vector ); logic[2:0] vector_offset; - assign exception = undefined; //TODO - assign vector = {{16{high_vectors}}, 11'b0, vector_offset, 2'b00}; - - always_comb - vector_offset = 3'b001; //TODO - - //TODO: Considerar que data abort usa + 8, no + 4 + //TODO: irq, fiq, prefetch abort, swi + + assign exception = undefined || mem_fault; + assign exception_vector = {{16{high_vectors}}, 11'b0, vector_offset, 2'b00}; + + always @(posedge clk or negedge rst_n) begin + if(!rst_n) begin + vector_offset <= 0; + exception_mode <= 0; + exception_offset_pc <= 0; + end else if(mem_fault) begin + vector_offset <= 3'b100; + exception_mode <= `MODE_ABT; + end else if(undefined) begin + vector_offset <= 3'b001; + exception_mode <= `MODE_UND; + end + + if(next_cycle.escalate) + exception_offset_pc <= !mem_fault; + end endmodule |
