用VHDL语言设计一个N分频器。N的默认值为10.

来源:百度知道 编辑:UC知道 时间:2024/06/24 11:26:43
用VHDL语言设计一个N分频器。N的默认值为10.请哪位高手写出具体的语句。谢谢啦。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fenpin is
port( clk:in std_logic;
finout:out std_logic);
end fenpin;
architecture bhv of fenpin is
signal tmp:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if clk'event and clk='1' then
if tmp=9 then tmp<="0000";
else tmp<=tmp+1;
end if;
if tmp<5 then finout<='0';
else finout<='1';
end if;
end if;
end process;
end bhv;