Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
|
// Development version of RTL. Libraries are missing.
|
|
//
|
//
|
//
|
|
|
`include "general.h"
|
`include "general.h"
|
|
|
// Data cache
|
// Data cache
|
|
|
module dc(clk, rst, clkdiv_by_2, dcbiu_rdy, dclsu_addr, dclsu_lsuop, dclsu_datain, dcbiu_datain,
|
module dc(clk, rst, clkdiv_by_2, dcbiu_rdy, dclsu_addr, dclsu_lsuop, dclsu_datain, dcbiu_datain,
|
dclsu_dataout, dcbiu_dataout, dcbiu_addr, dcbiu_read, dcbiu_write, dclsu_stall,
|
dclsu_dataout, dcbiu_dataout, dcbiu_addr, dcbiu_read, dcbiu_write, dclsu_stall, dcbiu_sel,
|
tp2w, tp3w, tpdw
|
tp2w, tp3w, tpdw
|
);
|
);
|
|
|
parameter dw = `OPERAND_WIDTH;
|
parameter dw = `OPERAND_WIDTH;
|
|
|
Line 70... |
Line 73... |
output [dw-1:0] dcbiu_dataout;
|
output [dw-1:0] dcbiu_dataout;
|
output [31:0] dcbiu_addr;
|
output [31:0] dcbiu_addr;
|
output dcbiu_read;
|
output dcbiu_read;
|
output dcbiu_write;
|
output dcbiu_write;
|
output dclsu_stall;
|
output dclsu_stall;
|
|
output [3:0] dcbiu_sel;
|
|
|
input [`TP2W_WIDTH-1:0] tp2w;
|
input [`TP2W_WIDTH-1:0] tp2w;
|
input [`TP3W_WIDTH-1:0] tp3w;
|
input [`TP3W_WIDTH-1:0] tp3w;
|
input [31:0] tpdw;
|
input [31:0] tpdw;
|
|
|
Line 89... |
Line 93... |
wire [31:0] dc_addr;
|
wire [31:0] dc_addr;
|
wire refill_first;
|
wire refill_first;
|
wire refill_prepare;
|
wire refill_prepare;
|
wire refill_start;
|
wire refill_start;
|
wire refill_rest;
|
wire refill_rest;
|
|
wire [`LSUOP_WIDTH-1:0] dcfsm_lsuop;
|
|
wire dcfsm_read;
|
|
wire dcfsm_write;
|
|
wire dc_en;
|
|
wire [1:0] mem2reg_addr;
|
|
|
reg hit;
|
reg hit;
|
reg [1:0] valid_div;
|
reg [1:0] valid_div;
|
|
reg [3:0] dcbiu_sel;
|
|
reg [1:0] bypass_wait;
|
|
|
wire queue;
|
wire queue;
|
wire cntrbusy;
|
wire cntrbusy;
|
wire dcbiu_valid;
|
wire dcbiu_valid;
|
|
|
assign dcbiu_addr = dc_addr;
|
assign dcbiu_addr = dc_addr;
|
assign dctag_we = refill;
|
assign dctag_we = refill;
|
assign dcbiu_dataout = from_dcram;
|
assign dcbiu_dataout = (dc_en) ? from_dcram : lsu_datain_memaligned;
|
|
|
|
// Bypases of DC
|
|
assign dc_en = 1'b0;
|
|
assign dcfsm_lsuop = (dc_en) ? dclsu_lsuop : `LSUOP_NOP;
|
|
assign dcbiu_read = (dc_en) ? dcfsm_read : (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)
|
|
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'b01} : dcbiu_sel <= #1 4'b0100;
|
|
{1'b0, `LSUOP_SB, 2'b10} : dcbiu_sel <= #1 4'b0010;
|
|
{1'b0, `LSUOP_SB, 2'b11} : dcbiu_sel <= #1 4'b0001;
|
|
{1'b0, `LSUOP_SH, 2'b00} : dcbiu_sel <= #1 4'b1100;
|
|
{1'b0, `LSUOP_SH, 2'b10} : dcbiu_sel <= #1 4'b0011;
|
|
{1'b0, `LSUOP_SW, 2'b00} : dcbiu_sel <= #1 4'b1111;
|
|
{1'b0, `LSUOP_LBZ, 2'b00}, {1'b0, `LSUOP_LBS, 2'b00} : dcbiu_sel <= #1 4'b1000;
|
|
{1'b0, `LSUOP_LBZ, 2'b01}, {1'b0, `LSUOP_LBS, 2'b01} : dcbiu_sel <= #1 4'b0100;
|
|
{1'b0, `LSUOP_LBZ, 2'b10}, {1'b0, `LSUOP_LBS, 2'b10} : dcbiu_sel <= #1 4'b0010;
|
|
{1'b0, `LSUOP_LBZ, 2'b11}, {1'b0, `LSUOP_LBS, 2'b11} : dcbiu_sel <= #1 4'b0001;
|
|
{1'b0, `LSUOP_LHZ, 2'b00}, {1'b0, `LSUOP_LHS, 2'b00} : dcbiu_sel <= #1 4'b1100;
|
|
{1'b0, `LSUOP_LHZ, 2'b10}, {1'b0, `LSUOP_LHS, 2'b10} : dcbiu_sel <= #1 4'b0011;
|
|
{1'b0, `LSUOP_LWZ, 2'b00}, {1'b0, `LSUOP_LWS, 2'b00} : dcbiu_sel <= #1 4'b1111;
|
|
7'b1xxxxxx : dcbiu_sel <= #1 4'b1111;
|
|
default : dcbiu_sel <= #1 4'b0000;
|
|
endcase
|
|
|
// assign dc_stall = dcbiu_read | dcbiu_write | refill_start; // can't remember if it works
|
assign mem2reg_addr = (dc_en) ? saved_addr[1:0] : dclsu_addr[1:0];
|
assign queue = (refill && dclsu_lsuop && !refill_first & !refill_rest) ? 1'b1 : 1'b0;
|
|
|
// Wait for DC bypass acess
|
|
always @(posedge rst or posedge clk)
|
|
if (rst)
|
|
bypass_wait <= #1 2'b0;
|
|
else if (dcbiu_valid)
|
|
bypass_wait <= #1 2'b0;
|
|
else if (dcbiu_read | dcbiu_write)
|
|
bypass_wait <= #1 {bypass_wait, 1'b1};
|
|
else
|
|
bypass_wait <= #1 2'b00;
|
|
|
|
// assign dc_stall = dcfsm_read | dcfsm_write | refill_start; // can't remember if it works
|
|
assign queue = (refill && dcfsm_lsuop && !refill_first & !refill_rest) ? 1'b1 : 1'b0;
|
|
|
// assign dclsu_stall = refill_start | (refill_first & ~dcbiu_valid)| refill_rest | queue; // kind of working
|
// assign dclsu_stall = refill_start | (refill_first & ~dcbiu_valid)| refill_rest | queue; // kind of working
|
assign dclsu_stall = refill_start | (refill_first & ~dcbiu_valid)| refill_rest | queue | cntrbusy;
|
assign dclsu_stall = refill_start | (refill_first & ~dcbiu_valid)| refill_rest | queue | cntrbusy | (~dc_en & bypass_wait[1] & ~dcbiu_valid);
|
|
|
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
|
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
|
assign dc_addr = (refill == 1'b1) ? saved_addr : dclsu_addr;
|
assign dc_addr = (refill == 1'b1) ? saved_addr : dclsu_addr;
|
|
|
// Select between input data generated by LSU or by BIU
|
// Select between input data generated by LSU or by BIU
|
assign to_dcram = (refill == 1'b1) ? dcbiu_datain : lsu_datain_memaligned;
|
assign to_dcram = (refill == 1'b1) ? dcbiu_datain : lsu_datain_memaligned;
|
|
|
// Select between data generated by DCRAM or passed by BIU
|
// Select between data generated by DCRAM or passed by BIU
|
assign to_mem2reg = (refill_first == 1'b1) ? dcbiu_datain : from_dcram;
|
assign to_mem2reg = (refill_first == 1'b1) | (~dc_en) ? dcbiu_datain : from_dcram;
|
|
|
// Tag comparison
|
// Tag comparison
|
always @(tag or saved_addr) begin
|
always @(tag or saved_addr) begin
|
if (tag == saved_addr[31:13])
|
if (tag == saved_addr[31:13])
|
hit <= #1 1'b1;
|
hit <= #1 1'b1;
|
Line 157... |
Line 206... |
);
|
);
|
|
|
dc_fsm dc_fsm(
|
dc_fsm dc_fsm(
|
.clk(clk),
|
.clk(clk),
|
.rst(rst),
|
.rst(rst),
|
.lsu_op(dclsu_lsuop),
|
.lsu_op(dcfsm_lsuop),
|
.miss(~hit),
|
.miss(~hit),
|
.biudata_valid(dcbiu_valid),
|
.biudata_valid(dcbiu_valid),
|
.start_addr(dclsu_addr),
|
.start_addr(dclsu_addr),
|
.saved_addr(saved_addr),
|
.saved_addr(saved_addr),
|
.refill(refill),
|
.refill(refill),
|
.refill_first(refill_first),
|
.refill_first(refill_first),
|
.refill_prepare(refill_prepare),
|
.refill_prepare(refill_prepare),
|
.dcram_we(dcram_we),
|
.dcram_we(dcram_we),
|
.biu_read(dcbiu_read),
|
.biu_read(dcfsm_read),
|
.biu_write(dcbiu_write),
|
.biu_write(dcfsm_write),
|
.refill_rest(refill_rest),
|
.refill_rest(refill_rest),
|
.cntrbusy(cntrbusy)
|
.cntrbusy(cntrbusy)
|
);
|
);
|
|
|
// Regfile-to-memory aligner
|
// Regfile-to-memory aligner
|
Line 202... |
Line 251... |
.tpdw(tpdw)
|
.tpdw(tpdw)
|
);
|
);
|
|
|
// Memory-to-regfile aligner
|
// Memory-to-regfile aligner
|
mem2reg mem2reg(
|
mem2reg mem2reg(
|
.addr(saved_addr[1:0]),
|
.addr(mem2reg_addr[1:0]),
|
.lsu_op(dclsu_lsuop),
|
.lsu_op(dclsu_lsuop),
|
.memdata(to_mem2reg),
|
.memdata(to_mem2reg),
|
.regdata(dclsu_dataout)
|
.regdata(dclsu_dataout)
|
);
|
);
|
|
|