Lab 2

Turn six switches into a two-digit decimal display

Use SW5…SW0 to represent an unsigned number from 0 to 63. Display the tens on HEX1 and the ones on HEX0. Setting the input to 001010 should make the camera show 10.

Lab setup

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

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

Design the converter

The two seven-segment decoders are already connected to the result nibbles. Complete the logic that produces those nibbles. One approach consumes the input from left to right, one bit per stage. Before each shift, add three to the ones digit if it is already five or more. Trace the six stages for 101101 and identify the first decimal carry.

Build

Download the starter in your language. Create a Standard DE1-SoC project in the Online Editor with six_bit_decimal as the top-level design. Synthesize, send the design to the board and wait for the display camera.

Test the boundaries

Predict the displays for 0, 9, 10, 19, 20, 45, 59, 60 and 63. Set each input and record both observed digits. Hold the six lower bits at 63 and turn on the four unused switches. Hand in the table and explain why the display retains its value.

Adapted from FPGAcademy Digital Logic 21.1, Verilog Lab 2, Part VI and the VHDL edition. LabsLand wrote the programs, tests and worksheet. MIT notice