mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-24 13:18:56 +00:00
Added $shift and $shiftx cell types (needed for correct part select behavior)
This commit is contained in:
parent
48822e79a3
commit
397b00252d
12 changed files with 214 additions and 40 deletions
|
@ -418,6 +418,54 @@ endmodule
|
|||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$shift (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
parameter A_WIDTH = 0;
|
||||
parameter B_WIDTH = 0;
|
||||
parameter Y_WIDTH = 0;
|
||||
|
||||
input [A_WIDTH-1:0] A;
|
||||
input [B_WIDTH-1:0] B;
|
||||
output [Y_WIDTH-1:0] Y;
|
||||
|
||||
generate
|
||||
if (B_SIGNED) begin:BLOCK1
|
||||
assign Y = $signed(B) < 0 ? A << -B : A >> B;
|
||||
end else begin:BLOCK2
|
||||
assign Y = A >> B;
|
||||
end
|
||||
endgenerate
|
||||
|
||||
endmodule
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$shiftx (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
parameter A_WIDTH = 0;
|
||||
parameter B_WIDTH = 0;
|
||||
parameter Y_WIDTH = 0;
|
||||
|
||||
input [A_WIDTH-1:0] A;
|
||||
input [B_WIDTH-1:0] B;
|
||||
output [Y_WIDTH-1:0] Y;
|
||||
|
||||
generate
|
||||
if (B_SIGNED) begin:BLOCK1
|
||||
assign Y = A[$signed(B) +: Y_WIDTH];
|
||||
end else begin:BLOCK2
|
||||
assign Y = A[B +: Y_WIDTH];
|
||||
end
|
||||
endgenerate
|
||||
|
||||
endmodule
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$lt (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue