我COPY的,原作者见谅!!!<br>
非整数分频实用例子 分频比=32/7, 拓展可以任意 2^(N)/M,分子比分母大, 理论上可以实现任意精度的小数分频<br>
library ieee;<br>
use ieee.std_logic_1164.all;<br>
use ieee.std_logic_unsigned.all;<br>
<br>
entity fsu2 is<br>
port(clk:in bit;<br>
f_out
ut bit<br>
);<br>
end;<br>
<br>
architecture a of fsu2 is<br>
signal q: std_logic_vector(5 downto 0) :="000111";<br>
constant step: std_logic_vector(5 downto 0):="000111";<br>
begin<br>
p1: process(clk)<br>
variable temp: std_logic_vector(5 downto 0);<br>
<br>
begin<br>
if(clk'event and clk='1') then<br>
if q>"011000" and q<="011111" then<br>
temp:= q+step;<br>
q<=temp-"100000";<br>
else<br>
q<=q+step;<br>
end if;<br>
<br>
<br>
<br>
end if;<br>
if (q>"011000" and q<="011111"
then <br>
f_out<='1';<br>
else <br>
f_out<='0';<br>
end if;<br>
<br>
end process;<br>
<br>
<br>
end; |