本帖最后由 fpgaw 于 2010-7-18 09:58 编辑
初学VHDL的.前几天写了一个简单的记数器,如下,如果我把Q<=Q_S放在进程里面,就是下洚沿记述了。如果我放在进程外面的话才是上升沿计数,不太明白为什么,请各位高人帮指点下
-------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
---------------------------------------------------------------
entitycount is -----异步复位同步记数器
port ( clk ,reset ,en: in std_logic;
q: out std_logic_vector(3 downto 0 ));
end count ;
-----------------------------------------------------------------
architecture rtl of count is
signal q_s :std_logic_vector(3 downto 0);
begin
------------------------------------------------------------------
process(clk)
begin
ifreset='1'then
q_s<="0000";
elsif clk'event andclk='1' then
if en='1' then
if q_s="1111" then
q_s<="0000";
else
q_s<=q_s+'1';
end if;
end if ;
end if ;
q<=q_s;
--edn if ;
end process;
--q<=q_s;
end rtl; |