永发信息网

verilog hdl 十进制乘法器

答案:2  悬赏:40  手机版
解决时间 2021-03-21 14:46
  • 提问者网友:辞取
  • 2021-03-20 18:31
跪求达人牛人高各种高手给一个4位十进制乘法器编程!
最佳答案
  • 五星知识达人网友:你哪知我潦倒为你
  • 2021-03-20 20:06
module mult_4(a,b,sum);
input [13:0]a,b;
ouput sum;
reg [26:0]sum;
integer width;
begin
sum=8'd00000000;
for(width=0;width<14;width=width+1)
begin
if(a[width])
begin
sum<=sum+b;
end
b<=b<<1;
end
end
endmodule
全部回答
  • 1楼网友:我住北渡口
  • 2021-03-20 20:29
module cnt10 (clk, rst, en, cq, cout); input clk,rst,en; output[3:0] cq; output cout; reg[3:0] cq,cqi; reg cout; always @(posedge clk)//检测时钟上升沿 begin : u1 if (rst == 1'b1)//计数器复位 begin cqi={4{1'b0}}; end begin if(en==1'b1)//检测是否允许计数 begin if (cqi<9) begin cqi=cqi+1; //允许计数 end else begin cqi={4{1'b0}}; //大于9,计数值清零 end end end if (cqi==9) begin cout<=1'b1 ; //计数大于9,输出进位信号 end else begin cout<=1'b0 ; end cq<=cqi ; //将计数值向端口输出 end endmodule
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