Inferring Multipliers and DSP Functions

Inferring Multipliers

module unsigned_mult (out, a, b);
output [:] out;
input [:] a;
input [:] b;
assign out = a * b;
endmodule

Verilog HDL Usigned Multiplier

Note: The signed declaration in Verilog HDL is a feature of the Verilog 2001 Standard.

module signed_mult (out, clk, a, b);
output [:] out;
input clk;
input signed [:] a;
input signed [:] b;
reg signed [:] a_reg;
reg signed [:] b_reg;
reg signed [:] out;
wire signed [:] mult_out;
assign mult_out = a_reg * b_reg;
always @ (posedge clk)
begin
a_reg <= a;
b_reg <= b;
out <= mult_out;
end
endmodule

Verilog HDL Signed Multiplier with Input and Output Regist

Inferring Multiply‑Accumulator and Multiply-Adder

The Verilog HDL and VHDL code samples infer multiply-accumulators and multiply-adders with input, output, and pipeline registers, as well as an optional asynchronous clear signal. Using the three sets of registers provides the best performance through the function, with a latency of three. You can remove the registers in your design to reduce the latency.

module unsig_altmult_accum (dataout, dataa, datab, clk, aclr, clken);
input [:] dataa, datab;
input clk, aclr, clken;
output reg[:] dataout;
reg [:] dataa_reg, datab_reg;
reg [:] multa_reg;
wire [:] multa;
wire [:] adder_out;
assign multa = dataa_reg * datab_reg;
assign adder_out = multa_reg + dataout;
always @ (posedge clk or posedge aclr)
begin
if (aclr)
begin
dataa_reg <= 'b0;
datab_reg <= 'b0;
multa_reg <= 'b0;
dataout <= 'b0;
end
else if (clken)
begin
dataa_reg <= dataa;
datab_reg <= datab;
multa_reg <= multa;
dataout <= adder_out;
end
end
endmodule

Verilog HDL Unsigned Multiply-Accumulator

module sig_altmult_add (dataa, datab, datac, datad, clock, aclr, result);
input signed [:] dataa, datab, datac, datad;
input clock, aclr;
output reg signed [:] result;
reg signed [:] dataa_reg, datab_reg, datac_reg, datad_reg;
reg signed [:] mult0_result, mult1_result;
always @ (posedge clock or posedge aclr) begin
if (aclr) begin
dataa_reg <= 'b0;
datab_reg <= 'b0;
datac_reg <= 'b0;
datad_reg <= 'b0;
mult0_result <= 'b0;
mult1_result <= 'b0;
result <= 'b0;
end
else begin
dataa_reg <= dataa;
datab_reg <= datab;
datac_reg <= datac;
datad_reg <= datad;
mult0_result <= dataa_reg * datab_reg;
mult1_result <= datac_reg * datad_reg;
result <= mult0_result + mult1_result;
end
end
endmodule

Verilog HDL Signed Multiply-Adder

最新文章

  1. 【转】 memcmp源码实现
  2. 单独部署activemq-web-console (转载)
  3. hdu 4403 dfs
  4. NLP 自然语言处理
  5. timus 1136 Parliament(二叉树)
  6. js实现复选框的全选、全不选、反选
  7. 微软TTS尝试系列之开篇杂谈(仅思路)
  8. ED/EP系列3《基本指令》
  9. 【bzoj1300】大数计算器
  10. phpcmsv9更改fckeditor编者ueditor编辑
  11. mongodb 面试题总结
  12. 在PHP中,将一个汉字数组按照拼音首字母进行排序
  13. Delphi7通过SendMessage来实现默认打印机的切换
  14. Android JSON解析库Gson和Fast-json的使用对比和图书列表小案例
  15. Canal 源码走读
  16. MySQL DataType--字符串函数
  17. 【Java】Maven Tomcat插件使用
  18. 使用devenv.exe自动编译项目
  19. asp.net core 使用identityServer4的密码模式来进行身份认证(一)
  20. Ionic step by step (1)

热门文章

  1. C# Winform App 获取当前路径
  2. Dom4j的一个小例子,用于解析xml文件的元素获取方式
  3. AngularJs学习笔记--Understanding the Model Component
  4. python 时间和时间戳的转化
  5. PHP------面向对象的特性
  6. HDU 1698 【线段树,区间修改 + 维护区间和】
  7. Linux实用指令(1):运行级别&amp;找回密码&amp;帮助指令&amp;文件目录类
  8. WMIC_2
  9. Ajax跨域问题及解决方案
  10. [转]MFC子线程中更新控件内容的两种办法