Line 76... |
Line 76... |
|
|
// Internal i/f
|
// Internal i/f
|
dc_en, dclsu_addr, dclsu_lsuop, dclsu_datain, dclsu_dataout, dclsu_stall, dclsu_unstall,
|
dc_en, dclsu_addr, dclsu_lsuop, dclsu_datain, dclsu_dataout, dclsu_stall, dclsu_unstall,
|
|
|
// SPRs
|
// SPRs
|
spr_cs, spr_write, spr_addr, spr_dat_i,
|
spr_cs, spr_write, spr_addr, spr_dat_i
|
|
|
// Trace
|
|
tp2w
|
|
);
|
);
|
|
|
parameter dw = `OPERAND_WIDTH;
|
parameter dw = `OPERAND_WIDTH;
|
|
|
//
|
//
|
Line 126... |
Line 123... |
input spr_write;
|
input spr_write;
|
input [31:0] spr_addr;
|
input [31:0] spr_addr;
|
input [31:0] spr_dat_i;
|
input [31:0] spr_dat_i;
|
|
|
//
|
//
|
// Trace
|
|
//
|
|
input [`TP2W_WIDTH-1:0] tp2w;
|
|
|
|
//
|
|
// Internal wires and regs
|
// Internal wires and regs
|
//
|
//
|
wire tag_v;
|
wire tag_v;
|
wire [18:0] tag;
|
wire [18:0] tag;
|
wire [dw-1:0] to_dcram;
|
wire [dw-1:0] to_dcram;
|
Line 185... |
Line 177... |
|
|
//
|
//
|
// Bypases of the DC when DC is disabled
|
// Bypases of the DC when DC is disabled
|
//
|
//
|
assign dcfsm_lsuop = (dc_en) ? dclsu_lsuop : `LSUOP_NOP;
|
assign dcfsm_lsuop = (dc_en) ? dclsu_lsuop : `LSUOP_NOP;
|
assign dcbiu_read = (dc_en) ? dcfsm_read : (dclsu_lsuop && ~dclsu_lsuop[3]);
|
assign dcbiu_read = (dc_en) ? dcfsm_read : ((|dclsu_lsuop) && ~dclsu_lsuop[3]);
|
assign dcbiu_write = (dc_en) ? dcfsm_write : (dclsu_lsuop && dclsu_lsuop[3]);
|
assign dcbiu_write = (dc_en) ? dcfsm_write : ((|dclsu_lsuop) && dclsu_lsuop[3]);
|
always @(dc_en or dclsu_lsuop or dclsu_addr)
|
always @(dc_en or dclsu_lsuop or dclsu_addr)
|
casex({dc_en, dclsu_lsuop, dclsu_addr[1:0]})
|
casex({dc_en, dclsu_lsuop, dclsu_addr[1:0]})
|
{1'b0, `LSUOP_SB, 2'b00} : dcbiu_sel <= #1 4'b1000;
|
{1'b0, `LSUOP_SB, 2'b00} : dcbiu_sel = 4'b1000;
|
{1'b0, `LSUOP_SB, 2'b01} : dcbiu_sel <= #1 4'b0100;
|
{1'b0, `LSUOP_SB, 2'b01} : dcbiu_sel = 4'b0100;
|
{1'b0, `LSUOP_SB, 2'b10} : dcbiu_sel <= #1 4'b0010;
|
{1'b0, `LSUOP_SB, 2'b10} : dcbiu_sel = 4'b0010;
|
{1'b0, `LSUOP_SB, 2'b11} : dcbiu_sel <= #1 4'b0001;
|
{1'b0, `LSUOP_SB, 2'b11} : dcbiu_sel = 4'b0001;
|
{1'b0, `LSUOP_SH, 2'b00} : dcbiu_sel <= #1 4'b1100;
|
{1'b0, `LSUOP_SH, 2'b00} : dcbiu_sel = 4'b1100;
|
{1'b0, `LSUOP_SH, 2'b10} : dcbiu_sel <= #1 4'b0011;
|
{1'b0, `LSUOP_SH, 2'b10} : dcbiu_sel = 4'b0011;
|
{1'b0, `LSUOP_SW, 2'b00} : dcbiu_sel <= #1 4'b1111;
|
{1'b0, `LSUOP_SW, 2'b00} : dcbiu_sel = 4'b1111;
|
{1'b0, `LSUOP_LBZ, 2'b00}, {1'b0, `LSUOP_LBS, 2'b00} : dcbiu_sel <= #1 4'b1000;
|
{1'b0, `LSUOP_LBZ, 2'b00}, {1'b0, `LSUOP_LBS, 2'b00} : dcbiu_sel = 4'b1000;
|
{1'b0, `LSUOP_LBZ, 2'b01}, {1'b0, `LSUOP_LBS, 2'b01} : dcbiu_sel <= #1 4'b0100;
|
{1'b0, `LSUOP_LBZ, 2'b01}, {1'b0, `LSUOP_LBS, 2'b01} : dcbiu_sel = 4'b0100;
|
{1'b0, `LSUOP_LBZ, 2'b10}, {1'b0, `LSUOP_LBS, 2'b10} : dcbiu_sel <= #1 4'b0010;
|
{1'b0, `LSUOP_LBZ, 2'b10}, {1'b0, `LSUOP_LBS, 2'b10} : dcbiu_sel = 4'b0010;
|
{1'b0, `LSUOP_LBZ, 2'b11}, {1'b0, `LSUOP_LBS, 2'b11} : dcbiu_sel <= #1 4'b0001;
|
{1'b0, `LSUOP_LBZ, 2'b11}, {1'b0, `LSUOP_LBS, 2'b11} : dcbiu_sel = 4'b0001;
|
{1'b0, `LSUOP_LHZ, 2'b00}, {1'b0, `LSUOP_LHS, 2'b00} : dcbiu_sel <= #1 4'b1100;
|
{1'b0, `LSUOP_LHZ, 2'b00}, {1'b0, `LSUOP_LHS, 2'b00} : dcbiu_sel = 4'b1100;
|
{1'b0, `LSUOP_LHZ, 2'b10}, {1'b0, `LSUOP_LHS, 2'b10} : dcbiu_sel <= #1 4'b0011;
|
{1'b0, `LSUOP_LHZ, 2'b10}, {1'b0, `LSUOP_LHS, 2'b10} : dcbiu_sel = 4'b0011;
|
{1'b0, `LSUOP_LWZ, 2'b00}, {1'b0, `LSUOP_LWS, 2'b00} : dcbiu_sel <= #1 4'b1111;
|
{1'b0, `LSUOP_LWZ, 2'b00}, {1'b0, `LSUOP_LWS, 2'b00} : dcbiu_sel = 4'b1111;
|
7'b1xxxxxx : dcbiu_sel <= #1 4'b1111;
|
7'b1xxxxxx : dcbiu_sel = 4'b1111;
|
default : dcbiu_sel <= #1 4'b0000;
|
default : dcbiu_sel = 4'b0000;
|
endcase
|
endcase
|
|
|
assign mem2reg_addr = (dc_en) ? saved_addr[1:0] : dclsu_addr[1:0];
|
assign mem2reg_addr = (dc_en) ? saved_addr[1:0] : dclsu_addr[1:0];
|
|
|
//
|
//
|
// Wait for DC bypass access
|
// Wait for DC bypass access
|
//
|
//
|
always @(posedge rst or posedge clk)
|
always @(posedge rst or posedge clk)
|
if (rst)
|
if (rst)
|
bypass_wait <= #1 2'b0;
|
bypass_wait <= #1 2'b00;
|
else if (dcbiu_valid)
|
else if (dcbiu_valid)
|
bypass_wait <= #1 2'b0;
|
bypass_wait <= #1 2'b00;
|
else if (dcbiu_read | dcbiu_write)
|
else if (dcbiu_read | dcbiu_write)
|
bypass_wait <= #1 {bypass_wait, 1'b1};
|
bypass_wait <= #1 {bypass_wait[0], 1'b1};
|
else
|
else
|
bypass_wait <= #1 2'b00;
|
bypass_wait <= #1 2'b00;
|
|
|
//
|
//
|
// Queue
|
// Queue
|
//
|
//
|
assign queue = (refill && dcfsm_lsuop && !refill_first & !refill_rest) ? 1'b1 : 1'b0;
|
assign queue = (refill && (|dcfsm_lsuop) && !refill_first && !refill_rest) ? 1'b1 : 1'b0;
|
|
|
//
|
//
|
// DC/LSU stall
|
// DC/LSU stall
|
//
|
//
|
//assign dclsu_stall = refill_start | (refill_first & ~dcbiu_valid)| refill_rest | queue | cntrbusy | (~dc_en & bypass_wait[1] & ~dcbiu_valid);
|
//assign dclsu_stall = refill_start | (refill_first & ~dcbiu_valid)| refill_rest | queue | cntrbusy | (~dc_en & bypass_wait[1] & ~dcbiu_valid);
|
Line 253... |
Line 245... |
//
|
//
|
// Tag comparison
|
// Tag comparison
|
//
|
//
|
always @(tag or saved_addr) begin
|
always @(tag or saved_addr) begin
|
if ((tag == saved_addr[31:13]) && tag_v)
|
if ((tag == saved_addr[31:13]) && tag_v)
|
hit <= #1 1'b1;
|
hit = 1'b1;
|
else
|
else
|
hit <= #1 1'b0;
|
hit = 1'b0;
|
end
|
end
|
|
|
//
|
//
|
// Valid_div counts RISC clock cycles by modulo 4
|
// Valid_div counts RISC clock cycles by modulo 4
|
//
|
//
|