forked from Github_Repos/cvw
Added ALUSelect signal into datapath, ieu, controller
This commit is contained in:
parent
465aad372a
commit
25c0811d3d
@ -46,6 +46,7 @@ module controller(
|
|||||||
output logic [2:0] ALUControlE, // ALU operation to perform
|
output logic [2:0] ALUControlE, // ALU operation to perform
|
||||||
output logic ALUSrcAE, ALUSrcBE, // ALU operands
|
output logic ALUSrcAE, ALUSrcBE, // ALU operands
|
||||||
output logic ALUResultSrcE, // Selects result to pass on to Memory stage
|
output logic ALUResultSrcE, // Selects result to pass on to Memory stage
|
||||||
|
output logic [2:0] ALUSelectE, // ALU mux select signal
|
||||||
output logic MemReadE, CSRReadE, // Instruction reads memory, reads a CSR (needed for Hazard unit)
|
output logic MemReadE, CSRReadE, // Instruction reads memory, reads a CSR (needed for Hazard unit)
|
||||||
output logic [2:0] Funct3E, // Instruction's funct3 field
|
output logic [2:0] Funct3E, // Instruction's funct3 field
|
||||||
output logic [6:0] Funct7E, // Instruction's funct7 field
|
output logic [6:0] Funct7E, // Instruction's funct7 field
|
||||||
@ -90,6 +91,7 @@ module controller(
|
|||||||
logic BranchD, BranchE; // Branch instruction
|
logic BranchD, BranchE; // Branch instruction
|
||||||
logic ALUOpD; // 0 for address generation, 1 for all other operations (must use Funct3)
|
logic ALUOpD; // 0 for address generation, 1 for all other operations (must use Funct3)
|
||||||
logic [2:0] ALUControlD; // Determines ALU operation
|
logic [2:0] ALUControlD; // Determines ALU operation
|
||||||
|
logic [2:0] ALUSelectD; // ALU mux select signal
|
||||||
logic ALUSrcAD, ALUSrcBD; // ALU inputs
|
logic ALUSrcAD, ALUSrcBD; // ALU inputs
|
||||||
logic ALUResultSrcD, W64D, MDUD; // ALU result, is RV64 W-type, is multiply/divide instruction
|
logic ALUResultSrcD, W64D, MDUD; // ALU result, is RV64 W-type, is multiply/divide instruction
|
||||||
logic CSRZeroSrcD; // Ignore setting and clearing zeros to CSR
|
logic CSRZeroSrcD; // Ignore setting and clearing zeros to CSR
|
||||||
@ -102,7 +104,7 @@ module controller(
|
|||||||
logic InvalidateICacheE, FlushDCacheE;// Invalidate I$, flush D$
|
logic InvalidateICacheE, FlushDCacheE;// Invalidate I$, flush D$
|
||||||
logic [`CTRLW-1:0] ControlsD; // Main Instruction Decoder control signals
|
logic [`CTRLW-1:0] ControlsD; // Main Instruction Decoder control signals
|
||||||
logic SubArithD; // TRUE for R-type subtracts and sra, slt, sltu
|
logic SubArithD; // TRUE for R-type subtracts and sra, slt, sltu
|
||||||
logic subD, sraD, sltD, sltuD; // Indicates if is one of these instructions
|
logic subD, sraD, sltD, sltuD, bextD; // Indicates if is one of these instructions
|
||||||
logic BranchTakenE; // Branch is taken
|
logic BranchTakenE; // Branch is taken
|
||||||
logic eqE, ltE; // Comparator outputs
|
logic eqE, ltE; // Comparator outputs
|
||||||
logic unused;
|
logic unused;
|
||||||
@ -195,9 +197,18 @@ module controller(
|
|||||||
assign sltuD = (Funct3D == 3'b011);
|
assign sltuD = (Funct3D == 3'b011);
|
||||||
assign subD = (Funct3D == 3'b000 & Funct7D[5] & OpD[5]); // OpD[5] needed to distinguish sub from addi
|
assign subD = (Funct3D == 3'b000 & Funct7D[5] & OpD[5]); // OpD[5] needed to distinguish sub from addi
|
||||||
assign sraD = (Funct3D == 3'b101 & Funct7D[5]);
|
assign sraD = (Funct3D == 3'b101 & Funct7D[5]);
|
||||||
assign SubArithD = ALUOpD & (subD | sraD | sltD | sltuD); // TRUE for R-type subtracts and sra, slt, sltu
|
assign SubArithD = ALUOpD & (subD | sraD | sltD | sltuD | (`ZBS_SUPPORTED & bextD)); // TRUE for R-type subtracts and sra, slt, sltu
|
||||||
assign ALUControlD = {W64D, SubArithD, ALUOpD};
|
assign ALUControlD = {W64D, SubArithD, ALUOpD};
|
||||||
|
|
||||||
|
if (`ZBS_SUPPORTED) begin: bitmanipi //change the conditional expression to OR any Z supported flags
|
||||||
|
bmuctrl bmuctrl(.clk, .reset, .StallD, .FlushD, .InstrD, .ALUSelectD, .bextD, .StallE, .FlushE, .Funct7E, .ALUSelectE);
|
||||||
|
end else begin: bitmanipi
|
||||||
|
assign ALUSelectD = Funct3D;
|
||||||
|
assign ALUSelectE = Funct3E;
|
||||||
|
assign bextD = 1'b0;
|
||||||
|
assign Funct7E = 7'b0;
|
||||||
|
end
|
||||||
|
|
||||||
// Fences
|
// Fences
|
||||||
// Ordinary fence is presently a nop
|
// Ordinary fence is presently a nop
|
||||||
// fence.i flushes the D$ and invalidates the I$ if Zifencei is supported and I$ is implemented
|
// fence.i flushes the D$ and invalidates the I$ if Zifencei is supported and I$ is implemented
|
||||||
@ -239,9 +250,6 @@ module controller(
|
|||||||
{RegWriteE, ResultSrcE, MemRWE, CSRReadE, CSRWriteE, PrivilegedE, Funct3E, FWriteIntE, AtomicE, InvalidateICacheE, FlushDCacheE, FenceE, InstrValidE, IntDivE},
|
{RegWriteE, ResultSrcE, MemRWE, CSRReadE, CSRWriteE, PrivilegedE, Funct3E, FWriteIntE, AtomicE, InvalidateICacheE, FlushDCacheE, FenceE, InstrValidE, IntDivE},
|
||||||
{RegWriteM, ResultSrcM, MemRWM, CSRReadM, CSRWriteM, PrivilegedM, Funct3M, FWriteIntM, AtomicM, InvalidateICacheM, FlushDCacheM, FenceM, InstrValidM, IntDivM});
|
{RegWriteM, ResultSrcM, MemRWM, CSRReadM, CSRWriteM, PrivilegedM, Funct3M, FWriteIntM, AtomicM, InvalidateICacheM, FlushDCacheM, FenceM, InstrValidM, IntDivM});
|
||||||
|
|
||||||
// BMU control register
|
|
||||||
flopenrc#(7) controlregBMU(clk, reset, FlushM, ~StallM, {Funct7D}, {Funct7E});
|
|
||||||
|
|
||||||
// Writeback stage pipeline control register
|
// Writeback stage pipeline control register
|
||||||
flopenrc #(5) controlregW(clk, reset, FlushW, ~StallW,
|
flopenrc #(5) controlregW(clk, reset, FlushW, ~StallW,
|
||||||
{RegWriteM, ResultSrcM, IntDivM},
|
{RegWriteM, ResultSrcM, IntDivM},
|
||||||
|
@ -15,6 +15,7 @@ module datapath (
|
|||||||
input logic [2:0] ALUControlE, // Indicate operation ALU performs
|
input logic [2:0] ALUControlE, // Indicate operation ALU performs
|
||||||
input logic ALUSrcAE, ALUSrcBE, // ALU operands
|
input logic ALUSrcAE, ALUSrcBE, // ALU operands
|
||||||
input logic ALUResultSrcE, // Selects result to pass on to Memory stage
|
input logic ALUResultSrcE, // Selects result to pass on to Memory stage
|
||||||
|
input logic [2:0] ALUSelectE, // ALU mux select signal
|
||||||
input logic JumpE, // Is a jump (j) instruction
|
input logic JumpE, // Is a jump (j) instruction
|
||||||
input logic BranchSignedE, // Branch comparison operands are signed (if it's a branch)
|
input logic BranchSignedE, // Branch comparison operands are signed (if it's a branch)
|
||||||
output logic [1:0] FlagsE, // Comparison flags ({eq, lt})
|
output logic [1:0] FlagsE, // Comparison flags ({eq, lt})
|
||||||
@ -81,7 +82,7 @@ module datapath (
|
|||||||
comparator #(`XLEN) comp(ForwardedSrcAE, ForwardedSrcBE, BranchSignedE, FlagsE);
|
comparator #(`XLEN) comp(ForwardedSrcAE, ForwardedSrcBE, BranchSignedE, FlagsE);
|
||||||
mux2 #(`XLEN) srcamux(ForwardedSrcAE, PCE, ALUSrcAE, SrcAE);
|
mux2 #(`XLEN) srcamux(ForwardedSrcAE, PCE, ALUSrcAE, SrcAE);
|
||||||
mux2 #(`XLEN) srcbmux(ForwardedSrcBE, ImmExtE, ALUSrcBE, SrcBE);
|
mux2 #(`XLEN) srcbmux(ForwardedSrcBE, ImmExtE, ALUSrcBE, SrcBE);
|
||||||
alu #(`XLEN) alu(SrcAE, SrcBE, ALUControlE, Funct7E, Funct3E, ALUResultE, IEUAdrE);
|
alu #(`XLEN) alu(SrcAE, SrcBE, ALUControlE, ALUSelectE, Funct7E, Funct3E, ALUResultE, IEUAdrE);
|
||||||
mux2 #(`XLEN) altresultmux(ImmExtE, PCLinkE, JumpE, AltResultE);
|
mux2 #(`XLEN) altresultmux(ImmExtE, PCLinkE, JumpE, AltResultE);
|
||||||
mux2 #(`XLEN) ieuresultmux(ALUResultE, AltResultE, ALUResultSrcE, IEUResultE);
|
mux2 #(`XLEN) ieuresultmux(ALUResultE, AltResultE, ALUResultSrcE, IEUResultE);
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ module ieu (
|
|||||||
logic ALUSrcAE, ALUSrcBE; // ALU source operands
|
logic ALUSrcAE, ALUSrcBE; // ALU source operands
|
||||||
logic [2:0] ResultSrcW; // Selects result in Writeback stage
|
logic [2:0] ResultSrcW; // Selects result in Writeback stage
|
||||||
logic ALUResultSrcE; // Selects ALU result to pass on to Memory stage
|
logic ALUResultSrcE; // Selects ALU result to pass on to Memory stage
|
||||||
|
logic [2:0] ALUSelectE; // ALU select mux signal
|
||||||
logic SCE; // Store Conditional instruction
|
logic SCE; // Store Conditional instruction
|
||||||
logic FWriteIntM; // FPU writing to integer register file
|
logic FWriteIntM; // FPU writing to integer register file
|
||||||
logic IntDivW; // Integer divide instruction
|
logic IntDivW; // Integer divide instruction
|
||||||
@ -95,7 +96,7 @@ module ieu (
|
|||||||
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, .ALUSelectE, .MemReadE, .CSRReadE,
|
||||||
.Funct3E, .Funct7E, .IntDivE, .MDUE, .W64E, .JumpE, .SCE, .BranchSignedE, .StallM, .FlushM, .MemRWM,
|
.Funct3E, .Funct7E, .IntDivE, .MDUE, .W64E, .JumpE, .SCE, .BranchSignedE, .StallM, .FlushM, .MemRWM,
|
||||||
.CSRReadM, .CSRWriteM, .PrivilegedM, .AtomicM, .Funct3M,
|
.CSRReadM, .CSRWriteM, .PrivilegedM, .AtomicM, .Funct3M,
|
||||||
.RegWriteM, .InvalidateICacheM, .FlushDCacheM, .InstrValidM, .InstrValidE, .InstrValidD, .FWriteIntM,
|
.RegWriteM, .InvalidateICacheM, .FlushDCacheM, .InstrValidM, .InstrValidE, .InstrValidD, .FWriteIntM,
|
||||||
@ -103,7 +104,7 @@ module ieu (
|
|||||||
|
|
||||||
datapath dp(
|
datapath dp(
|
||||||
.clk, .reset, .ImmSrcD, .InstrD, .StallE, .FlushE, .ForwardAE, .ForwardBE,
|
.clk, .reset, .ImmSrcD, .InstrD, .StallE, .FlushE, .ForwardAE, .ForwardBE,
|
||||||
.ALUControlE, .Funct3E, .Funct7E, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .JumpE, .BranchSignedE,
|
.ALUControlE, .Funct3E, .Funct7E, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .ALUSelectE, .JumpE, .BranchSignedE,
|
||||||
.PCE, .PCLinkE, .FlagsE, .IEUAdrE, .ForwardedSrcAE, .ForwardedSrcBE,
|
.PCE, .PCLinkE, .FlagsE, .IEUAdrE, .ForwardedSrcAE, .ForwardedSrcBE,
|
||||||
.StallM, .FlushM, .FWriteIntM, .FIntResM, .SrcAM, .WriteDataM, .FCvtIntW,
|
.StallM, .FlushM, .FWriteIntM, .FIntResM, .SrcAM, .WriteDataM, .FCvtIntW,
|
||||||
.StallW, .FlushW, .RegWriteW, .IntDivW, .SquashSCW, .ResultSrcW, .ReadDataW, .FCvtIntResW,
|
.StallW, .FlushW, .RegWriteW, .IntDivW, .SquashSCW, .ResultSrcW, .ReadDataW, .FCvtIntResW,
|
||||||
|
Loading…
Reference in New Issue
Block a user