This guide will help you get up and running with the DRAM controller project.
- Installation
- First Simulation
- Understanding the Output
- Viewing Waveforms
- Modifying Parameters
- Next Steps
- Download and install Icarus Verilog from https://bleyer.org/icarus/
- Add to PATH:
C:\iverilog\bin - GTKWave is included with the installation
sudo apt-get update
sudo apt-get install iverilog gtkwavebrew install icarus-verilog gtkwavegit clone https://github.com/0xSA7/dram-controller.git
cd dram-controllerWindows:
cd scripts
simulate.batLinux/Mac:
cd scripts
chmod +x simulate.sh
./simulate.sh-
Compilation Phase
- All Verilog files are compiled
- Include paths are resolved
- Syntax is checked
-
Simulation Phase
- Testbench initializes the controller
- Multiple test cases run:
- Write operations
- Read operations
- Sequential operations
- Refresh cycles
-
Output Generation
- Console shows test progress
- VCD waveform file is created
- Pass/fail summary is displayed
========================================
DRAM Controller Testbench
========================================
[65000] TEST #1: Write - Addr=0x012345, Data=0xabcd
[DRAM Model] Time 95000: ACTIVATE - Row=0091
[DRAM Model] Time 135000: WRITE - Col=145, Data=abcd
[85000] Write complete
[85000] TEST #2: Read - Addr=0x012345, Expected=0xabcd
[DRAM Model] Time 195000: READ - Col=145, Data=abcd
[105000] Read complete - Data=0xabcd [PASS]
========================================
Test Summary
========================================
Total Tests: 7
Passed: 7
Failed: 0
========================================
*** ALL TESTS PASSED ***
- ✅ PASS - Operation completed successfully with correct data
- ❌ FAIL - Data mismatch or timing violation
- Timeout - Operation didn't complete within expected time
Windows:
cd sim_output
C:\iverilog\gtkwave\bin\gtkwave.exe dram_controller.vcdLinux/Mac:
cd sim_output
gtkwave dram_controller.vcdAdd these signals to see controller operation:
Top Level:
dram_controller_tb.clk- Clock signaldram_controller_tb.rst_n- Reset
CPU Interface:
dut.cpu_addr- Address from CPUdut.cpu_data_in- Write datadut.cpu_data_out- Read datadut.cpu_read_req- Read requestdut.cpu_write_req- Write requestdut.cpu_ready- Controller readydut.cpu_data_valid- Data valid flag
DRAM Interface:
dut.dram_addr- Address to DRAMdut.dram_dq- Data busdut.dram_ras_n- Row Address Strobedut.dram_cas_n- Column Address Strobedut.dram_we_n- Write Enable
Internal State:
dut.u_dram_fsm.current_state- FSM statedut.u_timing_generator.counter_value- Timing counter
Look for these patterns in waveforms:
- RAS goes low → Row activation
- Wait tRCD cycles → RAS to CAS delay
- CAS goes low → Column access
- Data appears → After CAS latency
- Precharge → Row deactivation
Edit rtl/dram_controller_top.v or instantiate with different parameters:
dram_controller_top #(
.T_RCD(5), // Change RAS-to-CAS delay
.T_RP(5), // Change precharge time
.T_CAS(3), // Change CAS latency
.REFRESH_INTERVAL(600) // Change refresh interval
) dut (
// ... connections
);dram_controller_top #(
.ROW_ADDR_WIDTH(14), // Increase row address
.COL_ADDR_WIDTH(10), // Increase column address
.DATA_WIDTH(32) // Wider data bus
) dut (
// ... connections
);After making changes:
cd scripts
./simulate.sh- Read Architecture Guide for design details
- Study Project Tree for code organization
- Check Examples for usage patterns
- Modify timing parameters and observe effects
- Add new test cases to the testbench
- Try different address patterns
- Fix bugs or add features
- Improve documentation
- Share your use case
- See Contributing Guide
Problem: Include file not found
Solution: Check that all files exist in rtl/ directory
Problem: Syntax error
Solution: Check Verilog syntax, ensure Verilog-2012 support (-g2012)
Problem: Simulation timeout
Solution: Check FSM is transitioning properly, verify timing parameters
Problem: Data mismatch
Solution: Check address mapping, verify DRAM model behavior
Problem: Command not found: iverilog
Solution: Install Icarus Verilog, add to PATH
Problem: Cannot open VCD file
Solution: Check sim_output/ directory exists and has write permissions
- 📖 Check the Documentation
- 🐛 Report Issues
- 💬 Start a Discussion
- 📧 Contact maintainers
Happy Simulating! 🚀