Skip to content

Commit 596ba46

Browse files
committed
Initial Release
1 parent 5b28594 commit 596ba46

21 files changed

+654
-21
lines changed

.devcontainer/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM wokwi/builder-clang-wasm
2+
3+
USER root
4+
RUN apk add gcompat libc6-compat
5+
6+
# Install arduino-cli:
7+
RUN wget -O /tmp/cli.tar.gz \
8+
https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz && \
9+
tar -C /usr/local/bin -zxvf /tmp/cli.tar.gz && \
10+
rm /tmp/cli.tar.gz
11+
RUN arduino-cli core update-index && arduino-cli core install arduino:avr

.devcontainer/devcontainer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Wokwi-chips clang ",
3+
"dockerFile": "Dockerfile",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": [
7+
"Wokwi.wokwi-vscode"
8+
]
9+
}
10+
}
11+
}

.github/workflows/build.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build Chip
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: Check out repository
13+
uses: actions/checkout@v3
14+
- name: Build chip
15+
uses: wokwi/wokwi-chip-clang-action@main
16+
with:
17+
sources: "src/main.c"
18+
- name: Copy chip.json
19+
run: sudo cp chip.json dist
20+
- name: 'Upload Artifacts'
21+
uses: actions/upload-artifact@v3
22+
with:
23+
name: chip
24+
path: |
25+
dist/chip.json
26+
dist/chip.wasm
27+
28+
# The release job only runs when you push a tag starting with "v", e.g. v1.0.0
29+
release:
30+
name: Release
31+
needs: build
32+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Download compiled chip
36+
uses: actions/download-artifact@v3
37+
with:
38+
name: chip
39+
path: chip
40+
- name: Create a zip archive
41+
run: cd chip && zip -9 ../chip.zip chip.*
42+
env:
43+
ZIP_VERSION: ${{ github.ref_name }}
44+
- name: Upload release
45+
uses: ncipollo/release-action@v1
46+
with:
47+
artifacts: chip.zip
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
generateReleaseNotes: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"wokwi.wokwi-vscode",
4+
"ms-vscode.makefile-tools",
5+
"vsciot-vscode.vscode-arduino"
6+
]
7+
}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"makefile.launchConfigurations": [
3+
{
4+
"cwd": "/workspaces/sn74lv1t86-q1/dist",
5+
"binaryPath": "/workspaces/sn74lv1t86-q1/dist/chip.wasm",
6+
"binaryArgs": []
7+
}
8+
]
9+
}

