Fix exc wiring (not working yet)

This commit is contained in:
Sven Stucki 2015-10-16 01:21:59 +02:00
parent c68a098059
commit c28ca4444a
5 changed files with 50 additions and 32 deletions

View file

@ -43,7 +43,7 @@ module riscv_controller
// decoder related signals
output logic deassert_we_o, // deassert write enable for next instruction
input logic illegal_insn_i, // decoder encountered an invalid instruction // TODO: Remove?
input logic illegal_insn_i, // decoder encountered an invalid instruction
input logic eret_insn_i, // decoder encountered an eret instruction
input logic pipe_flush_i, // decoder wants to do a pipe flush
@ -82,6 +82,9 @@ module riscv_controller
// TODO
input logic trap_hit_i, // a trap was hit, so we have to flush EX and WB
output logic save_pc_if_o,
output logic save_pc_id_o,
// Debug Unit Signals
input logic dbg_stall_i, // Pipeline stall is requested
input logic dbg_set_npc_i, // Change PC to value from debug unit
@ -164,21 +167,23 @@ module riscv_controller
always_comb
begin
// Default values
instr_req_o = 1'b1;
instr_req_o = 1'b1;
exc_ack_o = 1'b0;
exc_ack_o = 1'b0;
save_pc_if_o = 1'b0;
save_pc_id_o = 1'b0;
pc_mux_sel_o = `PC_BOOT;
pc_set_o = 1'b0;
pc_mux_sel_o = `PC_BOOT;
pc_set_o = 1'b0;
ctrl_fsm_ns = ctrl_fsm_cs;
ctrl_fsm_ns = ctrl_fsm_cs;
core_busy_o = 1'b1;
is_decoding_o = 1'b0;
core_busy_o = 1'b1;
is_decoding_o = 1'b0;
halt_if_o = 1'b0;
halt_id_o = 1'b0;
dbg_trap_o = 1'b0;
halt_if_o = 1'b0;
halt_id_o = 1'b0;
dbg_trap_o = 1'b0;
unique case (ctrl_fsm_cs)
// We were just reset, wait for fetch_enable
@ -272,6 +277,12 @@ module riscv_controller
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;
// we don't have to change our current state here as the prefetch
// buffer is automatically invalidated, thus the next instruction
// that is served to the ID stage is the one of the jump to the

View file

@ -35,7 +35,8 @@ module riscv_decoder
output logic illegal_insn_o, // illegal instruction encountered
output logic trap_insn_o, // trap instruction encountered
output logic eret_insn_o, // trap instruction encountered
output logic eret_insn_o, // return from exception instruction encountered
output logic ecall_insn_o, // environment call (syscall) instruction encountered
output logic pipe_flush_o, // pipeline flush is requested
output logic rega_used_o, // rs1 is used by current instruction
@ -159,6 +160,7 @@ module riscv_decoder
illegal_insn_o = 1'b0;
trap_insn = 1'b0;
eret_insn = 1'b0;
ecall_insn_o = 1'b0;
pipe_flush = 1'b0;
rega_used_o = 1'b0;
@ -512,7 +514,7 @@ module riscv_decoder
32'h00_00_00_73: // ECALL
begin
// environment (system) call
// TODO: Handle in controller
ecall_insn_o = 1'b1;
end
32'h00_10_00_73: // ebreak

View file

