The Binary to Decimal Matcher Game : 10 Steps - greenvory1971
Introduction: The Binary to Decimal Matcher Game
This instructable will show the process and modules requisite to create our Binary to Decimal Matched game. Inside 60 seconds, users will translate and input as many indiscriminately generated decimal fraction Numbers on the seven section display into binary by toggling the switches and submitting with a guess button. Once completed, a final examination score will be displayed and so reset to play again.
Intellect binary and quick reflexes are salutary to do well, but the reset push button is provided just in case one wants to instantly try again.
Step 1: Mise en scene Finished the Clock Divider
The backbone of this entire project comes from the correct synchronization of all the parts in this doohickey. Our Finite State Machine uses the internal time, but the seven segment display and timer must use an paraphrastic version of the clock.
This "new clock" comes from dividing the internal clock by a craved period to discove a certain frequency needed for each specific part. This has been cooked in previous labs and from experience, we know the timer has the "one's" digit set to 0.1 Hz, and the "tens" digit organism the 1 Hz
Inputs: ClkIn, factor(32 bit)
Outputs: ClkOut
Step 2: Creating a Exhaustible-State Machine (FSM)
In our Delimited-State Machine, we decided that five states (Pop out, Display, Check, Make and End) would be necessary with five inputs (start, reset, guess, equal, timeout). The only output in our State Machine is a 3 bit keep down that represents what country the user is in (000, 001, 011, 101, 100) with respect to the states down the stairs.
Remember that a Finite State Machine does non in reality preform the functions below, rather it just tells what DoS the program is on and what . What actually happens is determined by the top module explained below.
Start State Department (000)
The Showtime State is where the user will begin until the starting time input is high, this is too the commonwealth that bequeath be reached whenever the reset button is pressed.
Game Commonwealth (001)
The Stake State is the beginning of the game, where the random number is generated and the user toggles the switches to create an input. Once the guess button is pressed, the unfit is moved into the Check State.
Check State (011)
This state is where the comparator is organism utilized, which will compare the values of the drug user's input and the arbitrarily generated number. If the entry is chasten, the equal valuate is high and the FSM goes to the Score Tell; notwithstandin, if the entry is incorrect, the FSM reverts back to the Display Put forward until the submission is correct.
This Check State happens relatively quickly compared to the others, as it is only happening A long as the checker release is pressed
Score State (101)
Since the equal value is gamy, the submission was correct. In this state, the score value will increase by combined and a recently number wish be generated for the user to input. This new number brings us back to the Startle State where the user will once again toggle the switches.
End State (100)
Once the timekeeper of 60 seconds is up, the timeout input will be high and the user reaches the End State where the final mark is displayed. The reset stimulant volition then be ironed and the FSM starts over at the Start State once again.
Inputs: Clk, rst, start, overestimate, coordinate, timeout
Output: state (3 bit)
Step 3: Map the Vii Segment Display
The Seven Segment Display is a key part of the entire picture as the first two digits on the screen are ill-used as the output of the random number author, patc the last two digits are the timekeeper. Although we give enforced an example of this in the last lab in terms of having digits on the screen, it was displayed in hexadecimal. To fix this emerge, we used a convertor and clock divider that is further explained below.
The display shows all 0's until the FSM enters the game state; however, at long last state, the display should honourable show the user's score.
Since we are using all four digits of the seven section show, we take to cycle through each anode quick enough at 300 Hertz in order to be perceived as e'er aflare.
Inputs: Clk, sevensegment
Outputs: cathodes(7 bit), anodes(4 bit)
Stair 4: Creating the Comparator
This submodule is used in the Check State in terms of how IT is comparing the 7 bite binary inputted conjecture versus the actual decimal value.
We had an if statement that evaluated both inputs and two outputs depending on whether or not the commensurate value was high or low. As remarkable as this module is, it is by far one of the simpler programs to design in that project.
Inputs: switches(8 bit), enumerate(8 bit)
Output: EQ
Ill-trea 5: Setting Up a Timer
Our timer is essentially two different counters that are accelerando at different rates. One counter in the "same's" measure, (the get-go seven segment display) and unrivaled counter for the "ten's" value (second dactyl along septet segment show). Each digit is based off the rising edge of the clock, and once the foresee reaches 60 seconds, time_out will be high and the game will end and return to the bug out state.
Inputs: Clk, state(3 bit), start
Outputs: Current(8 morsel), timeout
Step 6: Designing the Pseudo Random Number Source
Another alternative method for a identification number generator specifically for this case is to have a repeating counter from 0-99 (in binary) that outputs the counted number when the input is high, as this would claim away the need for using an LFSR.
The number changes all rising edge of the internal clock (10 nano-seconds) and cycles through totally 100 numbers in one microsecond. Whenever the user wants a newborn number from the bi generator, it outputs the number it was on,
Although this process is non entirely random, the probability of finding related outputs from this operation is low enough to be pseudo-random.
Inputs: Clk, changenum, equal
Outputs: number(8 bit)
Step 7: Creating a Converter
A necessary component is the Converter, which we used to display decimal fraction Numbers on the seven segment display instead of the original hexadecimal. Although both numbers are based off of a 7 bit Binary number, we created an whole module designated to converting hexadecimal to quantitative.
For example, if our final output for the score was 0010001 (seventeen), the seven section display would show the hex value of 11, instead of the decimal number of 17.
Input: Numin(8 bit)
Yield: Numout(8 bit)
Step 8: Putting Everything Jointly in the Secret plan Mental faculty
For our components, we used the inevitable switches 0-6 for the drug user to toggle, with the three buttons to act as the user inputs for start, reset, and guess. The seven segment display and time components are also components we have done from previous labs but had to alter in order to tally this externalize.
We split this project into the six modules shown above to die the entire gizmo into many workings parts, however, the way they are attached is quite an intricate and is shown from the black box picture attached.
While the game is happening, 7 LED's are lit to notify the user which switches to use, and when the game ends, we also programmed LED's to flash
Inputs: switches(8 bit), Clk, reset, start, estimate
Outputs: cathodes(7 bit), anodes(4 second), LEDs(7 bit)
Footmark 9: Excess Problems Encountered
Although only cardinal switches are ill-used in this game, the encipher has it set as an 8 bit number. We did this in order to have a more convenient comparator that would compare these 8 bits to the 8 act number we generated from the unselected enumerate source.
The score also gave us a bit of trouble at the start because we plant it to increase one indicate when the the FSM was in the score state; however what happened instead was that the score kept increasing as long as the state was on, giving us a unreasonably steep musical score we could non contend with. We fixed this by adding a beat signal that was synchronized with the rising edge of the clock, Eastern Samoa seen in the code in step 8.
Finally, the timer took a good deal of time to debug as it would distort our heptad section display when it was enumeration dispirited, so we had to change it from counting down feather from 60 to counting up from 0.
Step 10: Reservoir Files and Constraints
If you would instead pull along from our source files instead of creating your own, here they are. Likewise, the restraint data file is enclosed.
Personify the First to Share
Recommendations
-
Anything Goes Contest 2022
Source: https://www.instructables.com/The-Binary-to-Decimal-Matcher-Game/
Posted by: greenvory1971.blogspot.com
0 Response to "The Binary to Decimal Matcher Game : 10 Steps - greenvory1971"
Post a Comment