Lab 5

Send a letter as pulses of light

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

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.

  1. Get the starterDownload morse_sender.v
  2. Open the LabsLand Online EditorOpen the lab LabsLand asks you to sign in. Use the access your course or institution provides.
  3. Follow the worksheetPredict first, then build, read the board and hand in. The build steps are below.

Starter files · Verilog · VHDL · SystemVerilog

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.

test_morse.v

test_morse.vhd

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.

  1. In the LabsLand Online Editor, choose DE1-SoC for your HDL and the Standard interface.
  2. Create morse_sender, paste the design and set it as the top level.
  3. 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