Line 1... |
Line 1... |
/* $Id: aeMB2_ctrl.v,v 1.4 2008-04-26 17:57:43 sybreon Exp $
|
/* $Id: aeMB2_ctrl.v,v 1.5 2008-04-28 08:15:25 sybreon Exp $
|
**
|
**
|
** AEMB2 EDK 6.2 COMPATIBLE CORE
|
** AEMB2 EDK 6.2 COMPATIBLE CORE
|
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
|
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
|
**
|
**
|
** This file is part of AEMB.
|
** This file is part of AEMB.
|
Line 98... |
Line 98... |
assign {wOPC, wRD, wRA, wIMM} = ich_dat;
|
assign {wOPC, wRD, wRA, wIMM} = ich_dat;
|
assign wRB = wIMM[15:11];
|
assign wRB = wIMM[15:11];
|
|
|
// decode main opgroups
|
// decode main opgroups
|
|
|
wire fSFT = (wOPC == 6'o44);
|
//wire fSFT = (wOPC == 6'o44);
|
wire fLOG = ({wOPC[5:4],wOPC[2]} == 3'o4);
|
//wire fLOG = ({wOPC[5:4],wOPC[2]} == 3'o4);
|
wire fMUL = (wOPC == 6'o20) | (wOPC == 6'o30);
|
wire fMUL = (wOPC == 6'o20) | (wOPC == 6'o30);
|
wire fBSF = (wOPC == 6'o21) | (wOPC == 6'o31);
|
wire fBSF = (wOPC == 6'o21) | (wOPC == 6'o31);
|
wire fDIV = (wOPC == 6'o22);
|
//wire fDIV = (wOPC == 6'o22);
|
wire fRTD = (wOPC == 6'o55);
|
wire fRTD = (wOPC == 6'o55);
|
wire fBCC = (wOPC == 6'o47) | (wOPC == 6'o57);
|
wire fBCC = (wOPC == 6'o47) | (wOPC == 6'o57);
|
wire fBRU = (wOPC == 6'o46) | (wOPC == 6'o56);
|
wire fBRU = (wOPC == 6'o46) | (wOPC == 6'o56);
|
wire fBRA = fBRU & wRA[3];
|
//wire fBRA = fBRU & wRA[3];
|
wire fIMM = (wOPC == 6'o54);
|
wire fIMM = (wOPC == 6'o54);
|
wire fMOV = (wOPC == 6'o45);
|
wire fMOV = (wOPC == 6'o45);
|
wire fLOD = ({wOPC[5:4],wOPC[2]} == 3'o6);
|
wire fLOD = ({wOPC[5:4],wOPC[2]} == 3'o6);
|
wire fSTR = ({wOPC[5:4],wOPC[2]} == 3'o7);
|
wire fSTR = ({wOPC[5:4],wOPC[2]} == 3'o7);
|
wire fLDST = (wOPC[5:4] == 2'o3);
|
//wire fLDST = (wOPC[5:4] == 2'o3);
|
wire fPUT = (wOPC == 6'o33) & wRB[4];
|
//wire fPUT = (wOPC == 6'o33) & wRB[4];
|
wire fGET = (wOPC == 6'o33) & !wRB[4];
|
wire fGET = (wOPC == 6'o33) & !wRB[4];
|
|
|
|
|
// control signals
|
// control signals
|
wire [31:0] wXCEOP = 32'hBA2D0020; // Vector 0x20
|
//wire [31:0] wXCEOP = 32'hBA2D0020; // Vector 0x20
|
wire [31:0] wINTOP = 32'hB9CE0010; // Vector 0x10
|
//wire [31:0] wINTOP = 32'hB9CE0010; // Vector 0x10
|
wire [31:0] wNOPOP = 32'h88000000; // branch-no-delay/stall
|
//wire [31:0] wNOPOP = 32'h88000000; // branch-no-delay/stall
|
|
|
localparam [2:0] MUX_SFR = 3'o7,
|
localparam [2:0] MUX_SFR = 3'o7,
|
MUX_BSF = 3'o6,
|
MUX_BSF = 3'o6,
|
MUX_MUL = 3'o5,
|
MUX_MUL = 3'o5,
|
MUX_MEM = 3'o4,
|
MUX_MEM = 3'o4,
|
Line 143... |
Line 143... |
rd_of <= 5'h0;
|
rd_of <= 5'h0;
|
// End of automatics
|
// End of automatics
|
end else if (dena) begin
|
end else if (dena) begin
|
|
|
mux_of <= #1
|
mux_of <= #1
|
(hzd_bpc | hzd_fwd) ? MUX_NOP :
|
(hzd_bpc | hzd_fwd | fSTR | fRTD | fBCC) ? MUX_NOP :
|
|
(fLOD | fGET) ? MUX_MEM :
|
(fMOV) ? MUX_SFR :
|
(fMOV) ? MUX_SFR :
|
(fMUL) ? MUX_MUL :
|
(fMUL) ? MUX_MUL :
|
(fBSF) ? MUX_BSF :
|
(fBSF) ? MUX_BSF :
|
(fLOD | fGET) ? MUX_MEM :
|
|
(fBRU) ? MUX_RPC :
|
(fBRU) ? MUX_RPC :
|
(fSTR | fRTD | fBCC) ? MUX_NOP :
|
MUX_ALU;
|
(|wRD) ? MUX_ALU :
|
|
MUX_NOP;
|
|
|
|
opc_of <= #1
|
opc_of <= #1
|
(hzd_bpc | hzd_fwd) ? 6'o42 :
|
(hzd_bpc | hzd_fwd) ? 6'o42 : // XOR (SKIP)
|
wOPC;
|
wOPC;
|
|
|
rd_of <= #1 wRD;
|
rd_of <= #1 wRD;
|
ra_of <= #1 wRA;
|
ra_of <= #1 wRA;
|
imm_of <= #1 wIMM;
|
imm_of <= #1 wIMM;
|
Line 199... |
Line 197... |
reg [2:0] mux_mx;
|
reg [2:0] mux_mx;
|
|
|
wire opb_fwd, opa_fwd, opd_fwd;
|
wire opb_fwd, opa_fwd, opd_fwd;
|
|
|
assign mux_opb = {wOPC[3], opb_fwd};
|
assign mux_opb = {wOPC[3], opb_fwd};
|
assign opb_fwd = ~|(wRB ^ rd_ex) & // RB forwarding needed
|
assign opb_fwd = ((wRB ^ rd_ex) == 5'd0) & // RB forwarding needed
|
fwd_ex & wrb_ex;
|
fwd_ex & wrb_ex;
|
|
|
assign mux_opa = {(fBRU|fBCC), opa_fwd};
|
assign mux_opa = {(fBRU|fBCC), opa_fwd};
|
assign opa_fwd = ~|(wRA ^ rd_ex) & // RA forwarding needed
|
assign opa_fwd = ((wRA ^ rd_ex) == 5'd0) & // RA forwarding needed
|
fwd_ex & wrb_ex;
|
fwd_ex & wrb_ex;
|
|
|
assign mux_opd = {fBCC, opd_fwd};
|
assign mux_opd = {fBCC, opd_fwd};
|
assign opd_fwd = (( ~|(wRA ^ rd_ex) & fBCC) |
|
assign opd_fwd = (( ((wRA ^ rd_ex) == 5'd0) & fBCC) | // RA forwarding
|
( ~|(wRD ^ rd_ex) & fSTR)) &
|
( ((wRD ^ rd_ex) == 5'd0) & fSTR)) & // RD forwarding
|
fwd_ex & wrb_ex;
|
fwd_ex & wrb_ex;
|
|
|
always @(posedge gclk)
|
always @(posedge gclk)
|
if (grst) begin
|
if (grst) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
Line 265... |
Line 263... |
endcase // case (mux_opa)
|
endcase // case (mux_opa)
|
|
|
end // if (dena)
|
end // if (dena)
|
|
|
// Hazard Detection
|
// Hazard Detection
|
wire wFMUL = (mux_ex == MUX_MUL);
|
//wire wFMUL = (mux_ex == MUX_MUL);
|
wire wFBSF = (mux_ex == MUX_BSF);
|
//wire wFBSF = (mux_ex == MUX_BSF);
|
wire wFMEM = (mux_ex == MUX_MEM);
|
//wire wFMEM = (mux_ex == MUX_MEM);
|
wire wFMOV = (mux_ex == MUX_SFR);
|
//wire wFMOV = (mux_ex == MUX_SFR);
|
|
|
assign hzd_fwd = (opd_fwd | opa_fwd | opb_fwd) & mux_ex[2];
|
assign hzd_fwd = (opd_fwd | opa_fwd | opb_fwd) & mux_ex[2];
|
//(wFMUL | wFBSF | wFMEM | wFMOV);
|
//(wFMUL | wFBSF | wFMEM | wFMOV);
|
assign hzd_bpc = (bra_ex[1] & !bra_ex[0]);
|
assign hzd_bpc = (bra_ex[1] & !bra_ex[0]);
|
|
|
endmodule // aeMB2_ctrl
|
endmodule // aeMB2_ctrl
|
|
|
/*
|
/*
|
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
|
Revision 1.4 2008/04/26 17:57:43 sybreon
|
|
Minor performance improvements.
|
|
|
Revision 1.3 2008/04/26 01:09:05 sybreon
|
Revision 1.3 2008/04/26 01:09:05 sybreon
|
Passes basic tests. Minor documentation changes to make it compatible with iverilog pre-processor.
|
Passes basic tests. Minor documentation changes to make it compatible with iverilog pre-processor.
|
|
|
Revision 1.2 2008/04/20 16:34:32 sybreon
|
Revision 1.2 2008/04/20 16:34:32 sybreon
|
Basic version with some features left out.
|
Basic version with some features left out.
|