利用硬件描述语言实现交通灯控制模型5,分频

分频

模块说明:通过对分频系统的循环,达到将50mhz的时钟分开成1hz时钟和100hz时钟的目的

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

 

entity fenpin is

port(clk:in std_logic; -----输入时钟

clk_out1:out std_logic; -----输出1hzʱ

clk_out2:out std_logic); ----输出100hzclk

end entity fenpin;

 

architecture behav of fenpin is

signal count1:integer range 0 to 24999999;     -----分频系数

signal count2:integer range 0 to 249999;    ---------分频系数

signal clk_data1:std_logic;        ----clk_data1信号

signal clk_data2:std_logic;        -----clk_data2信号

 

begin

shuchushizhong:process(clk)

begin

if clk'event and clk='1' then

   if count1=24999999 then       ----count1循环

      count1<=0;                -----

      clk_data1<=not clk_data1;  ---取反

   else count1<=count1+1;        -----count1循环

   end if;

end if;

end process shuchushizhong;

 

clk_out1<=clk_data1;             -----局部变量代入全局变量

 

 

dongtaisaomiaoshizhong:process(clk)

begin

if clk'event and clk='1' then  ----时钟上升沿

   if count2=249999 then       

      count2<=0;                

      clk_data2<=not clk_data2;  

   else count2<=count2+1;        

   end if;

end if;

end process dongtaisaomiaoshizhong;

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值