vhdl分频器设计

作者&投稿:谯寇 (若有异议请与网页底部的电邮联系)
怎样基于VHDL 设计一个分频器?~

是不是把MHz分频为0.2Hz
如果这样,给你个思路

输入信号10HZ的话 你要分频咯 这个频率无所谓的 主要看你分频的精度

毕业设计这个层次的东西要求不会很高的 那就选25MHz的吧 最好用有源晶振
无源也问题不大 呵呵


我给你个万能分频代码吧 你的分数也太低了吧 0分




VHDL的任意整数且占空比为50%分频代码

说明如下:

1.其中top file 为 division,其中的clk_com是比较的频率,用它来和分频后波形进行比较,便于观察,

2.any_enve为任意偶数分频文件

3.any_odd为任意奇数分频文件

4.是一个用于2进制与8进制的译码器,我用它来显示在数码管上当前到底是多少分频

5.以下代码在开发板上实验过,请大家放心使用,欢迎转载,但请注明出处,另外说明由于用的是quartus7.1编辑的,中间无法加中文注释,请大家慢慢读了;以下是代码:

------the top file of the design division
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity division is
port (input : in std_logic_vector(7 downto 0);
clk : in std_logic;
clk_out : out std_logic;
clk_com : out std_logic;
led1: out std_logic_vector(6 downto 0);
led2: out std_logic_vector(6 downto 0);
led3: out std_logic_vector(6 downto 0));
end entity division;
--------------------------------------------------

architecture freq of division is
component decoder is----decoder
port(bin : in std_logic_vector(2 downto 0);
de : out std_logic_vector(6 downto 0));
end component;
component any_even is----any_even division
generic (data_width : integer := 8 );
port(input1 : in std_logic_vector(data_width-1 downto 0);
clk_in : in std_logic;
clk_out : out std_logic);
end component any_even;
component any_odd is-----any_even division
generic (data_width : integer := 8);
port(input2 : in std_logic_vector(data_width - 1 downto 0);
clk_in : in std_logic;
clk_out : out std_logic);
end component any_odd;
signal temp1,temp2 : std_logic;
begin
u1: decoder port map(bin=>input(2)&input(1)&input(0),de=>led1);
u2: decoder port map(bin=>input(5)&input(4)&input(3),de=>led2);
u3: decoder port map(bin=>'0'&input(7)&input(6),de=>led3);
u4: any_even port map(input,clk,temp1);
U5: any_odd port map(input,clk,temp2);
process(clk,input)
begin
if input(0)= '0' then
clk_out <= temp1;
else clk_out <= temp2;
end if;
end process;
clk_com <= clk;
end architecture freq;







library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity any_even is
generic (data_width : integer := 8 );
port(input1 : in std_logic_vector(data_width-1 downto 0);
clk_in : in std_logic;
clk_out : out std_logic);
end entity any_even;

architecture div1 of any_even is
signal clk_outQ : std_logic ;
signal coutQ : std_logic_vector (data_width - 1 downto 0);
begin
-------------------------------------------------
process(clk_in)
begin
if clk_in'event and clk_in = '1' then
if coutQ < (conv_integer(input1) - 1) then
coutQ <= coutQ + 1;
else coutQ '0');
end if;
end if;
end process;
---------------------------------------------------
process(coutQ)
begin
if coutQ < (conv_integer(input1))/2 then
clk_outQ <= '0';
else clk_outQ <= '1';
end if;
end process;
clk_out <= clk_outQ;
end architecture div1;





library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity any_odd is
generic (data_width : integer := 8);
port(input2 : in std_logic_vector(data_width - 1 downto 0);
clk_in : in std_logic;
clk_out : out std_logic);
end entity any_odd;

architecture div2 of any_odd is
signal cout1,cout2 : std_logic_vector(data_width - 1 downto 0);
signal clk1,clk2 : std_logic;
begin
process(clk_in)------rising edge
begin
if clk_in'event and clk_in='1' then
if cout1 < (conv_integer(input2)-1) then
cout1 <= cout1 + 1;
else cout1 '0');
end if;
if cout1 < (conv_integer(input2)-1)/2 then
clk1 <= '1';
else clk1 <= '0';
end if;
end if;
end process;

---------------------------
process(clk_in)------falling edge
begin
if clk_in'event and clk_in='0' then
if cout2 < (conv_integer(input2)-1) then
cout2 <= cout2 + 1;
else cout2 '0');
end if;
if cout2 < (conv_integer(input2)-1)/2 then
clk2 <= '1';
else clk2 <= '0';
end if;
end if;
end process;
clk_out <= clk1 or clk2;
end architecture div2;



