简体   繁体   English

如何使用系统verilog设计一个在2个时钟周期后对输入进行采样的触发器?

[英]how to design a flip flop that samples the input after 2 clock cycles using system verilog?

the data is input in the first posedge clock but the output should present after 2 clock cycles.数据在第一个 posedge 时钟中输入,但 output 应该在 2 个时钟周期后出现。

i've tried using #delay but not quite getting it.我试过使用#delay,但不太明白。

clk=0;
forever #10 clk = ~clk;
always @ (posedge clk) begin //synchronous rst
#60 q<=d;
end

One way to solve your problem would be to have 2 flip-flops.解决问题的一种方法是使用 2 个触发器。

reg q1, q2;
always @(posedge clk) begin
   q1 <= d;
   q2 <= q1;
end

Now, q2 will follow the input with a 2 clock-cycle latency, which is what you wanted.现在,q2 将以 2 个时钟周期延迟跟随输入,这正是您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM