rtl: fix sync interrupt return address

Signed-off-by: liangkangnan <liangkangnan@163.com>
pull/1/head
liangkangnan 2020-07-25 22:15:03 +08:00
parent b39062a4ea
commit e23ad11e7e
1 changed files with 21 additions and 13 deletions

View File

@ -112,7 +112,11 @@ module clint(
S_CSR_IDLE: begin S_CSR_IDLE: begin
if (int_state == S_INT_SYNC_ASSERT) begin if (int_state == S_INT_SYNC_ASSERT) begin
csr_state <= S_CSR_MEPC; csr_state <= S_CSR_MEPC;
if (jump_flag_i == `JumpEnable) begin
inst_addr <= jump_addr_i - 4'h4;
end else begin
inst_addr <= inst_addr_i; inst_addr <= inst_addr_i;
end
case (inst_i) case (inst_i)
`INST_ECALL: begin `INST_ECALL: begin
cause <= 32'd11; cause <= 32'd11;
@ -204,18 +208,22 @@ module clint(
int_assert_o <= `INT_DEASSERT; int_assert_o <= `INT_DEASSERT;
int_addr_o <= `ZeroWord; int_addr_o <= `ZeroWord;
end else begin end else begin
case (csr_state)
// .mcause // .mcause
if (csr_state == S_CSR_MCAUSE) begin S_CSR_MCAUSE: begin
int_assert_o <= `INT_ASSERT; int_assert_o <= `INT_ASSERT;
int_addr_o <= csr_mtvec; int_addr_o <= csr_mtvec;
end
// //
end else if (csr_state == S_CSR_MSTATUS_MRET) begin S_CSR_MSTATUS_MRET: begin
int_assert_o <= `INT_ASSERT; int_assert_o <= `INT_ASSERT;
int_addr_o <= csr_mepc; int_addr_o <= csr_mepc;
end else begin end
default: begin
int_assert_o <= `INT_DEASSERT; int_assert_o <= `INT_DEASSERT;
int_addr_o <= `ZeroWord; int_addr_o <= `ZeroWord;
end end
endcase
end end
end end