各位看看我这程序怎么不出波形呀???
主程序module counter_10(clock,counter);input clock;
output counter;
reg counter;
initial
begin
counter=6;
end
always @(posedge clock)
begin
if(counter<16)
counter <= counter + 1 ;
else
counter <= 6;
end
endmodule
测试模块
`include"counter_10.v"
module TESTcounter_10;
reg clock;
wire counter;
counter_10 U(clock,counter);
initial
begin
clock=0;
end
always #50 clock=~clock;
endmodule 我想设计一个十进制计数器 module counter_10(clock,counter);
input clock;
output counter;
reg counter;
// initial
// begin
// counter=6;
// end
// always @(posedge clock)
// begin
// if(counter<16)
// counter <= counter + 1 ;
// else
// counter <= 6;
// end
always @ (posedge clock)
begin
if (counter>=4'd9)
counter <= 4'd0;
else
counter <= counter + 4'd1;
end
endmodule 回复 3# njithjw
这是十进制的吗 你可以自己仿真一下看看就知道了。
不过不知道你想要的是自然二进制编码下的十进制,还是8421BCD码的十进制。 回复 1# 竹林听雨早晨
你这个在测试文件的开头没有加`timescale这一句,这个不能丢 6和16是做什么用的? counter_10 U(.clock(clock),.counter(counter));测试文件这句应该这样写吧。 counter也不会超过16最多=15
always @(posedge clock)
// begin
// if(counter<16)
// counter <= counter + 1 ;
// else
// counter <= 6;
// end
不会执行的 回复 6# xuanyuanchen
他有啥用啊
页:
[1]
2