关于rst_n_async到rst_n_sync的认识过程
从上次的经验教训,对同步reset和异步reset基本有了一个比较清醒的认识,这次正好在eetop上面看到了一个讨论的帖子,这里再说一下这个东西到底是怎么弄的,一般的工业界的硬件的reset是不会真的接给内部模块的rst_n的,而是同步过之后再给内部的模块,这样的话基本就不会有上次提到的removal_time的约束了,所以呢,这里介绍一下通用的电路结构是什么样的。
如图
这个电路的仿真结果(发出的rst_n_async是用$random函数生成的不规律信号)
可以看到这个电路输出的rst_n_sync还是比较令人满意的,代码很简单,如下
module rst_n_proc( input wire clk , input wire rst_n_async , output wire rst_n_sync ); //////////////////////////////////////////////////////////////////////////////// // variable declaration reg d_1 ; reg d_2 ; //////////////////////////////////////////////////////////////////////////////// // logic always @(posedge clk or negedge rst_n_async) begin if(~rst_n_async) d_1 <= 1'b0 ; else d_1 <= 1'b1 ; end always @(posedge clk or negedge rst_n_async) begin if(~rst_n_async) d_2 <= 1'b0 ; else d_2 <= d_1 ; end assign rst_n_sync = d_2 ; //////////////////////////////////////////////////////////////////////////////// endmodule ////////////////////////////////////////////////////////////////////////////////