目前程序如下:
//触发信号提取
always @(posedge clk100)
begin
TRIG_reg <= {TRIG_reg[5:0],TRIG};
end
//通道时间计数器
always @(posedge clk100)
begin
if(TRIG_reg == 6'b000001)
begin
Delay1_reg <= 0;
end
else if(Delay1_reg == 'D8_388_605)
begin
Delay1_reg <= 'D8_388_605;
end
else
begin
Delay1_reg <= Delay1_reg + 1'b1;
end
end
也试过触发标志位的方式,效果相同,程序如下:
//触发信号提取
always @(posedge clk100)
begin
TRIG_d <= TRIG;
TRIG_dd <= TRIG_d;
TRIG_up <= TRIG_d && (!TRIG_dd);
end
//通道时间计数器
always @(posedge clk100)
begin
if(TRIG_up)
begin
Delay1_reg <= 0;
end
else if(Delay1_reg == 'D8_388_605)
begin
Delay1_reg <= 'D8_388_605;
end
else
begin
Delay1_reg <= Delay1_reg + 1'b1;
end
end