Modelsim6.2b编译没有问题,但是在仿真的时候输出的counter_out1的值始终是"x",那位大虾能帮我看看是什么问题?modulecounter_4_bit(clk,counter_out);inputclk;output[3:0]counter_o...
Modelsim 6.2b编译没有问题,但是在仿真的时候输出的counter_out1的值始终是"x",那位大虾能帮我看看是什么问题?
module counter_4_bit(clk, counter_out);
input clk;
output[3:0] counter_out;
reg [3:0] counter_out;
always @(posedge clk)
begin
if(counter_out == 4'b1111)
counter_out = 4'b0000;
else
counter_out = counter_out + 4'b0001;
end
endmodule
module test_for_counter;
reg clk1;
wire [3:0] counter_out1 ;
counter_4_bit counter(clk1, counter_out1);
initial
begin
clk1 = 0;
#10 clk1 = 1;
#10 clk1 = 0;
#10 clk1 = 1;
#10 clk1 = 0;
#10 clk1 = 1;
#10 clk1 = 0;
#10 clk1 = 1;
#10 clk1 = 0;
#10 clk1 = 1;
#10 $finish;
end
initial
$monitor($time, " clk1=%d, counter_out1=%d", clk1, counter_out1);
endmodule
展开
博主使用Modelsim 6.2b编译4位二进制计数器代码无问题,但仿真时输出的counter_out1值始终为\x\。文中给出了计数器模块和测试模块的代码,希望有人帮忙找出问题所在。
1万+

被折叠的 条评论
为什么被折叠?



