可以的。
如果FPGA的主频设为mclk,控制信号用ctrl表示,可以在FPGA中设计一个由s1启动的延时设计,延时用ctrl来控制。参考下面Verilog代码和波形,希望有所提示。
module delay(mclk,rst,ctrl,s1,s2);
parameter size=5;
input mclk,rst;
input [size-1:0] ctrl;
input s1;
output s2;
reg s2;
reg ms;
reg [size-1:0] cnt;
always @ (posedge mclk)
begin
if (!rst) begin ms<=0; cnt<=0; s2<=0; end
case (ms)
1'b0:
begin
if(cnt>=ctrl) s2<=0;
if (s1==ms) cnt<=cnt+1'b1;
else begin ms<=1'b1; cnt<=1'b0; end
end
1'b1:
begin
if(cnt>=ctrl) s2<=1;
if (s1==ms) cnt<=cnt+1'b1;
else begin ms<=1'b0; cnt<=1'b0; end
end
default: begin ms<=0; cnt<=0; end
endcase
end
endmodule