分頻器VHDL描述

2022-03-31 18:02:30 字數 2673 閱讀 2031

在數位電路中,常需要對較高頻率的時鐘進行分頻操作,得到較低頻率的時鐘訊號。我們知道,在硬體電路設計中時鐘訊號時非常重要的。

下面我們介紹分頻器的vhdl描述,在源**中完成對時鐘訊號clk的2分頻,4分頻,8分頻,16分頻。

library  ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_unsigned.all;

entity  clkdiv  is

port(clk        : in std_logic;

clk_div2    : out std_logic;

clk_div4    : out std_logic;

clk_div8    : out std_logic;

clk_div16   : out std_logic);

end clk_div;

architecture rtl of clk_div is

signal  count : std_logic_vector(3 downto 0);

begin

process(clk)

begin

if (clk』event and clk=』1』) then

if(count=」1111」) then

count <= (others =>』0』);

else

count <= count +1;

end if ;

end if ;

end process;

clk_div2 <= count(0);

clk_div4 <= count(1);

clk_div8 <= count(2);

clk_div16 <= count(3);

end rtl;

對於分頻倍數不是2的整數次冪的情況,我們只需要對源**中的計數器進行一下計數控制就可以了,如下面源**描述乙個對時鐘訊號進行6分頻的分頻器。

entity  clkdiv  is

port(clk        : in std_logic;

clk_div6    : out std_logic);

end clk_div;

architecture rtl of clk_div is

signal  count     : std_logic_vector(1 downto 0);

signal  clk_temp  : std_logic;

begin

process(clk)

begin

if (clk』event and clk=』1』) then

if(count=」10」) then

count <= (others =>』0』);

clk_temp <=not clk_temp;

else

count <= count +1;

end if ;

end if ;

end process;

clk_div6 <= clk_temp;

end rtl;

前面兩個分頻器的例子描述的將時鐘訊號進行分頻,分頻後得到的時鐘訊號的占空比為1:1。在進行硬體設計的時候,往往要求得到乙個占空比不是1:1的分頻訊號,這時仍採用計數器的方法來產生占空比不是1:1的分頻訊號。下面源**描述的是這樣乙個分頻器:將輸入的時鐘訊號進行16分頻,分頻訊號的占空比為 1:15,也就是說,其中高電位的脈衝寬度為輸入時鐘訊號的乙個週期。

library  ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_unsigned.all;

entity  clkdiv  is

port(clk        : in std_logic;

clk_div16   : out std_logic);

end clk_div;

architecture rtl of clk_div is

signal  count : std_logic_vector(3 downto 0);

begin

process(clk)

begin

if (clk』event and clk=』1』) then

if(count=」1111」) then

count <= (others =>』0』);

else

count <= count +1;

end if ;

end if ;

end process;

process(clk)

begin

if (clk』event and clk=』1』) then

if(count=」1111」) then

clk_div16 <= 『1』;

else

clk_div <= 『0』;

end if ;

end if ;

end process;

end rtl;

對於上述源**描述的這種分頻器,在硬體電路設計中應用十分廣泛,設計人員常採用這種分頻器來產生選通訊號、中斷訊號和數字通訊中常常用到的幀頭訊號等

分頻器的VHDL描述

在數位電路中,常需要對較高頻率的時鐘進行分頻操作,得到較低頻率的時鐘訊號。我們知道,在硬體電路設計中時鐘訊號時非常重要的。下面我們介紹分頻器的vhdl描述,在源 中完成對時鐘訊號clk的2分頻,4分頻,8分頻,16分頻。library ieee use ieee.std logic 1164.all...

8位數控分頻器的設計 數控分頻器的VHDL設計

要求 在 quartus 上進行編輯 編譯 綜合 適配 給 出其所有訊號的時序 波形。選擇目標器件 ep1c3 建議選實驗電路模式 no.0 用鍵 鍵 作為置數資料d 的輸入端,clk接 clock0 fout 接至揚聲器 speaker 時序仿 真時clk 週期設5ns 10ns d分別設 33h...

時鐘分頻器

1 偶數倍分頻 2 奇數倍分頻,占空比50 3 小數分頻 1 在clk上公升沿和下降沿分別產生2n分頻時鐘,兩時鐘相位差90度。2 兩時鐘異或。如此下 11分頻 module clockdiv parameter n 11,counter width 4 input clk,input resetn...