dz论坛网站创建页面企业网站建设和运营
dz论坛网站创建页面,企业网站建设和运营,设计logo名字,wordpress主题很卡描述
编写一个4bit乘法器模块#xff0c;并例化该乘法器求解c12*a5*b#xff0c;其中输入信号a,b为4bit无符号数#xff0c;c为输出。注意请不要直接使用*符号实现乘法功能。
模块的信号接口图如下#xff1a; 要求使用Verilog HDL语言实现以上功能#xff0c;并编写tes…描述
编写一个4bit乘法器模块并例化该乘法器求解c12*a5*b其中输入信号a,b为4bit无符号数c为输出。注意请不要直接使用*符号实现乘法功能。
模块的信号接口图如下 要求使用Verilog HDL语言实现以上功能并编写testbench验证模块的功能。
输入描述
clk系统时钟信号
rst_n复位信号低电平有效
a输入信号位宽为4bit
b输入信号位宽为4bit
输出描述
c输出信号
参考答案
timescale 1ns/1nsmodule calculation(input clk,input rst_n,input [3:0] a,input [3:0] b,output [8:0] c);wire [7:0] product_1;wire [7:0] product_2;reg[3:0] mult_1 12;reg[3:0] mult_2 5;mult multiplier_1(.clk(clk),.rst_n(rst_n),.multiplicand(a),.multiplier(mult_1),.product(product_1) );mult multiplier_2(.clk(clk),.rst_n(rst_n),.multiplicand(b),.multiplier(mult_2),.product(product_2) ); assign c product_1product_2;
endmodulemodule mult(input clk , input rst_n ,input [3:0] multiplicand,input [3:0] multiplier ,output reg [7:0] product
);wire [7:0] temp0 ;
wire [7:0] temp1 ;
wire [7:0] temp2 ;
wire [7:0] temp3 ;assign temp0 multiplicand[0]? {4b0, multiplier} : 1d0;
assign temp1 multiplicand[1]? {3b0, multiplier, 1b0} : 1d0;
assign temp2 multiplicand[2]? {2b0, multiplier, 2b0} : 1d0;
assign temp3 multiplicand[3]? {1b0, multiplier, 3b0} : 1d0;always (posedge clk or negedge rst_n) begin if(~rst_n) beginproduct 1d0;end else beginproduct temp0 temp1 temp2 temp3;end
endendmodule
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/92291.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!