LICENSE

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2024 wokwi-custom-chips
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Uri Shaked
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-FileCopyrightText: © 2022 Uri Shaked <uri@wokwi.com>
2+
# SPDX-License-Identifier: MIT
3+
4+
SOURCES = src/main.c
5+
TARGET = dist/chip.wasm
6+
testFileName = logic
7+
testFolderName = test
8+
9+
.PHONY: all
10+
all: $(TARGET) dist/chip.json ; \
11+
12+
.PHONY: clean
13+
clean:
14+
rm -rf dist ; \
15+
rm -rf $(testFolderName) ; \
16+
17+
18+
dist:
19+
mkdir -p dist
20+
21+
$(TARGET): dist $(SOURCES) src/wokwi-api.h
22+
clang --target=wasm32-unknown-wasi --sysroot /opt/wasi-libc -nostartfiles -Wl,--import-memory -Wl,--export-table -Wl,--no-entry -Werror -o $(TARGET) $(SOURCES)
23+
24+
dist/chip.json: dist chip.json
25+
cp chip.json dist
26+
27+
28+
.PHONY: test
29+
test:
30+
mkdir -p $(testFolderName) ; \
31+
cd test && arduino-cli sketch new $(testFileName) && arduino-cli compile -e -b arduino:avr:uno $(testFileName) ; \

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Quadruple 2-Input Positive-NAND Gates Chip
2+
3+
SN74LV1T86-Q1 custom chip for [Wokwi](https://wokwi.com/).
4+
5+
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).
6+
7+
## Chip functionalities explained in DOCS
8+
9+
[Go-to-docs](docs/README.md)
10+
11+
## Building
12+
13+
The easiest way to build the project is to open it inside a Visual Studio Code dev container, and then run the `make` command.
14+
15+
## Testing
16+
17+
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".
18+
19+
If you want to make changes to the test project firmware, edit [test/logic/logic.ino](test/logic/logic.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.
20+
21+
## License
22+
23+
This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more details.

chip.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{ "version": 0.1,
2+
"name": "sn74lv4t00",
3+
"author": "Algovoid",
4+
"docs": "https://github.com/wokwi-custom-chips/cd4070b/blob/main/docs/README.md",
5+
"license": "MIT",
6+
"pins": [
7+
8+
"1A",
9+
"1B",
10+
"1Y",
11+
"2A",
12+
"2B",
13+
"2Y",
14+
"GND",
15+
"3Y",
16+
"3A",
17+
"3B",
18+
"4Y",
19+
"4A",
20+
"4B",
21+
"VCC"
22+
],
23+
"controls": []
24+
}

diagram.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"version": 1,
3+
"author": "Algovoid",
4+
"editor": "wokwi",
5+
"parts": [
6+
{ "type": "chip-sn74lv4t00", "id": "chip1", "top": -18.18, "left": 206.4, "attrs": {} },
7+
{
8+
"type": "wokwi-led",
9+
"id": "led1",
10+
"top": -99.6,
11+
"left": 90.2,
12+
"attrs": { "color": "blue" }
13+
},
14+
{
15+
"type": "wokwi-led",
16+
"id": "led2",
17+
"top": 34.8,
18+
"left": 90.2,
19+
"attrs": { "color": "yellow" }
20+
},
21+
{
22+
"type": "wokwi-dip-switch-8",
23+
"id": "sw1",
24+
"top": -32.5,
25+
"left": -56.1,
26+
"rotate": 90,
27+
"attrs": {}
28+
},
29+
{
30+
"type": "wokwi-led",
31+
"id": "led3",
32+
"top": 25.2,
33+
"left": 378.6,
34+
"attrs": { "color": "cyan", "flip": "1" }
35+
},
36+
{
37+
"type": "wokwi-led",
38+
"id": "led4",
39+
"top": -70.8,
40+
"left": 378.6,
41+
"attrs": { "color": "magenta", "flip": "1" }
42+
},
43+
{ "type": "wokwi-vcc", "id": "vcc2", "top": -162.44, "left": 153.6, "attrs": {} },
44+
{ "type": "wokwi-gnd", "id": "gnd1", "top": 134.4, "left": 201, "attrs": {} }
45+
],
46+
"connections": [
47+
[ "led2:A", "chip1:2Y", "green", [ "v0", "h76.8", "v-38.4" ] ],
48+
[ "led1:A", "chip1:1Y", "green", [ "v0", "h67.2", "v67.2" ] ],
49+
[ "sw1:1b", "chip1:1A", "green", [ "h0" ] ],
50+
[ "chip1:1B", "sw1:2b", "green", [ "h-19.2", "v-28.8" ] ],
51+
[ "sw1:1a", "sw1:2a", "red", [ "h-38.4", "v9.6" ] ],
52+
[ "sw1:2a", "sw1:3a", "red", [ "h-38.4", "v9.6" ] ],
53+
[ "sw1:4a", "sw1:3a", "red", [ "h-38.4", "v-9.6" ] ],
54+
[ "sw1:5a", "sw1:4a", "red", [ "h-38.4", "v-9.6" ] ],
55+
[ "sw1:8a", "sw1:7a", "red", [ "h-38.4", "v-9.6" ] ],
56+
[ "sw1:6a", "sw1:5a", "red", [ "h-38.4", "v-9.6" ] ],
57+
[ "sw1:7a", "sw1:6a", "red", [ "h-38.4", "v-9.6" ] ],
58+
[ "chip1:GND", "led2:C", "black", [ "h0", "v48", "h-105.6" ] ],
59+
[ "sw1:3b", "chip1:2A", "green", [ "h162.9", "v38.4" ] ],
60+
[ "chip1:2B", "sw1:4b", "green", [ "h-48", "v-38.4" ] ],
61+
[ "chip1:3A", "sw1:5b", "green", [ "h21.01", "v28.8", "h-182.4", "v-67.2" ] ],
62+
[ "sw1:6b", "chip1:3B", "green", [ "h134.1", "v57.6", "h201.6", "v-38.4" ] ],
63+
[ "sw1:7b", "chip1:4A", "green", [ "h124.5", "v67.2", "h230.4", "v-76.8" ] ],
64+
[ "sw1:8b", "chip1:4B", "green", [ "v0", "h124.5", "v57.6", "h240", "v-86.4" ] ],
65+
[ "chip1:4Y", "led4:A", "green", [ "h78.61" ] ],
66+
[ "chip1:3Y", "led3:A", "green", [ "v28.8", "h78.61" ] ],
67+
[ "led2:C", "led1:C", "green", [ "v0", "h-18.8", "v-134.4" ] ],
68+
[ "led4:C", "led3:C", "green", [ "v0", "h18.8", "v96" ] ],
69+
[ "led3:C", "led2:C", "green", [ "v38.4", "h-192.4" ] ],
70+
[ "vcc2:VCC", "chip1:VCC", "red", [ "v0", "h144" ] ],
71+
[ "vcc2:VCC", "sw1:1a", "red", [ "v0", "h-201.6" ] ],
72+
[ "gnd1:GND", "chip1:GND", "black", [ "v0" ] ]
73+
],
74+
"dependencies": {}
75+
}

