Lab 2

Display two decimal digits

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

Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser

  1. Get the starterDownload decimal_pair.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

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