SvPortSim.Verilator.DockerWorker (SvPortSim v0.2.0)

Copy Markdown View Source

Owns a long-running Verilator Docker container for repeated docker exec jobs.

The worker is intentionally small: it starts or reuses one container with the host workspace mounted at /work, then serializes Verilator invocations through GenServer.call/3. Callers can pass the worker to SvPortSim.Verilator.Docker.compile/4 with docker_mode: :persistent and docker_worker: worker.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns worker metadata.

Runs Verilator inside the persistent container.

Starts a Docker worker.

Starts or reuses a globally registered worker for :docker_worker_name.

Stops the worker process.

Types

run_result()

@type run_result() :: %{
  status: non_neg_integer(),
  log: String.t(),
  command: [String.t()],
  docker: Path.t(),
  workspace_dir: Path.t(),
  container_name: String.t(),
  container_id: String.t()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

info(worker)

@spec info(GenServer.server()) :: {:ok, map()}

Returns worker metadata.

run(worker, verilator_args, opts \\ [])

@spec run(GenServer.server(), [String.t()], keyword()) ::
  {:ok, run_result()} | {:error, term()}

Runs Verilator inside the persistent container.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts a Docker worker.

Useful options are :docker, :image, :workspace_dir, :container_name, :docker_worker_name, :user, :reuse, and :cleanup.

start_or_reuse(opts \\ [])

@spec start_or_reuse(keyword()) :: {:ok, pid()} | {:error, term()}

Starts or reuses a globally registered worker for :docker_worker_name.

stop(worker)

@spec stop(GenServer.server()) :: :ok

Stops the worker process.