專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

verilog同步復(fù)位PK異步復(fù)位

作者:kb129   來(lái)源:kb129   點(diǎn)擊數(shù):  更新時(shí)間:2014年06月21日   【字體:

     時(shí)鐘和復(fù)位是FPGA中關(guān)鍵,下面是特權(quán)寫的,復(fù)制以備找工作~~~

 
同步復(fù)位:
 
      1.復(fù)位信號(hào)只有在時(shí)鐘上升沿到來(lái)時(shí),才能有效。
 
      2.代碼為:
 
          always@(posedge clk)
 
               if ( !rst_n )
 
                   ....
 
               else
 
                   ....
 
異步復(fù)位:
 
      1.無(wú)論時(shí)鐘沿是否來(lái)到,只要復(fù)位信號(hào)有效就對(duì)系統(tǒng)復(fù)位。
 
      2.代碼為:
 
          always@ ( posedge clk or negedge rst_n )
 
              if ( !rst_n )
 
                      ....
 
              else
 
                      ....       
 
優(yōu)缺點(diǎn):
 
      同步復(fù)位優(yōu)點(diǎn):
 
           1. 有利于仿真   2. 100%為同步電路   3. 可以濾除高于時(shí)鐘的毛刺
 
       缺點(diǎn):
 
           1. 復(fù)位信號(hào)有效時(shí)長(zhǎng)要大于時(shí)鐘周期,同時(shí)還要考慮電路延時(shí)
 
           2. 大多數(shù)的邏輯器件只有異步復(fù)位接口,使用同步復(fù)位需要耗費(fèi)較多的邏輯資源
 
      異步復(fù)位優(yōu)點(diǎn):
 
           1. 節(jié)省資源     2. 設(shè)計(jì)簡(jiǎn)單  3. 可以使用專用的復(fù)位端口CLR
 
      缺點(diǎn):
 
           1. 在復(fù)位信號(hào)釋放時(shí),如果在時(shí)鐘沿附近容易導(dǎo)致寄存器輸出出現(xiàn)亞穩(wěn)態(tài)
 
           2. 復(fù)位信號(hào)容易受毛刺的影響
 
同時(shí)獲得兩者的優(yōu)點(diǎn):異步復(fù)位,同步釋放
 
代碼為:
 
         always@(poseedge clk or negedge rst_in)
 
              if ( ! rst_in )
 
                     begin
 
                               rst_buf <= 1'b0;
 
                               rst_n    <= 1'b0;
 
                     end
 
               else
 
                     begin
 
                              rst_buf <= 1'b1;
 
                              rst_n    <=  rst_buf ;
 
                     end
 
 
關(guān)閉窗口

相關(guān)文章