| 
 | 
 
我编的是一个时钟秒钟的设置 
敏感信号有时钟,上设置键,下设置键 
一开始我全部弄在一个process里面 
就是如果在set状态,(upset'event and upset='0')秒钟自动加1,(downset'event and downset='0')秒钟自动减1,正常情况下(clk'event and clk='1')秒钟自动加1 
结果报错,说一个process里面不能有2个以上的边沿触发; 
如果我改写了,将上述3个边沿触发放在了3个process里面,结果报错,不能有2个以上并行的process对同一个信号进行赋值; 
再然后我就设置了一个变量,先3个process对变量赋值,变量再给信号赋值,结果报错说不能在process外定义变量。 
上次提问了一次,最后还是没有解决问题,现在仿真错误,程序如下: 
library ieee; 
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all; 
 
entity second is 
port 
(clk0,clk,reset,setsecond,upset,downset:in std_logic; 
enmin ut std_logic; 
dh:buffer std_logic_vector (3 downto 0); 
dl:buffer std_logic_vector (3 downto 0)); 
end; 
 
architecture action of second is 
signal upset_r,downset_r:std_logic:='1'; 
begin 
process(reset,clk,setsecond,upset,downset,dh,dl,upset_r,downset_r) 
begin 
if reset='0' then 
        dh<="0000"; 
        dl<="0000"; 
elsif setsecond='1' then 
        if (upset_r='1' and upset='0') then 
                if dl=9 then 
                        dl<="0000"; 
                        if dh>=5 then 
                                dh<="0000"; 
                        else 
                                dh<=dh+1; 
                        end if; 
                else 
                        dl<=dl+1; 
                end if; 
        elsif (downset_r='1' and downset='0') then 
                if dl=0 then 
                        dl<="1001"; 
                        if dh=0 then 
                                dh<="0101"; 
                        else 
                                dh<=dh-1; 
                        end if; 
                else 
                        dl<=dl-1; 
                end if; 
        end if; 
else 
        if dl="1001" and dh="0101" then 
                enmin<='0'; 
        else 
                enmin<='1'; 
        end if;                 
        if (clk'event and clk='1') then 
                if dl=9 then 
                        dl<="0000"; 
                        if dh>=5 then 
                                dh<="0000"; 
                        else 
                                dh<=dh+1; 
                        end if; 
                else 
                        dl<=dl+1; 
                end if; 
        end if; 
end if; 
end process; 
process(clk0) 
begin 
if (clk0'event and clk0='1') then 
        upset_r<=upset; 
        downset_r<=downset; 
end if; 
end process; 
end; 
upset和downset的时候还是出错。clk0是200Hz信号,clk是1Hz的信号。 |   
 
 
 
 |