Lab 8

Scan initialized RAM while writing a different word

Display a 32-word memory in a loop while keeping an independent write address. A two-stage synchronizer brings the switches into the 50 MHz clock domain. Predict what a reset should do to the read address and to a word you have just changed.

Lab setup

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

Use desktop Quartus to generate the RAM component in its IP Catalog. Build the project, then upload the bitstream to the remote 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. Generate the memory, complete the design and compileComplete the design as Build in the worksheet below describes. Before compiling, create the memory component in the IP Catalog. Open memory_ip_scan.qpf and choose Processing → Start Compilation. Quartus writes output_files/memory_ip_scan.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/memory_ip_scan.qpf. In IP Catalog select RAM: 2-PORT, save a Verilog component named course_dual in the project directory and choose one read port and one write port. Use 32 four-bit words, a single clock and registered inputs. Clear the read-output register. For mixed-port read during write select I do not care (the outputs will be undefined). Enable memory initialization and enter pattern.mif from the project directory. Finish the wizard and check that course_dual.qip is included once.

Inspect the supplied MIF. Predict locations 00, 0F, 10 and 1F. The scan starts at zero and advances once per second. Inspect the read and write port connections in the starter. One uses the wrong address source. Repair it, then compile. Find the allocated memory block in the Fitter report and record its size and mode.

Simulate

Use Python 3 and Icarus Verilog. Generate the Verilog IP component in Quartus first. Run this command from the root of the extracted worksheet. Set QUARTUS_ROOTDIR to the Quartus folder that contains eda, or supply it with --quartus-root.

If you have both Quartus releases installed, open project/course_dual.qip and check its IP_TOOL_VERSION against the release at the top of your worksheet. If they differ, regenerate the component in the selected release. Use the quartus folder from that installation for the simulation library.

On Windows with the Python launcher, use py -3 wherever a command starts with python3.

Verilog

python3 simulation/simulate_memory_ip.py project/memory_ip_scan.v project/course_dual.v simulation/test_memory_ip_scan.v

SystemVerilog

python3 simulation/simulate_memory_ip.py project/memory_ip_scan.sv project/course_dual.v simulation/test_memory_ip_scan.v

VHDL also requires GHDL with synthesis support.

python3 simulation/simulate_memory_ip.py project/memory_ip_scan.vhd project/course_dual.v simulation/test_memory_ip_scan.v

The bench accelerates the read-address divider to four clock cycles per word. It reads all 32 initial words, writes two new values, resets the scanner and checks the full memory again.

Test on the DE1-SoC

Upload output_files/memory_ip_scan.sof. Keep SW9 low and press and release KEY0. HEX3–2 show the scanned address, HEX0 the word at that address. Watch the transition from 0F to 10 and the wrap from 1F to 00.

Set SW8–4 to 11 hexadecimal and SW3–0 to D. HEX5–4 and HEX1 show the proposed write. Raise SW9 briefly, then lower it before changing the switches. Write E at 02 in the same way. Read each word on the next scan with writing disabled. Hold KEY0 and release it again. Did resetting the scanner restore the original words? Read a neighboring address to justify your answer. A read during a write to the same address has an unspecified value. Use a later read when you record the result.

If glare makes two digits look alike, use the row of red LEDs below them. LEDR8–4 give the five-bit read address. LEDR3–0 give the four-bit word. Read both groups in the same camera frame and convert each to hexadecimal.

Read address Initial value After writes After scanner reset
01
02
10
11
1F

FPGAcademy · Digital Logic · Lab 8 · IV. Verilog · VHDL · MIT