mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Minor cosmetic update to fpu.sv
This commit is contained in:
parent
2eeb12c674
commit
564d7c4adb
@ -46,10 +46,6 @@ module fpu (
|
|||||||
output logic IllegalFPUInstrD,
|
output logic IllegalFPUInstrD,
|
||||||
output logic [`XLEN-1:0] FPUResultW);
|
output logic [`XLEN-1:0] FPUResultW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// control logic signal instantiation
|
// control logic signal instantiation
|
||||||
logic FWriteEnD, FWriteEnE, FWriteEnM, FWriteEnW; // FP register write enable
|
logic FWriteEnD, FWriteEnE, FWriteEnM, FWriteEnW; // FP register write enable
|
||||||
logic [2:0] FrmD, FrmE, FrmM, FrmW; // FP rounding mode
|
logic [2:0] FrmD, FrmE, FrmM, FrmW; // FP rounding mode
|
||||||
@ -163,8 +159,8 @@ module fpu (
|
|||||||
// classify signals
|
// classify signals
|
||||||
logic [63:0] ClassResultE, ClassResultM, ClassResultW;
|
logic [63:0] ClassResultE, ClassResultM, ClassResultW;
|
||||||
|
|
||||||
// other
|
// 64-bit FPU result
|
||||||
logic [63:0] FPUResult64W, FPUResult64E; // 64-bit FPU result
|
logic [63:0] FPUResult64W, FPUResult64E;
|
||||||
logic [4:0] FPUFlagsW;
|
logic [4:0] FPUFlagsW;
|
||||||
|
|
||||||
// pipeline control logic
|
// pipeline control logic
|
||||||
@ -180,28 +176,14 @@ module fpu (
|
|||||||
localparam PipeClear = 1'b0;
|
localparam PipeClear = 1'b0;
|
||||||
localparam PipeEnable = 1'b1;
|
localparam PipeEnable = 1'b1;
|
||||||
always_comb begin
|
always_comb begin
|
||||||
|
|
||||||
PipeEnableDE = ~StallE;
|
PipeEnableDE = ~StallE;
|
||||||
PipeEnableEM = ~StallM;
|
PipeEnableEM = ~StallM;
|
||||||
PipeEnableMW = ~StallW;
|
PipeEnableMW = ~StallW;
|
||||||
PipeClearDE = FlushE;
|
PipeClearDE = FlushE;
|
||||||
PipeClearEM = FlushM;
|
PipeClearEM = FlushM;
|
||||||
PipeClearMW = FlushW;
|
PipeClearMW = FlushW;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//DECODE STAGE
|
//DECODE STAGE
|
||||||
|
|
||||||
// Hazard unit for FPU
|
// Hazard unit for FPU
|
||||||
@ -210,21 +192,12 @@ module fpu (
|
|||||||
// top-level controller for FPU
|
// top-level controller for FPU
|
||||||
fctrl ctrl (.Funct7D(InstrD[31:25]), .OpD(InstrD[6:0]), .Rs2D(InstrD[24:20]), .Funct3D(InstrD[14:12]), .*);
|
fctrl ctrl (.Funct7D(InstrD[31:25]), .OpD(InstrD[6:0]), .Rs2D(InstrD[24:20]), .Funct3D(InstrD[14:12]), .*);
|
||||||
|
|
||||||
|
|
||||||
// regfile instantiation
|
// 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
|
// fpregfile D/E pipe registers
|
||||||
//*****************
|
//*****************
|
||||||
@ -250,22 +223,8 @@ module fpu (
|
|||||||
flopenrc #(1) DEReg16(clk, reset, PipeClearDE, PipeEnableDE, FOutputInput2D, FOutputInput2E);
|
flopenrc #(1) DEReg16(clk, reset, PipeClearDE, PipeEnableDE, FOutputInput2D, FOutputInput2E);
|
||||||
flopenrc #(2) DEReg17(clk, reset, PipeClearDE, PipeEnableDE, FMemRWD, FMemRWE);
|
flopenrc #(2) DEReg17(clk, reset, PipeClearDE, PipeEnableDE, FMemRWD, FMemRWE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//EXECUTION STAGE
|
//EXECUTION STAGE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// input muxs for forwarding
|
// input muxs for forwarding
|
||||||
mux4 #(64) FInput1Emux(FRD1E, FPUResult64W, FPUResult64E, SrcAM, FForwardInput1E, FInput1tmpE);
|
mux4 #(64) FInput1Emux(FRD1E, FPUResult64W, FPUResult64E, SrcAM, FForwardInput1E, FInput1tmpE);
|
||||||
mux3 #(64) FInput2Emux(FRD2E, FPUResult64W, FPUResult64E, FForwardInput2E, FInput2E);
|
mux3 #(64) FInput2Emux(FRD2E, FPUResult64W, FPUResult64E, FForwardInput2E, FInput2E);
|
||||||
@ -296,21 +255,6 @@ module fpu (
|
|||||||
// first and only instance of floating-point classify unit
|
// first and only instance of floating-point classify unit
|
||||||
fpuclassify fpuclass (.*);
|
fpuclassify fpuclass (.*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//*****************
|
//*****************
|
||||||
//fpregfile D/E pipe registers
|
//fpregfile D/E pipe registers
|
||||||
//*****************
|
//*****************
|
||||||
@ -410,13 +354,6 @@ module fpu (
|
|||||||
//*****************
|
//*****************
|
||||||
flopenrc #(64) EMRegClass(clk, reset, PipeClearEM, PipeEnableEM, ClassResultE, ClassResultM);
|
flopenrc #(64) EMRegClass(clk, reset, PipeClearEM, PipeEnableEM, ClassResultE, ClassResultM);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//BEGIN MEMORY STAGE
|
//BEGIN MEMORY STAGE
|
||||||
|
|
||||||
assign FWriteDataM = FInput1M;
|
assign FWriteDataM = FInput1M;
|
||||||
@ -429,17 +366,8 @@ module fpu (
|
|||||||
fpuaddcvt2 fpadd2 (.*);
|
fpuaddcvt2 fpadd2 (.*);
|
||||||
|
|
||||||
// second instance of two-stage floating-point comparator
|
// second instance of two-stage floating-point comparator
|
||||||
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), .*);
|
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), .*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//*****************
|
//*****************
|
||||||
// fma M/W pipe registers
|
// fma M/W pipe registers
|
||||||
@ -484,19 +412,11 @@ module fpu (
|
|||||||
flopenrc #(64) MWReg6(clk, reset, PipeClearMW, PipeEnableMW, FLoadStoreResultM, FLoadStoreResultW);
|
flopenrc #(64) MWReg6(clk, reset, PipeClearMW, PipeEnableMW, FLoadStoreResultM, FLoadStoreResultW);
|
||||||
flopenrc #(1) MWReg7(clk, reset, PipeClearMW, PipeEnableMW, FWriteIntM, FWriteIntW);
|
flopenrc #(1) MWReg7(clk, reset, PipeClearMW, PipeEnableMW, FWriteIntM, FWriteIntW);
|
||||||
|
|
||||||
|
|
||||||
//*****************
|
//*****************
|
||||||
// fpuclassify M/W pipe registers
|
// fpuclassify M/W pipe registers
|
||||||
//*****************
|
//*****************
|
||||||
flopenrc #(64) MWRegClass(clk, reset, PipeClearMW, PipeEnableMW, ClassResultM, ClassResultW);
|
flopenrc #(64) MWRegClass(clk, reset, PipeClearMW, PipeEnableMW, ClassResultM, ClassResultW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#########################################
|
//#########################################
|
||||||
// BEGIN WRITEBACK STAGE
|
// BEGIN WRITEBACK STAGE
|
||||||
//#########################################
|
//#########################################
|
||||||
@ -523,7 +443,6 @@ module fpu (
|
|||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
always_comb begin
|
always_comb begin
|
||||||
case (FResultSelW)
|
case (FResultSelW)
|
||||||
// div/sqrt
|
// div/sqrt
|
||||||
@ -544,16 +463,17 @@ module fpu (
|
|||||||
3'b111 : FPUResult64W = FLoadStoreResultW;
|
3'b111 : FPUResult64W = FLoadStoreResultW;
|
||||||
default : FPUResult64W = {64{1'bx}};
|
default : FPUResult64W = {64{1'bx}};
|
||||||
endcase
|
endcase
|
||||||
end
|
end // always_comb
|
||||||
|
|
||||||
// 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
|
end
|
||||||
endmodule
|
|
||||||
|
endmodule // fpu
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user