Lab 3

Compare a latch and two clock edges

Drive three storage elements from the same D and clock. LED0 shows the transparent latch, LED1 the positive-edge flip-flop and LED2 the negative-edge flip-flop. Draw three predicted output traces for one change on D during each clock level.

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 storage_edges.qpf and choose Processing → Start Compilation. Quartus writes output_files/storage_edges.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/storage_edges.qpf from your Quartus worksheet ZIP. Read the three assignments in the starter. One uses the wrong clock edge. Correct it and run the bench. Compile without forcing the discrete gates from the earlier parts. Open Technology Map Viewer (Post-Mapping) and identify the storage primitive used for each output. Trace the clock sense of both flip-flops.

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_storage_edges.v

test_storage_edges.vhd

Verilog

iverilog -g2005 -s test_storage_edges -o bench project/storage_edges.v simulation/test_storage_edges.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_storage_edges -o bench project/storage_edges.sv simulation/test_storage_edges.v
vvp bench

VHDL

nvc --std=2008 -a project/storage_edges.vhd simulation/test_storage_edges.vhd
nvc --std=2008 -e test_storage_edges
nvc --std=2008 -r test_storage_edges

Test on the DE1-SoC

Upload output_files/storage_edges.sof through the DE1-SoC bitstream uploader. Use SW0 for D and SW1 for clock. With D low, raise and lower the clock once. Raise D with the clock low, then raise the clock. Lower D before the falling edge. Predict and read LED2–0 at each step. Repeat with D high across the falling edge and state which outputs must differ.

Switch action Previous output Predicted Camera

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