Line 62... |
Line 62... |
dcpu_cycstb_i, dcpu_we_i, dcpu_adr_i, dcpu_dat_lsu,
|
dcpu_cycstb_i, dcpu_we_i, dcpu_adr_i, dcpu_dat_lsu,
|
dcpu_dat_dc, icpu_cycstb_i,
|
dcpu_dat_dc, icpu_cycstb_i,
|
ex_freeze, branch_op, ex_insn, id_pc,
|
ex_freeze, branch_op, ex_insn, id_pc,
|
spr_dat_npc, rf_dataw,
|
spr_dat_npc, rf_dataw,
|
du_dsr, du_dmr1, du_stall, du_addr, du_dat_i, du_dat_o,
|
du_dsr, du_dmr1, du_stall, du_addr, du_dat_i, du_dat_o,
|
du_read, du_write, du_except_stop, du_hwbkpt,
|
du_read, du_write, du_except_stop, du_hwbkpt, du_flush_pipe,
|
spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
|
spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
|
|
|
// External Debug Interface
|
// External Debug Interface
|
dbg_stall_i, dbg_ewt_i, dbg_lss_o, dbg_is_o, dbg_wp_o, dbg_bp_o,
|
dbg_stall_i, dbg_ewt_i, dbg_lss_o, dbg_is_o, dbg_wp_o, dbg_bp_o,
|
dbg_stb_i, dbg_we_i, dbg_adr_i, dbg_dat_i, dbg_dat_o, dbg_ack_o
|
dbg_stb_i, dbg_we_i, dbg_adr_i, dbg_dat_i, dbg_dat_o, dbg_ack_o
|
Line 104... |
Line 104... |
output [dw-1:0] du_dat_o; // Debug Unit Data Out
|
output [dw-1:0] du_dat_o; // Debug Unit Data Out
|
output du_read; // Debug Unit Read Enable
|
output du_read; // Debug Unit Read Enable
|
output du_write; // Debug Unit Write Enable
|
output du_write; // Debug Unit Write Enable
|
input [13:0] du_except_stop; // Exception masked by DSR
|
input [13:0] du_except_stop; // Exception masked by DSR
|
output du_hwbkpt; // Cause trap exception (HW Breakpoints)
|
output du_hwbkpt; // Cause trap exception (HW Breakpoints)
|
|
output du_flush_pipe; // Cause pipeline flush and pc<-npc
|
input spr_cs; // SPR Chip Select
|
input spr_cs; // SPR Chip Select
|
input spr_write; // SPR Read/Write
|
input spr_write; // SPR Read/Write
|
input [aw-1:0] spr_addr; // SPR Address
|
input [aw-1:0] spr_addr; // SPR Address
|
input [dw-1:0] spr_dat_i; // SPR Data Input
|
input [dw-1:0] spr_dat_i; // SPR Data Input
|
output [dw-1:0] spr_dat_o; // SPR Data Output
|
output [dw-1:0] spr_dat_o; // SPR Data Output
|
Line 162... |
Line 163... |
assign du_addr = dbg_adr_i;
|
assign du_addr = dbg_adr_i;
|
assign du_dat_o = dbg_dat_i;
|
assign du_dat_o = dbg_dat_i;
|
assign du_read = dbg_stb_i && !dbg_we_i;
|
assign du_read = dbg_stb_i && !dbg_we_i;
|
assign du_write = dbg_stb_i && dbg_we_i;
|
assign du_write = dbg_stb_i && dbg_we_i;
|
|
|
|
//
|
|
// After a sw breakpoint, the replaced instruction need to be executed.
|
|
// We flush the entire pipeline and set the pc to the current address
|
|
// to execute the restored address.
|
|
//
|
|
|
|
reg du_flush_pipe_r;
|
|
reg dbg_stall_i_r;
|
|
|
|
assign du_flush_pipe = du_flush_pipe_r;
|
|
|
|
//
|
|
// Register du_flush_pipe
|
|
//
|
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
|
if (rst == `OR1200_RST_VALUE) begin
|
|
du_flush_pipe_r <= 1'b0;
|
|
end
|
|
else begin
|
|
du_flush_pipe_r <= (dbg_stall_i_r && !dbg_stall_i && |du_except_stop);
|
|
end
|
|
end
|
|
|
|
//
|
|
// Detect dbg_stall falling edge
|
|
//
|
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
|
if (rst == `OR1200_RST_VALUE) begin
|
|
dbg_stall_i_r <= 1'b0;
|
|
end
|
|
else begin
|
|
dbg_stall_i_r <= dbg_stall_i;
|
|
end
|
|
end
|
|
|
reg dbg_ack;
|
reg dbg_ack;
|
//
|
//
|
// Generate acknowledge -- just delay stb signal
|
// Generate acknowledge -- just delay stb signal
|
//
|
//
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|