用VHDL语言写分频器

来源:百度知道 编辑:UC知道 时间:2024/06/20 11:26:49
用VHDL语言设计分频器要求是将128赫兹的脉冲信号经过分频器分别产生64赫兹,32赫兹,16赫兹,4赫兹,2赫兹,1赫兹,0.5赫兹的8种频率的信号.谢谢

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity fen is
port(
CLK:IN std_logic;
PU1,PU2,PU3,PU4,PU5,PU6,PU7,PU8:OUT std_logic
);
end fen;
architecture div of fen is
signal Q:std_logic_vector(7 downto 0);
begin

process(CLK)
begin
if CLK'EVENT AND CLK='1' then
if(Q="11111111")then
Q<="00000000";
else
Q<=Q+1;
end if;
end if;
end process;
PU1<=Q(0);--64Hz
PU2<=Q(1);--32Hz
PU3<=Q(2);--16Hz
PU4<=Q(3);--8Hz
PU5<=Q(4);--4Hz
PU6<=Q(5);--2Hz
PU7<=Q(6);--1Hz
PU8<=Q(7);--0.5Hz
end div;
--好了~~~