Fix interrupt not executed early enough after sleep

This commit is contained in:
Sven Stucki 2015-10-16 15:03:47 +02:00
parent 8d4c069d84
commit 30318e694a
2 changed files with 21 additions and 7 deletions

View file

@ -229,14 +229,25 @@ module riscv_controller
ctrl_fsm_ns = DECODE;
end
// TODO: Check if we need to handle IRQs here
// hwloop detected, jump to start address!
// Attention: This has to be done in the DECODE and the FIRST_FETCH states
if (hwloop_jump_i == 1'b1) begin
pc_mux_sel_o = `PC_HWLOOP;
pc_mux_sel_o = `PC_HWLOOP;
pc_set_o = 1'b1;
end
// handle exceptions
if (exc_req_i) begin
pc_mux_sel_o = `PC_EXCEPTION;
pc_set_o = 1'b1;
exc_ack_o = 1'b1;
// TODO: Check
if (jump_in_dec_i == `BRANCH_JALR || jump_in_dec_i == `BRANCH_JAL)
save_pc_if_o = 1'b1;
else
save_pc_id_o = 1'b1;
end
end
DECODE:

View file

@ -81,9 +81,10 @@ module riscv_exc_controller
pc_mux_int = `EXC_PC_ECALL;
end
if (illegal_insn_i)
if (illegal_insn_i) begin
cause_int = 6'b0_00010;
pc_mux_int = `EXC_PC_ILLINSN;
end
end
always_ff @(posedge clk, negedge rst_n)
@ -116,10 +117,12 @@ module riscv_exc_controller
unique case (exc_ctrl_cs)
IDLE:
begin
req_o = req_int;
if (irq_enable_i) begin
req_o = req_int;
if (req_int)
exc_ctrl_ns = WAIT_CONTROLLER;
if (req_int)
exc_ctrl_ns = WAIT_CONTROLLER;
end
end
WAIT_CONTROLLER: