Lab 2

C · Linux + remote seven-segment display

Scroll a message and freeze it with a pushbutton

Physical DE1-SoCYour computer

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.

The six seven-segment positions and pause indicator on the UW board.

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