記事一覧

ルーレットをつくる ~ ビンゴの判定、動作

2013年06月21日(金)17時00分

ビンゴの判定は簡単です。
全て止まった状態のルーレットが一致していることですね。

bingo_ctl.vhd

-- Bingo Control
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity BINGO_CTL is
    port(
        RESET       : in  std_logic;
        STOP1       : in  std_logic;    -- ルーレットが 0:動 1:止
        STOP2       : in  std_logic;    -- ルーレットが 0:動 1:止
        STOP3       : in  std_logic;    -- ルーレットが 0:動 1:止
        HIT1        : in  std_logic_vector(3 downto 0);
        HIT2        : in  std_logic_vector(3 downto 0);
        HIT3        : in  std_logic_vector(3 downto 0);
        BINGO_STATUS: out std_logic    -- BINGO 0:× 1:○
    );
end BINGO_CTL;

architecture RTL of BINGO_CTL is

signal ALL_STOP     : std_logic;

begin

    ALL_STOP <= STOP1 and STOP2 and STOP3;

    process(RESET,ALL_STOP,HIT1,HIT2,HIT3)
    begin
        if (RESET = '0') then
            BINGO_STATUS <= '0';
        else
            if (ALL_STOP = '1') then
                if (HIT1 = HIT2 and HIT2 = HIT3) then
                    BINGO_STATUS <= '1';
                else
                    BINGO_STATUS <= '0';
                end if;
            else
                BINGO_STATUS <= '0';
            end if;
        end if;
    end process;
    
end RTL;

ビンゴした時の動作ですが、
LEDがくるくる光るようにしてみます。

ファイル 93-1.jpg

ring.vhd

-- Ring Counter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity RING is
    port(
        DIV_CLK : in  std_logic;
        ENABLE  : in  std_logic;
        DOUT    : out std_logic_vector(3 downto 0)
    );
end RING;

architecture RTL of RING is
    signal DATA : std_logic_vector(3 downto 0);    

begin
    -- Ring Counter
    process(DIV_CLK,ENABLE)
    begin
        if (DIV_CLK'event and DIV_CLK='1') then
            if(ENABLE = '1') then
                DATA(0) <= not (DATA(0) or DATA(1) or DATA(2));
                DATA(1) <= DATA(0);
                DATA(2) <= DATA(1);
                DATA(3) <= DATA(2);
            else
                DATA <= "0000";
            end if;
        end if;
    end process;
    -- Ring Counter end

    DOUT <= not DATA;
    
end RTL;

LEDの出力は負論理なので、最後でデータを反転しています。