Build a class pack
Choose the parts and tools for your class. Print the worksheets together or share one link with your students.
Choose activities
Lab 1 · Linux bring-up
Lab 2 · Linux and FPGA I/O
Lab 3 · Character drivers
Lab 5 · Text graphics
Lab 8 · Audio and threads
Lab 9 · ADC and sampling
Lab 10 · Image processing
Share or print
Embedded Systems · Class activities
Your assigned activities
Your instructor chose these activities and how to build each one. Open an activity to start, or download its worksheet and files.
A single red light should travel to LEDR9, turn, and come back. In the starter it jumps across the board. Repair one C function, test its register writes on Linux, then run that same function on a processor inside a remote FPGA.
You can try the starter immediately with the included FPGA design and access to the LabsLand DE1-SoC Verilog Online Editor. To change it, you’ll also need a C compiler, Python 3 and a RISC-V bare-metal GCC toolchain. The physical exercise uses the board’s standard LED bank and camera. xPack RISC-V GCC · LabsLand DE1-SoC laboratory
Predict the turn
Number the lights from LEDR0 on the right to LEDR9 on the left. Write the expected ten-bit word in hexadecimal for ticks 0, 1, 8, 9, 10, 17 and 18. How many ticks separate two visits to LEDR0? Choose one LED in the middle and identify the two ticks on which you would see it.
If you have the C compiler ready, test your prediction in the terminal. You can also take your prediction straight to the board and run this trace afterwards.
cc -std=c11 -O2 -Wall -Wextra starter/sweep.c -o sweep
./sweep --trace
The left column is the tick and the right column is the register word. Compare tick 10 with your prediction. Keep the starter long enough to see the fault on the real board.
Run the starter in the FPGA
For a first board run, open the included starter FPGA design. You can paste it into the editor straight away. To generate it yourself from the supplied C, run this command.
On Windows with the Python launcher, use py -3 wherever a command starts with python3.
python3 resources/build_cpu.py starter/sweep.c sweep_cpu.v
The builder uses riscv-none-elf-gcc and riscv-none-elf-objcopy from your PATH. With another compatible command prefix, add it to the command, for example --prefix riscv64-unknown-elf-. The toolchain must support RV32I with the ILP32 ABI. Your C program is compiled to machine instructions and loaded into the FPGA design.
In the DE1-SoC Verilog Online Editor, select the Standard interface. Choose New, name the file sweep_cpu, paste the generated file, select it as the top level, and choose Synthesize → Upload to FPGA. Wait for the board camera to update. With SW9 and SW8 down, watch the light for two complete sweeps. Does it reverse at the far end?
Raise SW8 to examine one tick at a time. SW4 through SW0 select the tick in binary; SW0 has weight 1. Keep SW9 down. Try 01000, 01001 and 01010 in order. Record the lit LED at ticks 8, 9 and 10. Raising SW9 clears the LED register and resets the timer. Confirm the whole row goes dark.
Repair and repeat
Edit only led_word in starter/sweep.c. Choose a repeating sequence that visits each end once per turn. Recompile both versions using the commands above. Run the new trace, paste the regenerated Verilog into the editor and upload it again.
With SW8 up, test ticks 9, 10, 17 and 18. Lower SW8 to observe motion. Raise SW9 to stop and clear, then lower SW9 and watch where the light starts. Submit the register words for the two turns, a before-and-after observation at tick 10, the result of the clear test, and the identifier shown for your remote board.

This UW board is holding tick 10 after the repair. LEDR8, one place in from the left end, is lit.
Explain the two builds
The Linux executable prints the words from your C function. In the FPGA, a FemtoRV32 processor runs the compiled function, reads the switches and writes the physical LED register. The automatic tick advances every quarter second. A separate --board entry in the Linux source targets the DE1-SoC Computer HPS image. It needs that exact hardware system and an assigned ARM Linux console. Use --trace on your own Linux computer.
FPGAcademy exercise · Exercise notice · LabsLand source license · FemtoRV32 license
Show Intel SoC FPGA across six seven-segment displays. Each update moves the message one position to the left. A brief button press must freeze the current window even if the program next checks the buttons after you have let go. Press again to resume from that position.
Try the faulty design on the remote board first. Open the included starter FPGA design, then go to the DE1-SoC Verilog Online Editor. Choose the Standard interface. Create a file named scroll_cpu, paste the design, set it as the top level and choose Synthesize → Upload to FPGA. This first run needs no local installation.
Sketch two windows
Write the message with a trailing space. Label six neighboring positions HEX5 through HEX0, from left to right. At offset zero they contain “Intel ”. Write the next window and the window that begins at the final space. Sketch the seven bars you would use for a lowercase n. Someone viewing the board should see the shape move between displays.
Implement and trace
Open starter/scroll.c. The segment table, register mapping and signal cleanup are supplied. Complete three tasks. Advance the window by one only while running, wrapping at the length of the message. Pack the two leftmost display bytes in their proper order into the high register. Toggle the pause state when a captured key edge is acknowledged. Any group of pending key flags seen in one sample counts as one action.
Compile and inspect the six updates below from an ordinary terminal first. The trace argument supplies one edge flag per update.
cc -std=c99 -O2 -Wall -o scroll starter/scroll.c
./scroll --trace 001001
| Step | Edge | Offset | HEX5–0 | State |
|---|---|---|---|---|
| 0 | 0 | |||
| 1 | 0 | |||
| 2 | 1 | |||
| 3 | 0 | |||
| 4 | 0 | |||
| 5 | 1 |
Read the physical display
Raise SW8 to step the display by hand. Raise SW9 until all six digits are dark. With SW0 down, lower SW9. Record the six positions, including any blank digit. Raise SW0 and lower it once for each step. After two steps, tap and release KEY0, then step again. Record whether the word moved and whether LEDR0 signaled a pause.
After repairing the C program, use Python 3 and a RISC-V bare-metal GCC toolchain to regenerate the FPGA design. The course build used xPack RISC-V GCC with RV32I and ILP32 support.
python3 resources/build_cpu.py starter/scroll.c scroll_cpu.v
If your compiler prefix differs from riscv-none-elf-, pass it with --prefix. Paste the new scroll_cpu.v into the same file in the editor and synthesize again. Clear with SW9 and release it in manual mode. Follow one character across HEX4 and HEX3. Tap and release KEY0. Step twice and compare the camera images. Tap again, then step once. What did LEDR0 and the word do in each state?
Lower SW8 to scroll automatically. Watch the final space pass HEX5 and the first letter reappear. Raise SW9 to clear the display. Record the station identifier and the frozen and resumed windows. If the camera still shows the old word after a step, keep the controls steady until a new frame arrives.
The Linux trace and the processor inside the remote FPGA use the same C functions to pack the digits, advance the window and handle a captured button event. The separate Linux --board option is for a DE1-SoC Computer HPS Linux station with the matching FPGA system. On your own Linux computer, select --trace.

