記事一覧

野球ゲームをつくる ~ 7.イニングカウンターの作成

2015年06月03日(水)19時56分

イニングカウンターは単純に10進数のカウンターです。

ining_counter.vhd

-- INING Counter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity INING_COUNTER is
    port(
        CLK         : in  std_logic;
        RESET       : in  std_logic;
        COUNT       : out std_logic_vector(3 downto 0)
    );
end INING_COUNTER;

architecture RTL of INING_COUNTER is
signal COUNT_TMP    : std_logic_vector(3 downto 0);

begin

    process (CLK,RESET)
    begin
        if (RESET = '0') then
            COUNT_TMP <= "0001";
        elsif (CLK'event and CLK = '0') then
            COUNT_TMP <= COUNT_TMP + 1;
        end if;
    end process;

    COUNT <= COUNT_TMP;
        
end RTL;