Lab 3

Measure a transparent D latch

Use one data input to generate complementary set and reset signals. SW0 supplies D, SW1 opens the latch and LED0 shows Q. Predict two different values of Q for the same closed-gate inputs by choosing two different histories.

Lab setup

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

Use Technology Map Viewer in desktop Quartus to inspect the mapped logic. Upload the bitstream to check its behavior on the board.

  1. Install Quartus Prime Lite with Cyclone V supportSkip this if it is already installed.
  2. Download the activityDownload worksheet and Quartus project Includes the worksheet, the Quartus project and the simulation files.
  3. Complete the design and compileComplete the design as Build in the worksheet below describes. Open gated_data.qpf and choose Processing → Start Compilation. Quartus writes output_files/gated_data.sof.
  4. 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 · Quartus 24.1 · VHDL · Quartus 24.1 · SystemVerilog · Quartus 24.1

Build

Open project/gated_data.qpf from your Quartus worksheet ZIP. Inspect the gate connection at the top level and repair its active level. Preserve the individual data and gate terms. Compile and locate them in Technology Map Viewer (Post-Mapping). Run the functional bench. Open Timing Analyzer on the fitted Cyclone V design. Find the path from SW[0] to LEDR[0]. The fitted storage determines how Quartus reports it.

Project Command from the fitted project directory
Verilog or SystemVerilog quartus_sta -t ../simulation/latch_path.tcl
VHDL quartus_sta -t ../simulation/latch_feedback.tcl

Open latch-path.txt. For Verilog or SystemVerilog, record the two paths on either side of the fitted latch. For VHDL, locate the stored feedback output in the full switch-to-LED report. Read the cumulative delay up to that row. Subtract it from the total to find the remaining delay to the LED. In both cases name the endpoints and timing corner, and identify one logic and one routing contribution.

Simulate

Extract the complete worksheet ZIP. In the folder containing activity.md, run the commands below with Icarus Verilog for Verilog or SystemVerilog, or NVC for VHDL. The testbench applies the switch sequence and checks the observable retained states.

test_gated_data.v

test_gated_data.vhd

Verilog

iverilog -g2005 -s test_gated_data -o bench project/gated_data.v simulation/test_gated_data.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_gated_data -o bench project/gated_data.sv simulation/test_gated_data.v
vvp bench

VHDL

nvc --std=2008 -a project/gated_data.vhd simulation/test_gated_data.vhd
nvc --std=2008 -e test_gated_data
nvc --std=2008 -r test_gated_data

Test on the DE1-SoC

Upload output_files/gated_data.sof through the DE1-SoC bitstream uploader. Open the gate and switch D from 0 to 1. Close the gate and lower D. Reopen it. Repeat with the opposite stored value. Record both histories. Use the camera to record retained states and compare them with your functional predictions.

Switch action Previous output Predicted Camera

FPGAcademy · Digital Logic · Lab 3 · II. VERILOG · VHDL · MIT