A well-configured development environment makes hardware design more productive. This guide covers editor setup, project structure, and the RHDL toolchain.

Editor Support

RHDL works with any Ruby-capable editor. Recommended setups:

  • VS Code — Ruby LSP extension for autocompletion and diagnostics
  • Vim/Neovim — Solargraph for Ruby language server support
  • RubyMine — full IDE with built-in Ruby support

Project Structure

A typical RHDL project follows Ruby conventions:

my_design/
├── Gemfile
├── lib/
│   ├── components/
│   │   ├── alu.rb
│   │   ├── counter.rb
│   │   └── decoder.rb
│   └── my_design.rb
├── spec/
│   ├── alu_spec.rb
│   └── counter_spec.rb
├── export/
│   ├── verilog/          # Generated Verilog files
│   ├── gates/            # Gate-level JSON netlists
│   └── roms/             # Assembled ROM binaries
└── diagrams/             # Generated circuit diagrams

RHDL CLI Toolchain

The rhdl command provides a unified interface for all design tasks:

Interactive Debugging

# Launch TUI debugger with a counter
rhdl tui sequential/counter
 
# Debug an ALU with specific signals in hex
rhdl tui arithmetic/alu_8bit --signals a,b,result --format hex

Circuit Diagrams

# Generate all component diagrams
rhdl diagram --all
 
# Single component, specific format
rhdl diagram RHDL::HDL::ALU --level component --format svg

Verilog Export

# Export all components
rhdl export --all
 
# Export a single component
rhdl export --lang verilog --out ./output RHDL::HDL::Counter

Gate-Level Synthesis

# Synthesize all components to gate-level JSON
rhdl gates --export
 
# Show synthesis statistics
rhdl gates --stats

Development Tools

ToolPurpose
RSpecTest framework for hardware verification
GuardFile watcher for automatic re-simulation
BundlerDependency management
IRB / PryInteractive exploration of designs
GraphvizRequired for PNG diagram output (brew install graphviz or apt install graphviz)

Simulation Backends

RHDL supports multiple simulation backends. The Ruby behavioral backend works out of the box. For better performance:

BackendSetupSpeed
Ruby behavioralBuilt-inBaseline
Ruby gate-levelBuilt-in~2x
Rust nativecargo build in RHDL directory~50–100x
WASM (browser)Rust toolchain + wasm-pack~10–20x

Environment Variables

VariableDescription
RHDL_BENCH_LANESNumber of SIMD lanes for gate-level benchmarks (default: 64)
RHDL_BENCH_CYCLESNumber of cycles for benchmarks (default: 100,000)

Next Steps