<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 【E討論】關(guān)于邊沿檢測簡(jiǎn)單理解

【E討論】關(guān)于邊沿檢測簡(jiǎn)單理解

作者: 時(shí)間:2016-05-03 來(lái)源:網(wǎng)絡(luò ) 收藏

  1、所謂,就是檢測輸入信號或FPGA內部邏輯信號電平的跳變,即實(shí)現上升沿或下降沿的檢測,捕獲到以后以此用作使能信號(簡(jiǎn)單可理解為:一旦檢測到這個(gè)信號,則發(fā)生什么什么),來(lái)作為時(shí)序邏輯的觸發(fā)信號??傊?,在基礎中,這個(gè)還是很重要的,在后面的串口和SPI接口中都要用到。

本文引用地址:http://dyxdggzs.com/article/201605/290591.htm

  (一)、一級

    

blob.png

 

  從一級中很好理解下降沿和上升沿的檢測:a和b都是從trigger來(lái)的(三者一樣),只是b比a在時(shí)間上遲了一個(gè)的時(shí)間?,F在假設0時(shí)刻到了,trigger到a了,但是還沒(méi)有到b,到了寄存器,被寄存了;等待下一個(gè)時(shí)刻1到來(lái),a走了(不用管了),來(lái)了一個(gè)新的叫c,同時(shí),b從寄存器得到了之前寄存的,那個(gè)現在的1時(shí)刻,有了兩個(gè)信號,b和c,而且b是前一個(gè)時(shí)刻的,而c是現在時(shí)刻的(誰(shuí)先誰(shuí)后這點(diǎn)很重要)。所以:

  下降沿 neg_edge = b & ~c;

    

blob.png

 

  由上圖可以看出,當下降沿來(lái)的時(shí)候,c取反再與上b,得出輸出為1;反過(guò)來(lái)想,輸出neg_edge為1的時(shí)候就表示檢測到下降沿了。

  上升沿 pos_edge = ~b & c;

    

無(wú)標題.jpg

 

  同理。當pos_edge為1,表示檢測到上升沿。

  (二)兩級寄存器

  moduleedge_tech_design

  (

  clk,

  rst_n,

  s,

  neg_edge,

  pos_edge

  );

  inputclk;

  inputrst_n;

  inputs;

  outputneg_edge;

  outputpos_edge;

  regc,d;

  always@(posedgeclkornegedgerst_n)

  if(!rst_n)begin

  c<=1'b0;

  d<=1'b0;

  end

  elsebegin

  c<=s;

  d<=c;

  end

  assignneg_edge=d&!c;

  assignpos_edge=!d&c;

  endmodule

  為了在波形圖中能看到c、d寄存器,把程序修改為

  moduleedge_tech_design

  (

  clk,

  rst_n,

  s,

  neg_edge,

  pos_edge,

  c,//為了觀(guān)察c和d的波形而添加的

  d//為了觀(guān)察c和d的波形而添加的

  );

  inputclk;

  inputrst_n;

  inputs;

  outputneg_edge;

  outputpos_edge;

  outputc,d;//為了觀(guān)察c和d的波形而添加的

  regc,d;

  always@(posedgeclkornegedgerst_n)

  if(!rst_n)begin

  c<=1'b0;

  d<=1'b0;

  end

  elsebegin

  c<=s;

  d<=c;

  end

  assignneg_edge=d&!c;

  assignpos_edge=!d&c;

  endmodule

  測試文件如下:

  `timescale1ns/1ns

  `defineclk_period20

  moduleedge_tech_design_tb;

  regclk;

  regrst_n;

  regs;

  wireneg_edge;

  wirepos_edge;

  wirec,d;//為了觀(guān)察c和d的波形而添加的

  edge_tech_designedge_tech_design

  (

  .clk(clk),

  .rst_n(rst_n),

  .s(s),

  .neg_edge(neg_edge),

  .pos_edge(pos_edge),

  .c(c),//為了觀(guān)察c和d的波形而添加的

  .d(d)//為了觀(guān)察c和d的波形而添加的

  );

  initialclk=1;

  always#(`clk_period/2)clk=~clk;

  initialbegin

  rst_n=1'b0;

  s=1'b0;

  #(`clk_period/4)

  #(`clk_period)

  rst_n=1'b1;

  s=1'b1;

  #(`clk_period*5)

  s=1'b0;

  #(`clk_period)

  s=1'b1;

  #(`clk_period)

  s=1'b0;

  #(`clk_period*3)

  s=1'b1;

  #(`clk_period)

  s=1'b0;

  #(`clk_period*5)

  s=1'b1;

  #(`clk_period)

  s=1'b0;

  #(`clk_period*3)

  s=1'b1;

  #(`clk_period)

  s=1'b0;

  #(`clk_period)

  s=1'b1;

  #(`clk_period*3)

  s=1'b0;

  #(`clk_period)

  s=1'b1;

  #(`clk_period)

  s=1'b0;

  #(`clk_period)

  $stop;

  end

  endmodule

    

QQ截圖20160428235415.jpg

 

  在仿真圖中可以看到這樣的圖形(街區圖中下降沿部分一小段)

    

QQ截圖20160429000245.jpg

 

  輸入信號s從高變成低的時(shí)候,出現下降沿,然后等到時(shí)鐘clk的上升沿到來(lái),s傳輸到c,d還沒(méi)傳輸到,被寄存在d之前的寄存器內,等待第二個(gè)時(shí)鐘上升沿到來(lái),寄存器中的信號傳輸到d了,此時(shí)根據

  neg_edge = d & ~c;

  可以得到neg_edge的波形。



關(guān)鍵詞: 邊沿檢測 寄存器

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>