library ieee;
use ieee.std_logic_1164.all;
entity decoder is
port(bin : in std_logic_vector(2 downto 0);
de : out std_logic_vector(6 downto 0));
end entity;
----------------------------------------------------
architecture deco of decoder is
begin
process(bin)
begin
case bin is
when "000" => de <= "0111111";---0
when "001" => de <= "0000110";---1
when "010" => de <= "1011011";---2
when "011" => de <= "1001111";---3
when "100" => de <= "1100110";---4
when "101" => de <= "1101101";---5
when "110" => de <= "1111101";---6
when others => de <= "0000111";---7

end case;
end process;
end architecture;

LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
ENTITY counter IS
PORT
( clock: IN STD_LOGIC ;
q1khz: BUFFER STD_LOGIC;
q1hz: OUT STD_LOGIC);
END counter;
ARCHITECTURE bhv OF counter IS
BEGIN

KHZ:PROCESS(clock)
VARIABLE cout:INTEGER:=0;
BEGIN
IF clock'EVENT AND clock='1' THEN
cout:=cout+1;
IF cout<=500 THEN q1khz<='0';
ELSIF cout<1000 THEN q1khz<='1';
ELSE cout:=0;
END IF;
END IF;
END PROCESS;

HZ:PROCESS(q1khz)
VARIABLE cout:INTEGER:=0;
BEGIN
IF q1khz'EVENT AND q1khz='1' THEN
cout:=cout+1;
IF cout<=500 THEN q1hz<='0';
ELSIF cout<1000 THEN q1hz<='1';
ELSE cout:=0;
END IF;
END IF;
END PROCESS;
END bhv;
我测试过可以用的


VHDL怎么将进行16M分频成1HZ?
第二个分频器的最高位就是1Hz信号脉冲!注意: <1>第二个分频器的模是15626 ( 0x3D09 )!<2>如果要求输出脉冲有50%的占空比,那就先经过15625分频,在经过1024分频,即可!<3>才用两级分频的原因是,单级计数器的进位链不能太长,否则会脱链。我只会VerilogHDL,所以VHDL代码你自己写。

求一个基于Verilog HDL的音乐播放代码
module song(clk500khz,clk4hz,speaker);input clk500khz,clk4hz;output speaker;reg[11:0] divider,origin;reg[7:0] counter;reg[7:0] note;\/\/音符索引值 wire carry;\/\/可控分频器 assign carry=(divuder==4095);always@(posedge clk500khz)begin if(carry)divider=origin;else divider=...

如何利用74LS194设计分频器???
利用194来设计奇数或偶数型的计数器,可以用反馈移位的方法来设计,具体可以见西安电子科技大学出版社,杨颂华编的数字电子技术基础,第七章关于74LS194的部分 。设计时请注意能否自启动的问题。分频器和计数器有本质联系,比如把输入信号作为模4计数器的时钟信号,那么计数器的输出就可以将输入信号4分频。

求助!!!电子日历表课程设计
四、设计提示1.关于输入时钟试验板上可以输入4路时钟,并有多钟频率可以选择(详见后文实验板资源),问题:输入几路时钟?各多少赫兹?如何分频得到所需频率? 提示:选择时钟源的原则是:输入的时钟源尽量少,内部分频器也要尽量少。先查看一下需要哪些时钟。计时的基准时钟:1Hz跑表的基准时钟:100Hz数字闪烁显示:2Hz闹铃...

如何设计除频器
对於合成器来说,也较容易合成出好的电路,对於可读性来说,人类也较容易理解,甚至看完code後,自己都可以当合成器,合出一个电路,这也是为什麼说写HDL要『心中有电路』,而不是像写软体一样,只要考虑语法就好,反正编译器会帮你解决,这也是写硬体和写软体另一个差异很大的地方。

FPGA开发中的VHDL语言与Verilog HDL语言那个好学?各有什么优缺点?_百 ...
2015-01-28 学FPGA用VHDL语言还是Verilog语言比较好? 1 2010-04-16 VHDL和Verilog HDL两种语言的具体不同 57 更多类似问题 > vhdl语言的相关知识2011-08-09 学习VHDL语言,想买块开发板,买什么的好? 2009-03-19 VHDL语言设计分频器 32 2013-05-21 设计VHDL语言的软件有哪些 5 2010-07-08 VHDL语言编...

设计要求:设计一个六位数的频率计,测量精度高于0.2%
参考这个文库,网页链接 虽然他的方案很不完善,可以提供入门的思路。做频率计,基本的结构有:(1)前端整形电路,能把低于数字逻辑阈值的信号限幅放大到标准的TTL或CMOS或ECL电平。高频频率计前端还要有前置分频器。简单练手,这部分可以暂时舍掉。(2)参考时钟以及门控信号。闸门时间内计数,闸门时间...

微机题,编制完成EAX*5\/8的程序段。要求:1.用乘法指令实现。2.用移位和...
定时器0用作分频器,工作方式2,其初始化程序为: MOV AL, 34H OUT 343H, AL MOV AL, N1 OUT 342H, AL MOV AL, N2 OUT 342H, AL 定时器2用作外部事件计数器,工作在方式0,其初始程序: MOV AL, 0B0H OUT 343H,AL MOV AL, N1 OUT 342H,AL MOV AL, N2 OUT 342H,AL9.4 若已有一频率发生器...

