module test02(clk,rst,count,clk_odd);
input clk,rst;
output reg [1:0]clk_odd;
output[3:0] count;
reg[3:0] count;
parameter N = 2;
always @ (posedge clk)
if(! rst)
begin
count <= 1'b0;
clk_odd <= 1'b0;
end
else
if ( count < N)
begin
count <= count + 1'b1;
end
else
case(count)
4'b0001:
begin
clk_odd <= clk_odd + 1'b1;
end
4'b0010:
begin
count <= 1'b0;
clk_odd <= clk_odd + 1'b1;
end
endcase
endmodule
上面的程序仿真发现无法执行 count == 1 的情况,clk_odd都是在 count == 2之后才变化,在count == 1时波形没变化,请问是哪里出问题了?
我在下面会贴出testbench代码及仿真波形
|