马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 ccmao30 于 2009-12-17 15:56 编辑
C:%5CDocuments 我的想法是count60计数11次,然后count30计数1次,波形虽然出来了,但是有一个问题就是在count30记录到5的时候count60只记数1次,代码与仿真的结果如下,望高人指点:
`timescale 1ns / 1ps
module for_qiantao_test(clk40,rst,count30,count60);
input clk40; //输入时钟40M
input rst;
output [5:0] count30;
output [5:0] count60;
reg [10:0] count30;
reg [10:0] count60;
always @ (posedge clk40 or negedge rst)
if (!rst)
begin
count30<=0;
count60<=0;
end
else begin
if (count30==5)
count30<=0;
else
begin
if (count60==10)
begin
count30<=count30+1;
count60<=0;
end
else
count60<=count60+1;
end
end
endmodule
测试bench如下:
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
module for_qiantao_test_test_v;
// Inputs
reg clk40;
reg rst;
// Outputs
wire [10:0] count30;
wire [10:0] count60;
// Instantiate the Unit Under Test (UUT)
for_qiantao_test uut (
.clk40(clk40),
.rst(rst),
.count30(count30),
.count60(count60)
);
always # 20 clk40 = ~clk40;
initial begin
// Initialize Inputs
clk40 = 0;
rst = 1;
#20 rst = 0;
#20 rst = 1;
end
endmodule
C:%5CDocuments |