Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
algovoid committed May 30, 2024
1 parent ffe2435 commit b4189c9
Show file tree
Hide file tree
Showing 21 changed files with 610 additions and 22 deletions.
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM wokwi/builder-clang-wasm

USER root
RUN apk add gcompat libc6-compat

# Install arduino-cli:
RUN wget -O /tmp/cli.tar.gz \
https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz && \
tar -C /usr/local/bin -zxvf /tmp/cli.tar.gz && \
rm /tmp/cli.tar.gz
RUN arduino-cli core update-index && arduino-cli core install arduino:avr
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Wokwi-chips clang ",
"dockerFile": "Dockerfile",
"customizations": {
"vscode": {
"extensions": [
"Wokwi.wokwi-vscode"
]
}
}
}
49 changes: 49 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build Chip

on:
push:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build chip
uses: wokwi/wokwi-chip-clang-action@main
with:
sources: "src/main.c"
- name: Copy chip.json
run: sudo cp chip.json dist
- name: 'Upload Artifacts'
uses: actions/upload-artifact@v3
with:
name: chip
path: |
dist/chip.json
dist/chip.wasm
# The release job only runs when you push a tag starting with "v", e.g. v1.0.0
release:
name: Release
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download compiled chip
uses: actions/download-artifact@v3
with:
name: chip
path: chip
- name: Create a zip archive
run: cd chip && zip -9 ../chip.zip chip.*
env:
ZIP_VERSION: ${{ github.ref_name }}
- name: Upload release
uses: ncipollo/release-action@v1
with:
artifacts: chip.zip
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"wokwi.wokwi-vscode",
"ms-vscode.makefile-tools",
"vsciot-vscode.vscode-arduino"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"makefile.launchConfigurations": [
{
"cwd": "/workspaces/sn5454/dist",
"binaryPath": "/workspaces/sn5454/dist/chip.wasm",
"binaryArgs": []
}
]
}
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2024 wokwi-custom-chips

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The MIT License (MIT)
Copyright (c) 2022 Uri Shaked
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: © 2022 Uri Shaked <uri@wokwi.com>
# SPDX-License-Identifier: MIT

SOURCES = src/main.c
TARGET = dist/chip.wasm
testFileName = logic
testFolderName = test

.PHONY: all
all: $(TARGET) dist/chip.json ; \

.PHONY: clean
clean:
rm -rf dist ; \
rm -rf $(testFolderName) ; \


dist:
mkdir -p dist

$(TARGET): dist $(SOURCES) src/wokwi-api.h
clang --target=wasm32-unknown-wasi --sysroot /opt/wasi-libc -nostartfiles -Wl,--import-memory -Wl,--export-table -Wl,--no-entry -Werror -o $(TARGET) $(SOURCES)

dist/chip.json: dist chip.json
cp chip.json dist


.PHONY: test
test:
mkdir -p $(testFolderName) ; \
cd test && arduino-cli sketch new $(testFileName) && arduino-cli compile -e -b arduino:avr:uno $(testFileName) ; \
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# sn5454
# 4-Wide AND-OR-INVERT Gates