试用Veriloghdl设计一个七段数码管的显示译码器,要求可以同时兼容共阴共 ...
module led8_display(clk,rst,comsel,en,play);input clk;input rst;input comsel;output[7:0] en;output[7:0] play;reg[30:0] count;reg[7:0] en;reg[7:0] play;always@(posedge clk or negedge rst)begin if(!rst)begin if(comsel)\/\/共阳译码 begin count<=0;en<=1;play<=8'b...

七段数码管动态显示实验问题怎么办
四、实验要求:实现显示0000-9999的十进制计数器。五、实验步骤1.建立工程建立名为leddisplay的工程,并建立顶层图。2.设计技术时钟设计一分频器,对50MHz分频输出到计数器,让计数器以较慢速度递增。打开File..New,新建一个.v文件。输入以下程序:module int_div(clk, div_out);input clk;output ...

阿尔山市18664052870: vhdl分频器设计 -
年诞佐凯: =cout+1; if cout&lt.std_logic_unsigned; architecture bhv of counter is begin khz;=500 then q1khz< then cout:process(clock) variable cout;1' then cout; use ieee;; entity counter is port ( clock.std_logic_1164; else cout; elsif cout&lt.all;1000 then q1hz&lt:...

阿尔山市18664052870: 求用VHDL设计一个分频器 -
年诞佐凯: 是不是把48MHz分频为0.2Hz?如果这样,我给你个思路吧:1、分频器实质上就是一个计数器,48MHz分到0.2Hz实际上就是设计一个计数器,使得每次计录48*2.5*10^6个脉冲后将一个信号翻转(也就是2.5秒高电平,2.5秒低电平);2、具体...

阿尔山市18664052870: 【菜鸟求教:请用vhdl语言设计一个分频器.50分拜谢!!!】 -
年诞佐凯: 程序给你做出来了,完全符合你的要求.仿真的话时间用的太长,就仿了一个set1set2=00的50m的2500分频20k的,图也给你贴出来,不过频率太高,图片已经看不出clk的波形了.程序:library ieee; use ieee.std_logic_1164.all; use ieee.std_...

阿尔山市18664052870: 用VHDL编写分频器程序 -
年诞佐凯: 这个一般有两种方法,一种是分奇偶分频,因为奇偶分频不一样,所以先判断是奇偶,然后再相应处理就可以了,另一种是一种整体算法思想,不需要判断奇偶数...顶层模块程序:entity control_clk is port( Clk_i : in std_logic; Data_i : in std_...

阿尔山市18664052870: VHDL语言设计分频器 -
年诞佐凯: 输入信号10HZ的话 你要分频咯 这个频率无所谓的 主要看你分频的精度 毕业设计这个层次的东西要求不会很高的 那就选25MHz的吧 最好用有源晶振 无源也问题不大 呵呵 我给你个万能分频代码吧 你的分数也太低了吧 0分 VHDL的任意整数且占...

阿尔山市18664052870: 求设计一个分频器VHDL
年诞佐凯: <p>5hz 周期是 48hz的4800000倍,除以2是,转换成十六进制x493E00</p> <p> 程序如下:</p> <p>library ieee;</p> <p>use ieee.std_logic_1164.all;</p> <p>use ieee.std_logic_unsigned.all;</p> <p>entity fp33 is</p> <p> port(clk: in std_logic;</p...

阿尔山市18664052870: 用VHDL编写一个分频器,实现输出1MHz - 1Hz之间的任意频率 -
年诞佐凯: clk 输入一个相对较大的频率,频率要多少就用N_diviseur除!LIBRARY IEEE; USE IEEE.Std_Logic_1164.ALL; ENTITY div IS GENERIC( n_diviseur : INTEGER := 2 ); PORT ( clk : IN Std_Logic; clock : OUT Std_Logic); END ENTITY; ...

阿尔山市18664052870: 请用VHDL设计一个分频器,从50Mhz信号分频出440HZ信号 -
年诞佐凯: 50000000/440 = 113636分频倍数 程序 如下 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity fp isport(clk: in std_logic;fpclk: out std_logic); end fp;architecture arc of fp is beginprocess(clk)variable count: integer ...

阿尔山市18664052870: 用VHDL语言帮忙设计一个分频器,从50MHZ信号分频出500Khz,100Khz信号 -
年诞佐凯: LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY Frequency IS PORT (CLK: IN STD_LOGIC; Q1: INOUT STD_LOGIC := '0'; Q5: INOUT STD_LOGIC := '0'); END Frequency; ARCHITECTURE one OF Frequency IS SIGNAL cnt_0:...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网