Line 57... |
Line 57... |
module ifetch(
|
module ifetch(
|
// Clock and reset
|
// Clock and reset
|
clk, rst,
|
clk, rst,
|
|
|
// External i/f to IC
|
// External i/f to IC
|
ic_insn, ic_addr, ic_stall, ic_fetchop, tp_insn, tp_wr_insn,
|
ic_insn, ic_addr, ic_stall, ic_fetchop,
|
|
|
// Internal i/f
|
// Internal i/f
|
if_freeze, if_insn, if_pc, branch_op, except_type,
|
if_freeze, if_insn, if_pc, branch_op, except_type,
|
branch_addrofs, lr_restor, flag, taken, binsn_addr, except_start,
|
branch_addrofs, lr_restor, flag, taken, binsn_addr, except_start,
|
epcr, force_dslot_fetch, if_stall, branch_stall
|
epcr, force_dslot_fetch, if_stall, branch_stall
|
Line 82... |
Line 82... |
//
|
//
|
input [31:0] ic_insn;
|
input [31:0] ic_insn;
|
output [31:0] ic_addr;
|
output [31:0] ic_addr;
|
output [`FETCHOP_WIDTH-1:0] ic_fetchop;
|
output [`FETCHOP_WIDTH-1:0] ic_fetchop;
|
input ic_stall;
|
input ic_stall;
|
input [31:0] tp_insn;
|
|
input tp_wr_insn;
|
|
|
|
//
|
//
|
// Internal i/f
|
// Internal i/f
|
//
|
//
|
input if_freeze;
|
input if_freeze;
|
Line 114... |
Line 112... |
reg [32:0] if_saved;
|
reg [32:0] if_saved;
|
reg [31:0] pcaddr;
|
reg [31:0] pcaddr;
|
reg [31:0] pc_saved;
|
reg [31:0] pc_saved;
|
reg taken; /* Set to in case of jump or taken branch */
|
reg taken; /* Set to in case of jump or taken branch */
|
|
|
// Selection between insn from IC or Trace port
|
|
wire [31:0] ic_tp_insn = (tp_wr_insn) ? tp_insn : ic_insn;
|
|
|
|
//
|
//
|
// Current registered PC (corresponds to fetched instruction)
|
// Current registered PC (corresponds to fetched instruction)
|
//
|
//
|
//assign if_pc = {pcreg[31:2], 2'b00};
|
//assign if_pc = {pcreg[31:2], 2'b00};
|
assign if_pc = (if_saved[32]) ? pc_saved : ic_addr;
|
assign if_pc = (if_saved[32]) ? pc_saved : ic_addr;
|
Line 135... |
Line 130... |
assign ic_fetchop = (if_saved[32] & !if_stall) ? `FETCHOP_NOP : `FETCHOP_LW;
|
assign ic_fetchop = (if_saved[32] & !if_stall) ? `FETCHOP_NOP : `FETCHOP_LW;
|
|
|
//
|
//
|
// Just fetched instruction
|
// Just fetched instruction
|
//
|
//
|
assign if_insn = (if_saved[32]) ? if_saved[31:0] : (ic_stall) ? 32'h1500FFFF : ic_tp_insn;
|
assign if_insn = (if_saved[32]) ? if_saved[31:0] : (ic_stall) ? 32'h1500FFFF : ic_insn;
|
|
|
//
|
//
|
// Delay slot PC saved
|
// Delay slot PC saved
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or posedge rst)
|
Line 238... |
Line 233... |
`ifdef OR1200_VERBOSE
|
`ifdef OR1200_VERBOSE
|
// synopsys translate_off
|
// synopsys translate_off
|
$display("Starting exception: %h.", except_type);
|
$display("Starting exception: %h.", except_type);
|
// synopsys translate_on
|
// synopsys translate_on
|
`endif
|
`endif
|
pcaddr = { 21'h0, except_type, 8'h00};
|
pcaddr = { 20'h0_0000, except_type, 8'h00};
|
taken = 1'b1;
|
taken = 1'b1;
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
|
|
Line 268... |
Line 263... |
always @(posedge clk or posedge rst)
|
always @(posedge clk or posedge rst)
|
if (rst) begin
|
if (rst) begin
|
if_saved <= #1 33'b0;
|
if_saved <= #1 33'b0;
|
end
|
end
|
else if (if_freeze && !if_saved[32] && !ic_stall) begin // && !taken
|
else if (if_freeze && !if_saved[32] && !ic_stall) begin // && !taken
|
if_saved <= #1 {1'b1, ic_tp_insn};
|
if_saved <= #1 {1'b1, ic_insn};
|
`ifdef OR1200_VERBOSE
|
`ifdef OR1200_VERBOSE
|
// synopsys translate_off
|
// synopsys translate_off
|
$display("%t: if_saved <= %h", $time, {1'b1, ic_tp_insn});
|
$display("%t: if_saved <= %h", $time, {1'b1, ic_insn});
|
// synopsys translate_on
|
// synopsys translate_on
|
`endif
|
`endif
|
end
|
end
|
else if (!if_freeze) begin
|
else if (!if_freeze) begin
|
if_saved[32] <= #1 1'b0;
|
if_saved[32] <= #1 1'b0;
|