Send a letter as pulses of light
Online version: https://fpga.labsland.com/altera/digital-logic/lab-05/part-04/
Use one red LED to send one of eight letters. A dot lasts half a second, a dash lasts one and a half seconds, and successive symbols are separated by half a second of darkness. A has a short pulse then a long one. How could a classmate tell B and D apart?
| SW2…0 | Letter | Symbols | SW2…0 | Letter | Symbols |
|---|---|---|---|---|---|
| 000 | A | · — | 100 | E | · |
| 001 | B | — · · · | 101 | F | · · — · |
| 010 | C | — · — · | 110 | G | — — · |
| 011 | D | — · · | 111 | H | · · · · |
Locate where KEY1 captures both the pattern and the letter length. The starter gives a dash only two timing units. Find the two places a new pulse can start. Which one determines the first mark of B? Which one determines the second mark of A? Predict the total elapsed time from the first light to the end of the last light for A and B.
Lab setup
LabsLand Online Editor · DE1-SoC
Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser
Run the simulation on your computer with Icarus Verilog (Verilog or SystemVerilog) or NVC (VHDL). Then build your design and test it on the remote DE1-SoC.
Build
When the corrected design reports PASS A-H, use the same source file for the board. Keep the half-second unit at 25,000,000 clock cycles.
- From the extracted worksheet folder, open
starter/morse_sender.qpfin the selected release of Quartus Prime Lite with Cyclone V support. The project-only download has the QPF at its root. - Edit the HDL file for
morse_sender. If the exercise generates a new HDL file, copy its contents into that same project file. - Choose Processing → Start Compilation. Check the Fitter report for device 5CSEMA5F31C6.
- In the LabsLand bitstream upload lab, choose Standard and upload
output_files/morse_sender.sof. Wait for programming confirmation before using the controls. - If your course uses a LabsLand classroom, the upload opens a firmware library instead: check that your SOF is selected and choose Enter board with selected firmware.
- Get the starterDownload
morse_sender.v - Open the LabsLand Online EditorOpen the lab Choose DE1-SoC · Verilog when you open the lab. LabsLand asks you to sign in. Use the access your course or institution provides.
- Follow the worksheetPredict first, then build, read the board and hand in. The build steps are below.
- Install Quartus Prime Lite with Cyclone V supportSkip this if it is already installed.
- Download the activityDownload worksheet and Quartus project Includes the worksheet, the Quartus project and the simulation files.
- Complete the design and compileStart with Simulate the signal in the worksheet below, then complete the design as its build steps describe. Open
morse_sender.qpfand choose Processing → Start Compilation. Quartus writesoutput_files/morse_sender.sof. - Upload the bitstream to LabsLandUpload bitstream LabsLand asks you to sign in. Use the access your course or institution provides.
Already compiled? Upload your .sof directly
Starter files · Verilog · VHDL · SystemVerilog
Worksheet and starter (.zip) for offline work or printing
Simulate the signal
The testbench holds KEY1 down while sending E. Predict how many dots you should see before the key is released.
Extract the worksheet ZIP and run these commands from the folder containing activity.md.
The bench uses five clock edges per half-second unit and checks the light at every edge for all eight letters. It also changes the selector during a letter and asserts reset between clock edges. Run it on the starter, record the first pulse that is too short, and repeat after your correction.
Verilog
iverilog -g2005 -s test_morse -o bench starter/morse_sender.v simulation/test_morse.v
vvp bench
SystemVerilog
iverilog -g2012 -s test_morse -o bench starter/morse_sender.sv simulation/test_morse.v
vvp bench
VHDL
nvc --std=2008 -a starter/morse_sender.vhd simulation/test_morse.vhd
nvc --std=2008 -e test_morse
nvc --std=2008 -r test_morse
Build
When the corrected design reports PASS A-H, use the same source file for the board. Keep the half-second unit at 25,000,000 clock cycles.
- In the LabsLand Online Editor, choose DE1-SoC for your HDL and the Standard interface.
- Create
morse_sender, paste the design and set it as the top level. - Choose Synthesize → Upload to FPGA. After editing the design, synthesize and upload it again to test the change on the board.
Read a letter from the board
Press and release KEY0 once. Select a letter with SW2…0 and press and release KEY1. Watch LEDR0, the rightmost red light. Wait until the letter is complete before starting again. Have a partner choose a letter out of sight and see whether you can read it from the pulses.
| Letter selected | Predicted symbols | Observed short and long pulses | Time from first light to last light going out |
|---|---|---|---|
| A | |||
| B | |||
| D | |||
| One letter chosen by a partner |
During a second B, change the selector to C (010) but leave KEY1 alone. Which letter finishes? Start another B and press KEY0 in its first dash. Check that the light stays off until you start a new letter. Use the simulation to measure exact pulse widths. Camera frames and hand timing give approximate durations.
Source
Original LabsLand activity following FPGAcademy Digital Logic Lab 5, Part IV. Verilog handout · VHDL handout · MIT
