Skip to main content
Custom components written with the Chips API can be compiled into WebAssembly (WASM) for use with the Wokwi VS Code extension or the Wokwi CLI. The WASM binary can be compiled by the Wokwi CLI, GitHub Actions, a container, or locally. This guide will cover all four approaches.
The simplest way to get started is by cloning/forking the inverter-chip example repository from the Wokwi GitHub. You can then compile locally, use the dev container feature from VS Code, or push to GitHub to compile the WASM binary.

Configure your project

Before compiling your chip, you should make sure your project is configured properly to ensure that they can work in Wokwi.

Wokwi configuration

A custom chip requires a [[chip]] key in wokwi.toml. This key specifies the name and binary used by the custom chip. Wokwi also requires a JSON file that describes the pinout of the chip. This JSON file should have the same name as the WASM binary, but with its extension changed to .json instead of .wasm, e.g. inverter.chip.wasm is paired with inverter.chip.json.

Custom Chip Definitions

Learn how to configure the chip JSON file properly
An example excerpt from wokwi.toml:
[[chip]]
name = 'inverter' # To use the chip in diagram.json, add a part with "chip-inverter" type.
binary = 'chips/inverter.chip.wasm'
Multiple chips can be added to the same project by adding multiple [[chip]] keys, each with different name and binary values.

Source files

If you are cloning/forking the inverter chip repository, you can skip this section.
If you are setting up your project from scratch, you will need to ensure that the Wokwi C API is present within your source files. The easiest way to ensure this is to use the Wokwi CLI to compile your chip, as it will fetch the required files. It is also available from wokwi.com/api/chips/wokwi-api.h.
You need to ensure that the Wokwi API is included in your project, otherwise you will not be able to make use of the Chips API.

Compilation methods

As of v0.20.0, the wokwi-cli provides you the ability to easily compile chips from the terminal.
1

Download wokwi-cli

Download the wokwi-cli from github.com/wokwi/wokwi-cli.
2

Compile chip

Navigate to your project folder and run:
wokwi-cli chip compile main.c
Replace main.c with your source file name. The wokwi-cli will automatically fetch the required toolchain + SDK, and will output a WASM binary which is ready to use with Wokwi.
Running wokwi-cli for the first time to compile a chip

Additional options

You can also:
  • Pass multiple source files: wokwi-cli chip compile main.c utils.c
  • Specify output file name: wokwi-cli chip compile main.c -o my_chip.wasm
  • Generate a Makefile for more advanced projects: wokwi-cli chip makefile -n my_chip [source_files ...]
Additional examples are available via the -h/--help flag in wokwi-cli.

Build docs developers (and LLMs) love