Skip to content

Commit

Permalink
Add a combinational constant multiplication primitive (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewb1999 authored Mar 31, 2024
1 parent 6be8d86 commit 2423515
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions primitives/binary_operators.futil
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ extern "binary_operators.sv" {
comb primitive std_slsh<"share"=1>[WIDTH](@data left: WIDTH, @data right: WIDTH) -> (out: WIDTH);
comb primitive std_srsh<"share"=1>[WIDTH](@data left: WIDTH, @data right: WIDTH) -> (out: WIDTH);
comb primitive std_signext<"share"=1>[IN_WIDTH, OUT_WIDTH](@data in: IN_WIDTH) -> (out: OUT_WIDTH);
comb primitive std_const_mult<"share"=1>[WIDTH, VALUE](@data in: WIDTH) -> (out: WIDTH);
}
10 changes: 10 additions & 0 deletions primitives/binary_operators.sv
Original file line number Diff line number Diff line change
Expand Up @@ -763,3 +763,13 @@ module std_signext #(
end
`endif
endmodule

module std_const_mult #(
parameter WIDTH = 32,
parameter VALUE = 1
) (
input signed [WIDTH-1:0] in,
output signed [WIDTH-1:0] out
);
assign out = in * VALUE;
endmodule

0 comments on commit 2423515

Please sign in to comment.