求高手帮忙用vhdl编一个2,4,8,16分频程序

1. 端子说明
端子名
入出力
位宽
说明
RST_N
IN
1
全局异步复位
CLK1_IN
IN
1
输入时钟1
CLK2_IN
IN
1
输入时钟2
CLK_SEL
IN
1
CLK1_IN/ CLK2_IN的选择信号
CLK_PTN
IN
2
时钟输出模式
00:2分频
01:4分频
10:8分频
11:16分频
CLK_OUT
OUT
1
输出时钟

2. 式样说明
CLK1_IN和CLK2_IN选择之后,进行分频输出
3. 式样要求
① CLK_PTN输入固定值
② 时钟系统使用BUFG相关器件
③ CLK_OUT使用ODDR器件输出

第1个回答  推荐于2016-11-05
这是对时钟进行10分频的VHDL代码,2,4,8,16分频原理与其相同。

entity clk_div is
port (clk_in :in std_logic;
clk_out:out std_logic);
end clk_div;

architecture Behavioral of clk_div is
signal cnt:integer range 1 to 10;
signal clk_temp:std_logic:='0';
begin
process (clk_in,cnt)
begin
if clk_in'event and clk_in='1' then
if cnt=10 then cnt<=1;
else cnt<=cnt+1;
end if;
if cnt>5 then clk_temp<='1';
else clk_temp<='0';
end if;
end if;
end process;
clk_out<=clk_temp;
end Behavioral;本回答被提问者采纳