-- file: char_codes -- The entity controls what the screen outputs based on what the -- state of the hand dealt is. library ieee; library work; use work.LCD_types.all; use ieee.std_logic_1164.all; -- Outputs all the data to an LCD entity char_codes is port ( clock : in std_logic; card_dealt : in std_logic; -- Check whether all card have been dealt factorin : in std_logic_vector(factor_bit downto 0); -- Action codes action_1 : in std_logic_vector(action_bits-1 downto 0); -- The display data factor: out std_logic_vector(databit-1 downto 0); address: out std_logic_vector(addressbit-1 downto 0); datascreen: out std_logic ); end entity char_codes; architecture behaviour of char_codes is component BintoChar port (Factor : in std_logic_vector(factor_bit -1 downto 0); Char: out std_logic_vector(databit -1 downto 0)); end component BintoChar; type state_type is (deal_wait, split_act, pos_stay, neg_stay, pos_hit, neg_hit, pos_double, neg_double); signal state, nextstate : state_type; begin factorchoose:BintoChar port map (Factor => factorin(factor_bit-1 downto 0), Char => factor); -- Chooses what address should be used statechoose: process (factorin, card_dealt, action_1) begin if card_dealt = '0' then state <= deal_wait; else if action_1 = splitcode then state <= split_act; else if factorin(factor_bit) = '0' then --factor is positive if action_1 = staycode then --stay state <= pos_stay; elsif action_1 = hitcode then -- hit state <= pos_hit; elsif action_1 = doublecode then -- double state <= pos_double; end if; else -- factor is negative if action_1 = staycode then --stay state <= neg_stay; elsif action_1 = hitcode then -- hit state <= neg_hit; elsif action_1 = doublecode then -- double state <= neg_double; end if; end if; end if; end if; -- This sets the address of the screen case state is when deal_wait => datascreen <='0'; address <= dealscr; when split_act => datascreen <='0'; address <= splitscr; when pos_stay => datascreen <='1'; address <= pstayscr; when neg_stay => datascreen <='1'; address <= nstayscr; when pos_hit => datascreen <='1'; address <= phitscr; when neg_hit => datascreen <='1'; address <= nhitscr; when pos_double => datascreen <='1'; address <= pdoublescr; when neg_double => datascreen <= '1'; address <= ndoublescr; end case; end process; end behaviour;