@ -124,7 +124,7 @@ module riscv_id_stage
input logic irq_enable_i,
output logic [5:0] exc_cause_o,
input logic save_exc_cause_o,
output logic save_exc_cause_o,
output logic save_pc_if_o,
output logic save_pc_id_o,
@ -166,6 +166,7 @@ module riscv_id_stage
logic illegal_insn_dec;
logic trap_insn;
logic eret_insn_dec;
logic ecall_insn_dec;
logic pipe_flush_dec;
logic rega_used_dec;
@ -193,15 +194,13 @@ module riscv_id_stage
logic [31:0] jump_target; // calculated jump target (-> EX -> IF)
logic exc_pc_sel;
logic irq_present;
// Signals running between controller and exception controller
logic illegal_insn;
logic exc_req, exc_ack; // handshake
logic trap_hit;
logic clear_isr_running;
logic exc_pipe_flush;
assign trap_hit = 1'b0; // TODO: Fix
// Register file interface
logic [4:0] regfile_addr_ra_id;
@ -248,7 +247,6 @@ module riscv_id_stage
logic [1:0] hwloop_regid;
logic [2:0] hwloop_we;
logic hwloop_jump;
logic hwloop_enable;
logic hwloop_start_mux_sel;
logic hwloop_end_mux_sel;
logic hwloop_cnt_mux_sel;
@ -535,6 +533,7 @@ module riscv_id_stage
.illegal_insn_o ( illegal_insn_dec ),
.trap_insn_o ( trap_insn ),
.eret_insn_o ( eret_insn_dec ),
.ecall_insn_o ( ecall_insn_dec ),
.pipe_flush_o ( pipe_flush_dec ),
.rega_used_o ( rega_used_dec ),
@ -647,6 +646,9 @@ module riscv_id_stage
.exc_ack_o ( exc_ack ),
.trap_hit_i ( trap_hit ),
.save_pc_id_o ( save_pc_id_o ),
.save_pc_if_o ( save_pc_if_o ),
// Debug Unit Signals
.dbg_stall_i ( dbg_stall_i ),
.dbg_set_npc_i ( dbg_set_npc_i ),
@ -702,8 +704,8 @@ module riscv_id_stage
.rst_n ( rst_n ),
// to controller
.req_o ( exc_req_o ),
.ack_i ( exc_ack_i ),
.req_o ( exc_req ),
.ack_i ( exc_ack ),
// to IF stage
.pc_mux_o ( exc_pc_mux_o ),
@ -713,11 +715,12 @@ module riscv_id_stage
.irq_i ( irq_i ),
.irq_enable_i ( irq_enable_i ),
.illegal_insn_i ( illegal_insn ),
.ecall_insn_i ( ecall_insn ),
.eret_insn_i ( eret_insn ),
.illegal_insn_i ( illegal_insn_dec ),
.ecall_insn_i ( ecall_insn_dec ),
.eret_insn_i ( eret_insn_dec ),
.cause_o ( exc_cause_o )
.cause_o ( exc_cause_o ),
.save_cause_o ( save_exc_cause_o )
);
@ -733,7 +736,7 @@ module riscv_id_stage
riscv_hwloop_controller hwloop_controller_i
(
// from ID stage
.enable_i ( hwloop_enable ),
.enable_i ( 1'b1 ),
.current_pc_i ( current_pc_if_i ),
// to IF stage/controller

View file

@ -122,7 +122,6 @@ module riscv_if_stage
logic [31:0] instr_rdata_int;
logic [31:0] exc_pc;
logic [31:0] irq_pc;
// output data and PC mux

View file

@ -90,6 +90,7 @@ module riscv_core
logic pc_set;
logic [2:0] pc_mux_sel_id; // Mux selector for next PC
logic [1:0] exc_pc_mux_id; // Mux selector for exception PC
logic [4:0] exc_vec_pc_mux_id; // Mux selector for vectorized IR lines
logic branch_done; // Branch already done
@ -253,10 +254,11 @@ module riscv_core
.current_pc_id_o ( current_pc_id ), // current pc in ID stage
// control signals
.pc_set_i ( pc_set ),
.exception_pc_reg_i ( epcr ), // exception return address
.pc_mux_sel_i ( pc_mux_sel_id ), // sel for pc multiplexer
.exc_pc_mux_i ( exc_pc_mux_id ), // selector for exception multiplexer
.pc_set_i ( pc_set ),
.exception_pc_reg_i ( epcr ), // Exception PC register
.pc_mux_sel_i ( pc_mux_sel_id ), // sel for pc multiplexer
.exc_pc_mux_i ( exc_pc_mux_id ),
.exc_vec_pc_mux_i ( exc_vec_pc_mux_id ),
.branch_done_o ( branch_done ),
@ -316,6 +318,7 @@ module riscv_core
.pc_set_o ( pc_set ),
.pc_mux_sel_o ( pc_mux_sel_id ),
.exc_pc_mux_o ( exc_pc_mux_id ),
.exc_vec_pc_mux_o ( exc_vec_pc_mux_id ),
.branch_done_i ( branch_done ),