Kod: Markera allt
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
entity twobit_mod3_counter is
port(clk, E, U: in std_logic;
q: out std_logic_vector(1 downto 0));
end entity twobit_mod3_counter;
architecture behavior of twobit_mod3_counter is
subtype state_type is integer range 0 to 2;
signal now, next state_type;
begin
next_state: process(now, U)
begin
if (U = '0') then
if (now = '0') then
now <= 2;
else
next <= (now - 1);
end if;
else
next <= (now + 1) mod 3;
end if;
end process;
q <= conv_std_logic_vector(now,2);
state_register: process(clk)
begin
if rising_edge(clk) and E = '1' then
now <= next;
end if;
end process;
end architecture behavior;
Får compile error:
PS. Det är en räknare som räknar upp (...0, 1, 2, 0, 1...) om U=1 och ner om U=0.Untitled2.vhd (line 12, col 18 ): (E10) Syntax error at/before reserved symbol 'next'.
Error occurred within 'ARCHITECTURE' at line 10, column 45 in Untitled2.vhd.
Den har dessutom en signal Enable E.