forked from Github_Repos/cvw
Shifter capitalization
This commit is contained in:
parent
9f1c1958a6
commit
a5e569245b
@ -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
|
||||||
@ -45,45 +45,45 @@ module shifter (
|
|||||||
if (`XLEN==32) begin // rv32 with rotates
|
if (`XLEN==32) begin // rv32 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};
|
2'b11: Z = {A[30:0], A};
|
||||||
endcase
|
endcase
|
||||||
assign amttrunc = Amt; // shift amount
|
assign TruncAmt = Amt; // shift amount
|
||||||
end else begin // rv64 with rotates
|
end else begin // rv64 with rotates
|
||||||
// shifter rotate source select mux
|
// shifter rotate source select mux
|
||||||
logic [`XLEN-1:0] RotA; // rotate source
|
logic [`XLEN-1:0] RotA; // rotate source
|
||||||
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 = {A[63:0],{63'b0}};
|
2'b00: Z = {A[63:0],{63'b0}};
|
||||||
2'b01: z = {RotA, RotA[63:1]};
|
2'b01: Z = {RotA, RotA[63:1]};
|
||||||
2'b10: z = {{63{Sign}}, A[63:0]};
|
2'b10: Z = {{63{Sign}}, A[63:0]};
|
||||||
2'b11: z = {RotA[62:0], RotA};
|
2'b11: Z = {RotA[62:0], RotA};
|
||||||
endcase
|
endcase
|
||||||
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
|
||||||
end else begin: norotfunnel
|
end else begin: norotfunnel
|
||||||
if (`XLEN==32) begin:shifter // RV32
|
if (`XLEN==32) begin:shifter // RV32
|
||||||
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};
|
||||||
assign amttrunc = Amt; // shift amount
|
assign TruncAmt = Amt; // shift amount
|
||||||
end else begin:shifter // RV64
|
end else begin:shifter // RV64
|
||||||
always_comb // funnel mux
|
always_comb // funnel mux
|
||||||
if (Right) z = {{63{Sign}}, A[63:0]};
|
if (Right) Z = {{63{Sign}}, A[63:0]};
|
||||||
else z = {A[63:0], {63'b0}};
|
else Z = {A[63:0], {63'b0}};
|
||||||
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
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user