求大侠指教,eda延时问题

[复制链接]
 楼主| widpj 发表于 2011-5-28 19:24 | 显示全部楼层 |阅读模式
本帖最后由 widpj 于 2011-5-28 19:28 编辑

求指教,本人做的是一个计数器,但要求到一个使能端,即其中的EN,程序看似没错,但却不能编译,求大侠指教,不甚感激!!!
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity timecnt is
  port(clk  :in std_logic;
        EN :in std_logic;
         cnt1  :  out std_logic_vector(3 downto 0);
         cnt2  :  out std_logic_vector(3 downto 0)
        );
end timecnt;
architecture timecnt_1 of timecnt is
  signal count1:std_logic_vector(3 downto 0);
  signal count2:std_logic_vector(3 downto 0);
begin
process(clk,EN)
   begin
       if EN 'event and EN='0' then
             count1<="0000";
             count2<="0000";           
           if clk 'event and clk='1' then
               if count2="1001" and count1="1001" then
             count2<="0000";count1<="0000";
        elsif  count1="1001" then
               count2<=count2+1;count1<="0000";
        else count1<=count1+1;
        end if;
        end if;
     end if;
cnt1<=count1;
cnt2<=count2;
end process;
end timecnt_1;
mr.king 发表于 2011-5-29 07:24 | 显示全部楼层
当然错了,你不能使用EN的边沿,不然是一个进程两个时钟控制
 楼主| widpj 发表于 2011-5-29 13:25 | 显示全部楼层
2# mr.king
EN 是个按键  ,做使能端,那请问应该怎么改?
mr.king 发表于 2011-5-29 13:58 | 显示全部楼层
if EN ='0' then
             count1<="0000";
             count2<="0000";           
elsif  clk 'event and clk='1' then
               if count2="1001" and count1="1001" then
             count2<="0000";count1<="0000";
        elsif  count1="1001" then
.......................
lxc806705 发表于 2011-5-30 10:49 | 显示全部楼层
2# mr.king  
EN 是个按键  ,做使能端,那请问应该怎么改?
widpj 发表于 2011-5-29 13:25

做一个按键扫描,然后导出一个信号
sxhhhjicbb 发表于 2011-5-30 20:47 | 显示全部楼层
4楼的方法可以.
习惯上将elsif  clk 'event and clk='1' then作为同步触发的最外围的if ...endif
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

40

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部

0

主题

40

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部