On this board, LEDR0 is lit and the first letter stays in place after two manual steps. Identify the blank between the two words.
Hand in
Submit the completed table, your byte-packing expression and three camera readings from the moving, paused and resumed states. Explain how reading the KEY edge-capture register at offset 0x5C differs from reading the current button level at 0x50. Which part of the trace test can diagnose reversed HEX5 and HEX4 before a board session?
Adapted from FPGAcademy Embedded Systems 21.1, Lab 2, Part I. LabsLand wrote the programs, test and worksheet. MIT notice · LabsLand MIT · FemtoRV32 BSD
A character device looks like a file to a program. Here, the kernel supplies the bytes you read. Build a small driver, send it a message from the shell and fix a C client that stops reading too soon.
Build and load
Use a disposable Linux VM where you can load kernel modules. The module creates a message buffer in kernel memory and needs no FPGA wiring. The course test used 32-bit Alpine Linux with the virt kernel, a root shell, and matching headers. In an Alpine VM, install the build tools with apk add build-base linux-virt-dev kmod. Ask the instructor for the matching headers if the running release and installed development package differ. A container sharing your computer's kernel is unsuitable for this exercise.
Extract the download inside the VM. In its root shell, enter the starter folder, which contains the complete driver, a Makefile and the editable client. Check the build tree exists and that the device name is free before loading your module.
cd starter
uname -r
test -d "/lib/modules/$(uname -r)/build" && test ! -e /dev/chardev
make
insmod ./chardev.ko
sleep 1
ls -l /dev/chardev
cat /dev/chardev
printf 'FPGA display' > /dev/chardev
cat /dev/chardev
Which part of the node listing identifies a character device? Record its major and minor numbers. Why can cat stop reading a message whose length it did not know in advance?
The default greeting should appear in full. After the write, cat should show FPGA display. The client works through the same device as cat. Before running it, predict how many successful reads of up to five bytes it will take to fetch all twelve bytes. How many calls to read will the complete loop make, including the final one?
Repair the client
Run ./client. The starter shows only the first five bytes. In read_message, keep reading into the same five-byte buffer until read returns zero. Write exactly the number of bytes each successful read returned. Preserve the error return when read fails. Rebuild and compare the client with cat.
Test a one-character message, a message of exactly five characters and a message that needs three reads. Then use the client's replacement-text argument to write an 80-byte message. A write of 81 bytes should fail and leave the earlier message intact. State which result you observed in each case.
Remove and reload
rmmod chardev
sleep 1
test ! -e /dev/chardev && echo OK
insmod ./chardev.ko
sleep 1
cat /dev/chardev
rmmod chardev
Hand in your client loop, the two node listings and one sentence explaining where the message lived between a write and a read. Explain the effect of unloading and reloading the module.
Adapted from FPGAcademy Embedded Systems 21.1 · Lab 3, Part I. LabsLand wrote the driver, client and worksheet. FPGAcademy notice · MIT
A terminal can act as a character display. You supply a row, a column, a color and a symbol. Use a Linux terminal at least 32 columns by 30 rows and a C compiler. Knowing how to compile a short C program is enough for this activity.
Extract the worksheet pack, enter its starter directory and run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal
Look for a cyan A, a cyan B and seven yellow stars. Press Enter to clear the picture and restore the cursor. The intended coordinates are A at (2,2), B at (28,10) and the stars in column 15 from rows 3 to 9. Coordinates in these instructions are written as (column,row), starting at 1.
| Mark | Intended column, row | Observed column, row |
|---|---|---|
| A | 2, 2 | |
| B | 28, 10 | |
| First star | 15, 3 | |
| Last star | 15, 9 |
Find the call that emits the cursor-position command. Predict what its first number means, change the call, rebuild, and repeat the observation. Explain why checking A alone would let the bug pass. Add a green C at (9,5) and give the escape sequence that positions it. If you interrupt the program before pressing Enter, type reset to restore your terminal.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part I. Original handout · MIT
Build an integer line plotter for a Linux terminal of at least 32 columns by 14 rows. The C program accepts a first and a last cell as column/row pairs. Its drawing loop keeps an error term to decide whether to move horizontally, vertically, or both.
From the extracted starter directory run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal
Press Enter after each drawing. The default picture contains a cyan shallow line and a yellow steep line. Supply coordinates to draw one line. For example, run ./terminal 2 3 7 3. Count the marks before pressing Enter.
| Requested endpoints | Predicted cell count | Last cell shown by starter | After repair |
|---|---|---|---|
| (2,3) to (7,3) | |||
| (7,8) to (7,3) | |||
| (9,9) to (3,1) | |||
| (5,5) to (5,5) |
Both endpoints belong to the segment. Decide which loop exit drops a cell, repair it and retest all four rows. For the steep line, explain which coordinate changes on every iteration. Finish by reversing both endpoints of each test and checking the count. Compare the number of characters with the larger of the horizontal and vertical distances.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part II. Original handout · MIT
How can you tell a real bounce from a line that simply misses the boundary? Write down the last three row numbers you expect before and after the lower turn. The display is 12 rows high. A twelve-character bar moves one row per frame, starting at row 1.
Use a Linux terminal with at least 32 columns and 14 rows. From the extracted starter directory run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal 28 350
The arguments select the number of frames and the delay in milliseconds. Use a second terminal or a screen recording if you want to count at your own pace. The program restores your cursor when it finishes. Running ./terminal animates continuously until Ctrl-C.
| Observation | Your prediction | Starter | Repaired program |
|---|---|---|---|
| Lowest row reached | |||
| Rows around the lower turn | |||
| Frames between visits to row 1 |
Read the test that decides whether to reverse the direction. Repair it so every row from 1 through 12 is visited and the bar never crosses either edge. Compare ./terminal 20 50 with ./terminal 20 200. Predict the elapsed time for each, measure with time, and explain small differences. Check the cursor after interrupting one continuous run.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part III. Original handout · MIT
Four colored characters move diagonally on a 30-column by 12-row display. Each reverses its horizontal or vertical direction at the corresponding wall. Connect A to B, B to C and C to D. Draw the dotted links first so the colored endpoints remain visible.
Use a Linux terminal of at least 32 columns by 14 rows. Compile the extracted starter and run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal 35 180 24
The arguments are frame count, delay in milliseconds and random seed. Start with the same seed twice. Find a frame in which D is far from the other characters. Which of the three expected links is missing? Examine the bounds of the loop that connects adjacent objects. Repair the code without closing the chain from D back to A.
| Test | What to record |
|---|---|
| Seed 24 repeated | Initial positions and the two ends of the missing link |
| Seed 91 | A different arrangement and the same three connections |
| One vertical and one horizontal bounce | Which coordinate changes direction in each case |
| A run stopped with Ctrl-C | Whether the cursor returns and the color resets |
Try ./terminal 0 100 24 for a continuous run with a repeatable seed. Submit sketches or screenshots of two successive frames and explain why the endpoints are drawn after the links. When two objects occupy one cell, use a later frame to identify them separately.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part IV. Original handout · MIT
Embedded Systems · Audio · C on Linux. Make a stereo recording of thirteen notes, from middle C to the next C. You need a C compiler and Python 3. You can measure every note without speakers. This activity writes a WAV file on your computer.
Predict the recording
The audio clock advances by 8,000 stereo frames each second. Each note lasts 300 ms. Predict the number of frames per note, the total duration, and how many periods of a 440 Hz tone fit in one note. The two channels should contain the same signal.
From the extracted worksheet directory run:
cc -std=c11 -O2 -Wall -Wextra -Werror starter/scale.c -lm -o scale
./scale before.wav
python3 resources/inspect_audio.py scale before.wav
Open the file in an audio player or inspect the printed frequencies. The first note should be about 261.63 Hz, the tenth 440 Hz and the last 523.25 Hz. Record those three measured frequencies before changing anything. Does doubling the playback speed also give the requested duration?
Repair the oscillator
Follow one sample from oscillator through phase_at to stereo_frame. What should happen to the phase each time the sample index increases by one? Change the oscillator so that its frequency in radians per sample agrees with the 8 kHz clock. Build again, write after.wav and repeat the same measurements. Keep the 300 ms duration and the header sample rate unchanged.
| Measurement | Prediction | Initial recording | After repair |
|---|---|---|---|
| Total duration | |||
| First C, Hz | |||
| A, Hz | |||
| Last C, Hz |
For a further experiment, change the note length to 150 ms. Predict the new recording length. Listen or examine the duration in the file properties. The supplied meter groups samples into 300 ms windows, so restore the original duration before using it again to grade individual pitches.
On a DE1-SoC Computer, the same sample can be written to each channel's output FIFO when both have room. The board clock consumes each stereo pair. Which component plays that timing role when someone opens your WAV file? Submit the three frequency pairs, your source edit and your explanation.
FPGAcademy audio exercise · Exercise notice · LabsLand source license
Embedded Systems · Audio · C on Linux. Build a one-second stereo chord from a thirteen-switch score. You need a C compiler and Python 3. Work from the extracted worksheet directory. The output is a WAV file you can play or measure locally.
Listen to a three-note request
The leftmost bit selects middle C. Each position to its right rises by one semitone. Bit positions 0, 4 and 7 make a C major triad. Predict which pitches a correct program would produce and which of them you actually expect to see after reading the inner loop.
cc -std=c11 -O2 -Wall -Wextra -Werror starter/chord.c -lm -o chord
./chord 1000100100000 before.wav
python3 resources/inspect_audio.py chord before.wav
The meter prints thirteen amplitudes in low-to-high note order. For this recording, an amplitude above 50 identifies a sounding note. Listen if you have speakers. Can a single low-to-high zero-crossing count tell you which three notes are present?
Repair and stress the mixer
Inspect what happens to total every time the inner loop discovers another selected note. Make the smallest edit that retains all contributors to a frame. Recompile, write after.wav, measure it and fill in the table. Use another filename for each trial.
| Score | Expected note positions | Heard or measured before | Measured after |
|---|---|---|---|
| 1000100100000 | |||
| 0100010010000 | |||
| 0000000000000 | |||
| 1111111111111 |
Explain why the code scales the sum before converting to a signed integer. Bound the largest possible absolute sample when all thirteen notes are active. Then edit the score to play a two-note interval of your choice. Submit the score, measured positions, before/after triad results and your bound. Include the WAV files or the meter's output.
FPGAcademy audio exercise · Exercise notice · LabsLand source license
Embedded Systems · Audio · POSIX threads in C. Build a piano with a keyboard thread and an audio thread. You will record the notes each thread produces together, then diagnose a stuck chord. Use a Linux computer with a C compiler, Linux userspace headers and Python 3. The included score player gives you the same key events on every trial.
Play the score
In this keyboard layout, Q, W, E, R, T, Y, U and I play the eight white keys from middle C to the next C. The five intervening black keys are 2, 3, 5, 6 and 7. A press starts a sound, a held key slowly decays and a release damps the sound much faster. From the extracted worksheet directory run:
cc -std=c11 -O2 -Wall -Wextra -Werror starter/piano.c -pthread -lm -o piano
python3 resources/play_score.py ./piano before.wav triad
python3 resources/measure_release.py before.wav
The score presses Q, E and T to build a C major chord, releases each key and finishes with a repeat event for T. Listen to the ending or inspect the thirteen measured amplitudes. Positions 0, 4 and 7 represent C, E and G. Compare the quiet interval at the start with the interval from 2.55 to 2.85 seconds. When should the sound have died away?
Find the missing transition
In resources/piano_engine.h, follow the key event from the input thread to the next 80-frame audio block. Find where the mutex protects a note's held flag and strike count. At 8 kHz, how long is a block? Why does the audio thread release the mutex before generating samples?
Track the bit for middle C through a press, a duplicate press and a release. Inspect update_held in starter/piano.c. Change it so a release affects only the released note. Rebuild and record after.wav. Include the measured triad and release windows for both programs. A repeat event by itself should never start a fresh note.
| Time in the score | Sound you predict | Before your edit | After your edit |
|---|---|---|---|
| 0.42–0.65 s | |||
| 1.32–1.51 s | |||
| 2.55–2.85 s |
Run again with octave in place of triad. This score releases the lower C before pressing the upper C. During the upper note, which bins would distinguish a stuck key from ordinary decay? Change one note or one release time in your own copy of play_score.py and predict the result before measuring.
The score player sends Linux key-event records through a private pipe. If your instructor has provided a dedicated readable Linux event device, you can pass its path directly, for example ./piano /dev/input/by-id/CLASSROOM-event-kbd live.wav 3 with the actual classroom path. The file records the synthesized notes and can be played afterward. Submit your edit, two recordings or their measurements, and an explanation of how the threads share key state.
FPGAcademy audio exercise · Exercise notice · LabsLand source license
Embedded Systems · Linux, C and threads. In the previous activity, one thread read keys while another produced sound. Add a third thread to draw a trace when the pianist presses or releases a key. The local screen and WAV recording work on a Linux computer with a C compiler, Linux userspace headers and Python 3.
Predict what fits on the screen
A 320-column screen displays 320 consecutive stereo frames sampled at 8,000 frames per second. How many milliseconds fit across the display? How many cycles of middle C (261.63 Hz) and of the C above it (523.25 Hz) should fit in that time? The two reference traces below came from the working program. Both panels cover the same amount of time.
Separate a display error from a tuning error
From the extracted worksheet directory, compile the starter. Open the viewer in a second terminal and follow the local address it prints. The viewer can wait for the first note while you run the score in the first terminal.
cc -std=c11 -O2 -Wall -Wextra -Werror starter/scope.c -pthread -lm -o scope
python3 resources/view_scope.py before.wav
On Windows with the Python launcher, use py -3 wherever a command starts with python3.
python3 resources/play_score.py ./scope before.wav octave
Play the WAV. In the viewer, choose the first change (low C) and then the third change (high C). Count the cycles by counting upward crossings of the center line. You can also open the numbered SVG files inside before.wav.scope/ individually. Each filename gives the starting sample number. The viewer stops following live changes when you select a frame.
To measure the low C directly from the recording with no speakers, run:
python3 -c "import sys; sys.path.insert(0,'resources'); from inspect_audio import samples, positive_crossings; print(positive_crossings(samples('before.wav')[3360:5200]))"
Trace one column back to its PCM sample in sample_for_column in starter/scope.c. Repair the mapping. Recompile, run the octave score with the new filename after.wav, and point the viewer at that file. Keep the 8 kHz audio clock unchanged.
| Trace | Predicted cycles | Starter display | Repaired display |
|---|---|---|---|
| Low C | |||
| High C |
Play three notes together
Run the repaired program with python3 resources/play_score.py ./scope chord.wav triad. Inspect the third captured change, when C, E and G sound together. Compare its shape with a single sine wave. The last capture begins just after the final key is released. Explain why it can still contain a decaying sound. Use fresh output filenames for new takes.
The audio thread hands the display thread a copy of the exact 320 samples being recorded. It then continues generating sound while the display draws. On a two-core system, the program places the audio thread on a separate allowed core from the input and video threads. Very close changes can share a snapshot. Explain why a slow display should be allowed to skip an old snapshot, and what would happen if the audio thread waited for each line to finish drawing.
Submit the completed table, the low-C frequency measured from the WAV, your code edit and one captured chord. Clearly identify the local display or instructor-provided video device you used.
FPGAcademy exercise · Exercise notice · LabsLand source license
Embedded Systems · Linux and C. Record a two-note performance, then listen to its replay. The notes overlap, the first finger lifts while the second note continues, and both hands are off the keys before the recording ends. Can a player reproduce that phrasing with just a list of pitches and start times?
You need a Linux computer with a C compiler, Linux userspace headers and Python 3. In the local exercise, two timed button events stand in for the board pushbuttons. A WAV file contains your performance followed by its replay. The waveform viewer works without speakers.
Predict the timeline
Open resources/duet.txt. The first KEY1 asks the empty recorder to play. KEY0 then starts a take at 0.30 s and stops it at 1.65 s. The second KEY1 starts replay at 2.00 s. Q plays middle C and E plays the E above it. A stopwatch tick lasts 0.01 s.
| Change | Tick within the take | Predicted time in the replay |
|---|---|---|
| C pressed at 0.50 s | ||
| E pressed at 0.75 s | ||
| C released at 1.00 s | ||
| E released at 1.25 s |
On the board, LEDR0 marks recording, LEDR1 marks playback and both are dark when idle. At the start of each pass the six HEX digits show 00:30:00 and count down in minutes, seconds and hundredths. Predict their reading when E is released.
Hear what the recorder saved
From the extracted folder, run:
cc -std=c11 -O2 -Wall -Wextra -Werror starter/recorder.c -pthread -lm -o recorder
python3 resources/play_take.py ./recorder before.wav resources/duet.txt
python3 resources/view_scope.py before.wav
Open the local address printed by the viewer. Play before.wav in your audio player. Compare the silence after both fingers lift in the first pass with the same interval in the replay. In the viewer, step through the first four changes and the replay changes. Which note disappears first in each pass? Stop the viewer with Ctrl+C when finished.
The upper trace (1) shows the original performance. The lower trace (2) shows the starter’s replay, aligned to the same start time. Each vertical slice gives the peak amplitude of a short section of the WAV. Where should the last silent interval begin?
Read the terminal rows: saved and played give the tick, Linux key code and state (1 down, 0 up). The two codes in this performance are 16 for Q and 18 for E. Did the replay scheduler miss a saved event, or did the recorder discard it before playback?
Repair and stress the recording
Change save_transition in starter/recorder.c. Preserve the two meaningful transitions of a piano key. Recompile, then repeat the command using a fresh name, after.wav. Compare the four saved times with the four played times; Linux scheduling may shift a reading by a few hundredths. Use the WAV and the viewer to verify the rest before the return to idle.
Make a copy of the score. Insert a repeated Q event (state 2) at 0.60 s and extend the E note by 0.15 s. Predict which rows and sounds should change, then run your score. Hand in the table, one before/after playback observation and the rows from your edited performance that support it.
FPGAcademy exercise · Exercise notice · LabsLand source license
Embedded Systems · Linux and C. A pianist records two overlapping notes and plays them back. The monitor file sounds right in both ears, yet the signal sent to the audio device is silent on one channel. Find the first place the two channels disagree.
Use a Linux terminal with a C compiler, Linux userspace headers and Python 3. The local exercise opens a private pseudo-terminal and captures the commands your piano writes. You can measure both channels even with a mono speaker or no headphones.
Follow one stereo frame
Each frame starts as a signed 32-bit sample. This piano sends the same music to both speakers. At startup it writes init once to clear the output FIFOs. For each frame it writes waitw to wait for room, followed by one left command and one right command. The device receives each command in its own write. At 8,000 stereo frames per second, predict how many waits and channel writes a four-second take needs.
| Measurement | Before repair | After repair |
|---|---|---|
| Frames captured | ||
| Left peak (16-bit PCM) | ||
| Right peak (16-bit PCM) | ||
| Number of note changes during replay |
Compare the two listening points
From the extracted folder, run:
cc -std=c11 -O2 -Wall -Wextra -Werror starter/stereo_piano.c -pthread -lm -o piano
python3 resources/capture_audio.py ./piano before resources/duet.txt
Open before/monitor.wav, then before/device.wav. Both files contain the performance and its replay. The monitor takes its samples from the synthesizer; the device file is reconstructed from the signed numbers your program sent to each channel. Compare the printed L and R peaks. The L != R line counts unequal pairs, and First negative L lets you check the sign on both sides. The first frame is silent by design, so the first two channel commands alone cannot reveal the fault. The example below shows a sounding interval from the starter's device output.
Repair the channel and check the timing
Read send_frame in starter/stereo_piano.c. For a negative sample, what exact value will reach each channel? Change the call responsible for the disagreement. Recompile and repeat the capture using a fresh folder named after. The peak and polarity should now match on both channels. Check the four saved and four played rows against the score. Their first column counts hundredths of a second since recording or replay began.
Open the waveform viewer with python3 resources/view_scope.py after/monitor.wav. Compare the first two note presses with the same two presses during replay. Which evidence checks the timing, and which proves the device actually received the right-channel samples?
For a final test, reduce only the right channel to half amplitude, keeping its sign. Predict the two peaks, then repeat with a third folder. Submit the table, your repair, and the measured peak ratio from the final test. Explain why checking the synthesizer's monitor alone would have missed the original fault.
FPGAcademy exercise · Exercise notice · LabsLand source license
Embedded Systems · Linux and C. Two instruments disagree. An external oscilloscope connected to a DE1-SoC at the University of Deusto measured a pulse near 3.3 V. A program reading modeled 12-bit conversions of the same trace reports a much smaller high level. Find out where the high bits went.
You need a C compiler and Python 3. The ZIP includes the measured voltage trace, a short register capture with known inputs and the C reader. The analog-to-digital converter (ADC) in this terminal exercise is a model with a 4.096 V span.
Read the register
The controller's channel-0 register contains a 12-bit unsigned conversion in bits 11–0. Bit 15 means a new conversion is ready. A register read consumes that flag. Two fresh samples can have the same value.
At a 4.096 V span, one of the 4,096 equal code intervals is 1 mV wide. Code 4095 represents the final interval, which begins at 4.095 V. The program reports the lower edge of the interval in microvolts. Predict the output for the four register reads below before compiling.
| Raw register | Fresh? | Expected code | Starter output | Repaired output |
|---|---|---|---|---|
| 0x00000400 | ||||
| 0x000083ff | ||||
| 0x00008400 | ||||
| 0x00008fff |
cc -std=c11 -O2 -Wall -Wextra -Werror starter/read_adc.c -o read_adc
./read_adc replay resources/reference-reads.txt 4096 8
Find the first fresh row that disagrees with your prediction. Compare the raw register with the decimal output in that row. Repair adc_code in the starter, recompile and repeat. Why should both occurrences of the fresh word 8800 appear in the output, while 0400 produces no row?
Follow a signal from the remote lab
The green line shows the first 100 measurements of channel 1 on the external instrument. The lower panel shows what the starter reports when those voltages are passed through the ADC model. Both use the same vertical scale and sample numbers.
On Windows with the Python launcher, use py -3 wherever a command starts with python3.
python3 resources/model_input.py resources/deusto-trace-A.csv pulse.txt --full-scale-mv 4096
./read_adc replay pulse.txt 4096 500 > pulse.csv
Find the largest reconstructed voltage and count how many of the 500 samples exceed 1.5 V. Use this command to check both readings:
python3 -c "import csv; a=[int(r['microvolts']) for r in csv.DictReader(open('pulse.csv'))]; print(max(a)/1000000, sum(v>1500000 for v in a))"
Compare your results with the measured voltages in resources/deusto-trace-A.csv. The external scope measured small negative values near ground. Explain why the modeled unipolar ADC returns zero for them. The file's first column is a sample number; use it to locate an edge.
Change the measuring range
Repeat with a new model file, range5.txt, and a full-scale value of 5000 in both commands. This changes a software setting. Predict whether the high pulse will change in code, in reconstructed volts or in both. Turn in the register table, your edit and a comparison of the two reconstructed high voltages. Identify the measurement that came from the physical board and the two results computed by your program.
FPGAcademy exercise · Exercise notice · LabsLand source license
Embedded Systems · Linux interrupts. You are building a test signal for an oscilloscope. Four switches select its frequency, ten LEDs mirror the switches, and the display shows the requested frequency in hertz. The display reads 100, but the instrument sees a different frequency. Use the edges to find the fault.
Measure before you edit
Unzip the activity and work from its top-level directory. You need a C compiler. The register bench advances a modeled 100 MHz timer directly to its next interrupt. It prints the level of JP1 pin D0 after each interrupt. The first row is the initial level.
cc -std=c11 -O2 -Wall -Wextra -Werror starter/generator.c resources/bench.c -o wave
./wave 0x240 8
With SW9–SW6 set to 1001, which frequency do you request? Find the first two rising edges in the output. Subtract their timestamps. Each tick lasts 10 ns. Calculate the frequency in hertz and compare it with the requested value.
These are register-bench traces for the same switch setting. Which trace matches your program? Mark a half-period and a full period on that trace. Explain why counting every change as one cycle would hide the fault.
Change the timer reload
Open starter/generator.c. Follow one timeout through generator_interrupt. Find the instruction that clears the timeout flag and the write that changes D0. How many times must this handler run before the output has made a complete cycle?
Edit period_register. If an interval takes N input clocks, the reload register stores N − 1. Round the interval to the nearest whole clock. Rebuild and complete the table from your CSV output. One register tick is 0.00000001 s.
| Switch word | Requested Hz | First two rising timestamps | Measured Hz after repair | LEDR word |
|---|---|---|---|---|
| 0x000 | 10 | |||
| 0x240 | 100 | |||
| 0x26d | 100 | |||
| 0x3c0 | 160 |
Compare the middle two rows. Which outputs change when you flip switches below SW6? The HEX column packs four displays into four bytes, with HEX0 at the right. It should stay the same for those two rows.
Put the same interrupt handler in Linux
For this section use a disposable Linux 6.18 VM with a compiler, matching kernel headers, and permission to load local modules. The downloads include a platform driver and a register fixture. The fixture raises interrupts through the Linux IRQ subsystem while the timer and GPIO registers live in RAM. The terminal measurements above are in modeled FPGA time.
cp starter/generator.c resources/selected.c
make -C "/lib/modules/$(uname -r)/build" M="$PWD/resources" COURSE_BENCH=1 modules
sudo insmod resources/course_wave.ko
sudo insmod resources/irq_fixture.ko intervals_per_cycle=2 original_d0=1
sudo rmmod irq_fixture
sudo rmmod course_wave
sudo dmesg | grep 'course-wave fixture' | tail -1
With the repair, expect edges=112 result=0. The test changes the switch word while the module is running, dispatches an interrupt with no timeout pending and checks the outputs again after the device detaches. Find the part of the driver that stops an interrupt from writing to a detached device. If fixture insertion fails, read its kernel log and unload course_wave before rebuilding. A VM that restricts unsigned modules can still run the terminal bench.
Submit your timer expression, the four measured rows and one observation that would distinguish a bad display decoder from a bad timer. A physical frequency measurement would require a scope on JP1 D0 and a common ground. The standard remote FPGA upload session gives you a different FPGA image and no Linux module shell.
FPGAcademy exercise · Exercise notice · LabsLand source license
Embedded Systems · Triggered acquisition. A signal generator feeds a 100 Hz square wave into channel 0 of an oscilloscope. Move the trigger switch and the first visible edge should change direction. Your scope ignores the switch. Find the error without changing the generator or the timebase.
You need Linux, a C compiler and Python 3. Unzip the activity. The three input files record output edges from the register bench in the preceding activity, at 10, 100 and 160 Hz. Here a modeled ADC converts the low level to 0 V and the high level to 3.3 V. The visualizer plots a 100 ms window across 320 columns and a vertical range of 0–5 V.
Capture both edges
Compile the program, then take three sweeps with each setting. A value of 1 represents SW0 up (rising trigger). A value of 0 represents SW0 down (falling trigger).
cc -std=c11 -O2 -Wall -Wextra -Werror starter/scope.c -lrt -o scope
export SCOPE_REPLAY_SLOW=8
./scope edges resources/generator-100.csv 1 3 4096 up > up.csv
./scope edges resources/generator-100.csv 0 3 4096 down > down.csv
python3 resources/read_sweep.py up.csv
python3 resources/read_sweep.py down.csv
Open up-01.svg and down-01.svg in a browser. In a rising-trigger sweep, should column zero be high or low? Predict the result for a falling trigger. Compare your two predictions with the first ADC codes in the CSVs.
The figure shows two reference sweeps. Identify their trigger directions from the left edge. Locate one period on each trace. Changing the trigger should change the starting phase while leaving the frequency unchanged.
Repair the trigger
Open starter/scope.c. The two inputs to crossing indicate whether the previous and current conversions are above the trigger threshold of 1.65 V. Make the function accept the requested transition. Holding a constant level must never trigger a sweep. Recompile, repeat both commands and fill in the table.
Record the first ADC code before and after the edit, then two successive rising columns from the repaired capture.
| SW0 | Transition | First code | Fixed code | Rising columns |
|---|---|---|---|---|
| 1 | low to high | |||
| 0 | high to low |
Read the spacing between two successive rising columns in a complete portion of the trace. Each column represents 100 ms ÷ 320, so a separation of 32 columns corresponds to 10 ms. How does that compare with the generator setting? Keep the three separate sweeps separate when counting cycles. The scope rearms between them.
Test the ends of the range
Repeat with generator-10.csv and generator-160.csv. Predict how many periods fit in each window before opening an SVG. In which case might the screen show too little to measure two successive rising edges?
At a 4.096 V ADC span, a code of 3300 represents 3.300 V. Select a 5000 mV span in the command and repeat one sweep. Use code × span / 4096 to recover millivolts. Explain why the high code changes while the trace stays at about the same height.
Account for gaps
The acquisition uses a POSIX interval timer. A late wake-up can skip one or more sample times. The CSV records each missed column as −1, and the drawing leaves a gap. Running the replay at eight times its normal wall-clock duration gives a busy machine more time between notifications. Its 100 ms signal window and column labels stay the same.
Unset the replay adjustment with unset SCOPE_REPLAY_SLOW and repeat a capture. Compare the gap counts. Keep an unbroken region for measuring a period. If both runs have zero gaps, explain what the program would lose if the scheduler delayed a sample.
Turn in your repaired function, the completed table and a labeled sweep. Identify the evidence that the program rearmed for a new trigger, and explain how you distinguished a missing sample from a measured zero.
FPGAcademy exercise · Exercise notice · LabsLand source license
Embedded Systems · Oscilloscope timebase. You are measuring a 10 Hz signal. A 100 ms screen shows one period. Press KEY0 twice and the label changes to 300 ms, but the trace still shows one period. Is the generator slowing down, or is the scope giving you the wrong scale?
Use Linux, a C compiler and Python 3. This activity starts with the working rising and falling triggers from the preceding exercise. The input file records the 10 Hz setting of the timer-driven generator. Leave that file alone throughout the experiment.
Press a key between sweeps
From the unzipped directory, run the five-sweep sequence below. The key file contains one hexadecimal edge mask for each new sweep. The sequence is no press, KEY0, KEY0, KEY1, KEY1. The acquisition reads each mask once, so a change applies to the whole next frame.
cc -std=c11 -O2 -Wall -Wextra -Werror starter/scope.c -lrt -o scope
export SCOPE_KEYS=resources/key-edges.txt
export SCOPE_REPLAY_SLOW=4
./scope edges resources/generator-10.csv 1 5 4096 zoom > zoom.csv
python3 resources/read_sweep.py zoom.csv
Open zoom-01.svg and zoom-03.svg. Compare their rightmost time labels and the number of cycles visible. The CSV column spacing is a second way to measure the timebase. Multiply step_ns by 320 and divide by one million to get the window duration in milliseconds.
Both traces have the same input frequency and scale label. Which agrees with the generator? What input frequency would you incorrectly infer from the other?
Fix the time between samples
Open starter/scope.c and find sampling_interval_ns. Derive the interval from the requested sweep duration and the number of columns. Keep the 100 ms case working. Recompile, run the five-sweep sequence again and complete the table from your measured CSV values.
| Requested | Before (ms) | Fixed interval (ns) | Cycles |
|---|---|---|---|
| 100 ms | |||
| 200 ms | |||
| 300 ms | |||
| 200 ms | |||
| 100 ms |
Do two separate checks on frame 3. First recover the 300 ms duration from its timestamps. Then use the measured separation of two rising edges to estimate the generator frequency. Ignore a gap marked −1 when selecting the edges. At 300 ms, a period can span 106 or 107 columns because the scope samples at discrete instants.
Drive the controls yourself
Use SCOPE_KEYS=- to read masks from your terminal. Type one selection and press Enter before each sweep. A mask of 1 represents KEY0, 2 represents KEY1 and 0 leaves the duration unchanged. The scope operates between 100 and 1000 ms. Simultaneous KEY0 and KEY1 presses leave the scale unchanged.
SCOPE_KEYS=- ./scope edges resources/generator-100.csv 0 3 4096 personal > personal.csv
python3 resources/read_sweep.py personal.csv
Try 2, 1, 3. Predict all three durations and check them. With SW0 down, what should the first sample of every sweep be? Submit your timer calculation, the table and your two frame-3 measurements. Explain why changing the scale should leave the independently measured input frequency unchanged.
FPGAcademy exercise · Exercise notice · LabsLand source license
Can you keep the outline of a colored object while removing an isolated bright pixel? Implement a five-stage edge detector in C, inspect each image and measure the CPU time. This software activity runs in a Linux terminal with a C compiler and an image viewer. It assumes you can index a two-dimensional array and convolve a small kernel.

