程序代写代做代考 CSC258H Lab 6: The GoldenEye Pen

CSC258H Lab 6: The GoldenEye Pen

1 Introduction

In this lab, we will implement a James Bond gadget – the Pen Grenade – from the 1995 movie
“GoldenEye”. At the following link is the clip that we showed in the lecture about the usage of it.

At the link below is the device’s official documentation at MI6 HQ.

https://www.mi6-hq.com/sections/q-branch/pengrenade.php3?t=mi6&s=ge

We will design and implement the circuit in this pen that does “3 clicks to arm, 3 clicks to disarm”,
using the finite state machine design techniques that we learned from the lectures.

This lab involves longer prelab design tasks than the previous labs, so please make sure you
spend some time over the reading week to finish all the prelab work before the lab, and prepare
the prelab report.

PRELAB REPORT: This lab requires the submission of a prelab report to MarkUs by
Wednesday March 1st, 12:00 PM (noon). The required filename is “prelab6.pdf”.

2 Prelab: Circuit Design

The main part of the circuit has one input (a push button) and one output (an LED that indicates
whether the pen is armed). The push button connects to the clock inputs of all flip-flops used in
the circuit. To complete the circuit design, you need to finish the following steps:

1. Determine what the different states are of the circuit.

2. Determine the transitions between the states, i.e., draw the state transition diagram.

3. Determine the number of flip-flops that are needed to store these states.

4. Assign flip-flop values to each of the states, so that none of the transitions would cause
unexpected behaviour.

5. Write down the state table according to the state transition diagram and the flip-flop value
assignment.

6. Derive the combinational logic based on the state table.

7. Connect the flip-flops in the circuit diagram according to the derived combinational logic.

8. Determine the output value assigned to each state, i.e., which states should be considered
“armed” and which states should be considered “disarmed”.

9. Derive the logic expression of the output in terms of flip-flop values.

10. Add the combinational logic for the output to the circuit diagram.

1

Additional reset input: To make the circuit easier to test, you should also add a “reset” input
that sets the FSM to the initial state anytime you want. You have two options for implementing
the reset input.

1. If you are using the D flip-flops that you implemented in previous labs, the reset function can
be implemented by adding some AND logic at the input of each flip-flop. You can reset the
circuit by first switching the reset input to 0 and then provide a positive edge of clock.

2. You can also use the D flip-flop symbol that is provided by Quartus (“dff” under “storage”),
which has a “CLRN” input. The value of the D flip-flop is immediately set to 0 whenever
CLRN is 0 – this is called an “asynchronous active-low clear”. It is asynchronous because
it does not depend on the clock signal, and it is active-low because the clear happens when
CLRN is low.

Complete and submit the PRELAB REPORT which includes the following content:

1. Your name and student number.

2. Your state transition diagram with flip-flop values assigned.

3. Your state table and the K-maps for the combinational logic to be generated.

4. The expressions of the combination logic.

5. The logic expression of the output LED (armed or disarmed).

6. The circuit diagram.

The prelab report must be completed individually.

3 In-Lab: Implement and Test Your Circuit

In the lab, implement your design using Quartus and create a test vector to verify that your circuit
works as expected. Show your TA the simulation result.

After your circuit is simulated, load it to the DE-2 board to verify it on the hardware. Connect
the clock input to the push button KEY[0] and connect the output armed-or-disarm indicator to
LEDR[0]. Connect the reset input to SW[0] and connect the outputs of the flip-flops to some LEDs
of your choice. Show it to your TA once you are convinced that your circuit is working exactly
like the pen in the movie.

Feeling its missing the timer and the bomb? You’ll get a chance to add them to your GoldenEye
pen next week.

4 Summary of TODOs

Below is a short summary of the steps to be completed for this lab:

1. Before the lab, design the circuit, complete and submit the prelab report, individually.

2. In the lab, implement your circuit using Quartus, simulate it and show the TA your simulation
results.

2

3. Get your circuit working on the DE-2 board and show your TA.

Evaluation (3 marks in total): 1 mark for the prelab report, 1 mark for the simulation
result, 1 mark for getting it working on DE-2.

3