-------------------------------------------------------------------------- -------------------------------------------------------------------------- -- File Name : blackjack.v -- Author(s) : Mitchel D. Horton -- Affiliation : Laboratory for Digital Design Environments -- Department of Electrical & Computer Engineering -- University of Cincinnati -- Date Created : June, 1991. -- Introduction : Behavioral description for the black-jack m/c -- written in a synthesizable subset of VHDL. -- -- Source : Textual description compiled from the book -- F. Prosser and D. Winkel, -- ``The Art of Digital Design'', -- Prentice-Hall, 1987. -- -- -- Modified For Synthesis by Jay(anta) Roy, University of Cincinnati. -- Date Modified : Sept, 91. -- -- Disclaimer : This comes with absolutely no guarantees of any -- kind (just stating the obvious ...) -- -- Acknowledgement : The Distributed Synthesis Systems research at -- the Laboratory for Digital Design Environments, -- University of Cincinnati, is sponsored in part -- by the Defense Advanced Research Projects Agency -- under order number 7056 monitored by the Federal -- Bureau of Investigation under contract number -- J-FBI-89-094. -- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -- use Work.functions.all; entity blackjack is end blackjack; architecture behavior of blackjack is type CARDDECK is array(0 to 51) of BIT_VECTOR(3 downto 0); signal card : BIT_VECTOR(3 downto 0); signal score : INTEGER := 0; signal state : BIT_VECTOR(1 downto 0) := "00"; signal card_number : INTEGER := 0; signal deck : CARDDECK := ("1011", "1011", "1011", "1011", "1010", "1010", "0111", "0100", "1010", "1010", "0111", "0100", "1010", "1010", "0111", "0100", "1010", "1010", "0111", "0100", "1010", "1001", "0110", "0011", "1010", "1001", "0110", "0011", "1010", "1001", "0110", "0011", "1010", "1001", "0110", "0011", "1010", "1000", "0101", "0010", "1010", "1000", "0101", "0010", "1010", "1000", "0101", "0010", "1010", "1000", "0101", "0010"); begin bj : process begin -- CARD GRABBING LOOP Loop1 : while (bits_to_int(state) < 1) loop -- GRAB NEXT CARD OFF THE DECK card <= deck(card_number); -- UPDATE NUMBER OF CARDS IN THIS HAND card_number <= card_number + 1; -- UPDATE SCORE score <= score + bits_to_int(card); -- IF SCORE GT 15 THEN if score > 15 then -- IF SCORE LT 22 THEN if score < 22 then -- STAY state <= "10"; -- ELSE; SCORE GT 22 else -- IF ACE THEN if card = "1011" then -- ENHANCE VALUE OF ACE FROM 11 TO 1 score <= score - 10; -- IF SCORE GT 15 THEN if score > 15 then -- STAY state <= "10"; -- ELSE; SCORE LT 16 else -- HIT ME state <= "00"; end if; -- ELSE; CARD NOT ACE else -- BUST state <= "01"; end if; end if; -- ELSE; SCORE LT 16 else -- HIT ME state <= "00"; end if; end loop; end process; end behavior;