Merge pull request #162 from davidharrishmc/dev

Merging spaces
This commit is contained in:
Ross Thompson 2023-03-24 17:49:26 -05:00 committed by GitHub
commit fef025cb91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,8 +35,8 @@ module shifter (
input logic Right, Rotate, W64, SubArith, // Shift right, rotate, W64-type operation, arithmetic shift input logic Right, Rotate, W64, SubArith, // Shift right, rotate, W64-type operation, arithmetic shift
output logic [`XLEN-1:0] Y); // Shifted result output logic [`XLEN-1:0] Y); // Shifted result
logic [2*`XLEN-2:0] z, zshift; // Input to funnel shifter, shifted amount before truncated to 32 or 64 bits logic [2*`XLEN-2:0] Z, ZShift; // Input to funnel shifter, shifted amount before truncated to 32 or 64 bits
logic [`LOG_XLEN-1:0] amttrunc, Offset; // Shift amount adjusted for RV64, right-shift amount logic [`LOG_XLEN-1:0] TruncAmt, Offset; // Shift amount adjusted for RV64, right-shift amount
logic Sign; // Sign bit for sign extension logic Sign; // Sign bit for sign extension
assign Sign = A[`XLEN-1] & SubArith; // sign bit for sign extension assign Sign = A[`XLEN-1] & SubArith; // sign bit for sign extension
@ -44,17 +44,17 @@ module shifter (
if (`ZBB_SUPPORTED) begin: rotfunnel32 //rv32 shifter with rotates if (`ZBB_SUPPORTED) begin: rotfunnel32 //rv32 shifter with rotates
always_comb // funnel mux always_comb // funnel mux
case({Right, Rotate}) case({Right, Rotate})
2'b00: z = {A[31:0], 31'b0}; 2'b00: Z = {A[31:0], 31'b0};
2'b01: z = {A[31:0], A[31:1]}; 2'b01: Z = {A[31:0], A[31:1]};
2'b10: z = {{31{Sign}}, A[31:0]}; 2'b10: Z = {{31{Sign}}, A[31:0]};
2'b11: z = {A[30:0], A[31:0]}; 2'b11: Z = {A[30:0], A[31:0]};
endcase endcase
end else begin: norotfunnel32 //rv32 shifter without rotates end else begin: norotfunnel32 //rv32 shifter without rotates
always_comb // funnel mux always_comb // funnel mux
if (Right) z = {{31{Sign}}, A[31:0]}; if (Right) Z = {{31{Sign}}, A[31:0]};
else z = {A[31:0], 31'b0}; else Z = {A[31:0], 31'b0};
end end
assign amttrunc = Amt; // shift amount assign TruncAmt = Amt; // shift amount
end else begin // rv64 end else begin // rv64
logic [`XLEN-1:0] A64; logic [`XLEN-1:0] A64;
mux3 #(64) extendmux({{32{1'b0}}, A[31:0]}, {{32{A[31]}}, A[31:0]}, A, {~W64, SubArith}, A64); // bottom 32 bits are always A[31:0], so effectively a 32-bit upper mux mux3 #(64) extendmux({{32{1'b0}}, A[31:0]}, {{32{A[31]}}, A[31:0]}, A, {~W64, SubArith}, A64); // bottom 32 bits are always A[31:0], so effectively a 32-bit upper mux
@ -64,25 +64,25 @@ module shifter (
mux2 #(`XLEN) rotmux(A, {A[31:0], A[31:0]}, W64, RotA); // W64 rotatons mux2 #(`XLEN) rotmux(A, {A[31:0], A[31:0]}, W64, RotA); // W64 rotatons
always_comb // funnel mux always_comb // funnel mux
case ({Right, Rotate}) case ({Right, Rotate})
2'b00: z = {A64[63:0],{63'b0}}; 2'b00: Z = {A64[63:0],{63'b0}};
2'b01: z = {RotA[63:0], RotA[63:1]}; 2'b01: Z = {RotA[63:0], RotA[63:1]};
2'b10: z = {{63{Sign}}, A64[63:0]}; 2'b10: Z = {{63{Sign}}, A64[63:0]};
2'b11: z = {RotA[62:0], RotA[63:0]}; 2'b11: Z = {RotA[62:0], RotA[63:0]};
endcase endcase
end else begin: norotfunnel64 // rv64 shifter without rotates end else begin: norotfunnel64 // rv64 shifter without rotates
always_comb // funnel mux always_comb // funnel mux
if (Right) z = {{63{Sign}}, A64[63:0]}; if (Right) Z = {{63{Sign}}, A64[63:0]};
else z = {A64[63:0], {63'b0}}; else Z = {A64[63:0], {63'b0}};
end end
assign amttrunc = W64 ? {1'b0, Amt[4:0]} : Amt; // 32- or 64-bit shift assign TruncAmt = W64 ? {1'b0, Amt[4:0]} : Amt; // 32- or 64-bit shift
end end
// Opposite offset for right shifts // Opposite offset for right shifts
assign Offset = Right ? amttrunc : ~amttrunc; assign Offset = Right ? TruncAmt : ~TruncAmt;
// Funnel operation // Funnel operation
assign zshift = z >> Offset; assign ZShift = Z >> Offset;
assign Y = zshift[`XLEN-1:0]; assign Y = ZShift[`XLEN-1:0];
endmodule endmodule