The same 63 × 47 target before processing (left) and after thinning and thresholding at 45 (right).
Run the starter
Extract the complete ZIP and work in its root directory. The supplied 63 × 47 color target contains a rectangle, a disk, a diagonal band and scattered bright pixels. Open resources/target.bmp and predict which features will survive smoothing.
cc -std=c11 -O2 -Wall -Wextra -Werror starter/edges.c -lm -o edges
./edges resources/target.bmp edges.bmp 45 --stages
Open 01-gray.bmp through 04-thin.bmp and edges.bmp. The starter reports 1,293 selected pixels. Several stages initially show the same image. Implement each stage before moving to the next.
Build the detector
- Grayscale. Inspect the supplied conversion. For RGB (45,140,225), predict the integer intensity and check a pixel inside the rectangle.
- Gaussian smoothing. Convolve with these five rows:
1 4 7 4 1,4 16 26 16 4,7 26 41 26 7,4 16 26 16 4,1 4 7 4 1. Divide the sum by 273. Treat pixels outside the image as zero. Check the center of the rectangle and a point near a corner. - Sobel gradients. Subtract the left column from the right using weights 1, 2, 1 for
gx. Subtract the bottom row from the top using the same weights forgy. Storemin(255, (abs(gx)+abs(gy))/2)and the gradient direction rounded to the nearest 45 degrees modulo 180. The first raster row is the top of the image. - Thin each edge. Compare a pixel with the two neighbors along its gradient. Keep it only when its intensity exceeds both. For 45 degrees compare northeast and southwest. Use a separate output buffer so an earlier update cannot change the next comparison.
- Threshold and check adjacency. Retain the intensity of a pixel only if it and at least one of its eight neighbors both exceed the threshold. Compare against the entire thinned input, including diagonal neighbors.
Check the result
At threshold 45 the supplied image should contain 525 edge pixels. At 255 it should contain none. Try 0, 45 and 120 and inspect the same corner and diagonal in each output. Look for an outer border introduced by zero padding. Test a second uncompressed 24-bit BMP of your own.
| Threshold | Edge pixels | Median CPU time over five runs | Visible change |
|---|---|---|---|
| 0 | |||
| 45 | |||
| 120 |
Record the image size, compiler options and machine alongside your timing. The program measures only the five processing stages. Explain which steps an FPGA accelerator would need to perform to produce the same output.
FPGAcademy · Embedded Systems · Lab 10 · I. Original handout · MIT
Embedded Systems · Framebuffer layout. A lighthouse has a red stripe, a yellow sun above it and the sea below. Your C program sends it to the screen upside down, with the stripe blue. Correct the framebuffer, then use a switch on a physical DE1-SoC to show what you changed.

