diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-12-13 21:57:04 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-12-16 16:29:10 -0600 |
| commit | f3c153f342ed969b1abfbe79d1017b651f21a649 (patch) | |
| tree | 20fb2e5d867d4412a46a0d928461119722c0be9a /rtl/core/control/exception.sv | |
| parent | 0c63c46e31642d0102542a745af6b445a9d22b3b (diff) | |
Implement IRQ exceptions
Diffstat (limited to 'rtl/core/control/exception.sv')
| -rw-r--r-- | rtl/core/control/exception.sv | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/rtl/core/control/exception.sv b/rtl/core/control/exception.sv index 038cd2b..76abc5c 100644 --- a/rtl/core/control/exception.sv +++ b/rtl/core/control/exception.sv @@ -5,11 +5,14 @@ module core_control_exception input logic clk, rst_n, - input ctrl_cycle next_cycle, - input logic high_vectors, - undefined, - prefetch_abort, - mem_fault, + input ctrl_cycle next_cycle, + input psr_intmask intmask, + input logic issue, + irq, + high_vectors, + undefined, + prefetch_abort, + mem_fault, output logic exception, exception_offset_pc, @@ -17,27 +20,38 @@ module core_control_exception output word exception_vector ); + logic pending_irq; logic[2:0] vector_offset; //TODO: irq, fiq, prefetch abort, swi - assign exception = undefined || prefetch_abort || mem_fault; + assign exception = undefined || prefetch_abort || mem_fault || pending_irq; assign exception_vector = {{16{high_vectors}}, 11'b0, vector_offset, 2'b00}; always @(posedge clk or negedge rst_n) begin if(!rst_n) begin + pending_irq <= 0; 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(prefetch_abort) begin - vector_offset <= 3'b011; - exception_mode <= `MODE_ABT; - end else if(undefined) begin - vector_offset <= 3'b001; - exception_mode <= `MODE_UND; + end begin + if(issue) + pending_irq <= irq && !intmask.i; + + // A2.6.10 Exception priorities + if(mem_fault) begin + vector_offset <= 3'b100; + exception_mode <= `MODE_ABT; + end else if(pending_irq) begin + vector_offset <= 3'b110; + exception_mode <= `MODE_IRQ; + end else if(prefetch_abort) begin + vector_offset <= 3'b011; + exception_mode <= `MODE_ABT; + end else if(undefined) begin + vector_offset <= 3'b001; + exception_mode <= `MODE_UND; + end end if(next_cycle.escalate) |
