Added missing signal modules
This commit is contained in:
31
cores/util/mul_const/rtl/mul_const.v
Normal file
31
cores/util/mul_const/rtl/mul_const.v
Normal file
@@ -0,0 +1,31 @@
|
||||
`timescale 1ns/1ps
|
||||
|
||||
module mul_const_shiftadd #(
|
||||
parameter integer C = 0,
|
||||
parameter integer IN_W = 16,
|
||||
parameter integer OUT_W = 32
|
||||
)(
|
||||
input wire signed [IN_W-1:0] i_x,
|
||||
output reg signed [OUT_W-1:0] o_y
|
||||
);
|
||||
integer k;
|
||||
integer abs_c;
|
||||
reg signed [OUT_W-1:0] acc;
|
||||
reg signed [OUT_W-1:0] x_ext;
|
||||
|
||||
always @* begin
|
||||
abs_c = (C < 0) ? -C : C;
|
||||
acc = {OUT_W{1'b0}};
|
||||
x_ext = {{(OUT_W-IN_W){i_x[IN_W-1]}}, i_x};
|
||||
|
||||
for (k = 0; k < 32; k = k + 1) begin
|
||||
if (abs_c[k])
|
||||
acc = acc + (x_ext <<< k);
|
||||
end
|
||||
|
||||
if (C < 0)
|
||||
o_y = -acc;
|
||||
else
|
||||
o_y = acc;
|
||||
end
|
||||
endmodule
|
||||
Reference in New Issue
Block a user