This capture came from the VGA output of a University of Washington board on LabsLand. You will make the pixels in C on your own Linux computer. The LabsLand Online Editor then builds a Verilog design that displays those pixels on the remote board. You need a C compiler and Python 3 for the local steps, and access to a DE1-SoC Verilog lab with VGA for the board step.
Find the two faults
Open resources/beacon.bmp in an image viewer. A 24-bit BMP stores blue, green and red bytes for each pixel. This file starts with the bottom row. The display expects the top row first, with one little-endian 32-bit word per pixel. Its word layout is 0x00RRGGBB.
Predict the four bytes in memory for a pure red pixel, starting at its lowest address. Where should file row zero land in a display with 480 rows?
cc -std=c11 -O2 -Wall -Wextra -Werror starter/display.c -o display
truncate -s 1228800 before.xrgb
./display resources/beacon.bmp before.xrgb
python3 resources/view_frame.py before.xrgb before.bmp
Open before.bmp. Compare it with the original and the remote capture. Which error could turn a red stripe blue while leaving it in the same position?
Repair one thing at a time
In starter/display.c, change pixel_word to put each channel in its specified set of bits. Recompile. Use a new destination so you can keep the baseline.
truncate -s 1228800 yours.xrgb
./display resources/beacon.bmp yours.xrgb
python3 resources/view_frame.py yours.xrgb yours.bmp
Inspect the result, then fix display_row. A positive BMP height means its rows run bottom-up. A negative height means the file already starts at the top. Recompile and regenerate the second frame. Record the stripe color and the sun position for your original, color-only and final versions. Explain why 640 × 480 pixels occupy 1,228,800 bytes in the framebuffer.
Compare your frames on the physical board
On Windows with the Python launcher, use py -3 wherever a command starts with python3.
python3 resources/vga_tiles.py before.xrgb yours.xrgb frame_beacon.v
Open your institution’s DE1-SoC Verilog Online Editor. In the interface chooser, select the Media group and the interface with VGA and audio, then apply it. Choose New, enter the name frame_beacon, paste the generated Verilog into the new file, select it as the top level and choose Synthesize. When the build succeeds, choose Upload to FPGA and enter the board session. LabsLand DE1-SoC laboratory
- Set SW0 down. Wait until the lighthouse appears in the VGA pane. Color bars can briefly appear while the capture locks onto the signal.
- Set SW0 up. Record what happens to the stripe and the sun. The board is now showing the bytes your edited C program produced.
- Return SW0 down. Verify that both faults return. Save the two VGA observations with the board identifier and switch position.
The Verilog exporter preserves every pixel of this teaching image. It stores one color per 8 × 8 tile, using a palette of up to 16 colors across both frames. The C program still packs every pixel individually. Submit your two C edits, the red-pixel byte prediction and your observed switch comparison. If you did only the local steps, identify the two BMP previews as local output.
FPGAcademy exercise · Exercise notice · LabsLand source license
A lighthouse stays in color even after the FPGA has finished finding its edges. The input reader and the output writer finish at different times. Your job is to find which completion event the program missed, repair the transfer sequence in C and show the result on a remote DE1-SoC.
You need a Linux terminal with a C compiler and Python 3, plus access to the LabsLand DE1-SoC Verilog Online Editor with VGA. The C program runs on your computer. It supplies four commands to a sequencer on the FPGA. The board computes the edges from the color picture each time you change the threshold.
Follow one frame
From the extracted worksheet folder, run the starter and trace its four commands. The trace uses a model of three DMA controllers. A write of 1 to a controller’s buffer register requests a swap. Bit 0 at offset 12 stays set until that swap completes.
cc -std=c11 -O2 starter/transfer.c -o transfer
cc -std=c11 -O2 resources/trace_transfer.c -o trace
./transfer > commands.txt
./trace < commands.txt
The starter reports a rejected presentation and returns status 4. In the trace, find the source at 0xff203100, the sink at 0xff203120 and video at 0xff203020. The color picture begins at 0xc0000000 and the output buffer at 0xc2000000. Which address is on screen at the end? When the input reader first goes idle, what is the writer still doing?
Try the original sequence on the board
On Windows with the Python launcher, use py -3 wherever a command starts with python3.
python3 resources/build_board.py commands.txt resources/beacon80.bmp edge_dma.v
Open the DE1-SoC Verilog Online Editor, choose Change → Media → VGA and audio, and apply the interface. Use New to create edge_dma, paste the contents of edge_dma.v, select that file as the top level, and choose Synthesize → Upload to FPGA. Wait for the lighthouse in the VGA pane. Set SW1 down. Move SW0 up to request the edge view. Record the board identifier, the image and the state of LEDR3. LabsLand DE1-SoC laboratory
Repair the handoff
Reorder the commands in starter/transfer.c. The output bank can be presented only after both transfer controllers have finished. Rebuild the C program, regenerate commands.txt and rerun the trace. Which buffer is now on screen? Run ./trace stall-sink < commands.txt to hold the writer busy. Explain why the original front buffer stays visible after the timeout.
Regenerate edge_dma.v, replace the editor contents, synthesize and upload again. In the board session, make these three observations:
| Switch state | What to record |
|---|---|
| SW0 down | Locate the sun, tower and water on the color image. |
| SW0 up, SW1 down | At threshold 20, identify two outlines. Check LEDR2 for a completed presentation. |
| SW0 up, SW1 up | At threshold 100, find one feature that disappears and one that survives. Return SW1 down and verify the feature comes back. |

