vcc_force
Force a signal to a specific value, with optional timing, to override or set initial conditions in HDL simulation.
Instructions
Force signal to value (e.g. force sim.top.rst 1 0; force sim.top.clk 0 50ns).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| signal | Yes | ||
| value | Yes | ||
| time | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/visualizer_mcp/server.py:214-220 (handler)The `vcc_force` tool handler. Wraps the Visualizer 'force' Tcl command to force a signal to a given value, optionally at a specific simulation time. Uses `shlex.quote` for safe shell quoting and delegates to the generic `vcc_eval` tool.
@mcp.tool() async def vcc_force(signal: str, value: str, time: str | None = None) -> dict[str, Any]: """Force `signal` to `value` (e.g. force sim.top.rst 1 0; force sim.top.clk 0 50ns).""" suffix = f" {time}" if time else "" return await vcc_eval( f"force {shlex.quote(signal)} {shlex.quote(value)}{suffix}" ) # type: ignore[misc] - src/visualizer_mcp/server.py:213-214 (registration)Tool registration via the `@mcp.tool()` decorator, which registers `vcc_force` as an MCP tool on the FastMCP server instance.
@mcp.tool() - src/visualizer_mcp/server.py:215-215 (schema)Input schema for vcc_force: `signal` (str, required), `value` (str, required), `time` (str, optional). Returns a dict with keys 'ok' and 'result' or 'ok' and 'error'.
async def vcc_force(signal: str, value: str, time: str | None = None) -> dict[str, Any]: - src/visualizer_mcp/server.py:138-155 (helper)The underlying `vcc_eval` helper that `vcc_force` delegates to. It sends the Tcl command to the Visualizer VCC server and handles error cases (command error, not running, connection closed, timeout).
@mcp.tool() async def vcc_eval(tcl: str, timeout_s: float | None = None) -> dict[str, Any]: """Send any Tcl command to Visualizer's command interpreter. This is the escape hatch — every Visualizer Tcl command (run, step, wave add, force, examine, env, ...) can be sent through this tool. """ try: result = await session.eval(tcl, timeout_s=timeout_s) return {"ok": True, "result": result} except VccCommandError as e: return {"ok": False, "error": e.server_message} except VisualizerNotRunning as e: return {"ok": False, "error": str(e)} except VccConnectionClosed as e: return {"ok": False, "error": f"connection_closed: {e}"} except asyncio.TimeoutError: return {"ok": False, "error": "timeout"}