-- Counter1bit
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter1bit is
port(
D, clk, clr : in bit; -- input
Q: out bit ); -- output
end counter1bit;
architecture behavior of counter1bit is
begin
process (clk,clr)
begin
if clr <= '0' then
Q <= '0';
elsif rising_edge (clk) then
Q<=D;
end if;
end process;
end behavior;
-- counter 4 bit
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(
D: in bit_vector (3 downto 0); -- input
clr, clk : in bit; -- input
Q: out bit_vector (3 downto 0)); -- output
end counter;
architecture structure of counter is
component counter1bit
port(
D, clk , clr : in bit; -- input
Q: out bit ); -- output
end component;
begin --Instantiate 4 copies of the Flipflop
C0: counter1bit port map (D(0), Clr, Clk, Q(0));
C1: counter1bit port map (D(1), Clr, Clk, Q(1));
C2: counter1bit port map (D(2), Clr, Clk, Q(2));
C3: counter1bit port map (D(3), Clr, Clk, Q(3));
end structure;
architecture behavioral of counter is
begin
process is
begin
if D<9 then
Q <= Q+1;
elsif D>9 then
Q <= Q-1;
else
Q <= Q;
end if;
end process;
end behavioral;
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(
D: in bit_vector (3 downto 0); -- input
clr, clk : in bit; -- input
Q: out bit_vector (3 downto 0)); -- output
end counter;
architecture structure of counter is
component counter1bit
port(
D, clk , clr : in bit; -- input
Q: out bit ); -- output
end component;
begin --Instantiate 4 copies of the Flipflop
C0: counter1bit port map (D(0), Clr, Clk, Q(0));
C1: counter1bit port map (D(1), Clr, Clk, Q(1));
C2: counter1bit port map (D(2), Clr, Clk, Q(2));
C3: counter1bit port map (D(3), Clr, Clk, Q(3));
end structure;
architecture behavioral of counter is
begin
process is
begin
if D<9 then
Q <= Q+1;
elsif D>9 then
Q <= Q-1;
else
Q <= Q;
end if;
end process;
end behavioral;
Error (10327): VHDL error at counter.vhd(26): can't determine definition of operator ""<"" -- found 0 possible definitions