基于vhdl的分频器设计

一 设计要求

  1. 将EDA 板上的系统时钟50MHz 分频为1Hz 的时钟信号
  2. 占空比为50%
  3. 利用流水灯点亮程序,在EDA 板上观察效果

二 代码实现

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

entity clkdiv is
    generic(n:integer:=50000000);
    port(clk_50MHZ:in std_logic;
         clk_1HZ:out std_logic);
end clkdiv;

architecture behavior of clkdiv is
 signal count:integer range n-1 downto 0:=n-1;
begin
  process(clk_50MHZ)
  begin
    if(clk_50MHZ'event and clk_50MHZ='1'and clk_50MHZ'last_value='0') then
      count<=count-1;
       if count>=n/2 then
          clk_1HZ<='0';
       else
          clk_1HZ<='1';
       end if;
       if count<=0 then
          count<=n-1;
       end if;
     end if;
   end process;
end behavior;


三 整机电路
在这里插入图片描述
四 实验结果

状态1
在这里插入图片描述
状态2
在这里插入图片描述
状态3
在这里插入图片描述
状态4
在这里插入图片描述
状态5
在这里插入图片描述
状态6
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43789635/article/details/112978596