in this lab, we implemented an analog to digital converter circuit. the first part of our circuit took the output of a photocell and amplified it to a working range of 0 to 5 volts. this signal was then sent through a low pass filter to remove excess noise. we then converted the filtered analog signal it to a digital signal, which was relayed through parallel communication to 7-segment display.
for our final lab, we chose to expand upon the reaction timer we created while completing the sequential circuit lab. the idea of our project was to create a game in which two players compete to see who can react quicker, without having to manually keep track of individual reaction times. we decided that an appropriate setup would be to have an altera board for each of the players, and a third altera board to act as a referee and govern the players. the referee board takes as inputs the actions of the two player boards, and determines who the winner is in each round of the game.
part 1 . interaction overview
the first part of this lab consisted of conceptualizing an efficient way of completing our task. we decided to use parallel communication between the boards to send data between them; using serial communication would cause our vhdl code to be much more complicated than necessary. after consideration, we decided that all necessary communications could be accomplished with five lines running from each player board to the referee board. the first two of these, called commOUT, are set by the player boards and read by the referee board. there is one line per player board, so this constitutes a two bit vector coming into the referee board; these lines are responsible for relaying data from the player boards to the referee board. another commOUT line runs in the other direction. this commOUT line is read into the plyer boards as commSIGNAL, and us used to tell each of the player boards what to do. the remaining two lines are a vector called winner that comes out of the referee board and into the player boards.
in creating the communication architecture, we had a clever idea which enabled us to use identical code for each of the player boards. the lines that relay the winner (the winner vector) are set in a '10' state if the first player wins, and are set in a '01' state if the second player wins. switching the input of the winner lines going into one of the player boards enabled our code to interpret an incoming signal of '10' as a win on either board.
another fairly intelligent idea was used when checking for a ready state from both boards. as stated earlier, the commOUT lines that run from the players to the referee are sent as one bit per player and read as a two bit vector on the referee board. to check whether both boards are ready, the referee simply must look for a '11' signal coming in; signals of '10' or '01' could be used to check for the readiness of a specific board.
figure 1. a diagram of the proposed interaction of boards.
part 2 . the referee board
the operation of the referee was whittled down to consist of five states. the first, called idle, used the clock to wait a second before entering any of the game states. this was deemed necessary so that players could have a second of recovery time between each round of the game. once a counter had reached this one second mark, the referee moved into the punish state. in this state, the counter variable was increased until it matched a random number that had been previously stored in the program. (the random number was created by implementing a five bit linear feedback shift register.) during this state, player would have to wait anxiously to see the signal they need to react to. this is the reason for the name of this state; the referee punishes any player for reacting before the signal was given. by pressing their button during this state, a player automatically loses the round.
if both players survive the punish state, then the referee board moves into the gameon state. as soon as this state is entered, the referee lights up an led and waits for a reaction signal from either of the play boards. the fist player to press their button is deemed the winner.
the next two states are used for processing the results of the game. in getready, the referee board sends a signal to each of the boards, and in send looks for an echo, and then sets all variables for the next round of the game.
the code for the referee board can be found in thegame.vhd.
part 3 . the player boards
implementing the desired functionality on the player boards required only three states. the first of these, waiting, is the default state of the boards. while in this state, each of the player boards is waiting for the pushbutton reasction of the player. when the board recieves this signal it is forwarded across to the referee board, and then the player board moves into the getdata state.
in getdata, a response from the referee as to the outcome of the game is recieved. if a player has won, their altera board moves into the incerement state; otherwise their board goes back to the ready state. in increment, the score displayed on a player's board is increased by one to signal another victory.
the code for each of the referee boards can be found in player.vhd.
part 4 . board connection and troubleshooting
unfortunately, our project hit a snag very early on; the wire insert for one of the pushbutton broke.
figure 2. broken.
besides this setback, our operation also hit another major problem. nothing worked. after panicking for some time, and with two hours to go in the night, we almost gave up hope. in a last ditch effort, we thought up and completed another entire final project while still trying to salvage this one. this is yet to be written up, but will be; some pictures of it are avalible here. ironically, just as we were getting to the finishing touches of this project, we realized that the b pin out section was actually not the c pin out section. he cleverly switched the pin assignments, and the game worked perfectly. figure 3 shows the completed - and correctly connected - project.
figure 3. the connected altera boards.
part 5 . adem versus karl
the the only thing left to do at this point was to play. in an unpredicted turn of events, karl found himself faced up with a daunting task: dethrone adem and take his place as the reigning reaction master.
figure 4. karl.
figure 5. adem.
mas was unable to participate in any form of competition, so he defaulted to the referee position.
figure 6. mas, as the referee.
in the end it was adem on top; his lead of 12 to 0A was enough to cause him to forget himself and let go of his pushbutton contact (he got to hold the wire to his broken pushbutton as he played). this caused an early end to the game. mas had nothing to say, so the victory stood.
figure 7. the final score.
by completing this lab, we had the opportunity to tie together several digital system concepts that we have been learning throughout the semester. we used parallel communication, state design, a linear feedback shift register, a counter, and several other smaller components of vhdl design. the most enjoyable and therefore most rewarding part of this lab was coming up with the communication schematic. overall, however the last throes of this lab were spent in a dire state; the panic involved with our attempt to create an entire lab in the last two hours of the night was honestly not fun. in the end, we were able to finish our lab, and did get around to the whole point of it: play our silly little reaction game in the hicks lab, at ridiculous hours of the night.