完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
module mux(clk,rst_n,ena,ain,bin,yout,ready
); input clk,rst_n,ena; input [7:0]ain; input [7:0]bin; output reg [15:0]yout; output reg ready; reg [4:0]i; always@(posedge clk) if(!rst_n) begin yout<=0; ready<=0; i<=0; end else begin if(ena) begin if(i<5'd8) begin i<=i+1; end else i<=0; if(i<5'd7) begin if(ain) yout<=yout+({8'd0,bin}< else ; end else if(i==5'd7) begin if(ain) begin yout<=yout+({8'd0,bin}< i<=5'd0; end else ; ready<=1'b1; end else ready<=0; end else begin i<=5'd0; yout<=16'd0; end end endmodule 上面是代码,综合没得问题 下面是testbench module mux_test; // Inputs reg clk; reg rst_n; reg ena; reg [7:0] ain; reg [7:0] bin; reg [8:0] i,j; // Outputs wire [15:0] yout; wire ready; // Instantiate the Unit Under Test (UUT) mux uut ( .clk(clk), .rst_n(rst_n), .ena(ena), .ain(ain), .bin(bin), .yout(yout), .ready(ready) ); initial begin $display("this simulation is running.n"); // Initialize Inputs clk = 0; rst_n = 0; ena = 0; ain = 8'hzz; bin = 8'hzz; // Wait 100 ns for global reset to finish #1000; @(posedge clk); rst_n=1; for(i=0;i<256;i=i+1) begin for(j=0;j<256;j=j+1) begin mux_two(i,j); end end // Add stimulus here $display("mux simulation is over. All right.n"); $stop; end always #10 clk=~clk; task mux_two; input [7:0]a; input [7:0]b; begin @(posedge clk);#3; ain<=a; bin<=b; ena<=1; @(posedge ready); @(posedge clk);#3; if(a*b==yout) $display("%3d * %3d = %5d , it is right.",a,b,yout); else begin $display("%3d * %3d = %5d , it is wrong.",a,b,yout); $stop; end @(posedge clk);#3; ena=0; ain=8'hzz; bin=8'hzz; end endtask endmodule 在出波形的时候ain只能加到128就不能再继续加了。。加了也不出波形,没找出错误。。求大神。 # 127 * 247 = 31369 , it is right. # 127 * 248 = 31496 , it is right. # 127 * 249 = 31623 , it is right. # 127 * 250 = 31750 , it is right. # 127 * 251 = 31877 , it is right. # 127 * 252 = 32004 , it is right. # 127 * 253 = 32131 , it is right. # 127 * 254 = 32258 , it is right. # 127 * 255 = 32385 , it is right. # 128 * 0 = 0 , it is right.仿真结果到这就一直仿真不出结果了。波形显示是ready挂高了一直没下降。。 |
|
相关推荐
1个回答
|
|
这个是一个八位的移位乘法器。输入两个8位的数据做乘法然后输出16位的结果。。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
799 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1005 浏览 0 评论
867 浏览 0 评论
1879 浏览 0 评论
479 浏览 0 评论
1283 浏览 28 评论
5467 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-9 09:23 , Processed in 0.532686 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号