Line 1... |
Line 1... |
// $Id: aeMB_ctrl.v,v 1.6 2007-11-10 16:39:38 sybreon Exp $
|
// $Id: aeMB_ctrl.v,v 1.7 2007-11-14 22:14:34 sybreon Exp $
|
//
|
//
|
// AEMB CONTROL UNIT
|
// AEMB CONTROL UNIT
|
//
|
//
|
// 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... |
//
|
//
|
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
// License along with AEMB. If not, see <http://www.gnu.org/licenses/>.
|
// License along with AEMB. If not, see <http://www.gnu.org/licenses/>.
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.6 2007/11/10 16:39:38 sybreon
|
|
// Upgraded license to LGPLv3.
|
|
// Significant performance optimisations.
|
|
//
|
// Revision 1.5 2007/11/09 20:51:52 sybreon
|
// Revision 1.5 2007/11/09 20:51:52 sybreon
|
// Added GET/PUT support through a FSL bus.
|
// Added GET/PUT support through a FSL bus.
|
//
|
//
|
// Revision 1.4 2007/11/08 17:48:14 sybreon
|
// Revision 1.4 2007/11/08 17:48:14 sybreon
|
// Fixed data WISHBONE arbitration problem (reported by J Lee).
|
// Fixed data WISHBONE arbitration problem (reported by J Lee).
|
Line 42... |
Line 46... |
module aeMB_ctrl (/*AUTOARG*/
|
module aeMB_ctrl (/*AUTOARG*/
|
// Outputs
|
// Outputs
|
rMXDST, rMXSRC, rMXTGT, rMXALT, rMXALU, rRW, rDWBSTB, rFSLSTB,
|
rMXDST, rMXSRC, rMXTGT, rMXALT, rMXALU, rRW, rDWBSTB, rFSLSTB,
|
dwb_stb_o, dwb_wre_o, fsl_stb_o, fsl_wre_o,
|
dwb_stb_o, dwb_wre_o, fsl_stb_o, fsl_wre_o,
|
// Inputs
|
// Inputs
|
rXCE, rDLY, rIMM, rALT, rOPC, rRD, rRA, rRB, rPC, rBRA, rMSR_IE,
|
rDLY, rIMM, rALT, rOPC, rRD, rRA, rRB, rPC, rBRA, rMSR_IE, xIREG,
|
dwb_ack_i, iwb_ack_i, iwb_dat_i, fsl_ack_i, gclk, grst, gena
|
dwb_ack_i, iwb_ack_i, fsl_ack_i, gclk, grst, gena
|
);
|
);
|
// INTERNAL
|
// INTERNAL
|
//output [31:2] rPCLNK;
|
//output [31:2] rPCLNK;
|
output [1:0] rMXDST;
|
output [1:0] rMXDST;
|
output [1:0] rMXSRC, rMXTGT, rMXALT;
|
output [1:0] rMXSRC, rMXTGT, rMXALT;
|
output [2:0] rMXALU;
|
output [2:0] rMXALU;
|
output [4:0] rRW;
|
output [4:0] rRW;
|
output rDWBSTB;
|
output rDWBSTB;
|
output rFSLSTB;
|
output rFSLSTB;
|
|
|
input [1:0] rXCE;
|
//input [1:0] rXCE;
|
input rDLY;
|
input rDLY;
|
input [15:0] rIMM;
|
input [15:0] rIMM;
|
input [10:0] rALT;
|
input [10:0] rALT;
|
input [5:0] rOPC;
|
input [5:0] rOPC;
|
input [4:0] rRD, rRA, rRB;
|
input [4:0] rRD, rRA, rRB;
|
input [31:2] rPC;
|
input [31:2] rPC;
|
input rBRA;
|
input rBRA;
|
input rMSR_IE;
|
input rMSR_IE;
|
|
input [31:0] xIREG;
|
|
|
// DATA WISHBONE
|
// DATA WISHBONE
|
output dwb_stb_o;
|
output dwb_stb_o;
|
output dwb_wre_o;
|
output dwb_wre_o;
|
input dwb_ack_i;
|
input dwb_ack_i;
|
|
|
// INST WISHBONE
|
// INST WISHBONE
|
input iwb_ack_i;
|
input iwb_ack_i;
|
input [31:0] iwb_dat_i;
|
|
|
|
// FSL WISHBONE
|
// FSL WISHBONE
|
output fsl_stb_o;
|
output fsl_stb_o;
|
output fsl_wre_o;
|
output fsl_wre_o;
|
input fsl_ack_i;
|
input fsl_ack_i;
|
Line 88... |
Line 92... |
|
|
wire [5:0] wOPC;
|
wire [5:0] wOPC;
|
wire [4:0] wRD, wRA, wRB;
|
wire [4:0] wRD, wRA, wRB;
|
wire [10:0] wALT;
|
wire [10:0] wALT;
|
|
|
assign {wOPC, wRD, wRA, wRB, wALT} = iwb_dat_i; // FIXME: Endian
|
assign {wOPC, wRD, wRA, wRB, wALT} = xIREG; // FIXME: Endian
|
|
|
wire fSFT = (rOPC == 6'o44);
|
wire fSFT = (rOPC == 6'o44);
|
wire fLOG = ({rOPC[5:4],rOPC[2]} == 3'o4);
|
wire fLOG = ({rOPC[5:4],rOPC[2]} == 3'o4);
|
|
|
wire fMUL = (rOPC == 6'o20) | (rOPC == 6'o30);
|
wire fMUL = (rOPC == 6'o20) | (rOPC == 6'o30);
|
Line 177... |
Line 181... |
wire wAFWD_M = (xRW == wRA) & (xMXDST == 2'o2) & wRDWE;
|
wire wAFWD_M = (xRW == wRA) & (xMXDST == 2'o2) & wRDWE;
|
wire wBFWD_M = (xRW == wRB) & (xMXDST == 2'o2) & wRDWE;
|
wire wBFWD_M = (xRW == wRB) & (xMXDST == 2'o2) & wRDWE;
|
wire wAFWD_R = (xRW == wRA) & (xMXDST == 2'o0) & wRDWE;
|
wire wAFWD_R = (xRW == wRA) & (xMXDST == 2'o0) & wRDWE;
|
wire wBFWD_R = (xRW == wRB) & (xMXDST == 2'o0) & wRDWE;
|
wire wBFWD_R = (xRW == wRB) & (xMXDST == 2'o0) & wRDWE;
|
|
|
always @(/*AUTOSENSE*/rBRA or rXCE or wAFWD_M or wAFWD_R or wBCC
|
always @(/*AUTOSENSE*/rBRA or wAFWD_M or wAFWD_R or wBCC or wBFWD_M
|
or wBFWD_M or wBFWD_R or wBRU or wOPC)
|
or wBFWD_R or wBRU or wOPC)
|
if (rBRA | |rXCE) begin
|
//if (rBRA | |rXCE) begin
|
|
if (rBRA) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
// Beginning of autoreset for uninitialized flops
|
// Beginning of autoreset for uninitialized flops
|
xMXALT <= 2'h0;
|
xMXALT <= 2'h0;
|
xMXSRC <= 2'h0;
|
xMXSRC <= 2'h0;
|
xMXTGT <= 2'h0;
|
xMXTGT <= 2'h0;
|
Line 218... |
Line 223... |
end
|
end
|
*/
|
*/
|
|
|
reg [2:0] rMXALU, xMXALU;
|
reg [2:0] rMXALU, xMXALU;
|
|
|
always @(/*AUTOSENSE*/rBRA or rXCE or wBRA or wBSF or wDIV or wLOG
|
always @(/*AUTOSENSE*/rBRA or wBRA or wBSF or wDIV or wLOG or wMOV
|
or wMOV or wMUL or wSFT)
|
or wMUL or wSFT)
|
if (rBRA | |rXCE) begin
|
//if (rBRA | |rXCE) begin
|
|
if (rBRA) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
// Beginning of autoreset for uninitialized flops
|
// Beginning of autoreset for uninitialized flops
|
xMXALU <= 3'h0;
|
xMXALU <= 3'h0;
|
// End of automatics
|
// End of automatics
|
end else begin
|
end else begin
|
Line 240... |
Line 246... |
// --- DELAY SLOT REGISTERS ------------------------------
|
// --- DELAY SLOT REGISTERS ------------------------------
|
|
|
wire fSKIP = (rBRA & !rDLY);
|
wire fSKIP = (rBRA & !rDLY);
|
|
|
always @(/*AUTOSENSE*/fBCC or fBRU or fGET or fLOD or fRTD or fSKIP
|
always @(/*AUTOSENSE*/fBCC or fBRU or fGET or fLOD or fRTD or fSKIP
|
or fSTR or rRD or rXCE)
|
or fSTR or rRD)
|
if (fSKIP) begin
|
if (fSKIP) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
// Beginning of autoreset for uninitialized flops
|
// Beginning of autoreset for uninitialized flops
|
xMXDST <= 2'h0;
|
xMXDST <= 2'h0;
|
xRW <= 5'h0;
|
xRW <= 5'h0;
|
// End of automatics
|
// End of automatics
|
end else begin
|
end else begin
|
case (rXCE)
|
/*
|
2'o2: xMXDST <= 2'o1;
|
case (rXCE)
|
default: xMXDST <= (fSTR | fRTD | fBCC) ? 2'o3 :
|
2'o2: xMXDST <= 2'o1;
|
|
default: xMXDST <= (fSTR | fRTD | fBCC) ? 2'o3 :
|
|
(fLOD | fGET) ? 2'o2 :
|
|
(fBRU) ? 2'o1 :
|
|
2'o0;
|
|
endcase
|
|
|
|
case (rXCE)
|
|
2'o2: xRW <= 5'd14;
|
|
default: xRW <= rRD;
|
|
endcase
|
|
*/
|
|
xMXDST <= (fSTR | fRTD | fBCC) ? 2'o3 :
|
(fLOD | fGET) ? 2'o2 :
|
(fLOD | fGET) ? 2'o2 :
|
(fBRU) ? 2'o1 :
|
(fBRU) ? 2'o1 :
|
2'o0;
|
2'o0;
|
endcase
|
xRW <= rRD;
|
|
|
case (rXCE)
|
|
2'o2: xRW <= 5'd14;
|
|
default: xRW <= rRD;
|
|
endcase
|
|
|
|
end // else: !if(fSKIP)
|
end // else: !if(fSKIP)
|
|
|
|
|
// --- DATA WISHBONE ----------------------------------
|
// --- DATA WISHBONE ----------------------------------
|
|
|
Line 275... |
Line 287... |
|
|
assign dwb_stb_o = rDWBSTB;
|
assign dwb_stb_o = rDWBSTB;
|
assign dwb_wre_o = rDWBWRE;
|
assign dwb_wre_o = rDWBWRE;
|
|
|
|
|
always @(/*AUTOSENSE*/fLOD or fSKIP or fSTR or iwb_ack_i or rXCE)
|
always @(/*AUTOSENSE*/fLOD or fSKIP or fSTR or iwb_ack_i)
|
if (fSKIP | |rXCE) begin
|
//if (fSKIP | |rXCE) begin
|
|
if (fSKIP) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
// Beginning of autoreset for uninitialized flops
|
// Beginning of autoreset for uninitialized flops
|
xDWBSTB <= 1'h0;
|
xDWBSTB <= 1'h0;
|
xDWBWRE <= 1'h0;
|
xDWBWRE <= 1'h0;
|
// End of automatics
|
// End of automatics
|
Line 310... |
Line 323... |
reg rFSLWRE, xFSLWRE;
|
reg rFSLWRE, xFSLWRE;
|
|
|
assign fsl_stb_o = rFSLSTB;
|
assign fsl_stb_o = rFSLSTB;
|
assign fsl_wre_o = rFSLWRE;
|
assign fsl_wre_o = rFSLWRE;
|
|
|
always @(/*AUTOSENSE*/fGET or fPUT or fSKIP or iwb_ack_i or rXCE)
|
always @(/*AUTOSENSE*/fGET or fPUT or fSKIP or iwb_ack_i)
|
if (fSKIP | |rXCE) begin
|
//if (fSKIP | |rXCE) begin
|
|
if (fSKIP) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
// Beginning of autoreset for uninitialized flops
|
// Beginning of autoreset for uninitialized flops
|
xFSLSTB <= 1'h0;
|
xFSLSTB <= 1'h0;
|
xFSLWRE <= 1'h0;
|
xFSLWRE <= 1'h0;
|
// End of automatics
|
// End of automatics
|