docs/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Wokwi sn74lv4t00 Chip
2+
3+
This is a custom chip for [Wokwi](https://wokwi.com/). It implements the sn74lv4t00 IC.
4+
5+
## Description
6+
7+
The sn74lv4t00 contain Quadruple 2-input NAND gate. Each gate performs the Boolean function
8+
of Y = NOT(A . B) in positive logic.
9+
10+
## Truth Table
11+
12+
| INPUT A | INPUT B | OUTPUT |
13+
|---------|---------|---------|
14+
| L | L | H |
15+
| H | L | H |
16+
| L | H | H |
17+
| H | H | L |
18+
19+
## Pin names
20+
21+
| Name | Description |
22+
| ----- | ----------------------- |
23+
| 1A | Gate 1 Input signal A |
24+
| 1B | Gate 1 Input signal B |
25+
| 1Y | Gate 1 Output signal |
26+
| 2A | Gate 2 Input signal A |
27+
| 2B | Gate 2 Input signal B |
28+
| 2Y | Gate 2 Output signal |
29+
| 3A | Gate 3 Input signal A |
30+
| 3B | Gate 3 Input signal B |
31+
| 3Y | Gate 3 Output signal |
32+
| 4A | Gate 4 Input signal A |
33+
| 4B | Gate 4 Input signal B |
34+
| 4Y | Gate 4 Output signal |
35+
| GND | Ground |
36+
| VCC | Supply voltage |
37+
38+
39+
## Usage
40+
41+
To use this chip in your project, include it as a dependency in your `diagram.json` file:
42+
43+
```json
44+
"dependencies": {
45+
"chip-sn74lv4t00": "github:wokwi-custom-chips/sn74lv4t00@0.1.0"
46+
}
47+
```
48+
49+
Then, add the chip to your circuit by adding a `chip-sn74lv4t00` item to the `parts` section of diagram.json:
50+
51+
```json
52+
"parts": {
53+
...,
54+
{ "type": "chip-sn74lv4t00", "id": "chip1" }
55+
},
56+
```
57+
58+
For a complete example, see [The sn74lv4t00 chip test project](https://wokwi.com/projects/398980510024578049).

0 commit comments

Comments
 (0)