Store and retrieve a nibble from 32 addresses
Online version: https://fpga.labsland.com/altera/digital-logic/lab-08/part-03/
Build a memory from an HDL array of 32 four-bit words. You will write distinct values to addresses that differ by just their most significant bit. The last read value stays on the right-hand display while you prepare the next operation.
Lab setup
LabsLand Online Editor · DE1-SoC
Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser
Run the simulation on your computer with Icarus Verilog (Verilog or SystemVerilog) or NVC (VHDL). Then build your design and test it on the remote DE1-SoC.
Build
- From the extracted worksheet folder, open
starter/inferred_ram.qpfin the selected release of Quartus Prime Lite with Cyclone V support. The project-only download has the QPF at its root. - Edit the HDL file for
inferred_ram. If the exercise generates a new HDL file, copy its contents into that same project file. - Choose Processing → Start Compilation. Check the Fitter report for device 5CSEMA5F31C6.
- In the LabsLand bitstream upload lab, choose Standard and upload
output_files/inferred_ram.sof. Wait for programming confirmation before using the controls. - If your course uses a LabsLand classroom, the upload opens a firmware library instead: check that your SOF is selected and choose Enter board with selected firmware.
SW8–4 select the address, SW3–0 supply a nibble, and SW9 selects write (high) or read (low). KEY0 performs the operation when released. HEX5–4 show the address in hexadecimal, HEX2 shows the input data and HEX0 shows the last completed read. HEX3 and HEX1 are blank. Work out how many flip-flops a simple register implementation would need for the stored bits alone.
- Get the starterDownload
inferred_ram.v - Open the LabsLand Online EditorOpen the lab Choose DE1-SoC · Verilog when you open the lab. LabsLand asks you to sign in. Use the access your course or institution provides.
- Follow the worksheetPredict first, then build, read the board and hand in. The build steps are below.
- Install Quartus Prime Lite with Cyclone V supportSkip this if it is already installed.
- Download the activityDownload worksheet and Quartus project Includes the worksheet, the Quartus project and the simulation files.
- Complete the design and compileComplete the design as Build in the worksheet below describes. Open
inferred_ram.qpfand choose Processing → Start Compilation. Quartus writesoutput_files/inferred_ram.sof. - 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 · VHDL · SystemVerilog
Worksheet and starter (.zip) for offline work or printing
Build
- In the LabsLand Online Editor, choose DE1-SoC for your HDL and the Standard interface.
- Create
inferred_ram, paste the design and set it as the top level. - Choose Synthesize → Upload to FPGA. After editing the design, synthesize and upload it again to test the change on the board.
SW8–4 select the address, SW3–0 supply a nibble, and SW9 selects write (high) or read (low). KEY0 performs the operation when released. HEX5–4 show the address in hexadecimal, HEX2 shows the input data and HEX0 shows the last completed read. HEX3 and HEX1 are blank. Work out how many flip-flops a simple register implementation would need for the stored bits alone.
Simulate
Extract the worksheet ZIP and run these commands from the folder containing activity.md.
The testbench writes and reads every possible nibble at each of the 32 addresses. Before each read clock it checks that changing switches leaves the last result in place.
Verilog
iverilog -g2005 -s test_ram -o bench starter/inferred_ram.v simulation/test_ram.v
vvp bench
SystemVerilog
iverilog -g2012 -s test_ram -o bench starter/inferred_ram.sv simulation/test_ram.v
vvp bench
VHDL
nvc --std=2008 -a starter/inferred_ram.vhd simulation/test_ram.vhd
nvc --std=2008 -e test_ram
nvc --std=2008 -r test_ram
With the original starter, record the first address that fails. After you repair the read index, run the same commands again. Look for PASS 512 writes and 512 reads, address and data displays, registered hold.
Probe two addresses that look alike
Build the unchanged starter and program the DE1-SoC. Write A to address 00. Turn writing off, change the input nibble to F, and release KEY0 once. Then write B to address 10. Switch back to read mode with address 10 selected. Read HEX0 before and after the next key release. Changing the data switches in read mode should affect HEX2 immediately.
| Hex address | Value written | Readback before repair | Readback after repair |
|---|---|---|---|
| 00 | A | ||
| 10 | B | ||
| 0F | C | ||
| 1F | 3 |
Write the remaining two words from the table. Read all four addresses in a different order and fill in the before-repair column. Which address bit distinguishes each pair? Find where the read index loses that bit. After the repair, rerun the simulation, rebuild and program the board through the same workflow. Write all four words again before you fill in the after-repair column. Set up a write of 5 at 00 but turn off SW9 again before any KEY0 release. Test whether the previous word remains. Now perform that write and show which other addresses retained their contents. An unwritten location has no specified value in this exercise.
Original LabsLand activity following FPGAcademy Digital Logic Lab 8, Part III. Verilog handout · VHDL handout · MIT
