用vhdl设计一个十二分频器,占空比为50%

如题

第1个回答  2014-06-03
其实分频就是计数 我这么觉得的
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Use ieee.std_logic_arith.all;

Entity fdiv is
generic(N: integer:=12); --rate=N,N是偶数
port(
clkin: IN std_logic;
clkout: OUT std_logic
);
End fdiv;
Architecture a of fdiv is
signal cnt: integer range 0 to n-1;
Begin
process(clkin) --计数
begin
if(clkin'event and clkin='1') then
if(cnt<n-1) then
cnt <= cnt+1;
else
cnt <= 0;
end if;
end if;
end process;

process(cnt) --根据计数值,控制输出时钟脉冲的高、低电平
begin
if(cnt<n/2) then
clkout <= '1';
else
clkout <= '0';
end if;
end process;

End a;本回答被提问者采纳
相似回答