Skip to main content
Glama
NellyW8

EDA Tools MCP Server

by NellyW8

synthesize_verilog

Synthesize Verilog HDL code into optimized netlists for FPGA targets using Yosys, enabling hardware implementation from RTL descriptions.

Instructions

Synthesize Verilog code using Yosys for various FPGA targets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verilog_codeYesThe Verilog source code to synthesize
top_moduleYesName of the top-level module
targetNoTarget technology (generic, ice40, xilinx, intel)generic

Implementation Reference

  • Core implementation of the synthesize_verilog tool. Performs Verilog synthesis using Yosys by creating a temp project, generating target-specific scripts (generic, ice40, xilinx), executing yosys, and returning synthesized netlist with logs.
      async synthesizeVerilog(verilogCode: string, topModule: string, target = "generic"): Promise<string> {
        try {
          const projectId = Math.random().toString(36).substring(2, 15);
          const projectDir = join(this.tempDir, `project_${projectId}`);
          await fs.mkdir(projectDir, { recursive: true });
    
          // Store project info
          this.projects.set(projectId, { dir: projectDir, type: "synthesis" });
    
          // Write Verilog file
          const verilogFile = join(projectDir, "design.v");
          await fs.writeFile(verilogFile, verilogCode);
    
          // Create synthesis script
          let synthScript: string;
          switch (target.toLowerCase()) {
            case "ice40":
              synthScript = `
    read_verilog design.v
    hierarchy -check -top ${topModule}
    synth_ice40 -top ${topModule}
    write_verilog synth_output.v
    stat
    `;
              break;
            case "xilinx":
              synthScript = `
    read_verilog design.v
    hierarchy -check -top ${topModule}
    synth_xilinx -top ${topModule}
    write_verilog synth_output.v
    stat
    `;
              break;
            default:
              synthScript = `
    read_verilog design.v
    hierarchy -check -top ${topModule}
    synth -top ${topModule}
    techmap
    opt
    write_verilog synth_output.v
    stat
    `;
          }
    
          const scriptFile = join(projectDir, "synth.ys");
          await fs.writeFile(scriptFile, synthScript);
    
          // Run Yosys
          const { stdout, stderr } = await execAsync(`yosys -s ${scriptFile}`, {
            cwd: projectDir,
            timeout: 120000,
          });
    
          let synthVerilog = "";
          try {
            synthVerilog = await fs.readFile(join(projectDir, "synth_output.v"), 'utf8');
          } catch {
            synthVerilog = "Synthesis output not generated";
          }
    
          return JSON.stringify({
            project_id: projectId,
            success: true,
            stdout,
            stderr,
            synthesized_verilog: synthVerilog,
            target,
          }, null, 2);
        } catch (error: any) {
          return JSON.stringify({
            success: false,
            error: error.message || String(error),
          }, null, 2);
        }
      }
  • src/index.ts:727-748 (registration)
    MCP tool registration in listTools handler, defining name, description, and JSON input schema requiring verilog_code and top_module, with optional target.
      name: "synthesize_verilog",
      description: "Synthesize Verilog code using Yosys for various FPGA targets",
      inputSchema: {
        type: "object",
        properties: {
          verilog_code: { 
            type: "string", 
            description: "The Verilog source code to synthesize" 
          },
          top_module: { 
            type: "string", 
            description: "Name of the top-level module" 
          },
          target: { 
            type: "string", 
            description: "Target technology (generic, ice40, xilinx, intel)", 
            default: "generic" 
          },
        },
        required: ["verilog_code", "top_module"],
      },
    },
  • JSON schema for tool inputs: verilog_code (string, required), top_module (string, required), target (string, optional default 'generic').
    inputSchema: {
      type: "object",
      properties: {
        verilog_code: { 
          type: "string", 
          description: "The Verilog source code to synthesize" 
        },
        top_module: { 
          type: "string", 
          description: "Name of the top-level module" 
        },
        target: { 
          type: "string", 
          description: "Target technology (generic, ice40, xilinx, intel)", 
          default: "generic" 
        },
      },
      required: ["verilog_code", "top_module"],
    },
  • Dispatch handler in MCP callToolRequest that validates parameters and invokes the EDAServer.synthesizeVerilog method.
    case "synthesize_verilog": {
      const verilogCode = validateRequiredString(args, "verilog_code", name);
      const topModule = validateRequiredString(args, "top_module", name);
      const target = getStringProperty(args, "target", "generic");
      
      return {
        content: [{
          type: "text",
          text: await edaServer.synthesizeVerilog(verilogCode, topModule, target),
        }],
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the tool ('Yosys') and target types, but doesn't disclose critical behavioral traits like required permissions, rate limits, output format, error handling, or whether it's a read/write operation. For a synthesis tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a synthesis tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the synthesis output is (e.g., netlist, reports), error conditions, or performance implications. For a tool that likely produces significant results, more context is needed to understand its full scope.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema (e.g., it doesn't explain 'target' options further or provide examples). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('synthesize') and resource ('Verilog code'), and specifies the tool used ('Yosys') and target scope ('various FPGA targets'). It distinguishes from siblings like 'simulate_verilog' by focusing on synthesis rather than simulation, though it doesn't explicitly mention siblings. This provides a specific verb+resource but lacks explicit sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, when-not scenarios, or compare to sibling tools like 'run_openlane' or 'simulate_verilog'. The context is implied (FPGA synthesis), but there are no explicit usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NellyW8/MCP4EDA'

If you have feedback or need assistance with the MCP directory API, please join our Discord server