用高频时钟检测低频时钟的上升沿,用两个D触发器还是一个D触发器?一个D触发器,如下描述
- always@(posedge clk_quick)
- begin
- clk_buf<=clk_slow;
- end
- always@(posedge clk_quick)
- begin
- if({clk_slow,clk_buf}==2'b01)
- rise_flag<=1'b1;
- else
- rise_flag<=1'b0;
- end
上面的描述实现仅需一个时钟两个D触发器
- always@(posedge clk_quick)
- begin
- clk_buf[1:0]<={clk_buf[0],clk_slow};
- end
- always@(posedge clk_quick)
- begin
- if(clk_buf[1:0]==2'b01);
- rise_flag<=1'b1;
- else
- rise_flag<=1'b0;
- end
如上描述也常见,那么大家是如何选择的??
上述两种结构各有什么优缺点?