Académique Documents
Professionnel Documents
Culture Documents
G31_mastermind_controller:
The g_31_mastermind_controller circuit has two main modes. We have the
User guessing mode and the system-guessing mode. To accomplish the back
and forth switching between the two modes, we implemented one of the
dipswitches on the Altera board. The mode dipswitch output controls the
input, steering the controller (FSM) to the different sequences in the different
modes on the state diagram. In order to be able to play the mastermind
game in the user guessing mode, we created a new random pattern
generator that will be generating a random pattern on a button press (on the
Altera board). Now, the user will input a guessed pattern using the switches
on the Altera board and that guessed pattern will be displayed on the board.
Once the user guessed pattern is displayed on the board, the computer
(system created) will output the score of the guess. The score, as discussed
in previous laboratories, will be displayed on two 7-segment LEDs of the
Altera board. We can repeat this as many times as we want until we match
the hidden random pattern. Since we already know what the hidden pattern
is, we can input as the guessed pattern the actual pattern.
Figure 2, is the circuit implemented to allow the game to display all the
numbers needed to play the game. The score, the hidden pattern and the
guessed pattern will be displayed depending on the mode that we are
playing.
inst5
l4[3..0] INPUT
VCC
l3[3..0] INPUT
VCC
l2[3..0] INPUT
VCC
g31_7_segment_decoder
l3[3..0]
code[3..0] RippleBlank_Out INPUT
l1[3..0]
VCC
R ippleBlank_In segments[6..0]
inst7
OUTPUT Out1[6..0]
g31_7_segment_decoder
l1[3..0]
code[3..0] RippleBlank_Out
RippleBlank_In segments[6..0]
inst8
Figure 8: g31_Ledboard
Figure 3, Mastermind controller, takes the inputs and controls the states. This
controller was created in laboratory 4. We added muxes in order to increase
the controllability of the game and we encapsulated everything in a block
diagram called g31_mastermind_controller.
totalRST SR_SEL
SC_CMP P_SEL
TC_LAST GR_SEL
START GR_LD
READY SR_LD
CLK TM_IN
MODE TM_EN
guessPush TC_EN
inputPush TC_RST
RPGorInput SOLVED
Lef tOrRight Genable
userGuess[2..0] Ienable
publishScoreEnableIn LORout
scoreOrGuessIn scoreOrGuess
TM_OUT userScoreOut[5..0]
userScore[5..0] outputSelect[1..0]
userGuessOut[2..0]
ROIout
loadit
MODEout
publishScoreEnableOut
inst7
The random paten generator will generate, as the name states, a random
pattern. We used the possibility table and a latch to create the generator. We
grounded the TM_IN and TM_EN since we did not need them for the random
pattern generation. Each time we press the button KEY0 on the Altera board
(if we are in the user guessing mode).
q[11..9]
OUTPUT LED4[2..0]
q[8..6]
OUTPUT LED3[2..0]
q[5..3]
OUTPUT LED2[2..0]
q[2..0]
OUTPUT LED1[2..0]
g31_possibility _table
GND
enable INPUT
VCC
The g31_usergus circuit will get the input from the users and input it into next
block which will be the g31_mastermind_score circuit (Figure6). The input
inputcode[2..0] will take the numbers that the user will be entering as the
guessed pattern( user guessing mode). Since we are displaying the 4 digits in
only 2 LEDs, we will need the KEY3 that will switch and display the first two
g31_usergus
inputCode[2..0] LED4[2..0]
outputSelect[1..0] LED3[2..0]
enableLine LED2[2..0]
CLK LED1[2..0]
inst54
Figure 5: userguess
g31_mastermind_score
P1[2..0] exact_match_score[2..0]
P2[2..0] color_match_score[2..0]
P3[2..0] score_code[3..0]
P4[2..0]
G1[2..0]
G2[2..0]
G3[2..0]
G4[2..0]
inst36
Figure 6: mastermind_score
my Ground,l4[2..0]
l4[2..0] INPUT OUTPUT Out4[3..0]
VCC
my Ground,l3[2..0]
OUTPUT Out3[3..0]
l3[2..0] INPUT
VCC
my Ground,l2[2..0]
OUTPUT Out2[3..0]
l2[2..0] INPUT
VCC
my Ground,l1[2..0]
OUTPUT Out1[3..0]
l1[2..0] INPUT
VCC
my Ground
GND
Figure 7: 1birextention
For the system guessing mode, we played several times to make sure it was
working properly. We tested the system guessing mode and we computed
the average number of guesses it takes to get the right answer. As we can
see on table 1, the number of guesses varies between 3 and 6. The average
number of guesses over 10 trials is 4.8. We computed the average over 30
guesses and we get an average of 4.9 tries. We conclude that our system is
working properly.
Conclusion:
One of the main problems encountered was the fact that we had to scale the
circuits in order to make work in real time, slow down the clock. Fortunately,
thanks to conventional programming we were able to create counters that
will allow the circuit to work on a proper time. Another problem encountered
was the overheating of the board. This issue wasn’t a major one but it is goo
to address it for future reference.