library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library work; use work.LCD_types.all; -- This is the entire blackjack entity -- It combines the input, output and the strategy. -- The clock is slowed down through clk_div. entity top is port ( -- Keypad Inputs clock : in std_logic; reset : in std_logic; Row : IN STD_LOGIC_VECTOR(3 downto 0); -- Keypad Outputs Col : OUT STD_LOGIC_VECTOR(3 downto 0); LED : out std_logic_vector(13 downto 0); -- LCD outputs LCD_codes : out std_logic_vector(comm_bit -1 downto 0) ); end entity top; architecture components of top is -- Slows down the global clock component clk_div generic(N: positive:= 1000); port (fast_clk, reset: in std_logic; slow_clk: buffer std_logic ); end component clk_div; -- Outputs all the data to an LCD component output_logic port ( factorin : in std_logic_vector(factor_bit downto 0); reset : in std_logic; clock : in std_logic; card_dealt : in std_logic; action_1 : in std_logic_vector(action_bits-1 downto 0); LCD_codes : out std_logic_vector(comm_bit -1 downto 0) ); end component output_logic; -- Takes input from keypad component keypad PORT( clk : IN STD_LOGIC; reset : IN STD_LOGIC; Continue : IN STD_LOGIC; KeyDetected : OUT STD_LOGIC; KeyData : OUT STD_LOGIC_VECTOR(3 downto 0); led : OUT STD_LOGIC_VECTOR(6 downto 0); -- External Signals Row : IN STD_LOGIC_VECTOR(3 downto 0); Col : OUT STD_LOGIC_VECTOR(3 downto 0) ); END component keypad; -- Uses the input component control_in port ( clk : in std_logic; reset : in std_logic; KeyDetected : in std_logic; play_valid : in std_logic; play_code : in std_logic_vector(1 downto 0); KeyData : in std_logic_vector(3 downto 0); led_in : in std_logic_vector(6 downto 0); LED : out std_logic_vector(13 downto 0); dealer_data : out std_logic_vector(3 downto 0); player_card1: out std_logic_vector(3 downto 0); player_card2: out std_logic_vector(3 downto 0); card_total : buffer std_logic_vector(4 downto 0); bet : out std_logic_vector(4 downto 0); done : out std_logic; use_total : out std_logic; Continue : out std_logic -- reset_out : out std_logic ); end component control_in; -- Strategy Logic component extended port(dealer : in std_logic_vector(3 downto 0); first_card : in std_logic_vector(3 downto 0); second_card : in std_logic_vector(3 downto 0); sum : in std_logic_vector(4 downto 0); extra_card_bit : in std_logic; dealt : in std_logic; clock : in std_logic; play_code : out std_logic_vector (1 downto 0); code_valid : out std_logic); end component extended; signal valid : std_logic; signal key_detect:std_logic; signal key_data:std_logic_vector(3 downto 0); signal led_link:std_logic_vector(6 downto 0); signal continue:std_logic; signal slow_clock:std_logic; signal use_total:std_logic; signal dealer_data:std_logic_vector(3 downto 0); signal card1:std_logic_vector(3 downto 0); signal card2:std_logic_vector(3 downto 0); signal card_total:std_logic_vector(4 downto 0); signal dealt:std_logic; signal play_code: std_logic_vector (1 downto 0); signal factor:std_logic_vector(4 downto 0); begin slow_doooooown:clk_div port map ( fast_clk => clock, reset => reset, slow_clk => slow_clock ); User_input:keypad port map ( clk => slow_clock, reset => reset, Continue => continue, KeyDetected => key_detect, KeyData => key_data, led => led_link, Row => row, Col => col ); Input_control:control_in port map ( clk => slow_clock, reset => reset, KeyDetected => key_detect, play_valid => valid, play_code => play_code, KeyData => key_data, led_in => led_link, LED => LED, dealer_data => dealer_data, player_card1 => card1, player_card2 => card2, card_total => card_total, bet => factor, done => dealt, use_total => use_total, Continue => continue ); the_guts:extended port map( dealer => dealer_data, first_card => card1, second_card => card2, sum => card_total, extra_card_bit => use_total, dealt => dealt, clock => slow_clock, play_code => play_code, code_valid => valid ); the_output: output_logic port map ( factorin => factor, reset => reset, clock => slow_clock, card_dealt => dealt, action_1 => play_code, LCD_codes => LCD_codes ); end components;