
我在VHDL里面编写了如下的程序,后来发现process括号里面的d输入在原理图里面根本找不到,下载后d也不能用
entity testprocess is
Port ( en : in STD_LOGIC;
clk : in STD_LOGIC;
d : in STD_LOGIC;
q : out STD_LOGIC_VECTOR(7 downto 0));
end testprocess;
architecture Behavioral of testprocess is
signal data:std_logic_vector(7 downto 0):=(others => '0');
begin
q <= data;
process(d)
begin
if(en = '1') then
data <= data + 1;
end if;
end process;
end Behavioral; 展开
--看你的输入和你的程序,感觉你是想在d有变化的时候,如果en有效则data自加1.
--如下:(注意我在process处的注释,应该是关键所在)
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity testprocess is
Port ( en : in STD_LOGIC;
clk : in STD_LOGIC;
d : in STD_LOGIC;
q : out STD_LOGIC_VECTOR(7 downto 0));
end testprocess;
architecture Behavioral of testprocess is
signal data:std_logic_vector(7 downto 0):=(others => '0');
begin
process(en,d)--process里要有触发参数的相关语句,这样才有的执行。
--换句话说只有与触发有关的语句才会执行,继而引起其他参数(比如有一个参数a)的变化,
--然后如果有与a相关的语句,那么再继续执行,反之到此为止。
begin
-- if d'event and d = '1' then
-- if en = '1' then
-- data <= data + 1;
-- end if;
-- end if;
if d'event and d = '0' then
if en = '1' then
data <= data + 1;
end if;
end if;
end process;
q <= data;--信号赋值特点是在process执行完毕后赋值,所以此代码一般写在最后
end Behavioral;
非常感谢你的回答,还有一个问题,就是我想让d从0变到1和从1变到0时都触发该怎么写?要写两个process吗?谢谢。
process(d)
begin
if(d = '1') then
data <= data + 1;
end if;
end process;
这样就可以
如
process(d)
begin
if d'event and d='1' then
if(en = '1') then
data <= data + 1;
end if;
end if;
end process;