高速分频器设计(VHDL) 有一个10MHz的时钟源,为得到4Hz,3Hz,2Hz和1Hz的信号,请设计一种分频器。
展开全部
这是我这次毕业设计的部分分频模块,绝对可用,很简单的。
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_SIGNED.ALL;
ENTITY fenpin IS
PORT(cp_50m:IN STD_LOGIC; --50MHz 输入50MHz
cp0:OUT STD_LOGIC; --1MHz 输出1MHz
cp1:OUT STD_LOGIC); -4s
END fenpin;
ARCHITECTURE behavior OF fenpin IS
SIGNAL tout0:INTEGER RANGE 0 TO 49; --50分频
SIGNAL tout1:INTEGER RANGE 0 TO 999999; --1Hz
SIGNAL tout2:INTEGER RANGE 0 TO 3; --3s高电平,1s低电平
SIGNAL cp_0:STD_LOGIC;
SIGNAL cp_1:STD_LOGIC;
SIGNAL cp_2:STD_LOGIC;
BEGIN
PROCESS(cp_50m) --1MHz
BEGIN
IF(cp_50m'event AND cp_50m='1')THEN
IF tout0=49 THEN
tout0<=0;
ELSE tout0<=tout0+1;
END IF;
IF tout0=24 THEN
cp_0<='1';
ELSIF tout0=49 then cp_0<='0';
END IF;
END IF;
END PROCESS;
PROCESS(cp_0) --1Hz
BEGIN
IF(cp_0'event AND cp_0='1')THEN
IF tout1=999999 THEN
tout1<=0;
ELSE tout1<=tout1+1;
END IF;
IF tout1=999999 THEN
cp_1<='1';
ELSIF tout1=499999 then cp_1<='0';
END IF;
END IF;
END PROCESS;
PROCESS(cp_1) --4s
BEGIN
IF(cp_1'event AND cp_1='1')THEN
IF tout2=3 THEN
tout2<=0;
ELSE tout2<=tout2+1;
END IF;
IF tout2=3 THEN
cp_2<='1';
ELSIF tout2=2 then cp_2<='0';
END IF;
END IF;
END PROCESS;
cp0<=cp_0;cp1<=cp_2;
END behavior;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_SIGNED.ALL;
ENTITY fenpin IS
PORT(cp_50m:IN STD_LOGIC; --50MHz 输入50MHz
cp0:OUT STD_LOGIC; --1MHz 输出1MHz
cp1:OUT STD_LOGIC); -4s
END fenpin;
ARCHITECTURE behavior OF fenpin IS
SIGNAL tout0:INTEGER RANGE 0 TO 49; --50分频
SIGNAL tout1:INTEGER RANGE 0 TO 999999; --1Hz
SIGNAL tout2:INTEGER RANGE 0 TO 3; --3s高电平,1s低电平
SIGNAL cp_0:STD_LOGIC;
SIGNAL cp_1:STD_LOGIC;
SIGNAL cp_2:STD_LOGIC;
BEGIN
PROCESS(cp_50m) --1MHz
BEGIN
IF(cp_50m'event AND cp_50m='1')THEN
IF tout0=49 THEN
tout0<=0;
ELSE tout0<=tout0+1;
END IF;
IF tout0=24 THEN
cp_0<='1';
ELSIF tout0=49 then cp_0<='0';
END IF;
END IF;
END PROCESS;
PROCESS(cp_0) --1Hz
BEGIN
IF(cp_0'event AND cp_0='1')THEN
IF tout1=999999 THEN
tout1<=0;
ELSE tout1<=tout1+1;
END IF;
IF tout1=999999 THEN
cp_1<='1';
ELSIF tout1=499999 then cp_1<='0';
END IF;
END IF;
END PROCESS;
PROCESS(cp_1) --4s
BEGIN
IF(cp_1'event AND cp_1='1')THEN
IF tout2=3 THEN
tout2<=0;
ELSE tout2<=tout2+1;
END IF;
IF tout2=3 THEN
cp_2<='1';
ELSIF tout2=2 then cp_2<='0';
END IF;
END IF;
END PROCESS;
cp0<=cp_0;cp1<=cp_2;
END behavior;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询