我不知道如何结合计数器和秒表。
我尝试下面的代码,但是当我启动秒表时它变为0。 我希望它每秒显示一次减少。
always @(posedge clk)begin
if ( n_reset == 0)begin
counter <= 0;//unit digit
counter2 <= 0;//ten digit
end
else if (level_out == 1)
if (counter < 9)
counter <= counter +1;
else begin
counter <= 0;
counter2 <= counter2 + 1;
end
else if(D_count==1)begin//stop watch can not work in expected
if (counter >0)
counter <= counter - 1;
else if(counter == 0 && counter2 > 0)begin
counter <= 9;
counter2 <= counter2 - 1;
end
else if(counter==0 && counter2 == 0)begin
counter <= 0;
counter2 <= 0;
end
end
end