异步复位寄存器的0时刻是如何进行赋值的呢?

电子说

1.2w人已加入

描述

 Verilog规范告诉我们:negedge 事件指的是如表43所示的跳变,发生negedge事件时才会执行操作。那么0时刻,是如何执行操作的呢?

鸽子在Verilog标准中并没有找到0时刻赋值明确的说明。如下代码中,0时刻,rst_n为0,clk 处于低电平,那么cfg_mode的数值是多少呢?

 

always @(posedge clk or negedge rst_n)
    if (!rst_n) begin
      cfg_mode                   <= 1'b0;
    end else   begin
      cfg_mode                   <= cfg_mode_in               ;
end

 

实际电路中:

    在芯片上电之前,芯片的chip_reset一直处于复位状态,因此导致芯片内部的rst_n一直为0,且芯片内部PLL还没有工作,也没有产生clk,此时没有任何信号的跳变,即clk没有跳变,rst_n一直为0也没有跳变。在实际电路中,从D触发器的结构图可以看到,当复位R一直是1时,即使时钟信号不跳变,Q端输出也是0。

D触发器D触发器D触发器

VCS在0时刻赋值

D触发器

VCS 在0时刻会执行一次always块的赋值,而不是等到信号跳变。

D触发器

module zero_time_test;
    reg rst_n;
 
    initial begin
        rst_n = 0;
        #20 rst_n = 1;
    end
 
    always@(posedge rst_n) begin: always_case1
        $display("The always case1 executed @Time %f", $time());
    end
 
    always@(negedge rst_n) begin: always_case2
        $display("The always case2 executed @Time %f", $time());
    end
 
    always@(rst_n) begin: always_case3
        $display("The always case3 executed @Time %f", $time());
    end
 
endmodule
D触发器
module zero_time_test;
    reg rst_n;
 
    initial begin
        rst_n = 1;
        #20 rst_n = 0;
    end
 
    always@(posedge rst_n) begin: always_case4
        $display("The always case4 executed @Time %f", $time());
    end
 
    always@(negedge rst_n) begin: always_case5
        $display("The always case5 executed @Time %f", $time());
    end
 
    always@(rst_n) begin: always_case6
        $display("The always case6 executed @Time %f", $time());
    end
 
endmodule
  D触发器  

 






审核编辑:刘清

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分