summaryrefslogtreecommitdiff
path: root/rtl/core/control
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-12-15 00:41:05 -0600
committerAlejandro Soto <alejandro@34project.org>2022-12-16 16:29:10 -0600
commit7bf965b755b667f7da05e0995c2f09c54a8a2f11 (patch)
tree6695c6f9aecd84bdc542261d4bc32d73ef050ea8 /rtl/core/control
parentae7fd6a060c9bb1ce9db83f8eb23fa19e8fa0e7a (diff)
Implement swi (system call)
Diffstat (limited to '')
-rw-r--r--rtl/core/control/exception.sv15
1 files changed, 11 insertions, 4 deletions
diff --git a/rtl/core/control/exception.sv b/rtl/core/control/exception.sv
index 02560a6..21adb19 100644
--- a/rtl/core/control/exception.sv
+++ b/rtl/core/control/exception.sv
@@ -6,6 +6,7 @@ module core_control_exception
rst_n,
input ctrl_cycle next_cycle,
+ input insn_decode dec,
input psr_intmask intmask,
input logic issue,
irq,
@@ -20,23 +21,26 @@ module core_control_exception
output word exception_vector
);
- logic pending_irq;
+ logic pending_irq, syscall;
logic[2:0] vector_offset;
- //TODO: irq, fiq, prefetch abort, swi
+ //TODO: fiq
- assign exception = undefined || prefetch_abort || mem_fault || pending_irq;
+ assign exception = undefined || syscall || 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
+ syscall <= 0;
pending_irq <= 0;
vector_offset <= 0;
exception_mode <= 0;
exception_offset_pc <= 0;
end begin
- if(next_cycle.issue)
+ if(next_cycle.issue) begin
+ syscall <= issue && dec.ctrl.swi;
pending_irq <= issue && irq && !intmask.i;
+ end
// A2.6.10 Exception priorities
if(mem_fault) begin
@@ -51,6 +55,9 @@ module core_control_exception
end else if(undefined) begin
vector_offset <= 3'b001;
exception_mode <= `MODE_UND;
+ end else if(syscall) begin
+ vector_offset <= 3'b010;
+ exception_mode <= `MODE_SVC;
end
end