下面是一个异步清零的同步计数器的程序,错误在程序中标出了
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY counter IS
PORT(areset, enable, clk : IN STD_LOGIC;
q : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
cout : OUT STD_LOGIC);
END counter;
ARCHITECTURE beh_counter OF counter IS
variable cq : STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
PROCESS(areset, enable, clk)
BEGIN
if (areset = '1') then
cq := (others => '0');
elsif (clk'EVENT AND clk = '1') then
if(enable = '1') then
if(cq := 15) cq := (others => '0'); cout <= '1'; --Error (10500): near text ":="; expecting ")", or ","
else cq := cq + 1;
end if;
end if;
end if;
q <= cq; --Error (10500): VHDL syntax error at counter.vhd(24) near text "if"; expecting "process"
END PROCESS;
END beh_counter;
上面的第一个错误在IF后面少写了个then 不过加上之后编译Error (10500): VHDL syntax error at counter.vhd(20) near text ":="; expecting ")", or ","
还是在第一个错误那里