⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contr.txt

📁 用VHDL语言写的时钟程序。采用模块化编程。可在EPM7128芯片上下载。编译环境可用Maxplus或Quartus。
💻 TXT
字号:
--控制模块


 library ieee;
use ieee.std_logic_1164.all;        
use ieee.std_logic_signed.all;      

entity contr is
   port (cp100:in std_logic;         --100Hz时钟
         reset:in std_logic;         --清零按键
         startstop: in std_logic;    --启动停止键
         dao:in std_logic;           --正/倒记时转换键
         startstopctr: out std_logic;--启动停止控制信号
         kan  :out std_logic);       --暗走控制信号
   end contr;

architecture c of contr is
signal cp7:std_logic;
signal count7:integer range 0 to 6;
signal ctr,kanout:std_logic;
signal stst,res:std_logic;
begin
p0:process(cp100)                          --产生周期为70ms的时钟,
   begin                                   --作为下一进程的时钟
    if(cp100'event and cp100='1') then
      if(count7=6) then
         count7<=0;
      else count7<=count7+1;
      end if;
      if(count7<=3) then
          cp7<='0';
      else cp7<='1';
      end if;
    end if;
   end process;

     
p1:process(cp7)                            --防抖电路,在时钟边沿抽样
     begin
     if(cp7'event and cp7='0') then
       stst<=startstop;
       res<=reset;
     end if;
    end process;


    p2:process(stst)                      --防抖电路,同上
     begin                                 
      --if(dao='0' and res='0') then
          --ctr<='1';
        --else
        if(stst'event and stst='1') then  --产生开启停止控制信号
          if(ctr='0') then
          ctr<='1';
          else ctr<='0';
          end if;
        end if;
      --end if;
      startstopctr<=ctr;
     end process;

p3:process(res)                           --产生暗走控制信号
    begin
      if(res'event and res='1') then
        if(ctr='1' and dao='1')then
          if(kanout='0') then
          kanout<='1';
          else kanout<='0';
          end if;
        end if;
      end if;
    kan<=kanout;
   end process;
end c;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -