1 / 15

Randomhex Module

dalmar
Download Presentation

Randomhex Module

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ObjectiveThe object of the game is to convert as many hexadecimal numbers to binary coded decimal numbers correctly within thirty (30) seconds.How to PlayTo begin play press Button 4. The clock will begin and a value will be displayed. Enter the displayed value on the switches. Zero is towards the top of the game board and one is towards the bottom of the game board. The player has 30 seconds to convert as many numbers as possible. At the end of the 30 seconds, the player’s score will be displayed. If it is the new High Score “HI” will appear next to the player’s score. If it is not the new High Score then “00” will appear next to the player’s score. To display the High Score press Button 3. To clear the High Score Memory, press Button 2.

  2. RandomhexModule • Continually cycles through 00-FF at each rising edge of the clock. • When the game is started or a value gets checked, the random number output at that instant is displayed on the 7-segment display as the new hex value.

  3. BTNcontrolModule • This module sends W8Y_control the BTN2 signal, taking into account OutOfTime. This changes the button operations in different states.

  4. Check Module • Checks the random hex value against the switch value • Only checks when BTN1 is pressed during the game • Controlled by chkload, which is controlled by W8Y_control • If the values are equal, then the score is incremented. If they are not equal, the score remains unchanged.

  5. Check Module Score = 0 Score = 1 Score = 1 (unchanged)

  6. Timer Module • The 30-second game timer. • When time runs out, OurtOfTime goes high. • The game timer is displayed in decimal. • This was accomplished by a case statement. case time30 is when "00011110" => time <= "00110000"; --30 when "00011101" => time <= "00101001"; --29 … when others => time <= time30; --09to00 end case;

  7. Timer Module • Timer construction in VHDL. elsif (clk = '1' and clk'event) then … elsif decenable = '1' then -- during game time490 <= time490 + 1; if time490 = "1011011111" then -- 735 decimal time30 <= time30 - 1; time490 <= "0000000000"; end if; …

  8. Timer Module “Forced” decimal values Actual hex values OutOfTime goes low when timer is initialized and goes back to high when time runs out.

  9. ScoreLED Module • The running score is displayed as you play. • For each correct answer, one LED lights up. Beginning with the 9th correct answer, the LEDs turn off for each additional correct answer.

  10. The ROM BTN3 = 0 Show- High BTN3 = 1 Main Game BTN4 = 1 OutOfTime = 1 • Three states for HexBinIQ: Main, Game, ShowHigh • Main waits for BTN1 to start a new game , or you can press BTN3 to view the high score (ShowHigh). • ShowHigh cannot be executed during the game. • State Diagram:

  11. New OpCodes • There were seven new opcodes added to the set from Lab 9. -- New Data Stack Instructions constant swapNs: opcode := X"0B"; -- Swap N, N2 -- New Return Stack, Conditional, and I/O instructions constant e1fetch: opcode := X"38"; -- E1@ constant e2fetch: opcode := X"39"; -- E2@ constant Tstore: opcode := X"3A"; -- Tstore constant Nstore: opcode := X"3B"; -- Nstore constant reset: opcode := X"3C"; -- reset constant check: opcode := X"3D"; -- Check

  12. New OpCodes • The new opcodes defined in W8Y_Control. when E1fetch => tsel <= "01"; tload <= '1'; dssel <= "11"; esel <= '0'; when E2fetch => tsel <= "01"; tload <= '1'; dssel <= "11"; esel <= '1'; when swapNs => nsel <= '1'; nload <= '1'; dpush <= '1'; dpop <= '1'; when Tstore => tdload <= '1'; when Nstore => ndload <= '1'; when Reset => ResetSig <= '1'; when Check => chkload <= '1';

More Related