Verilator MCP Server

Verilator MCP Server

Enables RTL simulation and hardware verification with Verilator through automatic testbench generation, natural language queries about simulations, waveform analysis, and protocol-aware testing for Verilog/SystemVerilog designs.

Category
访问服务器

README

Verilator MCP Server

MCP Verilator License

An intelligent Model Context Protocol (MCP) server for Verilator that provides RTL simulation, automatic testbench generation, and natural language query capabilities. This tool bridges the gap between AI assistants and hardware verification, making RTL simulation more accessible and intelligent.

Features

🚀 Core Capabilities

  • Automatic Testbench Generation: Intelligently generates testbenches when none exist
  • Smart Simulation: Compile and run simulations with automatic dependency management
  • Natural Language Queries: Ask questions about your simulation in plain English
  • Waveform Analysis: Generate and analyze simulation waveforms
  • Coverage Collection: Track code coverage metrics
  • Protocol-Aware: Built-in support for standard protocols (AXI, APB, etc.)

🤖 Natural Language Examples

Simulation Control

  • "Run simulation on counter.v"
  • "Simulate my design with waveform capture"
  • "Execute the CPU testbench with coverage enabled"
  • "Compile and run my ALU module"

Testbench Generation

  • "Generate a testbench for my FIFO module"
  • "Create an AXI testbench for the memory controller"
  • "Make a testbench with random stimulus for my ALU"
  • "Generate a protocol-aware testbench for my APB slave"

Debugging & Analysis

  • "Why is data_valid low at 1000ns?"
  • "What caused the assertion failure at time 5000?"
  • "Show me when the reset signal changes"
  • "Why is my output signal X?"
  • "Debug the state machine transitions"

Coverage & Verification

  • "Show me the coverage report"
  • "Which code blocks are not tested?"
  • "How can I improve coverage for the controller?"
  • "Generate tests for uncovered scenarios"

Design Understanding

  • "Explain how the CPU module works"
  • "What are the inputs and outputs of the ALU?"
  • "Analyze timing performance"
  • "Show the module hierarchy"
  • "What's the maximum operating frequency?"

Installation

Prerequisites

  • Node.js 16+
  • Verilator 5.0+ installed and in PATH
  • Git

Step 1: Install Verilator

Verilator must be installed before using this MCP server.

macOS (Homebrew)

brew install verilator

Ubuntu/Debian

sudo apt-get update
sudo apt-get install verilator

From Source

git clone https://github.com/verilator/verilator
cd verilator
autoconf
./configure
make -j `nproc`
sudo make install

Verify Installation

verilator --version
# Should output: Verilator 5.0 or higher

Step 2: Install Verilator MCP

# Clone the repository
git clone https://github.com/ssql2014/verilator-mcp.git
cd verilator-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Test the server
npm test
# Or run diagnostic
./diagnose.sh

Step 3: Configure Claude Desktop

Add to your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "verilator": {
      "command": "node",
      "args": ["/path/to/verilator-mcp/dist/index.js"],
      "env": {
        "LOG_LEVEL": "info"
      }
    }
  }
}

Step 4: Restart Claude Desktop

After updating the configuration, restart Claude Desktop to load the MCP server.

Environment Variables

  • LOG_LEVEL: Set logging level (debug, info, warn, error)
  • VERILATOR_PATH: Override Verilator installation path

Available Tools

1. verilator_compile

Compile Verilog/SystemVerilog designs to C++.

Parameters:

  • files (required): Array of design files
  • topModule: Top module name
  • optimization: Optimization level (0-3)
  • trace: Enable waveform generation
  • coverage: Enable coverage collection

Example:

{
  "files": ["cpu.v", "alu.v"],
  "topModule": "cpu",
  "optimization": 2,
  "trace": true
}

2. verilator_simulate

Run RTL simulation with automatic testbench generation.

Parameters:

  • design (required): Design file or directory
  • testbench: Testbench file (auto-generated if missing)
  • autoGenerateTestbench: Enable auto-generation (default: true)
  • enableWaveform: Generate waveforms (default: true)
  • simulationTime: Override simulation duration

Example:

{
  "design": "counter.v",
  "autoGenerateTestbench": true,
  "enableWaveform": true,
  "simulationTime": 10000
}

3. verilator_testbenchgenerator

Generate intelligent testbenches for modules.

Parameters:

  • targetFile (required): Verilog file containing module
  • targetModule (required): Module name
  • template: Template style (basic, uvm, cocotb, protocol)
  • protocol: Protocol type (axi, apb, wishbone, avalon)
  • stimulusType: Stimulus generation (directed, random, constrained_random)

Example:

{
  "targetFile": "fifo.v",
  "targetModule": "fifo",
  "template": "basic",
  "stimulusType": "constrained_random",
  "generateAssertions": true
}

4. verilator_naturallanguage

Process natural language queries about simulation.

Parameters:

  • query (required): Natural language question
  • context: Current simulation context
  • history: Previous query history

Example:

{
  "query": "Why did the assertion fail at time 5000?",
  "context": {
    "currentSimulation": {
      "design": "cpu.v",
      "waveformFile": "simulation.vcd"
    }
  }
}

Resources

