diff --git a/docs/chips-api/getting-started.md b/docs/chips-api/getting-started.md index 1dacc2b..5710209 100644 --- a/docs/chips-api/getting-started.md +++ b/docs/chips-api/getting-started.md @@ -54,6 +54,12 @@ In addition, you can use the [Wokwi Logic Analyzer](../guides/logic-analyzer) to 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. ::: +## Packaged custom chips, at Github repositories + +Once you consider your custom chip stable enough, you can package it and publish it as a separate Github repository, with releases. WokWi is able to fetch the releases from Github and include them into other designs. Each release must include a `chip.zip` file containing exactly one `chip.json` and one `chip.wasm` file, describing the chip. For more information, see [Packaged Chips](./packaged-chip) or see the [Inverter chip example](https://github.com/wokwi/inverter-chip/releases) in Github. + +To use such a packaged custom chip in your design, use the [`"dependencies"` tag in your `diagram.json`](/diagram-format#connections) file. + ## Chips API reference 📖 - [GPIO pins API](gpio) diff --git a/docs/chips-api/packaged-chip.md b/docs/chips-api/packaged-chip.md new file mode 100644 index 0000000..31a0434 --- /dev/null +++ b/docs/chips-api/packaged-chip.md @@ -0,0 +1,48 @@ +--- +title: Packaged Wokwi Custom Chips +sidebar_label: Packaged Chips +--- + +# Packaged Custom Chips + +A packaged Custom Chip is a Wokwi Custom Chip that can be used in other design but that has not been (yet) included into the Wokwi proper. While the GUI does not currently include a direct way to add such chips into a design, you can add them by manually editing your `diagram.json` file. + +You can also create your own Packaged Custom Chips and make them available for others to be used. To do so, once your chip is ready (enough), you can publish it as a +[Github repository release](https://docs.github.com/en/repositories/releasing-projects-on-github). +In the future, there may be alternative ways to make chips available. + +## Introduction + +Essentially, a custom chip consists of two files, `chip.json` and `chip.wasm`. The former contains a [chip description](./chip-json) in JSON, defining the properties of the chip. The `chip.wasm` contains the Webassembly definition of the chip functionality. It is usually produced by compiling a C source code file that describes the chip functionality. + +Any custom chip may be packaged into a Packaged Custom Chip by creating a `chip.zip` package and publishing it in a release in a Github repository. Correspondingly, any Github repository release[^1] with a `chip.zip` package that contains a `chip.json` and a `chip.wasm` file is understood to be a custom chip by the Wokwi Diagram Editor. + +[^1]: Currently the release name must start with the letter `v`, see below. + +## Using a Packaged Custom Chip + +Let's imagine that you need an inverter in your design and there aren't one directly available. Consider the https://github.com/wokwi/inverter-chip/ repository. It contains a definition of a very simple Custom Chip, an inverter. The repository also contains a release named `v1.0.0`: https://github.com/wokwi/inverter-chip/releases/tag/v1.0.0 + +That release contains the `chip.zip` file as required, containing the required files. + +To use the Packaged Custom Chip inverter in your design, first include a dependency into your `diagram.json`: +``` + "dependencies": { "chip-inverter": "github.com/wokwi/inverter-chip@1.0.0" } +``` + +:::note + +Note that the release name in Github is `v1.0.0`, beginning with a letter `v`, but the dependency in the `diagram.json` lists it as `@1.0.0`, without the letter `v`. + +Once you have included it as a dependency, you can use it normally, by adding it to `"parts"`: +``` + "parts": [ + { + "type": "chip-inverter", + "id": "inverter1", + ... +``` + +## Creating a Packaged Custom Chip + +To create a Packaged Custom Chip, publish your chip design in Github as a repository and make there a release. Further documentation for this remains to be written. \ No newline at end of file diff --git a/docs/diagram-format.md b/docs/diagram-format.md index ad66ffb..a661d14 100644 --- a/docs/diagram-format.md +++ b/docs/diagram-format.md @@ -18,6 +18,7 @@ follows: "author": "Uri Shaked", "editor": "wokwi", "parts": [], + "dependencies": [], "connections": [] } ``` @@ -113,6 +114,10 @@ to pin 13 of the `uno` part: You can find the name of a component pin by moving the mouse over it. +### Dependencies + +The `"dependencies"` section currently defines custom chips that are not yet included into the WokWi itself but that are available as separate Github repositories. For more details, see [Packaged Chips](./packaged-chip). + ### Wire placement mini-language Each item in the `"connections"` section can specify a list of instructions