Verilog 始终在时间0处使用posedge触发进行阻止

Verilog 始终在时间0处使用posedge触发进行阻止,verilog,Verilog,我写了一段基本的Verilog代码 `timescale 1ns / 1ps module lab3_2( input[3:0] command, input CLK, input mode, output reg [7:0] total_time1, output reg [7:0] total_time0 ); initial begin

我写了一段基本的Verilog代码

    `timescale 1ns / 1ps
module lab3_2(
            input[3:0] command,
            input CLK,
            input mode,
            output reg [7:0] total_time1,
            output reg [7:0] total_time0
     );
     initial begin
     total_time1 = 8'b00000000;
     total_time0 = 8'b00000000;

     end

     always @(posedge CLK) begin

            if(total_time1 == 8'b00000001 && total_time0 == 8'b00001001)
                begin
                total_time0 <= 8'b00000000;
                total_time1 <= 8'b00000000;
                end
            else if(total_time0 == 8'b00001001)
                begin
                total_time1 <= 8'b00000001;
                total_time0 <= 8'b00000000;
                end
            else
                begin
                total_time0 <= total_time0 + 8'b00000001;
                end
        end

endmodule
我得到的输出是:

Time=                   0 | command=0000 mode=0| total_time1=00000000 total_time0=00000001   CLK=1      
Time=                5000 | command=0000 mode=0| total_time1=00000000 total_time0=00000001   CLK=0      
Current simulation time =                10000
Stopped at time : 10 ns : File "/home/bs04/e2237006/Desktop/liy/testbench_part2.v" Line 35 ** 
为什么在时间0时,
total_time0
等于1?应该不是0吗?我认为增加
总时间0
的唯一方法是触发
始终
块,但我是如何设法在时间0触发
始终
块的


根据我的代码,
CLK
从1开始。

在测试台上,
CLK
被声明为
reg
,而
reg
的初始值是
x
。然后将其分配给1。由于
x
到1的转换是一个posedge,因此将触发always块,并执行
else
子句,增加
total_time0

我认为CLK从x到1可能触发posedge<代码>初始CLK=0应该停止此操作。@david Shah,是的。如果我将clk=1更改为clk=0。它不会触发,所以可以安全地说我的模块是按预期设计的吗?
Time=                   0 | command=0000 mode=0| total_time1=00000000 total_time0=00000001   CLK=1      
Time=                5000 | command=0000 mode=0| total_time1=00000000 total_time0=00000001   CLK=0      
Current simulation time =                10000
Stopped at time : 10 ns : File "/home/bs04/e2237006/Desktop/liy/testbench_part2.v" Line 35 **