A high-performance modular Verilog SDRAM controller (v3.0.0) with page hit optimization for up to 60% faster sequential access. Implements full SDRAM protocol with configurable timing, bank addressing, and intelligent row management.
- Open Row Policy: Keeps rows open after access for faster subsequent operations
- Page Hit: Same row/bank access β ~3-4 cycles (60% faster than v2.0)
- Page Miss: Different row β Auto precharge and activate
- Smart Precharge: Only closes rows when necessary (refresh or different row)
- 4-Bank Architecture: Independent row management per bank (2-bit bank address)
- 24-bit Addressing:
[23:22]Bank |[21:9]Row |[8:0]Column - SDRAM Compatible: Standard JEDEC SDRAM signaling with
dram_ba[1:0]
| Access Pattern | v2.0 Latency | v3.0 Latency | Speedup |
|---|---|---|---|
| Sequential | 7 cycles | 3-4 cycles | ~57% |
| Block 256B | 896 cycles | 391 cycles | ~56% |
| Random | 7 cycles | 4.5 cycles | ~36% |
See ENHANCEMENTS.md for detailed technical analysis.
- Modular Design: 6 focused RTL modules + utils and testbench
- Full SDRAM Protocol: ACTIVATE/READ/WRITE/PRECHARGE/AUTO-REFRESH
- Page Hit Optimization: Intelligent row management for reduced latency
- Bank Addressing: 4-bank support with independent row tracking
- Configurable Timing: tRCD, tRP, tCAS, tRAS, tRC, tREF
- Comprehensive Testing: Testbench with page hit/miss verification
- Parameterizable: Flexible DRAM sizes and bus widths
dram-controller/
βββ rtl/
β βββ dram_controller_top.v # Top-level integration + CPU interface
β βββ core/
β β βββ dram_fsm.v # State machine (with page hit logic)
β β βββ dram_command_generator.v # SDRAM signal generator
β β βββ refresh_controller.v # Periodic refresh management
β βββ utils/
β βββ address_decoder.v # Bank/row/column decomposition
β βββ timing_generator.v # Timing countdown logic
β βββ dram_pkg.vh # Shared parameters
βββ tb/
β βββ dram_controller_tb.v # Comprehensive testbench
β βββ dram_model_simple.v # Behavioral DRAM model
βββ docs/
β βββ GETTING_STARTED.md
β βββ architecture.md
β βββ QUICK_REFERENCE.md # Code snippets and debug tips
βββ scripts/
β βββ simulate.bat/.ps1/.sh # Simulation scripts
βββ ENHANCEMENTS.md # v3.0 technical details
βββ README.md
- Integration layer connecting all submodules
- CPU interface: address, data, read/write requests
- DRAM interface: RAS/CAS/WE/CS/CKE + bank address
- Decomposes 24-bit address into bank (2b), row (13b), column (9b)
- Latches addresses during operations
- Main state machine with page hit/miss detection
- Tracks open row per bank for optimization
- Intelligent state transitions: IDLE β ACTIVATE β READ/WRITE β IDLE (row open)
- Priority: Refresh > Page Hit > Page Miss
- Generates DRAM control signals (RAS, CAS, WE, CS, CKE, BA)
- Multiplexes row/column addresses
- Controls bidirectional data bus
- Periodic refresh request generation
- Row counter for distributed refresh
- Configurable refresh interval
- Provides precise timing delays for DRAM operations
- Selectable timing modes (tRCD, tRP, tCAS, etc.)
- Icarus Verilog (iverilog) for simulation
- GTKWave for waveform viewing (optional)
# Windows PowerShell
.\scripts\simulate.ps1
# Windows CMD
.\scripts\simulate.bat
# Linux/Mac
./scripts/simulate.shiverilog -g2012 -o sim_output/dram_controller_sim.vvp \
rtl/utils/dram_pkg.vh \
rtl/utils/*.v \
rtl/core/*.v \
rtl/dram_controller_top.v \
tb/*.v
vvp sim_output/dram_controller_sim.vvp
gtkwave sim_output/dram_controller.vcd- β Reset and initialization
- β Single write/read operations
- β Page Hit Test: Sequential access to same row (3-4 cycles)
- β Page Miss Test: Access to different row (auto precharge)
- β Multi-Bank Test: Independent bank operations
- β Refresh cycle observation
- β Data integrity verification
- β Pass/fail reporting
========================================
DRAM Controller Testbench
========================================
=== Page Hit Test (Same Row Access) ===
[150] TEST #5: Write - Addr=0x010000, Data=0xAAAA
[220] Write complete
[230] TEST #6: Write - Addr=0x010001, Data=0xBBBB (PAGE HIT!)
[270] Write complete (40ns instead of 70ns!)
========================================
Test Summary
========================================
Total Tests: 20
Passed: 20
Failed: 0
*** ALL TESTS PASSED ***
BANK_ADDR_WIDTH = 2 // 4 banks
ROW_ADDR_WIDTH = 13 // 8192 rows per bank
COL_ADDR_WIDTH = 9 // 512 columns
DATA_WIDTH = 16 // 16-bit data bus
Total Addressable: 16MBT_RCD = 2 // Row-to-Column Delay (20ns)
T_RP = 2 // Row Precharge Time (20ns)
T_CAS = 3 // Column Access Strobe (30ns)
T_REF = 780 // Refresh interval (7.8ΞΌs)- ENHANCEMENTS.md - v3.0 page hit optimization details
- docs/QUICK_REFERENCE.md - Code snippets and debugging
- docs/GETTING_STARTED.md - Setup and integration guide
- docs/architecture.md - Detailed architecture documentation
- Sequential memory access
- Array processing
- Cache line fills
- Video frame buffers
- Sequential operations: 50-60% faster
- Block transfers: 50-60% faster
- Mixed workload: 30-40% faster
- Random access: Neutral to 12% slower
MIT License - See LICENSE for details
- v3.0.0 (December 2025) - Page hit optimization, bank addressing, performance enhancements
- v2.0.0 (November 2025) - Modular architecture, comprehensive testing
- v1.0.0 - Initial release
Version: 3.0.0 β Last updated December 2025