Skip to content

Add description of Packaged Custom Chips - #222

Open
pekkanikander wants to merge 1 commit into
wokwi:mainfrom
pekkanikander:main
Open

Add description of Packaged Custom Chips#222
pekkanikander wants to merge 1 commit into
wokwi:mainfrom
pekkanikander:main

Conversation

@pekkanikander

Copy link
Copy Markdown

docs(chips-api/packaged-chip): Add description of Packaged Custom Chips

* Update chips-api/getting-started to discuss packaged custom chips

* Update diagram-format to discuss dependencies

…hips

    * Update chips-api/getting-started to discuss packaged custom chips

    * Update diagram-format to discuss dependencies
@urish urish self-assigned this Jan 23, 2025
@urish urish added the documentation Improvements or additions to documentation label Jan 23, 2025
@drf5n

drf5n commented Jan 26, 2025

Copy link
Copy Markdown
Contributor

Thinking out loud: So there are a few ways to make the chip.zip file,

  1. Use a Makefile like https://github.com/wokwi/inverter-chip/blob/main/Makefile
  2. Use Github CI like https://github.com/wokwi/inverter-chip/blob/main/.github/workflows/build.yaml
  3. Compile the stuff from a command line

The inverter chip setup confused me because there are several different ways of getting the job done, and you don't /need/ to do all of them.

@ujjwalagrawal-max

Copy link
Copy Markdown

****

Creating a chip.zip File

A chip.zip file contains the compiled files required to use a custom chip in Wokwi. There are several ways to generate it, and these methods are alternatives rather than sequential steps. You only need to choose the approach that best fits your development workflow.

Method 1: Build with a Makefile

A Makefile can automate the compilation process and package the required files into chip.zip.

For example, the Wokwi Inverter Chip Makefile demonstrates how a build process can be organized so that the required files are compiled and packaged automatically.

A typical workflow is:

Source Code
    ↓
Makefile
    ↓
Compile Chip
    ↓
Package Required Files
    ↓
chip.zip

This approach is useful when you want a repeatable local build process that can be executed with a single command.

Method 2: Build Automatically with GitHub Actions

You can also use GitHub Actions to compile and package the chip automatically whenever changes are pushed to the repository.

The inverter-chip GitHub Actions workflow provides an example of this approach.

The process can be represented as:

Code Push / Pull Request
          ↓
GitHub Actions
          ↓
Build Environment
          ↓
Compile Chip
          ↓
Package Files
          ↓
chip.zip

This method is particularly useful when the project is maintained collaboratively or when you want every code change to produce a consistent build artifact automatically.

Method 3: Compile from the Command Line

The chip can also be compiled directly from a terminal without creating a Makefile or GitHub Actions workflow.

The general process is:

Open Terminal
     ↓
Run Compiler / Build Command
     ↓
Generate Compiled Files
     ↓
Package Required Files
     ↓
chip.zip

This approach provides direct control over the build process and can be useful for quick testing, development, and debugging.

Which Method Should You Use?

You do not need to use all three methods.

Choose the method according to your requirements:

Requirement | Recommended approach -- | -- Simple local build | Command line Repeatable local builds | Makefile Automatic builds after code changes | GitHub Actions Team-based development | GitHub Actions Quick experimentation | Command line Standardized project build process | Makefile

The important distinction is that these methods represent different ways of accomplishing the same objective:

                 Create chip.zip
                       │
          ┌────────────┼────────────┐
          ↓            ↓            ↓
      Makefile     GitHub CI    Command Line
          │            │            │
          └────────────┼────────────┘
                       ↓
                   chip.zip

Recommended Approach

For a new project, start with the command-line build process so that you understand exactly how the chip is compiled and which files are required. Once the process works reliably, you can place those commands in a Makefile to make local builds easier to reproduce.

When the project is hosted on GitHub and requires automatic builds, the same build process can then be incorporated into GitHub Actions.

This gives a logical progression:

Understand the build
        ↓
Compile manually
        ↓
Automate with Makefile
        ↓
Automate in GitHub Actions

However, the latter stages are optional. You only need one working method to generate chip.zip; a Makefile and GitHub Actions are conveniences for automation, not prerequisites for one another.

## Creating a `chip.zip` File

A chip.zip file contains the compiled files required to use a custom chip in Wokwi. There are several ways to generate it, and these methods are alternatives rather than sequential steps. You only need to choose the approach that best fits your development workflow.

Method 1: Build with a Makefile

A Makefile can automate the compilation process and package the required files into chip.zip.

For example, the [Wokwi Inverter Chip Makefile](https://github.com/wokwi/inverter-chip/blob/main/Makefile) demonstrates how a build process can be organized so that the required files are compiled and packaged automatically.

A typical workflow is:

Source Code
    ↓
Makefile
    ↓
Compile Chip
    ↓
Package Required Files
    ↓
chip.zip

This approach is useful when you want a repeatable local build process that can be executed with a single command.

Method 2: Build Automatically with GitHub Actions

You can also use GitHub Actions to compile and package the chip automatically whenever changes are pushed to the repository.

The [inverter-chip GitHub Actions workflow](https://github.com/wokwi/inverter-chip/blob/main/.github/workflows/build.yaml) provides an example of this approach.

The process can be represented as:

Code Push / Pull Request
          ↓
GitHub Actions
          ↓
Build Environment
          ↓
Compile Chip
          ↓
Package Files
          ↓
chip.zip

This method is particularly useful when the project is maintained collaboratively or when you want every code change to produce a consistent build artifact automatically.

Method 3: Compile from the Command Line

The chip can also be compiled directly from a terminal without creating a Makefile or GitHub Actions workflow.

The general process is:

Open Terminal
     ↓
Run Compiler / Build Command
     ↓
Generate Compiled Files
     ↓
Package Required Files
     ↓
chip.zip

This approach provides direct control over the build process and can be useful for quick testing, development, and debugging.

Which Method Should You Use?

You do not need to use all three methods.

Choose the method according to your requirements:

Requirement Recommended approach
Simple local build Command line
Repeatable local builds Makefile
Automatic builds after code changes GitHub Actions
Team-based development GitHub Actions
Quick experimentation Command line
Standardized project build process Makefile

The important distinction is that these methods represent different ways of accomplishing the same objective:

                 Create chip.zip
                       │
          ┌────────────┼────────────┐
          ↓            ↓            ↓
      Makefile     GitHub CI    Command Line
          │            │            │
          └────────────┼────────────┘
                       ↓
                   chip.zip

Recommended Approach

For a new project, start with the command-line build process so that you understand exactly how the chip is compiled and which files are required. Once the process works reliably, you can place those commands in a Makefile to make local builds easier to reproduce.

When the project is hosted on GitHub and requires automatic builds, the same build process can then be incorporated into GitHub Actions.

This gives a logical progression:

Understand the build
        ↓
Compile manually
        ↓
Automate with Makefile
        ↓
Automate in GitHub Actions

However, the latter stages are optional. You only need one working method to generate chip.zip; a Makefile and GitHub Actions are conveniences for automation, not prerequisites for one another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants