warning
The Chips API is currently in beta. Please share your experiments and provide feedback in the #custom-chips
channel on the Discord chat.
The Custom Chips API allows you to create new simulation models and extend the functionality of Wokwi. You can create new sensors, displays, memories, testing instruments, and even simulate your own custom hardware.
Custom Chips are usually written in C, but you can use any language that compiles to WebAssembly (e.g. Rust, AssemblyScript, etc.). There is also an experimental support for writing custom chips in Verilog.
TutorialsâOpen any Wokwi project (or create a new one) and click on the blue "+" button in the diagram editor. Select "Custom Chip" from the list of options.
You'll see a dialog where you can enter the chip name, as well as the language you wish to use. We recommend using C for now. After typing a name for your chip, click on the "Create Chip" button.
This will add a copy of the chip to your diagram and create two files in your project:
The JSON file file defines a minimal set of pins ("VCC", "GND", "IN", "OUT"). Change the pin names and add more pins as needed.
The C file contains a minimal chip implementation. Add your code to the chip_init()
function. This function is called for every instance of the chip in the diagram. You can use it to initialize the chip state, configure timers, and set up pin watches.
The example code also includes a chip_state_t
struct, where you can store any state that your chip needs. You can use the user_data
field of the i2c_config_t
, timer_config_t
, etc. to store a pointer to this struct.
You can print debugging messages using the standard C printf()
function. Make sure to also #include <stdio.h>
in your program. The debug messages will appear in a new "Chips Console" tab below the diagram view:
In addition, you can use the Wokwi Logic Analyzer to debug the communication with your custom chip.
tip
Make sure to include a newline ("\n") at the end of your printf()
messages. The simulator shows the messages only when it reaches a newline character.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4