At threshold 20, the board’s VGA output shows the lantern window and the small marks on the water.
Each of the 80 × 60 computed samples covers an 8 × 8 tile of the 640 × 480 display. The input reader streams the color samples into the five-stage detector from Part I. The output writer stores the final intensities in FPGA memory. Video starts using the completed frame during vertical blanking. This exercise runs in the programmable logic. The original HPS exercise uses a Linux process, two SDRAM frame buffers and a separate hardware system.
Save and compare the edge map
With Icarus Verilog installed, the following commands run the same detector without a board and save the luminance samples. The testbench measures clock cycles from transfer start to output completion. It excludes the wait for vertical blanking.
iverilog -g2012 -s check_engine -o engine edge_dma.v resources/check_engine.v
vvp engine +THRESHOLD=20 +OUTPUT=low.bin
python3 resources/save_edges.py low.bin low.bmp
Repeat with threshold 100 and a different filename. If you have your Part I C program, run it on resources/beacon80.bmp at both thresholds. Compare decoded pixel intensities, then divide the hardware cycle count by 50 MHz. Record what the C timing includes and where you ran it before drawing a conclusion about speed. Submit the four commands in order, the two final front-buffer addresses (normal and stalled), the two threshold observations and your timing calculation.
FPGAcademy exercise · Exercise notice · LabsLand source license
