(2建立工程( max value),在 assignments/etng/Fl中在 filename中选择添加 /./example. vhd 例:分频器 常用来对数字电路中的时钟信号分频,用以得到较低频率的时钟信号、选通信号 中断信号等。 ●偶数分频器 如果输入信号的频率为f,则分频器的输出信号为f/2n,n=1,2 分频系数为2的整数次幂的分频器 分频系数N=2n 如2分频(a=1)、4分频(n=2)、8分频(n=3) 可采用模为n的计数器实现如n=3 clk Q2 Q1 ↑↑↑↑个个↑ R00000000 S00000000 0 11111111 0 0 00110011 0
(2)建立工程(max_value),在assignments/setting/Files中在filename中选择添加 /../example.vhd. 例:分频器 常用来对数字电路中的时钟信号分频,用以得到较低频率的时钟信号、选通信号、 中断信号等。 ⚫偶数分频器 如果输入信号的频率为f,则分频器的输出信号为f/2n, n=1,2,… ➢分频系数为2的整数次幂的分频器 分频系数N=2n 如2分频(n=1)、4分频(n=2)、8分频(n=3) 可采用模为n的计数器实现,如n=3 clk R S EN Q2 Q1 Q0 ↑ 0 0 1 0 0 0 ↑ 0 0 1 0 0 1 ↑ 0 0 1 0 1 0 ↑ 0 0 1 0 1 1 ↑ 0 0 1 1 0 0 ↑ 0 0 1 1 0 1 ↑ 0 0 1 1 1 0 ↑ 0 0 1 1 1 1
counter lk-时钟 di2-2分频输出端 cIk div 2 di4-4分频输出端 diva div8-8分频输出端 div rary1eee 分频系数是2的整数次幂分频器的电路符号 use ieee std_logic_1164. all; use ieee std _logic_unsigned.all; entity counter 1s port(clk:in std_logic; div2 out std _logic;-2分频输出 div4 outsid logic;-41分频输出 div8: out std _logic);-:8分频输出 end counters architecture one of counter 1s signalcnt std _logic_vector(2 downto 0) B egin process(clk) if clk event and clk= hen +1; end if nd pr en rocess div 2<=cnt t(1);di8<=cnt(2; end one:
分频系数是2的整数次幂分频器的电路符号 counter clk div2 clk –时钟 div2 – 2分频输出端 div4- 4分频输出端 div4 div8 div8- 8分频输出端 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity counter is port(clk:in std_logic; div2:out std_logic; --2分频输出 div4:out std_logic; --4分频输出 div8:out std_logic); --8分频输出 end counter; architecture one of counter is signal cnt: std_logic_vector(2 downto 0); Begin process (clk) begin if clk’event and clk=‘1’ then cnt<=cnt+1; end if; end process; div2<=cnt(0);div4<=cnt(1);div8<=cnt(2); end one;
分频系数不是2的整数次幂的分频器 例:12分频器 cnt12 clk div 12 clkx-时钟 div12-12分频输出端 分频系数为12的分频器的电路符号 raryleees use ieeestd logic_1164.all; use ieee std _logicunsigned. all; entity cnt12is port(clk:in std_logic; div12 out std _ log;-12分频输出 end cnt12
➢分频系数不是2的整数次幂的分频器 例:12分频器 分频系数为12的分频器的电路符号 clk div12 clk –时钟 div12 – 12分频输出端 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt12 is port(clk:in std_logic; div12:out std_logic); --12分频输出 end cnt12; cnt12
architecture one of cnt12 is signal cnt std _ logic_vector(2 downto O); signalclk_tmp: std_logic constant m: Integer:=5;-控制计数器的常量m=n/2-1 gin p b if clk event and clk=·1′then if cnt=m then clk notc cnt<=“000 else nt+1: end if: end if: d process div 12<=clk_tm
architecture one of cnt12 is signal cnt: std_logic_vector(2 downto 0); signal clk_tmp: std_logic; constant m:integer:=5; --控制计数器的常量m=n/2-1 begin process (clk) begin if clk’event and clk=‘1’ then if cnt=m then clk_tmp<= not clk_tmp; cnt<=“000”; else cnt<=cnt+1; end if; end if; end process; div12<=clk_tmp; end one;