mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Merge branch 'main' of github.com:davidharrishmc/riscv-wally into main
This commit is contained in:
commit
babcea195a
@ -31,7 +31,7 @@
|
|||||||
`define XLEN 64
|
`define XLEN 64
|
||||||
|
|
||||||
// MISA RISC-V configuration per specification
|
// MISA RISC-V configuration per specification
|
||||||
`define MISA (32'h00000104 | 0 << 5 | 1 << 3 | 1 << 18 | 1 << 20 | 1 << 12 | 1 << 0)
|
`define MISA (32'h00000104 | 0 << 5 | 0 << 3 | 1 << 18 | 1 << 20 | 1 << 12 | 1 << 0)
|
||||||
`define A_SUPPORTED ((`MISA >> 0) % 2 == 1)
|
`define A_SUPPORTED ((`MISA >> 0) % 2 == 1)
|
||||||
`define C_SUPPORTED ((`MISA >> 2) % 2 == 1)
|
`define C_SUPPORTED ((`MISA >> 2) % 2 == 1)
|
||||||
`define D_SUPPORTED ((`MISA >> 3) % 2 == 1)
|
`define D_SUPPORTED ((`MISA >> 3) % 2 == 1)
|
||||||
|
@ -25,535 +25,455 @@
|
|||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module fpu (
|
module fpu (
|
||||||
input logic [2:0] FRM_REGW, // Rounding mode from CSR
|
input logic [2:0] FRM_REGW, // Rounding mode from CSR
|
||||||
input logic reset,
|
input logic reset,
|
||||||
//input logic clear, // *** not being used anywhere
|
//input logic clear, // *** not being used anywhere
|
||||||
input logic clk,
|
input logic clk,
|
||||||
input logic [31:0] InstrD,
|
input logic [31:0] InstrD,
|
||||||
input logic [`XLEN-1:0] SrcAE, // Integer input being processed
|
input logic [`XLEN-1:0] SrcAE, // Integer input being processed
|
||||||
input logic [`XLEN-1:0] SrcAM, // Integer input being written into fpreg
|
input logic [`XLEN-1:0] SrcAM, // Integer input being written into fpreg
|
||||||
input logic StallE, StallM, StallW,
|
input logic StallE, StallM, StallW,
|
||||||
input logic FlushE, FlushM, FlushW,
|
input logic FlushE, FlushM, FlushW,
|
||||||
input logic [`AHBW-1:0] HRDATA,
|
input logic [`AHBW-1:0] HRDATA,
|
||||||
input logic RegWriteD,
|
input logic RegWriteD,
|
||||||
output logic [4:0] SetFflagsM,
|
output logic [4:0] SetFflagsM,
|
||||||
output logic [31:0] FSROutW,
|
output logic [31:0] FSROutW,
|
||||||
output logic [1:0] FMemRWM,
|
output logic [1:0] FMemRWM,
|
||||||
output logic FStallD,
|
output logic FStallD,
|
||||||
output logic FWriteIntE, FWriteIntM, FWriteIntW,
|
output logic FWriteIntE, FWriteIntM, FWriteIntW,
|
||||||
output logic [`XLEN-1:0] FWriteDataM,
|
output logic [`XLEN-1:0] FWriteDataM,
|
||||||
output logic FDivSqrtDoneM,
|
output logic FDivSqrtDoneM,
|
||||||
output logic IllegalFPUInstrD,
|
output logic IllegalFPUInstrD,
|
||||||
output logic [`XLEN-1:0] FPUResultW);
|
output logic [`XLEN-1:0] FPUResultW);
|
||||||
|
|
||||||
|
// control logic signal instantiation
|
||||||
|
logic FWriteEnD, FWriteEnE, FWriteEnM, FWriteEnW; // FP register write enable
|
||||||
|
logic [2:0] FrmD, FrmE, FrmM, FrmW; // FP rounding mode
|
||||||
|
logic FmtD, FmtE, FmtM, FmtW; // FP precision 0-single 1-double
|
||||||
//control logic signal instantiation
|
logic FDivStartD, FDivStartE; // Start division
|
||||||
logic FWriteEnD, FWriteEnE, FWriteEnM, FWriteEnW; // FP register write enable
|
logic FWriteIntD; // Write to integer register
|
||||||
logic [2:0] FrmD, FrmE, FrmM, FrmW; // FP rounding mode
|
logic FOutputInput2D, FOutputInput2E; // Put Input2 in Input1 if a store instruction
|
||||||
logic FmtD, FmtE, FmtM, FmtW; // FP precision 0-single 1-double
|
logic [1:0] FMemRWD, FMemRWE; // Read and write enable for memory
|
||||||
logic FDivStartD, FDivStartE; // Start division
|
logic [1:0] FForwardInput1D, FForwardInput1E; // Input1 forwarding mux control signal
|
||||||
logic FWriteIntD; // Write to integer register
|
logic [1:0] FForwardInput2D, FForwardInput2E; // Input2 forwarding mux control signal
|
||||||
logic FOutputInput2D, FOutputInput2E; // Put Input2 in Input1 if a store instruction
|
logic FForwardInput3D, FForwardInput3E; // Input3 forwarding mux control signal
|
||||||
logic [1:0] FMemRWD, FMemRWE; // Read and write enable for memory
|
logic FInput2UsedD; // Is input 2 used
|
||||||
logic [1:0] FForwardInput1D, FForwardInput1E; // Input1 forwarding mux control signal
|
logic FInput3UsedD; // Is input 3 used
|
||||||
logic [1:0] FForwardInput2D, FForwardInput2E; // Input2 forwarding mux control signal
|
logic [2:0] FResultSelD, FResultSelE, FResultSelM, FResultSelW; // Select FP result
|
||||||
logic FForwardInput3D, FForwardInput3E; // Input3 forwarding mux control signal
|
logic [3:0] FOpCtrlD, FOpCtrlE, FOpCtrlM; // Select which opperation to do in each component
|
||||||
logic FInput2UsedD; // Is input 2 used
|
|
||||||
logic FInput3UsedD; // Is input 3 used
|
// regfile signals
|
||||||
logic [2:0] FResultSelD, FResultSelE, FResultSelM, FResultSelW; // Select FP result
|
logic [4:0] RdE, RdM, RdW; // ***Can take from ieu
|
||||||
logic [3:0] FOpCtrlD, FOpCtrlE, FOpCtrlM; // Select which opperation to do in each component
|
logic [`XLEN-1:0] FWDM; // Write data for FP register
|
||||||
|
logic [`XLEN-1:0] FRD1D, FRD2D, FRD3D; // Read Data from FP register
|
||||||
// regfile signals
|
logic [`XLEN-1:0] FRD1E, FRD2E, FRD3E;
|
||||||
logic [4:0] RdE, RdM, RdW; // ***Can take from ieu
|
logic [`XLEN-1:0] FInput1E, FInput1M, FInput1tmpE;
|
||||||
logic [`XLEN-1:0] FWDM; // Write data for FP register
|
logic [`XLEN-1:0] FInput2E, FInput2M;
|
||||||
logic [`XLEN-1:0] FRD1D, FRD2D, FRD3D; // Read Data from FP register
|
logic [`XLEN-1:0] FInput3E, FInput3M;
|
||||||
logic [`XLEN-1:0] FRD1E, FRD2E, FRD3E;
|
logic [`XLEN-1:0] FLoadStoreResultM, FLoadStoreResultW; // Result for load, store, and move to int-reg instructions
|
||||||
logic [`XLEN-1:0] FInput1E, FInput1M, FInput1tmpE;
|
|
||||||
logic [`XLEN-1:0] FInput2E, FInput2M;
|
// div/sqrt signals
|
||||||
logic [`XLEN-1:0] FInput3E, FInput3M;
|
logic DivDenormM, DivDenormW;
|
||||||
logic [`XLEN-1:0] FLoadStoreResultM, FLoadStoreResultW; // Result for load, store, and move to int-reg instructions
|
logic DivOvEn, DivUnEn;
|
||||||
|
logic DivBusyM;
|
||||||
// div/sqrt signals
|
logic [63:0] FDivResultM, FDivResultW;
|
||||||
logic DivDenormM, DivDenormW;
|
logic [4:0] FDivFlagsM, FDivFlagsW;
|
||||||
logic DivOvEn, DivUnEn;
|
|
||||||
logic DivBusyM;
|
// FMA signals
|
||||||
logic [63:0] FDivResultM, FDivResultW;
|
logic [12:0] aligncntE, aligncntM;
|
||||||
logic [4:0] FDivFlagsM, FDivFlagsW;
|
logic [105:0] rE, rM;
|
||||||
|
logic [105:0] sE, sM;
|
||||||
// FMA signals
|
logic [163:0] tE, tM;
|
||||||
logic [12:0] aligncntE, aligncntM;
|
logic [8:0] normcntE, normcntM;
|
||||||
logic [105:0] rE, rM;
|
logic [12:0] aeE, aeM;
|
||||||
logic [105:0] sE, sM;
|
logic bsE, bsM;
|
||||||
logic [163:0] tE, tM;
|
logic killprodE, killprodM;
|
||||||
logic [8:0] normcntE, normcntM;
|
logic prodofE, prodofM;
|
||||||
logic [12:0] aeE, aeM;
|
logic xzeroE, xzeroM;
|
||||||
logic bsE, bsM;
|
logic yzeroE, yzeroM;
|
||||||
logic killprodE, killprodM;
|
logic zzeroE, zzeroM;
|
||||||
logic prodofE, prodofM;
|
logic xdenormE, xdenormM;
|
||||||
logic xzeroE, xzeroM;
|
logic ydenormE, ydenormM;
|
||||||
logic yzeroE, yzeroM;
|
logic zdenormE, zdenormM;
|
||||||
logic zzeroE, zzeroM;
|
logic xinfE, xinfM;
|
||||||
logic xdenormE, xdenormM;
|
logic yinfE, yinfM;
|
||||||
logic ydenormE, ydenormM;
|
logic zinfE, zinfM;
|
||||||
logic zdenormE, zdenormM;
|
logic xnanE, xnanM;
|
||||||
logic xinfE, xinfM;
|
logic ynanE, ynanM;
|
||||||
logic yinfE, yinfM;
|
logic znanE, znanM;
|
||||||
logic zinfE, zinfM;
|
logic nanE, nanM;
|
||||||
logic xnanE, xnanM;
|
logic [8:0] sumshiftE, sumshiftM;
|
||||||
logic ynanE, ynanM;
|
logic sumshiftzeroE, sumshiftzeroM;
|
||||||
logic znanE, znanM;
|
logic prodinfE, prodinfM;
|
||||||
logic nanE, nanM;
|
logic [63:0] FmaResultM, FmaResultW;
|
||||||
logic [8:0] sumshiftE, sumshiftM;
|
logic [4:0] FmaFlagsM, FmaFlagsW;
|
||||||
logic sumshiftzeroE, sumshiftzeroM;
|
|
||||||
logic prodinfE, prodinfM;
|
// add/cvt signals
|
||||||
logic [63:0] FmaResultM, FmaResultW;
|
logic [63:0] AddSumE, AddSumTcE;
|
||||||
logic [4:0] FmaFlagsM, FmaFlagsW;
|
logic [3:0] AddSelInvE;
|
||||||
|
logic [10:0] AddExpPostSumE;
|
||||||
// add/cvt signals
|
logic AddCorrSignE, AddOp1NormE, AddOp2NormE, AddOpANormE, AddOpBNormE, AddInvalidE;
|
||||||
logic [63:0] AddSumE, AddSumTcE;
|
logic AddDenormInE, AddSwapE, AddNormOvflowE, AddSignAE;
|
||||||
logic [3:0] AddSelInvE;
|
logic AddConvertE;
|
||||||
logic [10:0] AddExpPostSumE;
|
logic [63:0] AddFloat1E, AddFloat2E;
|
||||||
logic AddCorrSignE, AddOp1NormE, AddOp2NormE, AddOpANormE, AddOpBNormE, AddInvalidE;
|
logic [11:0] AddExp1DenormE, AddExp2DenormE;
|
||||||
logic AddDenormInE, AddSwapE, AddNormOvflowE, AddSignAE;
|
logic [10:0] AddExponentE;
|
||||||
logic AddConvertE;
|
logic [2:0] AddRmE;
|
||||||
logic [63:0] AddFloat1E, AddFloat2E;
|
logic [3:0] AddOpTypeE;
|
||||||
logic [11:0] AddExp1DenormE, AddExp2DenormE;
|
logic AddPE, AddOvEnE, AddUnEnE;
|
||||||
logic [10:0] AddExponentE;
|
logic AddDenormM;
|
||||||
logic [2:0] AddRmE;
|
logic [63:0] AddSumM, AddSumTcM;
|
||||||
logic [3:0] AddOpTypeE;
|
logic [3:0] AddSelInvM;
|
||||||
logic AddPE, AddOvEnE, AddUnEnE;
|
logic [10:0] AddExpPostSumM;
|
||||||
logic AddDenormM;
|
logic AddCorrSignM, AddOp1NormM, AddOp2NormM, AddOpANormM, AddOpBNormM, AddInvalidM;
|
||||||
logic [63:0] AddSumM, AddSumTcM;
|
logic AddDenormInM, AddSwapM, AddNormOvflowM, AddSignAM;
|
||||||
logic [3:0] AddSelInvM;
|
logic AddConvertM, AddSignM;
|
||||||
logic [10:0] AddExpPostSumM;
|
logic [63:0] AddFloat1M, AddFloat2M;
|
||||||
logic AddCorrSignM, AddOp1NormM, AddOp2NormM, AddOpANormM, AddOpBNormM, AddInvalidM;
|
logic [11:0] AddExp1DenormM, AddExp2DenormM;
|
||||||
logic AddDenormInM, AddSwapM, AddNormOvflowM, AddSignAM;
|
logic [10:0] AddExponentM;
|
||||||
logic AddConvertM, AddSignM;
|
logic [63:0] AddOp1M, AddOp2M;
|
||||||
logic [63:0] AddFloat1M, AddFloat2M;
|
logic [2:0] AddRmM;
|
||||||
logic [11:0] AddExp1DenormM, AddExp2DenormM;
|
logic [3:0] AddOpTypeM;
|
||||||
logic [10:0] AddExponentM;
|
logic AddPM, AddOvEnM, AddUnEnM;
|
||||||
logic [63:0] AddOp1M, AddOp2M;
|
logic [63:0] FAddResultM, FAddResultW;
|
||||||
logic [2:0] AddRmM;
|
logic [4:0] FAddFlagsM, FAddFlagsW;
|
||||||
logic [3:0] AddOpTypeM;
|
|
||||||
logic AddPM, AddOvEnM, AddUnEnM;
|
// cmp signals
|
||||||
logic [63:0] FAddResultM, FAddResultW;
|
logic [7:0] WE, WM;
|
||||||
logic [4:0] FAddFlagsM, FAddFlagsW;
|
logic [7:0] XE, XM;
|
||||||
|
logic ANaNE, ANaNM;
|
||||||
//cmp signals
|
logic BNaNE, BNaNM;
|
||||||
logic [7:0] WE, WM;
|
logic AzeroE, AzeroM;
|
||||||
logic [7:0] XE, XM;
|
logic BzeroE, BzeroM;
|
||||||
logic ANaNE, ANaNM;
|
logic CmpInvalidM, CmpInvalidW;
|
||||||
logic BNaNE, BNaNM;
|
logic [1:0] CmpFCCM, CmpFCCW;
|
||||||
logic AzeroE, AzeroM;
|
logic [63:0] FCmpResultM, FCmpResultW;
|
||||||
logic BzeroE, BzeroM;
|
|
||||||
logic CmpInvalidM, CmpInvalidW;
|
// fsgn signals
|
||||||
logic [1:0] CmpFCCM, CmpFCCW;
|
logic [63:0] SgnResultE, SgnResultM, SgnResultW;
|
||||||
logic [63:0] FCmpResultM, FCmpResultW;
|
logic [4:0] SgnFlagsE, SgnFlagsM, SgnFlagsW;
|
||||||
|
|
||||||
// fsgn signals
|
// instantiation of W stage regfile signals
|
||||||
logic [63:0] SgnResultE, SgnResultM, SgnResultW;
|
logic [`XLEN-1:0] SrcAW;
|
||||||
logic [4:0] SgnFlagsE, SgnFlagsM, SgnFlagsW;
|
|
||||||
|
// classify signals
|
||||||
//instantiation of W stage regfile signals
|
logic [63:0] ClassResultE, ClassResultM, ClassResultW;
|
||||||
logic [`XLEN-1:0] SrcAW;
|
|
||||||
|
// 64-bit FPU result
|
||||||
// classify signals
|
logic [63:0] FPUResult64W, FPUResult64E;
|
||||||
logic [63:0] ClassResultE, ClassResultM, ClassResultW;
|
logic [4:0] FPUFlagsW;
|
||||||
|
|
||||||
// other
|
// pipeline control logic
|
||||||
logic [63:0] FPUResult64W, FPUResult64E; // 64-bit FPU result
|
logic PipeEnableDE;
|
||||||
logic [4:0] FPUFlagsW;
|
logic PipeEnableEM;
|
||||||
|
logic PipeEnableMW;
|
||||||
// pipeline control logic
|
logic PipeClearDE;
|
||||||
logic PipeEnableDE;
|
logic PipeClearEM;
|
||||||
logic PipeEnableEM;
|
logic PipeClearMW;
|
||||||
logic PipeEnableMW;
|
|
||||||
logic PipeClearDE;
|
// temporarily assign pipe clear and enable signals
|
||||||
logic PipeClearEM;
|
// to never flush & always be running
|
||||||
logic PipeClearMW;
|
localparam PipeClear = 1'b0;
|
||||||
|
localparam PipeEnable = 1'b1;
|
||||||
//temporarily assign pipe clear and enable signals
|
always_comb begin
|
||||||
//to never flush & always be running
|
PipeEnableDE = ~StallE;
|
||||||
localparam PipeClear = 1'b0;
|
PipeEnableEM = ~StallM;
|
||||||
localparam PipeEnable = 1'b1;
|
PipeEnableMW = ~StallW;
|
||||||
always_comb begin
|
PipeClearDE = FlushE;
|
||||||
|
PipeClearEM = FlushM;
|
||||||
PipeEnableDE = ~StallE;
|
PipeClearMW = FlushW;
|
||||||
PipeEnableEM = ~StallM;
|
end
|
||||||
PipeEnableMW = ~StallW;
|
|
||||||
PipeClearDE = FlushE;
|
//DECODE STAGE
|
||||||
PipeClearEM = FlushM;
|
|
||||||
PipeClearMW = FlushW;
|
// Hazard unit for FPU
|
||||||
|
fpuhazard hazard(.Adr1(InstrD[19:15]), .Adr2(InstrD[24:20]), .Adr3(InstrD[31:27]), .*);
|
||||||
end
|
|
||||||
|
// top-level controller for FPU
|
||||||
|
fctrl ctrl (.Funct7D(InstrD[31:25]), .OpD(InstrD[6:0]), .Rs2D(InstrD[24:20]), .Funct3D(InstrD[14:12]), .*);
|
||||||
|
|
||||||
|
// regfile instantiation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//DECODE STAGE
|
|
||||||
|
|
||||||
//Hazard unit for FPU
|
|
||||||
fpuhazard hazard(.Adr1(InstrD[19:15]), .Adr2(InstrD[24:20]), .Adr3(InstrD[31:27]), .*);
|
|
||||||
|
|
||||||
//top-level controller for FPU
|
|
||||||
fctrl ctrl (.Funct7D(InstrD[31:25]), .OpD(InstrD[6:0]), .Rs2D(InstrD[24:20]), .Funct3D(InstrD[14:12]), .*);
|
|
||||||
|
|
||||||
|
|
||||||
//regfile instantiation
|
|
||||||
FPregfile fpregfile (clk, reset, FWriteEnW,
|
FPregfile fpregfile (clk, reset, FWriteEnW,
|
||||||
InstrD[19:15], InstrD[24:20], InstrD[31:27], RdW,
|
InstrD[19:15], InstrD[24:20], InstrD[31:27], RdW,
|
||||||
FPUResult64W,
|
FPUResult64W,
|
||||||
FRD1D, FRD2D, FRD3D);
|
FRD1D, FRD2D, FRD3D);
|
||||||
|
|
||||||
|
//*****************
|
||||||
|
// fpregfile D/E pipe registers
|
||||||
|
//*****************
|
||||||
|
flopenrc #(64) DEReg1(clk, reset, PipeClearDE, PipeEnableDE, FRD1D, FRD1E);
|
||||||
|
flopenrc #(64) DEReg2(clk, reset, PipeClearDE, PipeEnableDE, FRD2D, FRD2E);
|
||||||
|
flopenrc #(64) DEReg3(clk, reset, PipeClearDE, PipeEnableDE, FRD3D, FRD3E);
|
||||||
|
|
||||||
|
//*****************
|
||||||
//*****************
|
// other D/E pipe registers
|
||||||
//fpregfile D/E pipe registers
|
//*****************
|
||||||
//*****************
|
flopenrc #(1) DEReg4(clk, reset, PipeClearDE, PipeEnableDE, FWriteEnD, FWriteEnE);
|
||||||
flopenrc #(64) DEReg1(clk, reset, PipeClearDE, PipeEnableDE, FRD1D, FRD1E);
|
flopenrc #(3) DEReg5(clk, reset, PipeClearDE, PipeEnableDE, FResultSelD, FResultSelE);
|
||||||
flopenrc #(64) DEReg2(clk, reset, PipeClearDE, PipeEnableDE, FRD2D, FRD2E);
|
flopenrc #(3) DEReg6(clk, reset, PipeClearDE, PipeEnableDE, FrmD, FrmE);
|
||||||
flopenrc #(64) DEReg3(clk, reset, PipeClearDE, PipeEnableDE, FRD3D, FRD3E);
|
flopenrc #(1) DEReg7(clk, reset, PipeClearDE, PipeEnableDE, FmtD, FmtE);
|
||||||
|
flopenrc #(5) DEReg8(clk, reset, PipeClearDE, PipeEnableDE, InstrD[11:7], RdE);
|
||||||
//*****************
|
flopenrc #(4) DEReg9(clk, reset, PipeClearDE, PipeEnableDE, FOpCtrlD, FOpCtrlE);
|
||||||
//other D/E pipe registers
|
flopenrc #(1) DEReg10(clk, reset, PipeClearDE, PipeEnableDE, FDivStartD, FDivStartE);
|
||||||
//*****************
|
flopenrc #(2) DEReg11(clk, reset, PipeClearDE, PipeEnableDE, FForwardInput1D, FForwardInput1E);
|
||||||
flopenrc #(1) DEReg4(clk, reset, PipeClearDE, PipeEnableDE, FWriteEnD, FWriteEnE);
|
flopenrc #(2) DEReg12(clk, reset, PipeClearDE, PipeEnableDE, FForwardInput2D, FForwardInput2E);
|
||||||
flopenrc #(3) DEReg5(clk, reset, PipeClearDE, PipeEnableDE, FResultSelD, FResultSelE);
|
flopenrc #(1) DEReg13(clk, reset, PipeClearDE, PipeEnableDE, FForwardInput3D, FForwardInput3E);
|
||||||
flopenrc #(3) DEReg6(clk, reset, PipeClearDE, PipeEnableDE, FrmD, FrmE);
|
flopenrc #(64) DEReg14(clk, reset, PipeClearDE, PipeEnableDE, FPUResult64W, FPUResult64E);
|
||||||
flopenrc #(1) DEReg7(clk, reset, PipeClearDE, PipeEnableDE, FmtD, FmtE);
|
flopenrc #(1) DEReg15(clk, reset, PipeClearDE, PipeEnableDE, FWriteIntD, FWriteIntE);
|
||||||
flopenrc #(5) DEReg8(clk, reset, PipeClearDE, PipeEnableDE, InstrD[11:7], RdE);
|
flopenrc #(1) DEReg16(clk, reset, PipeClearDE, PipeEnableDE, FOutputInput2D, FOutputInput2E);
|
||||||
flopenrc #(4) DEReg9(clk, reset, PipeClearDE, PipeEnableDE, FOpCtrlD, FOpCtrlE);
|
flopenrc #(2) DEReg17(clk, reset, PipeClearDE, PipeEnableDE, FMemRWD, FMemRWE);
|
||||||
flopenrc #(1) DEReg10(clk, reset, PipeClearDE, PipeEnableDE, FDivStartD, FDivStartE);
|
|
||||||
flopenrc #(2) DEReg11(clk, reset, PipeClearDE, PipeEnableDE, FForwardInput1D, FForwardInput1E);
|
//EXECUTION STAGE
|
||||||
flopenrc #(2) DEReg12(clk, reset, PipeClearDE, PipeEnableDE, FForwardInput2D, FForwardInput2E);
|
|
||||||
flopenrc #(1) DEReg13(clk, reset, PipeClearDE, PipeEnableDE, FForwardInput3D, FForwardInput3E);
|
// input muxs for forwarding
|
||||||
flopenrc #(64) DEReg14(clk, reset, PipeClearDE, PipeEnableDE, FPUResult64W, FPUResult64E);
|
mux4 #(64) FInput1Emux(FRD1E, FPUResult64W, FPUResult64E, SrcAM, FForwardInput1E, FInput1tmpE);
|
||||||
flopenrc #(1) DEReg15(clk, reset, PipeClearDE, PipeEnableDE, FWriteIntD, FWriteIntE);
|
mux3 #(64) FInput2Emux(FRD2E, FPUResult64W, FPUResult64E, FForwardInput2E, FInput2E);
|
||||||
flopenrc #(1) DEReg16(clk, reset, PipeClearDE, PipeEnableDE, FOutputInput2D, FOutputInput2E);
|
mux2 #(64) FInput3Emux(FRD3E, FPUResult64E, FForwardInput3E, FInput3E);
|
||||||
flopenrc #(2) DEReg17(clk, reset, PipeClearDE, PipeEnableDE, FMemRWD, FMemRWE);
|
mux2 #(64) FOutputInput2mux(FInput1tmpE, FInput2E, FOutputInput2E, FInput1E);
|
||||||
|
|
||||||
|
fma1 fma1 (.*);
|
||||||
|
|
||||||
|
// first and only instance of floating-point divider
|
||||||
|
logic fpdivClk;
|
||||||
|
|
||||||
|
clockgater fpdivclkg(.E(FDivStartE),
|
||||||
|
.SE(DivBusyM),
|
||||||
|
.CLK(clk),
|
||||||
|
.ECLK(fpdivClk));
|
||||||
|
|
||||||
|
fpdiv fpdivsqrt (.DivOpType(FOpCtrlE[0]), .clk(fpdivClk));
|
||||||
|
|
||||||
//EXECUTION STAGE
|
// first of two-stage instance of floating-point add/cvt unit
|
||||||
|
fpuaddcvt1 fpadd1 (.*);
|
||||||
|
|
||||||
|
// first of two-stage instance of floating-point comparator
|
||||||
// input muxs for forwarding
|
fpucmp1 fpcmp1 (WE, XE, ANaNE, BNaNE, AzeroE, BzeroE, FInput1E, FInput2E, FOpCtrlE[1:0]);
|
||||||
mux4 #(64) FInput1Emux(FRD1E, FPUResult64W, FPUResult64E, SrcAM, FForwardInput1E, FInput1tmpE);
|
|
||||||
mux3 #(64) FInput2Emux(FRD2E, FPUResult64W, FPUResult64E, FForwardInput2E, FInput2E);
|
// first and only instance of floating-point sign converter
|
||||||
mux2 #(64) FInput3Emux(FRD3E, FPUResult64E, FForwardInput3E, FInput3E);
|
fpusgn fpsgn (.SgnOpCodeE(FOpCtrlE[1:0]),.*);
|
||||||
mux2 #(64) FOutputInput2mux(FInput1tmpE, FInput2E, FOutputInput2E, FInput1E);
|
|
||||||
|
// first and only instance of floating-point classify unit
|
||||||
fma1 fma1 (.*);
|
fpuclassify fpuclass (.*);
|
||||||
|
|
||||||
//first and only instance of floating-point divider
|
//*****************
|
||||||
logic fpdivClk;
|
//fpregfile D/E pipe registers
|
||||||
|
//*****************
|
||||||
clockgater fpdivclkg(.E(FDivStartE),
|
flopenrc #(64) EMFpReg1(clk, reset, PipeClearEM, PipeEnableEM, FInput1E, FInput1M);
|
||||||
.SE(DivBusyM),
|
flopenrc #(64) EMFpReg2(clk, reset, PipeClearEM, PipeEnableEM, FInput2E, FInput2M);
|
||||||
.CLK(clk),
|
flopenrc #(64) EMFpReg3(clk, reset, PipeClearEM, PipeEnableEM, FInput3E, FInput3M);
|
||||||
.ECLK(fpdivClk));
|
|
||||||
|
//*****************
|
||||||
fpdiv fpdivsqrt (.DivOpType(FOpCtrlE[0]), .clk(fpdivClk));
|
// fma E/M pipe registers
|
||||||
|
//*****************
|
||||||
//first of two-stage instance of floating-point add/cvt unit
|
flopenrc #(13) EMRegFma1(clk, reset, PipeClearEM, PipeEnableEM, aligncntE, aligncntM);
|
||||||
fpuaddcvt1 fpadd1 (.*);
|
flopenrc #(106) EMRegFma2(clk, reset, PipeClearEM, PipeEnableEM, rE, rM);
|
||||||
|
flopenrc #(106) EMRegFma3(clk, reset, PipeClearEM, PipeEnableEM, sE, sM);
|
||||||
//first of two-stage instance of floating-point comparator
|
flopenrc #(164) EMRegFma4(clk, reset, PipeClearEM, PipeEnableEM, tE, tM);
|
||||||
fpucmp1 fpcmp1 (WE, XE, ANaNE, BNaNE, AzeroE, BzeroE, FInput1E, FInput2E, FOpCtrlE[1:0]);
|
flopenrc #(9) EMRegFma5(clk, reset, PipeClearEM, PipeEnableEM, normcntE, normcntM);
|
||||||
|
flopenrc #(13) EMRegFma6(clk, reset, PipeClearEM, PipeEnableEM, aeE, aeM);
|
||||||
//first and only instance of floating-point sign converter
|
flopenrc #(1) EMRegFma7(clk, reset, PipeClearEM, PipeEnableEM, bsE, bsM);
|
||||||
fpusgn fpsgn (.SgnOpCodeE(FOpCtrlE[1:0]),.*);
|
flopenrc #(1) EMRegFma8(clk, reset, PipeClearEM, PipeEnableEM, killprodE, killprodM);
|
||||||
|
flopenrc #(1) EMRegFma9(clk, reset, PipeClearEM, PipeEnableEM, prodofE, prodofM);
|
||||||
//first and only instance of floating-point classify unit
|
flopenrc #(1) EMRegFma10(clk, reset, PipeClearEM, PipeEnableEM, xzeroE, xzeroM);
|
||||||
fpuclassify fpuclass (.*);
|
flopenrc #(1) EMRegFma11(clk, reset, PipeClearEM, PipeEnableEM, yzeroE, yzeroM);
|
||||||
|
flopenrc #(1) EMRegFma12(clk, reset, PipeClearEM, PipeEnableEM, zzeroE, zzeroM);
|
||||||
|
flopenrc #(1) EMRegFma13(clk, reset, PipeClearEM, PipeEnableEM, xdenormE, xdenormM);
|
||||||
|
flopenrc #(1) EMRegFma14(clk, reset, PipeClearEM, PipeEnableEM, ydenormE, ydenormM);
|
||||||
|
flopenrc #(1) EMRegFma15(clk, reset, PipeClearEM, PipeEnableEM, zdenormE, zdenormM);
|
||||||
|
flopenrc #(1) EMRegFma16(clk, reset, PipeClearEM, PipeEnableEM, xinfE, xinfM);
|
||||||
|
flopenrc #(1) EMRegFma17(clk, reset, PipeClearEM, PipeEnableEM, yinfE, yinfM);
|
||||||
|
flopenrc #(1) EMRegFma18(clk, reset, PipeClearEM, PipeEnableEM, zinfE, zinfM);
|
||||||
|
flopenrc #(1) EMRegFma19(clk, reset, PipeClearEM, PipeEnableEM, xnanE, xnanM);
|
||||||
|
flopenrc #(1) EMRegFma20(clk, reset, PipeClearEM, PipeEnableEM, ynanE, ynanM);
|
||||||
|
flopenrc #(1) EMRegFma21(clk, reset, PipeClearEM, PipeEnableEM, znanE, znanM);
|
||||||
|
flopenrc #(1) EMRegFma22(clk, reset, PipeClearEM, PipeEnableEM, nanE, nanM);
|
||||||
|
flopenrc #(9) EMRegFma23(clk, reset, PipeClearEM, PipeEnableEM, sumshiftE, sumshiftM);
|
||||||
|
flopenrc #(1) EMRegFma24(clk, reset, PipeClearEM, PipeEnableEM, sumshiftzeroE, sumshiftzeroM);
|
||||||
|
flopenrc #(1) EMRegFma25(clk, reset, PipeClearEM, PipeEnableEM, prodinfE, prodinfM);
|
||||||
|
|
||||||
|
//*****************
|
||||||
//*****************
|
// fpadd E/M pipe registers
|
||||||
//fpregfile D/E pipe registers
|
//*****************
|
||||||
//*****************
|
flopenrc #(64) EMRegAdd1(clk, reset, PipeClearEM, PipeEnableEM, AddSumE, AddSumM);
|
||||||
flopenrc #(64) EMFpReg1(clk, reset, PipeClearEM, PipeEnableEM, FInput1E, FInput1M);
|
flopenrc #(64) EMRegAdd2(clk, reset, PipeClearEM, PipeEnableEM, AddSumTcE, AddSumTcM);
|
||||||
flopenrc #(64) EMFpReg2(clk, reset, PipeClearEM, PipeEnableEM, FInput2E, FInput2M);
|
flopenrc #(4) EMRegAdd3(clk, reset, PipeClearEM, PipeEnableEM, AddSelInvE, AddSelInvM);
|
||||||
flopenrc #(64) EMFpReg3(clk, reset, PipeClearEM, PipeEnableEM, FInput3E, FInput3M);
|
flopenrc #(11) EMRegAdd4(clk, reset, PipeClearEM, PipeEnableEM, AddExpPostSumE, AddExpPostSumM);
|
||||||
|
flopenrc #(1) EMRegAdd5(clk, reset, PipeClearEM, PipeEnableEM, AddCorrSignE, AddCorrSignM);
|
||||||
//*****************
|
flopenrc #(1) EMRegAdd6(clk, reset, PipeClearEM, PipeEnableEM, AddOp1NormE, AddOp1NormM);
|
||||||
//fma E/M pipe registers
|
flopenrc #(1) EMRegAdd7(clk, reset, PipeClearEM, PipeEnableEM, AddOp2NormE, AddOp2NormM);
|
||||||
//*****************
|
flopenrc #(1) EMRegAdd8(clk, reset, PipeClearEM, PipeEnableEM, AddOpANormE, AddOpANormM);
|
||||||
flopenrc #(13) EMRegFma1(clk, reset, PipeClearEM, PipeEnableEM, aligncntE, aligncntM);
|
flopenrc #(1) EMRegAdd9(clk, reset, PipeClearEM, PipeEnableEM, AddOpBNormE, AddOpBNormM);
|
||||||
flopenrc #(106) EMRegFma2(clk, reset, PipeClearEM, PipeEnableEM, rE, rM);
|
flopenrc #(1) EMRegAdd10(clk, reset, PipeClearEM, PipeEnableEM, AddInvalidE, AddInvalidM);
|
||||||
flopenrc #(106) EMRegFma3(clk, reset, PipeClearEM, PipeEnableEM, sE, sM);
|
flopenrc #(1) EMRegAdd11(clk, reset, PipeClearEM, PipeEnableEM, AddDenormInE, AddDenormInM);
|
||||||
flopenrc #(164) EMRegFma4(clk, reset, PipeClearEM, PipeEnableEM, tE, tM);
|
flopenrc #(1) EMRegAdd12(clk, reset, PipeClearEM, PipeEnableEM, AddConvertE, AddConvertM);
|
||||||
flopenrc #(9) EMRegFma5(clk, reset, PipeClearEM, PipeEnableEM, normcntE, normcntM);
|
flopenrc #(1) EMRegAdd13(clk, reset, PipeClearEM, PipeEnableEM, AddSwapE, AddSwapM);
|
||||||
flopenrc #(13) EMRegFma6(clk, reset, PipeClearEM, PipeEnableEM, aeE, aeM);
|
flopenrc #(1) EMRegAdd14(clk, reset, PipeClearEM, PipeEnableEM, AddNormOvflowE, AddNormOvflowM);
|
||||||
flopenrc #(1) EMRegFma7(clk, reset, PipeClearEM, PipeEnableEM, bsE, bsM);
|
flopenrc #(1) EMRegAdd15(clk, reset, PipeClearEM, PipeEnableEM, AddSignAE, AddSignAM);
|
||||||
flopenrc #(1) EMRegFma8(clk, reset, PipeClearEM, PipeEnableEM, killprodE, killprodM);
|
flopenrc #(64) EMRegAdd16(clk, reset, PipeClearEM, PipeEnableEM, AddFloat1E, AddFloat1M);
|
||||||
flopenrc #(1) EMRegFma9(clk, reset, PipeClearEM, PipeEnableEM, prodofE, prodofM);
|
flopenrc #(64) EMRegAdd17(clk, reset, PipeClearEM, PipeEnableEM, AddFloat2E, AddFloat2M);
|
||||||
flopenrc #(1) EMRegFma10(clk, reset, PipeClearEM, PipeEnableEM, xzeroE, xzeroM);
|
flopenrc #(12) EMRegAdd18(clk, reset, PipeClearEM, PipeEnableEM, AddExp1DenormE, AddExp1DenormM);
|
||||||
flopenrc #(1) EMRegFma11(clk, reset, PipeClearEM, PipeEnableEM, yzeroE, yzeroM);
|
flopenrc #(12) EMRegAdd19(clk, reset, PipeClearEM, PipeEnableEM, AddExp2DenormE, AddExp2DenormM);
|
||||||
flopenrc #(1) EMRegFma12(clk, reset, PipeClearEM, PipeEnableEM, zzeroE, zzeroM);
|
flopenrc #(11) EMRegAdd20(clk, reset, PipeClearEM, PipeEnableEM, AddExponentE, AddExponentM);
|
||||||
flopenrc #(1) EMRegFma13(clk, reset, PipeClearEM, PipeEnableEM, xdenormE, xdenormM);
|
flopenrc #(3) EMRegAdd23(clk, reset, PipeClearEM, PipeEnableEM, AddRmE, AddRmM);
|
||||||
flopenrc #(1) EMRegFma14(clk, reset, PipeClearEM, PipeEnableEM, ydenormE, ydenormM);
|
flopenrc #(4) EMRegAdd24(clk, reset, PipeClearEM, PipeEnableEM, AddOpTypeE, AddOpTypeM);
|
||||||
flopenrc #(1) EMRegFma15(clk, reset, PipeClearEM, PipeEnableEM, zdenormE, zdenormM);
|
flopenrc #(1) EMRegAdd25(clk, reset, PipeClearEM, PipeEnableEM, AddPE, AddPM);
|
||||||
flopenrc #(1) EMRegFma16(clk, reset, PipeClearEM, PipeEnableEM, xinfE, xinfM);
|
flopenrc #(1) EMRegAdd26(clk, reset, PipeClearEM, PipeEnableEM, AddOvEnE, AddOvEnM);
|
||||||
flopenrc #(1) EMRegFma17(clk, reset, PipeClearEM, PipeEnableEM, yinfE, yinfM);
|
flopenrc #(1) EMRegAdd27(clk, reset, PipeClearEM, PipeEnableEM, AddUnEnE, AddUnEnM);
|
||||||
flopenrc #(1) EMRegFma18(clk, reset, PipeClearEM, PipeEnableEM, zinfE, zinfM);
|
|
||||||
flopenrc #(1) EMRegFma19(clk, reset, PipeClearEM, PipeEnableEM, xnanE, xnanM);
|
//*****************
|
||||||
flopenrc #(1) EMRegFma20(clk, reset, PipeClearEM, PipeEnableEM, ynanE, ynanM);
|
// fpcmp E/M pipe registers
|
||||||
flopenrc #(1) EMRegFma21(clk, reset, PipeClearEM, PipeEnableEM, znanE, znanM);
|
//*****************
|
||||||
flopenrc #(1) EMRegFma22(clk, reset, PipeClearEM, PipeEnableEM, nanE, nanM);
|
flopenrc #(8) EMRegCmp1(clk, reset, PipeClearEM, PipeEnableEM, WE, WM);
|
||||||
flopenrc #(9) EMRegFma23(clk, reset, PipeClearEM, PipeEnableEM, sumshiftE, sumshiftM);
|
flopenrc #(8) EMRegCmp2(clk, reset, PipeClearEM, PipeEnableEM, XE, XM);
|
||||||
flopenrc #(1) EMRegFma24(clk, reset, PipeClearEM, PipeEnableEM, sumshiftzeroE, sumshiftzeroM);
|
flopenrc #(1) EMRegcmp3(clk, reset, PipeClearEM, PipeEnableEM, ANaNE, ANaNM);
|
||||||
flopenrc #(1) EMRegFma25(clk, reset, PipeClearEM, PipeEnableEM, prodinfE, prodinfM);
|
flopenrc #(1) EMRegCmp4(clk, reset, PipeClearEM, PipeEnableEM, BNaNE, BNaNM);
|
||||||
|
flopenrc #(1) EMRegCmp5(clk, reset, PipeClearEM, PipeEnableEM, AzeroE, AzeroM);
|
||||||
//*****************
|
flopenrc #(1) EMRegCmp6(clk, reset, PipeClearEM, PipeEnableEM, BzeroE, BzeroM);
|
||||||
//fpadd E/M pipe registers
|
|
||||||
//*****************
|
// put this in for the event we want to delay fsgn - will otherwise bypass
|
||||||
flopenrc #(64) EMRegAdd1(clk, reset, PipeClearEM, PipeEnableEM, AddSumE, AddSumM);
|
//*****************
|
||||||
flopenrc #(64) EMRegAdd2(clk, reset, PipeClearEM, PipeEnableEM, AddSumTcE, AddSumTcM);
|
// fpsgn E/M pipe registers
|
||||||
flopenrc #(4) EMRegAdd3(clk, reset, PipeClearEM, PipeEnableEM, AddSelInvE, AddSelInvM);
|
//*****************
|
||||||
flopenrc #(11) EMRegAdd4(clk, reset, PipeClearEM, PipeEnableEM, AddExpPostSumE, AddExpPostSumM);
|
flopenrc #(64) EMRegSgn2(clk, reset, PipeClearEM, PipeEnableEM, SgnResultE, SgnResultM);
|
||||||
flopenrc #(1) EMRegAdd5(clk, reset, PipeClearEM, PipeEnableEM, AddCorrSignE, AddCorrSignM);
|
flopenrc #(5) EMRegSgn3(clk, reset, PipeClearEM, PipeEnableEM, SgnFlagsE, SgnFlagsM);
|
||||||
flopenrc #(1) EMRegAdd6(clk, reset, PipeClearEM, PipeEnableEM, AddOp1NormE, AddOp1NormM);
|
|
||||||
flopenrc #(1) EMRegAdd7(clk, reset, PipeClearEM, PipeEnableEM, AddOp2NormE, AddOp2NormM);
|
//*****************
|
||||||
flopenrc #(1) EMRegAdd8(clk, reset, PipeClearEM, PipeEnableEM, AddOpANormE, AddOpANormM);
|
// other E/M pipe registers
|
||||||
flopenrc #(1) EMRegAdd9(clk, reset, PipeClearEM, PipeEnableEM, AddOpBNormE, AddOpBNormM);
|
//*****************
|
||||||
flopenrc #(1) EMRegAdd10(clk, reset, PipeClearEM, PipeEnableEM, AddInvalidE, AddInvalidM);
|
flopenrc #(1) EMReg1(clk, reset, PipeClearEM, PipeEnableEM, FWriteEnE, FWriteEnM);
|
||||||
flopenrc #(1) EMRegAdd11(clk, reset, PipeClearEM, PipeEnableEM, AddDenormInE, AddDenormInM);
|
flopenrc #(3) EMReg2(clk, reset, PipeClearEM, PipeEnableEM, FResultSelE, FResultSelM);
|
||||||
flopenrc #(1) EMRegAdd12(clk, reset, PipeClearEM, PipeEnableEM, AddConvertE, AddConvertM);
|
flopenrc #(3) EMReg3(clk, reset, PipeClearEM, PipeEnableEM, FrmE, FrmM);
|
||||||
flopenrc #(1) EMRegAdd13(clk, reset, PipeClearEM, PipeEnableEM, AddSwapE, AddSwapM);
|
flopenrc #(1) EMReg4(clk, reset, PipeClearEM, PipeEnableEM, FmtE, FmtM);
|
||||||
flopenrc #(1) EMRegAdd14(clk, reset, PipeClearEM, PipeEnableEM, AddNormOvflowE, AddNormOvflowM);
|
flopenrc #(5) EMReg5(clk, reset, PipeClearEM, PipeEnableEM, RdE, RdM);
|
||||||
flopenrc #(1) EMRegAdd15(clk, reset, PipeClearEM, PipeEnableEM, AddSignAE, AddSignAM);
|
flopenrc #(4) EMReg6(clk, reset, PipeClearEM, PipeEnableEM, FOpCtrlE, FOpCtrlM);
|
||||||
flopenrc #(64) EMRegAdd16(clk, reset, PipeClearEM, PipeEnableEM, AddFloat1E, AddFloat1M);
|
flopenrc #(1) EMReg7(clk, reset, PipeClearEM, PipeEnableEM, FWriteIntE, FWriteIntM);
|
||||||
flopenrc #(64) EMRegAdd17(clk, reset, PipeClearEM, PipeEnableEM, AddFloat2E, AddFloat2M);
|
flopenrc #(2) EMReg8(clk, reset, PipeClearEM, PipeEnableEM, FMemRWE, FMemRWM);
|
||||||
flopenrc #(12) EMRegAdd18(clk, reset, PipeClearEM, PipeEnableEM, AddExp1DenormE, AddExp1DenormM);
|
|
||||||
flopenrc #(12) EMRegAdd19(clk, reset, PipeClearEM, PipeEnableEM, AddExp2DenormE, AddExp2DenormM);
|
//*****************
|
||||||
flopenrc #(11) EMRegAdd20(clk, reset, PipeClearEM, PipeEnableEM, AddExponentE, AddExponentM);
|
// fpuclassify E/M pipe registers
|
||||||
flopenrc #(3) EMRegAdd23(clk, reset, PipeClearEM, PipeEnableEM, AddRmE, AddRmM);
|
//*****************
|
||||||
flopenrc #(4) EMRegAdd24(clk, reset, PipeClearEM, PipeEnableEM, AddOpTypeE, AddOpTypeM);
|
flopenrc #(64) EMRegClass(clk, reset, PipeClearEM, PipeEnableEM, ClassResultE, ClassResultM);
|
||||||
flopenrc #(1) EMRegAdd25(clk, reset, PipeClearEM, PipeEnableEM, AddPE, AddPM);
|
|
||||||
flopenrc #(1) EMRegAdd26(clk, reset, PipeClearEM, PipeEnableEM, AddOvEnE, AddOvEnM);
|
//BEGIN MEMORY STAGE
|
||||||
flopenrc #(1) EMRegAdd27(clk, reset, PipeClearEM, PipeEnableEM, AddUnEnE, AddUnEnM);
|
|
||||||
|
assign FWriteDataM = FInput1M;
|
||||||
//*****************
|
|
||||||
//fpcmp E/M pipe registers
|
mux2 #(64) FLoadStoreResultMux(HRDATA, FInput1M, |FOpCtrlM[2:1], FLoadStoreResultM);
|
||||||
//*****************
|
|
||||||
flopenrc #(8) EMRegCmp1(clk, reset, PipeClearEM, PipeEnableEM, WE, WM);
|
fma2 fma2(.*);
|
||||||
flopenrc #(8) EMRegCmp2(clk, reset, PipeClearEM, PipeEnableEM, XE, XM);
|
|
||||||
flopenrc #(1) EMRegcmp3(clk, reset, PipeClearEM, PipeEnableEM, ANaNE, ANaNM);
|
// second instance of two-stage floating-point add/cvt unit
|
||||||
flopenrc #(1) EMRegCmp4(clk, reset, PipeClearEM, PipeEnableEM, BNaNE, BNaNM);
|
fpuaddcvt2 fpadd2 (.*);
|
||||||
flopenrc #(1) EMRegCmp5(clk, reset, PipeClearEM, PipeEnableEM, AzeroE, AzeroM);
|
|
||||||
flopenrc #(1) EMRegCmp6(clk, reset, PipeClearEM, PipeEnableEM, BzeroE, BzeroM);
|
// second instance of two-stage floating-point comparator
|
||||||
|
fpucmp2 fpcmp2 (.Invalid(CmpInvalidM), .FCC(CmpFCCM), .ANaN(ANaNM), .BNaN(BNaNM), .Azero(AzeroM),
|
||||||
//put this in for the event we want to delay fsgn - will otherwise bypass
|
.Bzero(BzeroM), .w(WM), .x(XM), .Sel({1'b0, FmtM}), .op1(FInput1M), .op2(FInput2M), .*);
|
||||||
//*****************
|
|
||||||
//fpsgn E/M pipe registers
|
//*****************
|
||||||
//*****************
|
// fma M/W pipe registers
|
||||||
flopenrc #(64) EMRegSgn2(clk, reset, PipeClearEM, PipeEnableEM, SgnResultE, SgnResultM);
|
//*****************
|
||||||
flopenrc #(5) EMRegSgn3(clk, reset, PipeClearEM, PipeEnableEM, SgnFlagsE, SgnFlagsM);
|
flopenrc #(64) MWRegFma1(clk, reset, PipeClearMW, PipeEnableMW, FmaResultM, FmaResultW);
|
||||||
|
flopenrc #(5) MWRegFma2(clk, reset, PipeClearMW, PipeEnableMW, FmaFlagsM, FmaFlagsW);
|
||||||
//*****************
|
|
||||||
//other E/M pipe registers
|
//*****************
|
||||||
//*****************
|
// fpdiv M/W pipe registers
|
||||||
flopenrc #(1) EMReg1(clk, reset, PipeClearEM, PipeEnableEM, FWriteEnE, FWriteEnM);
|
//*****************
|
||||||
flopenrc #(3) EMReg2(clk, reset, PipeClearEM, PipeEnableEM, FResultSelE, FResultSelM);
|
flopenrc #(64) MWRegDiv1(clk, reset, PipeClearMW, PipeEnableMW, FDivResultM, FDivResultW);
|
||||||
flopenrc #(3) EMReg3(clk, reset, PipeClearEM, PipeEnableEM, FrmE, FrmM);
|
flopenrc #(5) MWRegDiv2(clk, reset, PipeClearMW, PipeEnableMW, FDivFlagsM, FDivFlagsW);
|
||||||
flopenrc #(1) EMReg4(clk, reset, PipeClearEM, PipeEnableEM, FmtE, FmtM);
|
flopenrc #(1) MWRegDiv3(clk, reset, PipeClearMW, PipeEnableMW, DivDenormM, DivDenormW);
|
||||||
flopenrc #(5) EMReg5(clk, reset, PipeClearEM, PipeEnableEM, RdE, RdM);
|
|
||||||
flopenrc #(4) EMReg6(clk, reset, PipeClearEM, PipeEnableEM, FOpCtrlE, FOpCtrlM);
|
//*****************
|
||||||
flopenrc #(1) EMReg7(clk, reset, PipeClearEM, PipeEnableEM, FWriteIntE, FWriteIntM);
|
// fpadd M/W pipe registers
|
||||||
flopenrc #(2) EMReg8(clk, reset, PipeClearEM, PipeEnableEM, FMemRWE, FMemRWM);
|
//*****************
|
||||||
|
flopenrc #(64) MWRegAdd1(clk, reset, PipeClearMW, PipeEnableMW, FAddResultM, FAddResultW);
|
||||||
//*****************
|
flopenrc #(5) MWRegAdd2(clk, reset, PipeClearMW, PipeEnableMW, FAddFlagsM, FAddFlagsW);
|
||||||
//fpuclassify E/M pipe registers
|
|
||||||
//*****************
|
//*****************
|
||||||
flopenrc #(64) EMRegClass(clk, reset, PipeClearEM, PipeEnableEM, ClassResultE, ClassResultM);
|
// fpcmp M/W pipe registers
|
||||||
|
//*****************
|
||||||
|
flopenrc #(1) MWRegCmp1(clk, reset, PipeClearMW, PipeEnableMW, CmpInvalidM, CmpInvalidW);
|
||||||
|
flopenrc #(2) MWRegCmp2(clk, reset, PipeClearMW, PipeEnableMW, CmpFCCM, CmpFCCW);
|
||||||
|
flopenrc #(64) MWRegCmp3(clk, reset, PipeClearMW, PipeEnableMW, FCmpResultM, FCmpResultW);
|
||||||
|
|
||||||
|
//*****************
|
||||||
|
// fpsgn M/W pipe registers
|
||||||
|
//*****************
|
||||||
//BEGIN MEMORY STAGE
|
flopenrc #(64) MWRegSgn1(clk, reset, PipeClearMW, PipeEnableMW, SgnResultM, SgnResultW);
|
||||||
|
flopenrc #(5) MWRegSgn2(clk, reset, PipeClearMW, PipeEnableMW, SgnFlagsM, SgnFlagsW);
|
||||||
assign FWriteDataM = FInput1M;
|
|
||||||
|
//*****************
|
||||||
mux2 #(64) FLoadStoreResultMux(HRDATA, FInput1M, |FOpCtrlM[2:1], FLoadStoreResultM);
|
// other M/W pipe registers
|
||||||
|
//*****************
|
||||||
fma2 fma2(.*);
|
flopenrc #(1) MWReg1(clk, reset, PipeClearMW, PipeEnableMW, FWriteEnM, FWriteEnW);
|
||||||
|
flopenrc #(3) MWReg2(clk, reset, PipeClearMW, PipeEnableMW, FResultSelM, FResultSelW);
|
||||||
//second instance of two-stage floating-point add/cvt unit
|
flopenrc #(1) MWReg3(clk, reset, PipeClearMW, PipeEnableMW, FmtM, FmtW);
|
||||||
fpuaddcvt2 fpadd2 (.*);
|
flopenrc #(5) MWReg4(clk, reset, PipeClearMW, PipeEnableMW, RdM, RdW);
|
||||||
|
flopenrc #(`XLEN) MWReg5(clk, reset, PipeClearMW, PipeEnableMW, SrcAM, SrcAW);
|
||||||
//second instance of two-stage floating-point comparator
|
flopenrc #(64) MWReg6(clk, reset, PipeClearMW, PipeEnableMW, FLoadStoreResultM, FLoadStoreResultW);
|
||||||
fpucmp2 fpcmp2 (.Invalid(CmpInvalidM), .FCC(CmpFCCM), .ANaN(ANaNM), .BNaN(BNaNM), .Azero(AzeroM), .Bzero(BzeroM), .w(WM), .x(XM), .Sel({1'b0, FmtM}), .op1(FInput1M), .op2(FInput2M), .*);
|
flopenrc #(1) MWReg7(clk, reset, PipeClearMW, PipeEnableMW, FWriteIntM, FWriteIntW);
|
||||||
|
|
||||||
|
//*****************
|
||||||
|
// fpuclassify M/W pipe registers
|
||||||
|
//*****************
|
||||||
|
flopenrc #(64) MWRegClass(clk, reset, PipeClearMW, PipeEnableMW, ClassResultM, ClassResultW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//fma M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(64) MWRegFma1(clk, reset, PipeClearMW, PipeEnableMW, FmaResultM, FmaResultW);
|
|
||||||
flopenrc #(5) MWRegFma2(clk, reset, PipeClearMW, PipeEnableMW, FmaFlagsM, FmaFlagsW);
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//fpdiv M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(64) MWRegDiv1(clk, reset, PipeClearMW, PipeEnableMW, FDivResultM, FDivResultW);
|
|
||||||
flopenrc #(5) MWRegDiv2(clk, reset, PipeClearMW, PipeEnableMW, FDivFlagsM, FDivFlagsW);
|
|
||||||
flopenrc #(1) MWRegDiv3(clk, reset, PipeClearMW, PipeEnableMW, DivDenormM, DivDenormW);
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//fpadd M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(64) MWRegAdd1(clk, reset, PipeClearMW, PipeEnableMW, FAddResultM, FAddResultW);
|
|
||||||
flopenrc #(5) MWRegAdd2(clk, reset, PipeClearMW, PipeEnableMW, FAddFlagsM, FAddFlagsW);
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//fpcmp M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(1) MWRegCmp1(clk, reset, PipeClearMW, PipeEnableMW, CmpInvalidM, CmpInvalidW);
|
|
||||||
flopenrc #(2) MWRegCmp2(clk, reset, PipeClearMW, PipeEnableMW, CmpFCCM, CmpFCCW);
|
|
||||||
flopenrc #(64) MWRegCmp3(clk, reset, PipeClearMW, PipeEnableMW, FCmpResultM, FCmpResultW);
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//fpsgn M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(64) MWRegSgn1(clk, reset, PipeClearMW, PipeEnableMW, SgnResultM, SgnResultW);
|
|
||||||
flopenrc #(5) MWRegSgn2(clk, reset, PipeClearMW, PipeEnableMW, SgnFlagsM, SgnFlagsW);
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//other M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(1) MWReg1(clk, reset, PipeClearMW, PipeEnableMW, FWriteEnM, FWriteEnW);
|
|
||||||
flopenrc #(3) MWReg2(clk, reset, PipeClearMW, PipeEnableMW, FResultSelM, FResultSelW);
|
|
||||||
flopenrc #(1) MWReg3(clk, reset, PipeClearMW, PipeEnableMW, FmtM, FmtW);
|
|
||||||
flopenrc #(5) MWReg4(clk, reset, PipeClearMW, PipeEnableMW, RdM, RdW);
|
|
||||||
flopenrc #(`XLEN) MWReg5(clk, reset, PipeClearMW, PipeEnableMW, SrcAM, SrcAW);
|
|
||||||
flopenrc #(64) MWReg6(clk, reset, PipeClearMW, PipeEnableMW, FLoadStoreResultM, FLoadStoreResultW);
|
|
||||||
flopenrc #(1) MWReg7(clk, reset, PipeClearMW, PipeEnableMW, FWriteIntM, FWriteIntW);
|
|
||||||
|
|
||||||
|
|
||||||
//*****************
|
|
||||||
//fpuclassify M/W pipe registers
|
|
||||||
//*****************
|
|
||||||
flopenrc #(64) MWRegClass(clk, reset, PipeClearMW, PipeEnableMW, ClassResultM, ClassResultW);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#########################################
|
//#########################################
|
||||||
//BEGIN WRITEBACK STAGE
|
// BEGIN WRITEBACK STAGE
|
||||||
//#########################################
|
//#########################################
|
||||||
|
|
||||||
always_comb begin
|
always_comb begin
|
||||||
case (FResultSelW)
|
case (FResultSelW)
|
||||||
// div/sqrt
|
// div/sqrt
|
||||||
3'b000 : FPUFlagsW = FDivFlagsW;
|
3'b000 : FPUFlagsW = FDivFlagsW;
|
||||||
// cmp
|
// cmp
|
||||||
3'b001 : FPUFlagsW = {CmpInvalidW, 4'b0};
|
3'b001 : FPUFlagsW = {CmpInvalidW, 4'b0};
|
||||||
//fma/mult
|
//fma/mult
|
||||||
3'b010 : FPUFlagsW = FmaFlagsW;
|
3'b010 : FPUFlagsW = FmaFlagsW;
|
||||||
// sgn inj
|
// sgn inj
|
||||||
3'b011 : FPUFlagsW = SgnFlagsW;
|
3'b011 : FPUFlagsW = SgnFlagsW;
|
||||||
// add/sub/cnvt
|
// add/sub/cnvt
|
||||||
3'b100 : FPUFlagsW = FAddFlagsW;
|
3'b100 : FPUFlagsW = FAddFlagsW;
|
||||||
// classify
|
// classify
|
||||||
3'b101 : FPUFlagsW = 5'b0;
|
3'b101 : FPUFlagsW = 5'b0;
|
||||||
// output SrcAW
|
// output SrcAW
|
||||||
3'b110 : FPUFlagsW = 5'b0;
|
3'b110 : FPUFlagsW = 5'b0;
|
||||||
// output FRD1
|
// output FRD1
|
||||||
3'b111 : FPUFlagsW = 5'b0;
|
3'b111 : FPUFlagsW = 5'b0;
|
||||||
default : FPUFlagsW = 5'bxxxxx;
|
default : FPUFlagsW = 5'bxxxxx;
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
always_comb begin
|
||||||
always_comb begin
|
case (FResultSelW)
|
||||||
case (FResultSelW)
|
// div/sqrt
|
||||||
// div/sqrt
|
3'b000 : FPUResult64W = FDivResultW;
|
||||||
3'b000 : FPUResult64W = FDivResultW;
|
// cmp
|
||||||
// cmp
|
3'b001 : FPUResult64W = FCmpResultW;
|
||||||
3'b001 : FPUResult64W = FCmpResultW;
|
//fma/mult
|
||||||
//fma/mult
|
3'b010 : FPUResult64W = FmaResultW;
|
||||||
3'b010 : FPUResult64W = FmaResultW;
|
// sgn inj
|
||||||
// sgn inj
|
3'b011 : FPUResult64W = SgnResultW;
|
||||||
3'b011 : FPUResult64W = SgnResultW;
|
// add/sub/cnvt
|
||||||
// add/sub/cnvt
|
3'b100 : FPUResult64W = FAddResultW;
|
||||||
3'b100 : FPUResult64W = FAddResultW;
|
// classify
|
||||||
// classify
|
3'b101 : FPUResult64W = ClassResultW;
|
||||||
3'b101 : FPUResult64W = ClassResultW;
|
// output SrcAW
|
||||||
// output SrcAW
|
3'b110 : FPUResult64W = SrcAW;
|
||||||
3'b110 : FPUResult64W = SrcAW;
|
// Load/Store/Move to FP-register
|
||||||
// Load/Store/Move to FP-register
|
3'b111 : FPUResult64W = FLoadStoreResultW;
|
||||||
3'b111 : FPUResult64W = FLoadStoreResultW;
|
default : FPUResult64W = {64{1'bx}};
|
||||||
default : FPUResult64W = {64{1'bx}};
|
endcase
|
||||||
endcase
|
end // always_comb
|
||||||
end
|
|
||||||
//interface between XLEN size datapath and double-precision sized
|
// interface between XLEN size datapath and double-precision sized
|
||||||
//floating-point results
|
// floating-point results
|
||||||
//
|
//
|
||||||
//define offsets for LSB zero extension or truncation
|
// define offsets for LSB zero extension or truncation
|
||||||
always_comb begin
|
always_comb begin
|
||||||
|
// zero extension
|
||||||
//zero extension
|
|
||||||
FPUResultW = FPUResult64W[63:64-`XLEN];
|
FPUResultW = FPUResult64W[63:64-`XLEN];
|
||||||
SetFflagsM = FPUFlagsW;
|
SetFflagsM = FPUFlagsW;
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule // fpu
|
||||||
|
|
||||||
end
|
|
||||||
endmodule
|
|
||||||
|
@ -76,7 +76,7 @@ module muldiv (
|
|||||||
assign Den0 = W64E ? {{32{SrcBE[31]&signedDivide}}, SrcBE[31:0]} : SrcBE;
|
assign Den0 = W64E ? {{32{SrcBE[31]&signedDivide}}, SrcBE[31:0]} : SrcBE;
|
||||||
end else begin // RV32 has no W-type instructions
|
end else begin // RV32 has no W-type instructions
|
||||||
assign Num0 = SrcAE;
|
assign Num0 = SrcAE;
|
||||||
assign Den0 = SrcAE;
|
assign Den0 = SrcBE;
|
||||||
end
|
end
|
||||||
|
|
||||||
// capture the Numerator/Denominator
|
// capture the Numerator/Denominator
|
||||||
|
@ -320,11 +320,11 @@ string tests32f[] = '{
|
|||||||
"rv32m/I-MUL-01", "2000",
|
"rv32m/I-MUL-01", "2000",
|
||||||
"rv32m/I-MULH-01", "2000",
|
"rv32m/I-MULH-01", "2000",
|
||||||
"rv32m/I-MULHSU-01", "2000",
|
"rv32m/I-MULHSU-01", "2000",
|
||||||
"rv32m/I-MULHU-01", "2000"
|
"rv32m/I-MULHU-01", "2000",
|
||||||
//"rv32m/I-DIV-01", "2000",
|
"rv32m/I-DIV-01", "2000",
|
||||||
//"rv32m/I-DIVU-01", "2000",
|
"rv32m/I-DIVU-01", "2000",
|
||||||
//"rv32m/I-REM-01", "2000",
|
"rv32m/I-REM-01", "2000",
|
||||||
//"rv32m/I-REMU-01", "2000"
|
"rv32m/I-REMU-01", "2000"
|
||||||
};
|
};
|
||||||
|
|
||||||
string tests32ic[] = '{
|
string tests32ic[] = '{
|
||||||
|
Loading…
Reference in New Issue
Block a user