Line 1... |
Line 1... |
// $Id: aeMB_regf.v,v 1.1 2007-11-02 03:25:41 sybreon Exp $
|
// $Id: aeMB_regf.v,v 1.2 2007-11-09 20:51:52 sybreon Exp $
|
//
|
//
|
// AEMB REGISTER FILE
|
// AEMB REGISTER FILE
|
//
|
//
|
// Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
|
// Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
|
//
|
//
|
Line 18... |
Line 18... |
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
// USA
|
// USA
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.1 2007/11/02 03:25:41 sybreon
|
|
// New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
|
|
// Fixed various minor data hazard bugs.
|
|
// Code compatible with -O0/1/2/3/s generated code.
|
|
//
|
|
|
module aeMB_regf (/*AUTOARG*/
|
module aeMB_regf (/*AUTOARG*/
|
// Outputs
|
// Outputs
|
rREGA, rREGB, rDWBDI, dwb_dat_o,
|
rREGA, rREGB, rDWBDI, dwb_dat_o, fsl_dat_o,
|
// Inputs
|
// Inputs
|
rOPC, rRA, rRB, rRW, rRD, rMXDST, rPCLNK, rRESULT, rDWBSEL, rBRA,
|
rOPC, rRA, rRB, rRW, rRD, rMXDST, rPCLNK, rRESULT, rDWBSEL, rBRA,
|
rDLY, dwb_dat_i, gclk, grst, gena
|
rDLY, dwb_dat_i, fsl_dat_i, gclk, grst, gena
|
);
|
);
|
// INTERNAL
|
// INTERNAL
|
output [31:0] rREGA, rREGB;
|
output [31:0] rREGA, rREGB;
|
output [31:0] rDWBDI;
|
output [31:0] rDWBDI;
|
input [5:0] rOPC;
|
input [5:0] rOPC;
|
Line 41... |
Line 46... |
|
|
// DATA WISHBONE
|
// DATA WISHBONE
|
output [31:0] dwb_dat_o;
|
output [31:0] dwb_dat_o;
|
input [31:0] dwb_dat_i;
|
input [31:0] dwb_dat_i;
|
|
|
|
// FSL WISHBONE
|
|
output [31:0] fsl_dat_o;
|
|
input [31:0] fsl_dat_i;
|
|
|
// SYSTEM
|
// SYSTEM
|
input gclk, grst, gena;
|
input gclk, grst, gena;
|
|
|
// --- LOAD SIZER ----------------------------------------------
|
// --- LOAD SIZER ----------------------------------------------
|
// Moves the data bytes around depending on the size of the
|
// Moves the data bytes around depending on the size of the
|
// operation.
|
// operation.
|
|
|
wire [31:0] wDWBDI = dwb_dat_i; // FIXME: Endian
|
wire [31:0] wDWBDI = dwb_dat_i; // FIXME: Endian
|
|
wire [31:0] wFSLDI = fsl_dat_i; // FIXME: Endian
|
|
|
reg [31:0] rDWBDI;
|
reg [31:0] rDWBDI;
|
|
|
always @(/*AUTOSENSE*/rDWBSEL or wDWBDI)
|
always @(/*AUTOSENSE*/rDWBSEL or wDWBDI or wFSLDI)
|
case (rDWBSEL)
|
case (rDWBSEL)
|
// 8'bit
|
// 8'bit
|
4'h8: rDWBDI <= {24'd0, wDWBDI[31:24]};
|
4'h8: rDWBDI <= {24'd0, wDWBDI[31:24]};
|
4'h4: rDWBDI <= {24'd0, wDWBDI[23:16]};
|
4'h4: rDWBDI <= {24'd0, wDWBDI[23:16]};
|
4'h2: rDWBDI <= {24'd0, wDWBDI[15:8]};
|
4'h2: rDWBDI <= {24'd0, wDWBDI[15:8]};
|
Line 63... |
Line 74... |
// 16'bit
|
// 16'bit
|
4'hC: rDWBDI <= {16'd0, wDWBDI[31:16]};
|
4'hC: rDWBDI <= {16'd0, wDWBDI[31:16]};
|
4'h3: rDWBDI <= {16'd0, wDWBDI[15:0]};
|
4'h3: rDWBDI <= {16'd0, wDWBDI[15:0]};
|
// 32'bit
|
// 32'bit
|
4'hF: rDWBDI <= wDWBDI;
|
4'hF: rDWBDI <= wDWBDI;
|
|
// FSL
|
|
4'h0: rDWBDI <= wFSLDI;
|
// Undefined
|
// Undefined
|
default: rDWBDI <= 32'hX;
|
default: rDWBDI <= 32'hX;
|
endcase
|
endcase
|
|
|
// --- GENERAL PURPOSE REGISTERS (R0-R31) -----------------------
|
// --- GENERAL PURPOSE REGISTERS (R0-R31) -----------------------
|
Line 104... |
Line 117... |
|
|
// --- STORE SIZER ---------------------------------------------
|
// --- STORE SIZER ---------------------------------------------
|
// Replicates the data bytes across depending on the size of the
|
// Replicates the data bytes across depending on the size of the
|
// operation.
|
// operation.
|
|
|
|
wire [31:0] xFSL;
|
|
wire fFFWD_M = (rRA == rRW) & (rMXDST == 2'o2) & fRDWE;
|
|
wire fFFWD_R = (rRA == rRW) & (rMXDST == 2'o0) & fRDWE;
|
|
|
|
assign fsl_dat_o = rDWBDO;
|
|
assign xFSL = (fFFWD_M) ? rDWBDI :
|
|
(fFFWD_R) ? rRESULT :
|
|
rREGA;
|
|
|
wire [31:0] xDST;
|
wire [31:0] xDST;
|
wire fDFWD_M = (rRW == rRD) & (rMXDST == 2'o2) & fRDWE;
|
wire fDFWD_M = (rRW == rRD) & (rMXDST == 2'o2) & fRDWE;
|
wire fDFWD_R = (rRW == rRD) & (rMXDST == 2'o0) & fRDWE;
|
wire fDFWD_R = (rRW == rRD) & (rMXDST == 2'o0) & fRDWE;
|
reg [31:0] rDWBDO, xDWBDO;
|
reg [31:0] rDWBDO, xDWBDO;
|
|
|
assign dwb_dat_o = rDWBDO;
|
assign dwb_dat_o = rDWBDO;
|
assign xDST = (fDFWD_M) ? rDWBDI :
|
assign xDST = (fDFWD_M) ? rDWBDI :
|
(fDFWD_R) ? rRESULT :
|
(fDFWD_R) ? rRESULT :
|
rREGD;
|
rREGD;
|
|
|
always @(/*AUTOSENSE*/rOPC or xDST)
|
always @(/*AUTOSENSE*/rOPC or xDST or xFSL)
|
case (rOPC[1:0])
|
case (rOPC[1:0])
|
// 8'bit
|
// 8'bit
|
2'h0: xDWBDO <= {(4){xDST[7:0]}};
|
2'h0: xDWBDO <= {(4){xDST[7:0]}};
|
// 16'bit
|
// 16'bit
|
2'h1: xDWBDO <= {(2){xDST[15:0]}};
|
2'h1: xDWBDO <= {(2){xDST[15:0]}};
|
// 32'bit
|
// 32'bit
|
2'h2: xDWBDO <= xDST;
|
2'h2: xDWBDO <= xDST;
|
default: xDWBDO <= 32'hX;
|
// FSL
|
|
2'h3: xDWBDO <= xFSL;
|
|
//default: xDWBDO <= 32'hX;
|
endcase // case (rOPC[1:0])
|
endcase // case (rOPC[1:0])
|
|
|
always @(posedge gclk)
|
always @(posedge gclk)
|
if (grst) begin
|
if (grst) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|