Added missing signal modules

This commit is contained in:
2026-03-02 19:28:36 +01:00
parent 50f71a2985
commit 4e3521e94a
20 changed files with 795 additions and 67 deletions

View File

@@ -0,0 +1,15 @@
CAPI=2:
name: joppeb:util:mul_const:1.0
description: Constant multiplier helpers implemented with shift-add logic
filesets:
rtl:
files:
- rtl/mul_const.v
file_type: verilogSource
targets:
default:
filesets:
- rtl

View 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