实例教学五 分频器 cpld fpga可编程逻辑器件

上传人:ji****en 文档编号:110832760 上传时间:2019-10-31 格式:PPT 页数:24 大小:1.25MB
返回 下载 相关 举报
实例教学五 分频器 cpld fpga可编程逻辑器件_第1页
第1页 / 共24页
实例教学五 分频器 cpld fpga可编程逻辑器件_第2页
第2页 / 共24页
实例教学五 分频器 cpld fpga可编程逻辑器件_第3页
第3页 / 共24页
实例教学五 分频器 cpld fpga可编程逻辑器件_第4页
第4页 / 共24页
实例教学五 分频器 cpld fpga可编程逻辑器件_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《实例教学五 分频器 cpld fpga可编程逻辑器件》由会员分享,可在线阅读,更多相关《实例教学五 分频器 cpld fpga可编程逻辑器件(24页珍藏版)》请在金锄头文库上搜索。

1、分频器 的VHDL设计,桂林师范高等专科学校 羊日飞,分频器(Divider),分频器可以用来降低信号的频率,是数字系统中常用的时序电路。 在数字系统中,常常需要各种频率的时钟信号,获得的方法一般是对晶振的时钟进行分频(降频)。,二分频、四分频、八分频,二分频器,输出信号的频率是输入信号频率的1/2,由于周期是频率的倒数,所以周期是输入信号的2倍。,输入脉冲,输出脉冲,2,分频器的应用,51单片机的定时/计数器结构,二分频电路的VHDL代码编写 库引用,引用IEEE库 引用IEEE库中的std_logic_1164程序包,library ieee; use ieee.std_logic_116

2、4.all,二分频电路的VHDL代码编写 实体,分频器电路的外特性: 有1个高频时钟信号输入端 clk; 有1个低频时钟信号输出端 q; 实体名: clk_div,entity clk_div is port( clk: in std_logic; q: buffer std_logic; ); end clk_div;,端口的 信号模式,二分频电路的VHDL代码编写 结构体,architecture clk_div_stru of clk_div is begin end clk_div_stru;,二分频电路的 行为/功能描述,输出信号只在输入信号的上升沿到来时变化,其余时间保持原有状态不

3、变; 输出信号在输入信号的上升沿到来时变化,新的状态为上升沿到来时刻的状态取反;,思考,观察输出信号的变化规律,找出与输入信号的联系,用自然语言描述出来,二分频电路的VHDL代码编写 结构体,时钟信号的上升沿如何描述?,复习,二分频电路的VHDL代码编写 结构体,“当时钟信号上升沿到来时,”如何描述?,复习,process(clk) begin if clkevent and clk=1 then end if; end process;,输出信号只在输入信号的上升沿到来时变化,其余时间保持原有状态不变;,二分频电路的VHDL代码编写 结构体,输出信号在输入信号的上升沿到来时变化,新的状态为上

4、升沿到来时刻的状态取反;,使用 if 语句进行描述,process(clk) begin if clkevent and clk=1 then q= not q; end if; end process;,讨论q的信号模式,实体定义中的端口说明,端口名:是赋于每个外部引脚的名称。 信号模式:用来说明数据、信号通过该端口的方向。有四种: (1)IN(输入) (2)OUT (输出) (3)INOUT (双向) (4)BUFFER (缓冲),IN(输入),信号从外部经该端口输入至实体; 单向端口;,entity,OUT(输出),从实体输出至外部; 单向端口;,entity,BUFFER(缓冲),可以

5、从实体输出至外部; 也可以从端口回读该输出值; 不可以从外部输入至实体; 单向端口;,entity,Q,D,architecture clk_div_stru of clk_div is begin process( clk) begin if clkevent and clock=1 then q= not q ; end if; end process; end clk_div_stru;,二分频电路的VHDL代码编写 结构体(完整代码),输出信号只在输入信号的上升沿到来时变化,其余时间保持原有状态不变; 输出信号在输入信号的上升沿到来时变化,新的状态为上升沿到来时刻的状态取反;,二分频电

6、路的VHDL代码 综合结果,二分频电路的VHDL代码 仿真结果,任意倍数的分频器如何实现,可以利用一个计数器来实现。 计数输入脉冲的个数,当输入脉冲的个数达到所要分频的倍数时,翻转输出波形。,8分频电路的VHDL代码编写 从计数器的VHDL入手,entity counter is port( reset: in std_logic; clock: in std_logic; Q: out std_logic_vector(3 downto 0) ); end counter;,entity clkdiv is port( reset: in std_logic; clock: in std_l

7、ogic; Q:buffer std_logic ); end clkdiv;,8分频电路的VHDL代码编写 从计数器的VHDL入手,architecture counter_stru of counter is signal count: std_logic_vector(3 downto 0); begin process( reset , clock) begin if reset=0 then count=“0000”; elsif clockevent and clock=1 then if count=“1111” then count=“0000”; else count=cou

8、nt+ “0001” ; end if; end if; end process; Q=count; end counter_stru;,8分频电路的VHDL代码编写 从计数器的VHDL入手,architecture counter_stru of counter is signal count: std_logic_vector(3 downto 0); begin process( reset , clock) begin if reset=0 then count=“0000”; elsif clockevent and clock=1 then if count=“1111” then

9、 count=“0000”; else count=count+ “0001” ; end if; end if; end process; Q=count; end counter_stru;,architecture clkdiv_stru of clkdiv is signal count: std_logic_vector(3 downto 0); begin process( reset , clock) begin if reset=0 then count=“0000”; q=0; elsif clockevent and clock=1 then if count=4 then count=“0000”; q= not q; else count=count+ “0001” ; end if; end if; end process; end clkdiv_stru;,LED闪烁电路的实现,时钟信号输入 板上6MHz有源晶振,2097150分频,Thank you!,See you next,

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 电子/通信 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号