Display two decimal digits
Online version: https://fpga.labsland.com/altera/digital-logic/lab-02/part-01/
Digital Logic · Lab 2, Part I · DE1-SoC
A switch pattern of 0001 0010 should show 12 on the two rightmost displays. Each four-switch group encodes a decimal digit separately. Design one decoder and use it twice. You will need binary place value, Boolean algebra and the active-low segment convention from Lab 1.
Lab setup
LabsLand Online Editor · DE1-SoC
Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser
Build in Quartus and upload the bitstream
Extract the project for your HDL and open decimal_pair.qpf in Quartus Prime Lite with the Cyclone V device package. Complete the six remaining segment equations. Choose Processing → Start Compilation and confirm the fitted device is 5CSEMA5F31C6.
In the Standard DE1-SoC binary upload lab, select output_files/decimal_pair.sof and enter the board. Locate HEX1 immediately to the left of HEX0 in the camera.
- Get the starterDownload
decimal_pair.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 and the Quartus project.
- Complete the design and compileStart with Work out the decoder in the worksheet below, then complete the design as its build steps describe. Open
decimal_pair.qpfand choose Processing → Start Compilation. Quartus writesoutput_files/decimal_pair.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
Work out the decoder
Draw a seven-segment digit. Label the top bar 0, the upper-right bar 1, then continue clockwise around the outside to 5. The middle bar is 6. A zero on a segment pin lights that bar. For each digit 0–9 draw its shape and write the seven pin levels in order 6 to 0. For example, digit 1 uses the two right bars, so its pin word is 1111001.
For each segment make a four-input Karnaugh map. Mark the six unused codes 1010–1111 as don't-cares. Group the ones to derive an expression for when the segment is dark. The starter gives the top bar. Check its expression at 1, 4 and 8 before deriving the other six. Use Boolean operators in your HDL for every segment.
Build
Download the starter. Open your HDL in the DE1-SoC Online Editor, choose Standard and create the file decimal_pair. Paste the starter, finish the six equations and choose decimal_pair as the top level. Synthesize, upload and wait for the programming confirmation. Locate HEX1 immediately to the left of HEX0 in the camera.
Read the two displays
Set SW7…4 to the left digit and SW3…0 to the right digit. Before touching the switches, predict the two characters in each row. Record what you can actually read on the board.
| SW7…4 | SW3…0 | Prediction | Camera HEX1 HEX0 |
|---|---|---|---|
| 0000 | 0000 | ||
| 0001 | 0010 | ||
| 0011 | 0100 | ||
| 0101 | 0110 | ||
| 0111 | 1000 | ||
| 1001 | 0000 |
Leave 9 on the right and 0 on the left. Toggle SW8 and SW9. Then set only the left group to 1111. Which digit can you still predict from the specification?
Hand in
Submit one labeled Karnaugh map, its equation, your HDL and the six camera readings. Give a switch setting that would reveal swapped digit groups. Explain why 1001 0000 shows 90 even though the same eight bits represent 144 as an unsigned binary integer.
Adapted from FPGAcademy Digital Logic 21.1, Lab 2, Part I. LabsLand wrote the worksheets, starters and reference designs. Verilog source handout · VHDL source handout · MIT notice