The server provides access to simulation artifacts through MCP resources:

  • simulation://[project]/logs/[sim_id] - Simulation output logs
  • simulation://[project]/waves/[sim_id] - Waveform data
  • simulation://[project]/coverage/[sim_id] - Coverage reports
  • design://[project]/hierarchy - Module hierarchy
  • design://[project]/interfaces - Interface definitions

Testbench Generation Features

Automatic Detection

  • Clock and reset signal identification
  • Port direction and width analysis
  • Protocol recognition
  • Parameter extraction

Generated Components

  • Clock generation with configurable frequency
  • Reset sequences with proper polarity
  • Directed and random stimulus
  • Basic assertions and checkers
  • Coverage points
  • Waveform dumping

Protocol Support

Built-in templates for:

  • AXI (AXI4, AXI4-Lite, AXI-Stream)
  • APB (APB3, APB4)
  • Wishbone
  • Avalon
  • Custom protocols

Natural Language Query Categories

Debug Queries

  • Signal value analysis
  • Assertion failure investigation
  • X/Z propagation tracking
  • Timing relationship analysis

Analysis Queries

  • Performance metrics
  • Resource utilization
  • Critical path analysis
  • Power estimation

Coverage Queries

  • Coverage statistics
  • Uncovered code identification
  • Test scenario suggestions

Generation Queries

  • Testbench creation
  • Stimulus pattern generation
  • Assertion generation
  • Coverage point creation

Examples

Basic Simulation Flow

// 1. Compile design
{
  "tool": "verilator_compile",
  "arguments": {
    "files": ["alu.v"],
    "topModule": "alu",
    "trace": true
  }
}

// 2. Run simulation (auto-generates testbench)
{
  "tool": "verilator_simulate",
  "arguments": {
    "design": "alu.v",
    "autoGenerateTestbench": true,
    "enableWaveform": true
  }
}

// 3. Query results
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Show me any errors in the simulation"
  }
}

Natural Language Workflow Examples

Example 1: Complete Design Verification

// Natural language: "Generate a testbench and run simulation for counter.v"
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Generate a testbench and run simulation for counter.v with coverage"
  }
}

// Response will trigger testbench generation and simulation automatically

Example 2: Debug Simulation Failure

// After simulation fails, ask why
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Why did my simulation fail?",
    "context": {
      "currentSimulation": {
        "design": "fifo.v",
        "testbench": "tb_fifo.sv",
        "waveformFile": "sim_output/simulation.vcd"
      }
    }
  }
}

// Follow up with specific signal investigation
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Why is the full signal high when count is only 5?",
    "context": {
      "currentSimulation": {
        "design": "fifo.v",
        "waveformFile": "sim_output/simulation.vcd"
      }
    }
  }
}

Example 3: Coverage Improvement

// Ask for coverage analysis
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "What's my current code coverage and how can I improve it?"
  }
}

// Generate specific tests for uncovered code
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Generate test cases for the error handling paths"
  }
}

Example 4: Design Understanding

// Ask about module functionality
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Explain how the AXI arbiter module works and what are its key signals"
  }
}

// Analyze performance
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "What's the critical path in my design and how can I optimize it?"
  }
}

Protocol-Based Testing

// Generate AXI testbench
{
  "tool": "verilator_testbenchgenerator",
  "arguments": {
    "targetFile": "axi_slave.v",
    "targetModule": "axi_slave",
    "template": "protocol",
    "protocol": "axi",
    "generateAssertions": true
  }
}

// Or use natural language
{
  "tool": "verilator_naturallanguage",
  "arguments": {
    "query": "Create an AXI testbench with burst transactions for my memory controller"
  }
}

Multi-Step Conversation Example

// Step 1: Initial query
User: "I have a new UART module, help me verify it"
Assistant: "I'll help you verify your UART module. Let me first generate a testbench..."

// Step 2: Run simulation  
User: "Run the simulation with baud rate 115200"
Assistant: "Running simulation with 115200 baud rate..."

// Step 3: Debug issue
User: "The parity bit seems wrong"
Assistant: "Looking at the waveform, I can see the parity calculation is using even parity..."

// Step 4: Fix and verify
User: "Generate a test specifically for odd parity mode"
Assistant: "I'll create a directed test case for odd parity verification..."

Development

Building from Source

npm install
npm run build

Running Tests

npm test

Debug Mode

LOG_LEVEL=debug npm start

Troubleshooting

Quick Diagnostics

Run the diagnostic script to check your setup:

./diagnose.sh

Common Issues

  1. Verilator not found

    # Install Verilator first!
    brew install verilator  # macOS
    sudo apt-get install verilator  # Ubuntu/Debian
    
    # Verify installation
    verilator --version
    
  2. Server not starting in Claude Desktop

    • Ensure Verilator is installed (see above)
    • Check paths in Claude Desktop config are absolute
    • Restart Claude Desktop after configuration changes
    • Run ./diagnose.sh to check setup
  3. Compilation errors

    • Check file paths are correct
    • Verify SystemVerilog syntax
    • Review error messages in logs
  4. Testbench generation fails

    • Ensure module has standard port declarations
    • Check for unsupported constructs
    • Try simpler template options

For detailed troubleshooting, see TROUBLESHOOTING.md

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Submit a pull request

License

MIT License - see LICENSE file for details

Acknowledgments

  • Built on the Model Context Protocol by Anthropic
  • Powered by Verilator open-source simulator
  • Natural language processing using Natural library

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选