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

Verilog hdl用d觸發(fā)器實(shí)現(xiàn)4分頻的程序

作者:huqin   來源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2014年05月03日   【字體:

Verilog用d觸發(fā)器實(shí)現(xiàn)4分頻的Verilog hdl源代碼:

module dff_4(clk,rst,clk_out);

input clk,rst;
output clk_out;

wire clk,rst;
reg clk_out;

reg q1,q2;

always @(posedge clk or negedge rst)
 if(!rst)
  begin
   q1 <= 1'b0;
  end
 else
  begin
   q1 <= ~q1;
  end

always @(posedge q1 or negedge rst)
 if(!rst)
  begin
   q2 <= 1'b0;
   clk_out <= 1'b0;
  end
 else
  begin
   q2 <= ~q2;
   clk_out <= q2;
  end

endmodule

RTL viewer原理圖:


仿真波形圖:


 

關(guān)閉窗口

相關(guān)文章