Lab 3

Trace a gated set-reset latch

Build one bit of memory from two cross-coupled NOR gates. Use SW0 for set, SW1 for reset, SW2 for the gate and LED0 for Q. Predict whether the output changes when set goes high while the gate is closed.

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_rs.qpf and choose Processing → Start Compilation. Quartus writes output_files/gated_rs.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_rs.qpf from your Quartus worksheet ZIP. The reset path is complete. Compare its gate polarity with the set path. Correct the path that can change Q with the gate closed. Preserve the marked intermediate signals. In RTL Viewer trace both feedback connections. Then open the post-mapping Technology Map Viewer and compare the LUTs with your gate drawing.

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

test_gated_rs.vhd

Verilog

iverilog -g2005 -s test_gated_rs -o bench project/gated_rs.v simulation/test_gated_rs.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_gated_rs -o bench project/gated_rs.sv simulation/test_gated_rs.v
vvp bench

VHDL

nvc --std=2008 -a project/gated_rs.vhd simulation/test_gated_rs.vhd
nvc --std=2008 -e test_gated_rs
nvc --std=2008 -r test_gated_rs

Test on the DE1-SoC

Upload output_files/gated_rs.sof through the DE1-SoC bitstream uploader. With the gate open, assert reset and release it. Assert set and release it. Close the gate, assert reset, then reopen the gate. Change one switch at a time. Keep set and reset from being asserted together. Annotate where the previous value survives.

Switch action Previous output Predicted Camera

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