rg350dxlover
Member level 1
Hi...
So, basically if the input is = 1000, then it's equal. otherwise not equal. I'm having trouble with some instantiation here. Can't figure out what it is. I hope you guys can help me with this. Thanks!
Here is my game_counter code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity game_counter is
port( RST, CLK: in std_logic;
COUNT_NUM: out unsigned(3 downto 0));
end game_counter;
architecture arch of game_counter is
signal COUNT: unsigned(3 downto 0);
begin
process (CLK, RST)
begin
if RST = '0' THEN
COUNT <= (others => '0');
elsif rising_edge(CLK) then
if COUNT < 9 then
COUNT <= COUNT + 1;
else
COUNT <= (others => '0');
end if;
end if;
end process;
COUNT_NUM <= COUNT;
end arch;
Here's my comparator code:
--libraries to be used are specified here
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--entity declaration with port definitions
entity compare is
port( inCLK, inRST : in std_logic_vector(3 downto 0);
equal, unequal : out std_logic_vector(3 downto 0));
end compare;
architecture Behavioral of compare is
component game_counter
port(RST, CLK: in std_logic_vector(3 downto 0);
COUNT_NUM: out unsigned(3 downto 0));
end component;
for all: game_counter use entity work.game_counter(arch);
signal X: std_logic_vector(3 downto 0);
begin
gc0: game_counter port map (inCLK, inRST, COUNT_NUM);
process(COUNT_NUM)
begin
if (COUNT_NUM = "1000") then
equal <= '1';
unequal <= '0';
else
equal <= '0';
unequal <= '1';
end if;
COUNT_NUM <= X;
end process;
end Behavioral;
So, basically if the input is = 1000, then it's equal. otherwise not equal. I'm having trouble with some instantiation here. Can't figure out what it is. I hope you guys can help me with this. Thanks!
Here is my game_counter code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity game_counter is
port( RST, CLK: in std_logic;
COUNT_NUM: out unsigned(3 downto 0));
end game_counter;
architecture arch of game_counter is
signal COUNT: unsigned(3 downto 0);
begin
process (CLK, RST)
begin
if RST = '0' THEN
COUNT <= (others => '0');
elsif rising_edge(CLK) then
if COUNT < 9 then
COUNT <= COUNT + 1;
else
COUNT <= (others => '0');
end if;
end if;
end process;
COUNT_NUM <= COUNT;
end arch;
Here's my comparator code:
--libraries to be used are specified here
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--entity declaration with port definitions
entity compare is
port( inCLK, inRST : in std_logic_vector(3 downto 0);
equal, unequal : out std_logic_vector(3 downto 0));
end compare;
architecture Behavioral of compare is
component game_counter
port(RST, CLK: in std_logic_vector(3 downto 0);
COUNT_NUM: out unsigned(3 downto 0));
end component;
for all: game_counter use entity work.game_counter(arch);
signal X: std_logic_vector(3 downto 0);
begin
gc0: game_counter port map (inCLK, inRST, COUNT_NUM);
process(COUNT_NUM)
begin
if (COUNT_NUM = "1000") then
equal <= '1';
unequal <= '0';
else
equal <= '0';
unequal <= '1';
end if;
COUNT_NUM <= X;
end process;
end Behavioral;