Example of a basic custom chip for [Wokwi](https://wokwi.com/).

The actual source code for the chip lives in [src/main.c](src/main.c), and the pins are described in [chip.json](chip.json).

## DOCS
Chip functionalities and how to use it are explained in docs .
[Go-to-docs](docs/README.md)

## Building

The easiest way to build the project is to open it inside a Visual Studio Code dev container, and then run the `make` command.

## Testing

You can test this project using the [Wokwi extension for VS Code](https://marketplace.visualstudio.com/items?itemName=wokwi.wokwi-vscode). Open the project with Visual Studio Code, press "F1" and select "Wokwi: Start Simulator".

If you want to make changes to the test project firmware, edit [test/logic/sketch.ino](test/logic/sketch.ino), and then run `make test` to rebuild the .hex file. You'll need the [arduino-cli](https://arduino.github.io/arduino-cli/latest/installation/), which is already installed in the dev container.

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more details.
22 changes: 22 additions & 0 deletions chip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "sn5454",
"docs": "https://github.com/wokwi-custom-chips/sn5454/blob/main/docs/README.md",
"author": "algovoid",
"pins": [
"A",
"C",
"D",
"E",
"F",
"NC",
"GND",
"Y",
"G",
"H",
"NU",
"NU",
"B",
"VCC"
],
"controls": []
}
41 changes: 41 additions & 0 deletions diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": 1,
"author": "algovoid",
"editor": "wokwi",
"parts": [
{ "type": "chip-sn5454", "id": "chip1", "top": 116.22, "left": 120, "attrs": {} },
{
"type": "wokwi-led",
"id": "led1",
"top": 140.4,
"left": 311.4,
"attrs": { "color": "green", "flip": "1" }
},
{ "type": "wokwi-vcc", "id": "vcc1", "top": -28.04, "left": 220.8, "attrs": {} },
{ "type": "wokwi-gnd", "id": "gnd1", "top": 268.8, "left": 114.6, "attrs": {} },
{ "type": "wokwi-dip-switch-8", "id": "sw1", "top": 25.5, "left": -27.3, "attrs": {} }
],
"connections": [
[ "chip1:GND", "gnd1:GND", "black", [ "h0" ] ],
[ "chip1:VCC", "vcc1:VCC", "red", [ "h1.81", "v-76.8" ] ],
[ "chip1:Y", "led1:A", "green", [ "v0" ] ],
[ "gnd1:GND", "led1:C", "black", [ "v0", "h211.2" ] ],
[ "sw1:1a", "chip1:A", "green", [ "v0" ] ],
[ "sw1:2a", "chip1:B", "green", [ "v28.8", "h259.2", "v28.8" ] ],
[ "sw1:3a", "chip1:C", "green", [ "v0" ] ],
[ "sw1:4a", "chip1:D", "green", [ "v0" ] ],
[ "sw1:5a", "chip1:E", "green", [ "v0" ] ],
[ "sw1:6a", "chip1:F", "green", [ "v0" ] ],
[ "sw1:7a", "chip1:G", "green", [ "v124.8", "h211.2", "v-28.8" ] ],
[ "sw1:8a", "chip1:H", "green", [ "v134.4", "h211.2", "v-48" ] ],
[ "vcc1:VCC", "sw1:8b", "red", [ "v0" ] ],
[ "vcc1:VCC", "sw1:7b", "red", [ "v19.2", "h-192" ] ],
[ "vcc1:VCC", "sw1:6b", "red", [ "v9.6", "h-201.6" ] ],
[ "vcc1:VCC", "sw1:5b", "red", [ "v9.6", "h-211.2" ] ],
[ "vcc1:VCC", "sw1:4b", "red", [ "v19.2", "h-220.8" ] ],
[ "vcc1:VCC", "sw1:3b", "red", [ "v9.6", "h-230.4" ] ],
[ "vcc1:VCC", "sw1:2b", "red", [ "v19.2", "h-240" ] ],
[ "vcc1:VCC", "sw1:1b", "red", [ "v9.6", "h-249.6" ] ]
],
"dependencies": {}
}
46 changes: 46 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Wokwi sn5454 Chip

This is a custom chip for [Wokwi](https://wokwi.com/). It implements the sn5454 IC.

## Description

The sn5454 contains 4-wide AND-OR-INVERT. They perform the Boolean function
of Y = NOT( (A . B) + (C . D) + (E . F) + (G . H) ) .

## Pin names

| Name | Description |
| ---- | ----------------- |
| A | Input signal A |
| B | Input signal B |
| C | Input signal C |
| D | Input signal D |
| E | Input signal E |
| F | Input signal F |
| G | Input signal G |
| H | Input signal H |
| Y | Output signal |
| GND | Ground |
| VCC | Supply voltage |


## Usage

To use this chip in your project, include it as a dependency in your `diagram.json` file:

```json
"dependencies": {
"chip-sn5454": "github:wokwi-custom-chips/sn5454@0.1.0"
}
```

Then, add the chip to your circuit by adding a `chip-sn5454` item to the `parts` section of diagram.json:

```json
"parts": {
...,
{ "type": "chip-sn5454", "id": "chip1" }
},
```

For a complete example, see [The sn5454 chip test project](https://wokwi.com/projects/399264986831740929).
Loading

0 comments on commit b4189c9

Please sign in to comment.