Practical 2 - Sequential A Reaction Tester Game
Logic
THE UNIVERSITY
ofADELAIDE
ELEC ENG 1101 Digital Electronics Last Revision September 5, 2025
2.1 Introduction
In this practical you will build a simple reaction tester game using an FPGA. After the game starts, the onboard LEDs will be turned on sequentially from right (LED0) to left (LED8) . The user needs to press the button before LED8 turns on.
This practical begins with some tasks that are similar to Practical 1 . This will give you more practice with the FPGA and the software tools. Later in the practical you are required to do some new digital design using blocks such as adders, registers and comparators.
Before attempting this practical you should complete Workshop 6. Before coming to the practical, copy your solution from to your practical exercise book.
All students are expected to be able to complete and demonstrate the practical on their own. Students in the labs can work in pairs but must be able to demonstrate that they understand and are able to complete the practical.
2.2 Objectives
This practical contributes to the following course learning objectives.
At the completion of this practical, students should be able to:
1. analyse and synthesise combinational logic circuits;
2. develop Moore finite state machines;
3. select, justify and use appropriate input and output devices and controllers for simple digital systems; and
4. demonstrate practical skills in the programming and testing of digital systems on FPGA and microcontroller development boards.
More specifically, at the completion of this practical and its accompanying workshop, students should be able to:
1. define and identify synchronous sequential and asynchronous sequential circuits;
2. analyse the behaviour of a Moore FSM given its gate-level circuit or Boolean equations; and
3. derive a gate-level schematic circuit for a Moore finite state machine from a written description of its required function.
2.3 System Overview
The top level schematic in the reaction tester is shown in Figure 2.1. The modules are:
• StateMachine: this module will contain a finite state machine to control the game.
• ReactionCounter: this module will count from the time a game starts to the moment the player presses the button.
• Clock: generates a CLK signal.
• sw15 is used to switch between fast and slow clock. The fast clock is 100Hz, and the slow clock is 50Hz. The blinking speed of LED15 indicates the clock speed.
The StateMachine and ReactionCounter are all incomplete. You should finish the StateMachine and the ReactionCounter in the practical session.
Figure 2.1: Top level schematic for local students.
2.4 The State Machine
2.4.1 Background
Recall that in Workshop 6you designed a state machine for the reaction tester game. The details are repeated here for completeness. The game uses a Moore finite state machine with the state transition diagram shown in Figure 2.2. The nodes show the current state and outputs in the form S1 S0 /DFR.
B=0
Figure 2.2: State Transition Diagram for a Reaction Tester Game
1. The outputs are:
• D: indicates the test is done.
• F: indicates the user has failed the test by pressing the button before the game is ready.
• R: indicates the tester is ready for the user to press the button.
D , F and R are connected to LED14, LED13 and LED12 on the Basys3 development board respectively.
2. The inputs are:
• B: is high when the user holds the button down. This is connected to the right button, BTNR, on the Basys3 development board.
• G: stands for the command of go. This is connected to the left button, BTNL, on the Basys3 development board.
Note that a third input N is indicated. This is used to start a new game. To keep the design simple, we will just connect this to the reset inputs on the state register so that when it goes high it will reset the machine to the waiting state. N is connected to the up button, BTNU, on the Basys3 development board.
From the workshop, you should now have equations for the next state logic to generate S0, and S1, .
2.4.2 Completing the State Machine
Your rst task in the practical is to complete the StateMachine module.
1. Build your state logic design and test it. Download SequentialLogicTest .zip from the course MyUni
page and extract it into a folder in your U:drive. Launch NI Multisim and open the SequentialLogicTest .ms14.
2. In NI Multisim, open the StateMachine module by double click it on Design Toolbox. In this module, inputs and outputs have been de ned. The module has two D- ip-fops and a 2:4 decoder (Figure 2.3) . These are D- ip- ops with synchronous reset inputs. You will use them to store the state variables. Because we can't use subscripts in NI Multisim, call the current state variables S0 and S1. Similarly, because we can't use the symbols S0, and S1, , call the next state inputs S0next and S1next.
3. Complete the next state logic using logic gates. Also remember to connect the reset inputs on the ip- ops so that the state machine functions as indicated in Figure 2.2. (Note: the reset input, CLR, is an inverted reset input.)
Table 2.1: Output table for the state machine (left) and truth table for a 2:4 decoder (right) .
B A
|
Y3
|
Y2
|
Y1
|
Y0
|
Y3
|
Y2
|
Y1
|
Y0
|
0 0
|
0
|
0
|
0
|
1
|
1
|
1
|
1
|
0
|
0 1
|
0
|
0
|
1
|
0
|
1
|
1
|
0
|
1
|
1 0
|
0
|
1
|
0
|
0
|
1
|
0
|
1
|
1
|
1 1
|
1
|
0
|
0
|
0
|
0
|
1
|
1
|
1
|
Figure 2.3: The FF D PCLR CO (D ip- op with reset) and DEC2 4 (2:4 decoder with enable) symbols in NI Multisim.
4. An output table for the state machine is shown in Table 2.1. Note that the state encoding and outputs have been chosen carefully so that they follow a particular pattern. In fact, this is such a common pattern that it corresponds to a standard logic block, a 2:4 decoder as shown in Table 2.1. So in this case we can use a 2:4 decoder for the output logic. As shown in Figure 2.3, the component outputted inverted outputs. Therefore, we have inverted these outputs from this decoder and connected them to the outputs of the module.
5. Once you have completed the next state and output logic in the StateMachine machine you should be able to synthesise your design. Upload it to the FPGA, and test it.
Press BTNU to reset to a new game. When you press BTNL the `go light', LED12, should turn on. If you press BTNR the `done light', LED14, should turn on. If you press BTNR before BTNL the `fail light', LED13, should turn on. Once this is working, your next task is to start counting the reaction time.
2.5 The Reaction Counter
The ReactionCounter module shown in Figure 2.1 produces 10 output bits which connect to indicate on LED0:9. These outputs should all reset to 0 when a new game starts (i.e. when the N input goes high) . The function of this module is to count up by 1 every clock cycle while the game is in the ready state, so the R input is used as enable to the counting function. The corresponding LED will be turned on while the number counts to it (i.e. if the number counts to 5, the LED5 should be on) . It should count up to and stop at 8, so the LED9 should never be turned on. In this practical, the clock has been slowed down to 50Hz. Therefore, it will take less than one second to count up to 8 .
Your task is to design the digital logic for this module. You may use any of the components described below, which are already added for you in the ReactionTester module as shown in Figure 2.4. Before you start, you will need to delete all connections to the DIGITAL LOW source, which provides a constant source of the LOW signal.
You may need the following components. Note that you may not need to use them all and you can duplicate the same component.
• Register4: this is a 4-bit D register with synchronous reset input. (Hint: you will need one of these to store the counting number.)
Figure 2.4: The Reaction Counter.
• Adder4: is a 4-bit binary adder with carry-in, C0 , and carry-out, C4 , pins.
• Comparator4: is a module that compares two 4-bit unsigned binary inputs A3:0 and B3:0 . It sets OAgtB high if A3:0 > B3:0 ; OAltB high if A3:0 < B3:0 ; and OAeqB high if A3:0 = B3:0 , when AGTB, ALTB are set low and AEQB is set high.
• Multiplexer4: a 4-bit 4:1 multiplexer with an enable input, and it selects one of four inputs, I3:0 , by S1:0 .
• HIGH/LOW signals: are standard NI Multisim symbols that outputs constant HIGH or LOW bits. (Hint: you will need to them for any binary constant.)
If you are using the Comparator4 module to compare A3:0 = B3:0 , please remember to connect AEQB is set high. Once you have entered your logic into NI Multisim, synthesise it, upload it to the FPGA, and test it.
When the game is at the ready state, the LED0 to LED8 will be sequently turned on until you change the state to the done state by pressing BTNR. Try to catch it before LED8. Only move on once everything is working as it should, and ask the demonstrator to mark the functionality of your design.
2.6 Exercise Questions
Write answers to the following questions in your exercise book.
1. What synchronous circuit elements have we used in this practical? What is their desired function?
2. In this practical we used a 2:4 decoder. Describe in words the function of a 4:10 decoder.
3. In this practical we have used the full adder. Draw a diagram of a full adder and describe in words the function of a 4-bit full adder.
4. Based on the system top level schematic, describe in words the function of each module.
5. Can you reuse modules from Practical 1 and add them into this system to improve its function? Draw a system schematic to show how you will connect them together, and describe in words the system behaviour.
2.6.1 Re ection
Use 100 to 200 words to describe what have you learned from this Practical and how they could link to contents from the lectures.
2.7 Final Assessment
Once your reaction tester is working, you are ready to be marked. The marker will also ask you some questions to check your understanding of this practical and to demonstrate you have completed the practical on your own. Your answers to the exercise questions in Section 2.6 will be marked at the beginning of the next session.
Submit your final schematic files (SequentialLogicTest .ms14 on MyUni before the end of your practical session to obtain the mark awarded. If you are working in a pair in the labs, both students must submit the schematic.
Prepare StateMachine .ms14 before session
|
1
|
|
Completed 2.4.2 Completing the State Machine
|
1
|
|
Completed 2.5 The Reaction Counter
|
1
|
|
Serious attempt 2.6 Exercise Questions
|
1
|
|
Mostly correct 2.6 Exercise Questions
|
1
|
|
Valid attempt 2.6.1 Reflection
|
1
|
|