mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
switched comparator to dc flip version
This commit is contained in:
parent
30891550f5
commit
fe31ee92e8
@ -80,7 +80,7 @@ module comparator #(parameter WIDTH=64) (
|
|||||||
assign flags = {eq, lt, ltu};
|
assign flags = {eq, lt, ltu};
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
// This comaprator is best
|
// This comparator is best
|
||||||
module comparator_dc_flip #(parameter WIDTH=64) (
|
module comparator_dc_flip #(parameter WIDTH=64) (
|
||||||
input logic [WIDTH-1:0] a, b,
|
input logic [WIDTH-1:0] a, b,
|
||||||
input logic sgnd,
|
input logic sgnd,
|
||||||
@ -94,7 +94,7 @@ module comparator_dc_flip #(parameter WIDTH=64) (
|
|||||||
assign bf = {b[WIDTH-1] ^ sgnd, b[WIDTH-2:0]};
|
assign bf = {b[WIDTH-1] ^ sgnd, b[WIDTH-2:0]};
|
||||||
|
|
||||||
// behavioral description gives best results
|
// behavioral description gives best results
|
||||||
assign eq = (af == bf);
|
assign eq = (a == b);
|
||||||
assign lt = (af < bf);
|
assign lt = (af < bf);
|
||||||
assign flags = {eq, lt};
|
assign flags = {eq, lt};
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -41,7 +41,7 @@ module controller(
|
|||||||
output logic IllegalBaseInstrFaultD,
|
output logic IllegalBaseInstrFaultD,
|
||||||
// Execute stage control signals
|
// Execute stage control signals
|
||||||
input logic StallE, FlushE,
|
input logic StallE, FlushE,
|
||||||
input logic [2:0] FlagsE,
|
input logic [1:0] FlagsE,
|
||||||
input logic FWriteIntE,
|
input logic FWriteIntE,
|
||||||
output logic PCSrcE, // for datapath and Hazard Unit
|
output logic PCSrcE, // for datapath and Hazard Unit
|
||||||
output logic [2:0] ALUControlE,
|
output logic [2:0] ALUControlE,
|
||||||
@ -52,6 +52,7 @@ module controller(
|
|||||||
output logic MDUE, W64E,
|
output logic MDUE, W64E,
|
||||||
output logic JumpE,
|
output logic JumpE,
|
||||||
output logic SCE,
|
output logic SCE,
|
||||||
|
output logic BranchSignedE,
|
||||||
// Memory stage control signals
|
// Memory stage control signals
|
||||||
input logic StallM, FlushM,
|
input logic StallM, FlushM,
|
||||||
output logic [1:0] MemRWM,
|
output logic [1:0] MemRWM,
|
||||||
@ -211,8 +212,9 @@ module controller(
|
|||||||
{IEURegWriteE, ResultSrcE, MemRWE, JumpE, BranchE, ALUControlE, ALUSrcAE, ALUSrcBE, ALUResultSrcE, CSRReadE, CSRWriteE, PrivilegedE, Funct3E, W64E, MDUE, AtomicE, InvalidateICacheE, FlushDCacheE, FencePendingE, InstrValidE});
|
{IEURegWriteE, ResultSrcE, MemRWE, JumpE, BranchE, ALUControlE, ALUSrcAE, ALUSrcBE, ALUResultSrcE, CSRReadE, CSRWriteE, PrivilegedE, Funct3E, W64E, MDUE, AtomicE, InvalidateICacheE, FlushDCacheE, FencePendingE, InstrValidE});
|
||||||
|
|
||||||
// Branch Logic
|
// Branch Logic
|
||||||
assign {eqE, ltE, ltuE} = FlagsE;
|
assign BranchSignedE = ~(Funct3E[2:1] == 2'b11);
|
||||||
mux4 #(1) branchflagmux(eqE, 1'b0, ltE, ltuE, Funct3E[2:1], BranchFlagE);
|
assign {eqE, ltE} = FlagsE;
|
||||||
|
mux3 #(1) branchflagmux(eqE, 1'b0, ltE, Funct3E[2:1], BranchFlagE);
|
||||||
assign BranchTakenE = BranchFlagE ^ Funct3E[0];
|
assign BranchTakenE = BranchFlagE ^ Funct3E[0];
|
||||||
assign PCSrcE = JumpE | BranchE & BranchTakenE;
|
assign PCSrcE = JumpE | BranchE & BranchTakenE;
|
||||||
|
|
||||||
|
@ -43,11 +43,12 @@ module datapath (
|
|||||||
input logic ALUSrcAE, ALUSrcBE,
|
input logic ALUSrcAE, ALUSrcBE,
|
||||||
input logic ALUResultSrcE,
|
input logic ALUResultSrcE,
|
||||||
input logic JumpE,
|
input logic JumpE,
|
||||||
|
input logic BranchSignedE,
|
||||||
input logic IllegalFPUInstrE,
|
input logic IllegalFPUInstrE,
|
||||||
input logic [`XLEN-1:0] FWriteDataE,
|
input logic [`XLEN-1:0] FWriteDataE,
|
||||||
input logic [`XLEN-1:0] PCE,
|
input logic [`XLEN-1:0] PCE,
|
||||||
input logic [`XLEN-1:0] PCLinkE,
|
input logic [`XLEN-1:0] PCLinkE,
|
||||||
output logic [2:0] FlagsE,
|
output logic [1:0] FlagsE,
|
||||||
output logic [`XLEN-1:0] IEUAdrE,
|
output logic [`XLEN-1:0] IEUAdrE,
|
||||||
output logic [`XLEN-1:0] ForwardedSrcAE, ForwardedSrcBE, // *** these are the src outputs before the mux choosing between them and PCE to put in srcA/B
|
output logic [`XLEN-1:0] ForwardedSrcAE, ForwardedSrcBE, // *** these are the src outputs before the mux choosing between them and PCE to put in srcA/B
|
||||||
// Memory stage signals
|
// Memory stage signals
|
||||||
@ -106,7 +107,7 @@ module datapath (
|
|||||||
|
|
||||||
mux3 #(`XLEN) faemux(R1E, ResultW, IFResultM, ForwardAE, ForwardedSrcAE);
|
mux3 #(`XLEN) faemux(R1E, ResultW, IFResultM, ForwardAE, ForwardedSrcAE);
|
||||||
mux3 #(`XLEN) fbemux(R2E, ResultW, IFResultM, ForwardBE, ForwardedSrcBE);
|
mux3 #(`XLEN) fbemux(R2E, ResultW, IFResultM, ForwardBE, ForwardedSrcBE);
|
||||||
comparator #(`XLEN) comp(ForwardedSrcAE, ForwardedSrcBE, FlagsE);
|
comparator_dc_flip #(`XLEN) comp(ForwardedSrcAE, ForwardedSrcBE, BranchSignedE, FlagsE);
|
||||||
mux2 #(`XLEN) srcamux(ForwardedSrcAE, PCE, ALUSrcAE, SrcAE);
|
mux2 #(`XLEN) srcamux(ForwardedSrcAE, PCE, ALUSrcAE, SrcAE);
|
||||||
mux2 #(`XLEN) srcbmux(ForwardedSrcBE, ExtImmE, ALUSrcBE, SrcBE);
|
mux2 #(`XLEN) srcbmux(ForwardedSrcBE, ExtImmE, ALUSrcBE, SrcBE);
|
||||||
alu #(`XLEN) alu(SrcAE, SrcBE, ALUControlE, Funct3E, ALUResultE, IEUAdrE);
|
alu #(`XLEN) alu(SrcAE, SrcBE, ALUControlE, Funct3E, ALUResultE, IEUAdrE);
|
||||||
|
@ -78,7 +78,7 @@ module ieu (
|
|||||||
);
|
);
|
||||||
|
|
||||||
logic [2:0] ImmSrcD;
|
logic [2:0] ImmSrcD;
|
||||||
logic [2:0] FlagsE;
|
logic [1:0] FlagsE;
|
||||||
logic [2:0] ALUControlE;
|
logic [2:0] ALUControlE;
|
||||||
logic ALUSrcAE, ALUSrcBE;
|
logic ALUSrcAE, ALUSrcBE;
|
||||||
logic [2:0] ResultSrcW;
|
logic [2:0] ResultSrcW;
|
||||||
@ -93,19 +93,20 @@ module ieu (
|
|||||||
logic RegWriteM, RegWriteW;
|
logic RegWriteM, RegWriteW;
|
||||||
logic MemReadE, CSRReadE;
|
logic MemReadE, CSRReadE;
|
||||||
logic JumpE;
|
logic JumpE;
|
||||||
|
logic BranchSignedE;
|
||||||
|
|
||||||
controller c(
|
controller c(
|
||||||
.clk, .reset, .StallD, .FlushD, .InstrD, .ImmSrcD,
|
.clk, .reset, .StallD, .FlushD, .InstrD, .ImmSrcD,
|
||||||
.IllegalIEUInstrFaultD, .IllegalBaseInstrFaultD, .StallE, .FlushE, .FlagsE, .FWriteIntE,
|
.IllegalIEUInstrFaultD, .IllegalBaseInstrFaultD, .StallE, .FlushE, .FlagsE, .FWriteIntE,
|
||||||
.PCSrcE, .ALUControlE, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .MemReadE, .CSRReadE,
|
.PCSrcE, .ALUControlE, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .MemReadE, .CSRReadE,
|
||||||
.Funct3E, .MDUE, .W64E, .JumpE, .StallM, .FlushM, .MemRWM,
|
.Funct3E, .MDUE, .W64E, .JumpE, .SCE, .BranchSignedE, .StallM, .FlushM, .MemRWM,
|
||||||
.CSRReadM, .CSRWriteM, .PrivilegedM, .SCE, .AtomicM, .Funct3M,
|
.CSRReadM, .CSRWriteM, .PrivilegedM, .AtomicM, .Funct3M,
|
||||||
.RegWriteM, .InvalidateICacheM, .FlushDCacheM, .InstrValidM, .FWriteIntM,
|
.RegWriteM, .InvalidateICacheM, .FlushDCacheM, .InstrValidM, .FWriteIntM,
|
||||||
.StallW, .FlushW, .RegWriteW, .ResultSrcW, .CSRWriteFencePendingDEM, .StoreStallD);
|
.StallW, .FlushW, .RegWriteW, .ResultSrcW, .CSRWriteFencePendingDEM, .StoreStallD);
|
||||||
|
|
||||||
datapath dp(
|
datapath dp(
|
||||||
.clk, .reset, .ImmSrcD, .InstrD, .StallE, .FlushE, .ForwardAE, .ForwardBE,
|
.clk, .reset, .ImmSrcD, .InstrD, .StallE, .FlushE, .ForwardAE, .ForwardBE,
|
||||||
.ALUControlE, .Funct3E, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .JumpE, .IllegalFPUInstrE,
|
.ALUControlE, .Funct3E, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .JumpE, .BranchSignedE, .IllegalFPUInstrE,
|
||||||
.FWriteDataE, .PCE, .PCLinkE, .FlagsE, .IEUAdrE, .ForwardedSrcAE, .ForwardedSrcBE,
|
.FWriteDataE, .PCE, .PCLinkE, .FlagsE, .IEUAdrE, .ForwardedSrcAE, .ForwardedSrcBE,
|
||||||
.StallM, .FlushM, .FWriteIntM, .FIntResM, .SrcAM, .WriteDataE, .FResSelW,
|
.StallM, .FlushM, .FWriteIntM, .FIntResM, .SrcAM, .WriteDataE, .FResSelW,
|
||||||
.StallW, .FlushW, .RegWriteW, .SquashSCW, .ResultSrcW, .ReadDataW, .FCvtIntResW,
|
.StallW, .FlushW, .RegWriteW, .SquashSCW, .ResultSrcW, .ReadDataW, .FCvtIntResW,
|
||||||
|
Loading…
Reference in New Issue
Block a user