From bfb7d606715db7792b25e33af7fb51c462e46dbf Mon Sep 17 00:00:00 2001 From: HelHeim Date: Sat, 1 Jun 2024 19:31:01 +0000 Subject: [PATCH] Initial Release --- .devcontainer/Dockerfile | 11 ++ .devcontainer/devcontainer.json | 11 ++ .github/workflows/build.yaml | 49 +++++++ .gitignore | 1 + .vscode/extensions.json | 7 + .vscode/settings.json | 9 ++ LICENSE | 42 +++--- Makefile | 31 ++++ README.md | 24 ++- chip.json | 22 +++ diagram.json | 57 ++++++++ docs/README.md | 24 +++ src/main.c | 113 ++++++++++++++ src/wokwi-api.h | 138 ++++++++++++++++++ .../logic/build/arduino.avr.uno/logic.ino.eep | 1 + .../logic/build/arduino.avr.uno/logic.ino.elf | Bin 0 -> 9832 bytes .../logic/build/arduino.avr.uno/logic.ino.hex | 29 ++++ .../logic.ino.with_bootloader.bin | Bin 0 -> 32768 bytes .../logic.ino.with_bootloader.hex | 63 ++++++++ test/logic/logic.ino | 6 + wokwi.toml | 8 + 21 files changed, 624 insertions(+), 22 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/build.yaml create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 Makefile create mode 100644 chip.json create mode 100644 diagram.json create mode 100644 docs/README.md create mode 100644 src/main.c create mode 100644 src/wokwi-api.h create mode 100644 test/logic/build/arduino.avr.uno/logic.ino.eep create mode 100644 test/logic/build/arduino.avr.uno/logic.ino.elf create mode 100644 test/logic/build/arduino.avr.uno/logic.ino.hex create mode 100644 test/logic/build/arduino.avr.uno/logic.ino.with_bootloader.bin create mode 100644 test/logic/build/arduino.avr.uno/logic.ino.with_bootloader.hex create mode 100644 test/logic/logic.ino create mode 100644 wokwi.toml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..ca761e6 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..8a0bd9b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,11 @@ +{ + "name": "Wokwi-chips clang ", + "dockerFile": "Dockerfile", + "customizations": { + "vscode": { + "extensions": [ + "Wokwi.wokwi-vscode" + ] + } + } +} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..70e91b3 --- /dev/null +++ b/.github/workflows/build.yaml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fc7bee --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..37ff25a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "wokwi.wokwi-vscode", + "ms-vscode.makefile-tools", + "vsciot-vscode.vscode-arduino" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..486b1fe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "makefile.launchConfigurations": [ + { + "cwd": "/workspaces/sn74ls51/dist", + "binaryPath": "/workspaces/sn74ls51/dist/chip.wasm", + "binaryArgs": [] + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 5fd3470..6e79ab5 100644 --- a/LICENSE +++ b/LICENSE @@ -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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..98e3850 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: © 2022 Uri Shaked +# 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) ; \ \ No newline at end of file diff --git a/README.md b/README.md index 8eeeb3e..10ff2db 100644 --- a/README.md +++ b/README.md @@ -1 +1,23 @@ -# sn74ls51 \ No newline at end of file +# one 2-wide 3-input and one 2-wide 2-input AND-OR-INVERT Gate + +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. diff --git a/chip.json b/chip.json new file mode 100644 index 0000000..350cd09 --- /dev/null +++ b/chip.json @@ -0,0 +1,22 @@ +{ + "name": "sn74ls51", + "docs": "https://github.com/wokwi-custom-chips/sn74ls51/blob/main/docs/README.md", + "author": "algovoid", + "pins": [ + "1A", + "2A", + "2B", + "2C", + "2D", + "2Y", + "GND", + "1Y", + "1C", + "1D", + "NU", + "NU", + "1B", + "VCC" + ], + "controls": [] +} diff --git a/diagram.json b/diagram.json new file mode 100644 index 0000000..5c9e39e --- /dev/null +++ b/diagram.json @@ -0,0 +1,57 @@ +{ + "version": 1, + "author": "algovoid", + "editor": "wokwi", + "parts": [ + { "type": "chip-sn74ls51", "id": "chip1", "top": 116.22, "left": 120, "attrs": {} }, + { + "type": "wokwi-led", + "id": "led1", + "top": 140.4, + "left": 321, + "attrs": { "color": "blue", "flip": "1" } + }, + { "type": "wokwi-vcc", "id": "vcc1", "top": 67.96, "left": 220.8, "attrs": {} }, + { "type": "wokwi-gnd", "id": "gnd1", "top": 268.8, "left": 114.6, "attrs": {} }, + { + "type": "wokwi-led", + "id": "led2", + "top": 207.6, + "left": 51.8, + "attrs": { "color": "red", "flip": "" } + }, + { "type": "wokwi-dip-switch-8", "id": "sw1", "top": 323.1, "left": 145.5, "attrs": {} }, + { "type": "wokwi-vcc", "id": "vcc2", "top": 355.96, "left": 57.6, "attrs": {} }, + { "type": "wokwi-dip-switch-8", "id": "sw2", "top": 323.1, "left": 231.9, "attrs": {} } + ], + "connections": [ + [ "chip1:GND", "gnd1:GND", "black", [ "h0" ] ], + [ "chip1:VCC", "vcc1:VCC", "red", [ "h1.81", "v-76.8" ] ], + [ "chip1:Y", "led1:A", "green", [ "v0" ] ], + [ "vcc2:VCC", "sw1:8a", "red", [ "v0", "h153.6" ] ], + [ "vcc2:VCC", "sw1:1a", "red", [ "v0", "h86.4" ] ], + [ "vcc2:VCC", "sw1:2a", "red", [ "v0", "h96" ] ], + [ "vcc2:VCC", "sw1:3a", "red", [ "v0", "h105.6" ] ], + [ "vcc2:VCC", "sw1:4a", "red", [ "v0", "h115.2", "v-38.4" ] ], + [ "vcc2:VCC", "sw1:5a", "red", [ "v0", "h124.8" ] ], + [ "vcc2:VCC", "sw1:6a", "red", [ "v0", "h134.4" ] ], + [ "vcc2:VCC", "sw1:7a", "red", [ "v0", "h144" ] ], + [ "gnd1:GND", "led2:C", "black", [ "v0", "h-48" ] ], + [ "chip1:2Y", "led2:A", "green", [ "h-28.8", "v76.8" ] ], + [ "led1:A", "chip1:1Y", "green", [ "v0" ] ], + [ "gnd1:GND", "led1:C", "black", [ "v0", "h220.8" ] ], + [ "sw1:1b", "chip1:1A", "green", [ "v0.3", "h-115.2", "v-201.6" ] ], + [ "sw1:2b", "chip1:1C", "green", [ "v-18.9", "h86.4", "v-172.8" ] ], + [ "sw1:3b", "chip1:1B", "green", [ "v-28.5", "h86.4", "v-153.6" ] ], + [ "sw1:4b", "chip1:1D", "green", [ "v-38.1", "h86.4", "v-115.2" ] ], + [ "sw1:5b", "chip1:1E", "green", [ "v-47.7", "h86.4", "v-115.2" ] ], + [ "sw1:6b", "chip1:1F", "green", [ "v-38.1", "h86.4", "v-134.4" ] ], + [ "sw1:7b", "chip1:2A", "green", [ "v-114.9", "h-105.6", "v-76.8" ] ], + [ "sw1:8b", "chip1:2B", "green", [ "h0", "v-124.5", "h-115.2", "v-57.6", "h-9.6" ] ], + [ "vcc2:VCC", "sw2:1a", "red", [ "v0", "h172.8" ] ], + [ "vcc2:VCC", "sw2:2a", "red", [ "v0", "h182.4" ] ], + [ "sw2:1b", "chip1:2C", "green", [ "v-9.3", "h-192", "v-163.2" ] ], + [ "sw2:2b", "chip1:2D", "green", [ "v-18.9", "h-192", "v-144" ] ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..07dc762 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,24 @@ +# Wokwi sn74ls51 Chip + +This is a custom chip for [Wokwi](https://wokwi.com/). It implements the sn74ls51 IC. + +## Usage + +To use this chip in your project, include it as a dependency in your `diagram.json` file: + +```json + "dependencies": { + "chip-sn74ls51": "github:wokwi-custom-chips/sn74ls51@0.1.0" + } +``` + +Then, add the chip to your circuit by adding a `chip-sn74ls51` item to the `parts` section of diagram.json: + +```json + "parts": { + ..., + { "type": "chip-sn74ls51", "id": "chip1" } + }, +``` + +For a complete example, see [The sn74ls51 chip test project](https://wokwi.com/projects/399517192859856897). diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..581a738 --- /dev/null +++ b/src/main.c @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: MIT +// Copyright 2024 Algovoid + +#include "wokwi-api.h" +#include +#include + +typedef struct { + pin_t pin_1A; + pin_t pin_1B; + pin_t pin_1C; + pin_t pin_1D; + pin_t pin_1E; + pin_t pin_1F; + + pin_t pin_2A; + pin_t pin_2B; + pin_t pin_2C; + pin_t pin_2D; + + pin_t pin_1Y; + pin_t pin_2Y; + +} chip_state_t; + +uint8_t subGate1; +uint8_t subGate2; +uint8_t subGate3; +uint8_t subGate4; + +static void set_logic(chip_state_t *chip) { + subGate1 = pin_read(chip->pin_1A) & pin_read(chip->pin_1B) & pin_read(chip->pin_1C) ; + subGate2 = pin_read(chip->pin_1D) & pin_read(chip->pin_1E) & pin_read(chip->pin_1F); + subGate3 = pin_read(chip->pin_2A) & pin_read(chip->pin_2B) ; + subGate4 = pin_read(chip->pin_2C) & pin_read(chip->pin_2D); + + pin_write(chip->pin_1Y, !( subGate1 | subGate2 ) ); + pin_write(chip->pin_2Y, !( subGate3 | subGate4 ) ); +} + + +static void chip_pin_change(void *user_data, pin_t pin, uint32_t value) { + chip_state_t *chip = (chip_state_t*)user_data; + set_logic(chip); + // uncomment to see gates and output states + /* + printf("Gate 1 : %d\n" , subGate1); + printf("Gate 2 : %d\n" , subGate2); + printf("Gate 3 : %d\n" , subGate3); + printf("Gate 4 : %d\n" , subGate4); + printf("Output State 1Y : %u\n" , pin_read(chip->pin_1Y)); + printf("Output State 2Y : %u\n" , pin_read(chip->pin_2Y)); */ +} + + +void chip_init() { + printf("Initialize sn74ls51 chip!\n"); + chip_state_t *chip = malloc(sizeof(chip_state_t)); + + chip->pin_1A = pin_init("1A", INPUT); + chip->pin_1B = pin_init("1B", INPUT); + chip->pin_1C = pin_init("1C", INPUT); + chip->pin_1D = pin_init("1D", INPUT); + + chip->pin_1E = pin_init("1E", INPUT); + chip->pin_1F = pin_init("1F", INPUT); + + chip->pin_2A = pin_init("2A", INPUT); + chip->pin_2B = pin_init("2B", INPUT); + chip->pin_2C = pin_init("2C", INPUT); + chip->pin_2D = pin_init("2D", INPUT); + + chip->pin_1Y = pin_init("1Y", OUTPUT); + chip->pin_2Y = pin_init("2Y", OUTPUT); + + pin_write(chip->pin_1A, LOW); + pin_write(chip->pin_1B, LOW); + + pin_write(chip->pin_1C, LOW); + pin_write(chip->pin_1D, LOW); + + pin_write(chip->pin_1E, LOW); + pin_write(chip->pin_1F, LOW); + + pin_write(chip->pin_2A, LOW); + pin_write(chip->pin_2B, LOW); + + pin_write(chip->pin_2C, LOW); + pin_write(chip->pin_2D, LOW); + + const pin_watch_config_t config = { + .edge = BOTH, + .pin_change = chip_pin_change, + .user_data = chip, + }; + + pin_watch(chip->pin_1A, &config); + pin_watch(chip->pin_1B, &config); + + pin_watch(chip->pin_1C, &config); + pin_watch(chip->pin_1D, &config); + + pin_watch(chip->pin_1E, &config); + pin_watch(chip->pin_1F, &config); + + pin_watch(chip->pin_2A, &config); + pin_watch(chip->pin_2B, &config); + + pin_watch(chip->pin_2C, &config); + pin_watch(chip->pin_2D, &config); + + set_logic(chip); +} \ No newline at end of file diff --git a/src/wokwi-api.h b/src/wokwi-api.h new file mode 100644 index 0000000..01300a5 --- /dev/null +++ b/src/wokwi-api.h @@ -0,0 +1,138 @@ +#include +#include + +#ifndef WOKWI_API_H +#define WOKWI_API_H + +enum pin_value { + LOW = 0, + HIGH = 1 +}; + +enum pin_mode { + INPUT = 0, + OUTPUT = 1, + INPUT_PULLUP = 2, + INPUT_PULLDOWN = 3, + ANALOG = 4, + + OUTPUT_LOW = 16, + OUTPUT_HIGH = 17, +}; + +enum edge { + RISING = 1, + FALLING = 2, + BOTH = 3, +}; + +int __attribute__((export_name("__wokwi_api_version_1"))) __attribute__((weak)) __wokwi_api_version_1(void) { return 1; } + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int32_t pin_t; +#define NO_PIN ((pin_t)-1) + +typedef struct { + void *user_data; + uint32_t edge; + void (*pin_change)(void *user_data, pin_t pin, uint32_t value); +} pin_watch_config_t; + +extern __attribute__((export_name("chipInit"))) void chip_init(void); + +extern __attribute__((import_name("pinInit"))) pin_t pin_init(const char *name, uint32_t mode); + +extern __attribute__((import_name("pinRead"))) uint32_t pin_read(pin_t pin); +extern __attribute__((import_name("pinWrite"))) void pin_write(pin_t pin, uint32_t value); +extern __attribute__((import_name("pinWatch"))) bool pin_watch(pin_t pin, const pin_watch_config_t *config); +extern __attribute__((import_name("pinWatchStop"))) void pin_watch_stop(pin_t pin); +extern __attribute__((import_name("pinMode"))) void pin_mode(pin_t pin, uint32_t value); +extern __attribute__((import_name("pinADCRead"))) float pin_adc_read(pin_t pin); +extern __attribute__((import_name("pinDACWrite"))) float pin_dac_write(pin_t pin, float voltage); + +extern __attribute__((import_name("attrInit"))) uint32_t attr_init(const char *name, uint32_t default_value); +extern __attribute__((import_name("attrInit"))) uint32_t attr_init_float(const char *name, float default_value); +extern __attribute__((import_name("attrRead"))) uint32_t attr_read(uint32_t attr_id); +extern __attribute__((import_name("attrReadFloat"))) float attr_read_float(uint32_t attr_id); + +typedef struct { + void *user_data; + uint32_t address; + pin_t scl; + pin_t sda; + bool (*connect)(void *user_data, uint32_t address, bool connect); + uint8_t (*read)(void *user_data); + bool (*write)(void *user_data, uint8_t data); + void (*disconnect)(void *user_data); + uint32_t reserved[8]; +} i2c_config_t; + +typedef uint32_t i2c_dev_t; + +extern __attribute__((import_name("i2cInit"))) i2c_dev_t i2c_init(const i2c_config_t *config); + +typedef struct { + void *user_data; + pin_t rx; + pin_t tx; + uint32_t baud_rate; + void (*rx_data)(void *user_data, uint8_t byte); + void (*write_done)(void *user_data); + uint32_t reserved[8]; +} uart_config_t; + +typedef uint32_t uart_dev_t; + +extern __attribute__((import_name("uartInit"))) uart_dev_t uart_init(const uart_config_t *config); +extern __attribute__((import_name("uartWrite"))) bool uart_write(uart_dev_t uart, uint8_t *buffer, uint32_t count); + +typedef struct { + void *user_data; + pin_t sck; + pin_t mosi; + pin_t miso; + uint32_t mode; + void (*done)(void *user_data, uint8_t *buffer, uint32_t count); + uint32_t reserved[8]; +} spi_config_t; +typedef uint32_t spi_dev_t; + +extern __attribute__((import_name("spiInit"))) spi_dev_t spi_init(const spi_config_t *spi_config); +extern __attribute__((import_name("spiStart"))) void spi_start(const spi_dev_t spi, uint8_t *buffer, uint32_t count); +extern __attribute__((import_name("spiStop"))) void spi_stop(const spi_dev_t spi); + +typedef struct { + void *user_data; + void (*callback)(void *user_data); + uint32_t reserved[8]; +} timer_config_t; + +typedef uint32_t timer_t; + +extern __attribute__((import_name("timerInit"))) timer_t timer_init(const timer_config_t *config); +extern __attribute__((import_name("timerStart"))) void timer_start(const timer_t timer, uint32_t micros, bool repeat); +extern __attribute__((import_name("timerStartNanos"))) void timer_start_ns_d(const timer_t timer, double nanos, bool repeat); +static void timer_start_ns(const timer_t timer, uint64_t nanos, bool repeat) { + timer_start_ns_d(timer, (double)nanos, repeat); +} +extern __attribute__((import_name("timerStop"))) void timer_stop(const timer_t timer); + +extern __attribute__((import_name("getSimNanos"))) double get_sim_nanos_d(void); + +static uint64_t get_sim_nanos(void) { + return (uint64_t)get_sim_nanos_d(); +} + +typedef uint32_t buffer_t; +extern __attribute__((import_name("framebufferInit"))) buffer_t framebuffer_init(uint32_t *pixel_width, uint32_t *pixel_height); +extern __attribute__((import_name("bufferRead"))) void buffer_read(buffer_t buffer, uint32_t offset, uint8_t *data, uint32_t data_len); +extern __attribute__((import_name("bufferWrite"))) void buffer_write(buffer_t buffer, uint32_t offset, uint8_t *data, uint32_t data_len); + +#ifdef __cplusplus +} +#endif + +#endif /* WOKWI_API_H */ diff --git a/test/logic/build/arduino.avr.uno/logic.ino.eep b/test/logic/build/arduino.avr.uno/logic.ino.eep new file mode 100644 index 0000000..1996e8f --- /dev/null +++ b/test/logic/build/arduino.avr.uno/logic.ino.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/test/logic/build/arduino.avr.uno/logic.ino.elf b/test/logic/build/arduino.avr.uno/logic.ino.elf new file mode 100644 index 0000000000000000000000000000000000000000..7e76abd80e48aa2a90396190273f71d0b48f277c GIT binary patch literal 9832 zcmd6seQcY@eaG*fhmuH1p(HDH9KXc0CBG#hDav|FVq2z2TBfbHkdo~d>u8F4B(dV# zNXmAzB$gbdO}k;SM6YSnZE=IHL5E?D+cfLaymrA}fNdVuVQ7b7^?(-WumOv<4Bggj z+V^+Q^N^>Dw-ng^*g<#q`+e?rcfY%Pp1b3t%aM^2oO5Oejm4R*^#H!v!B`#g9_C>h zJILCYTa=gW3dmnY1&U;+AyWM=AuK^bL~tS2BT`xOwI0M1|BHC?XR6!Qx%>5-|M&@eU$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uZ zmHIan{Wa)z|K!ixRNo37+8Zig!kd~0< z%PZ;R&oSuse3Blea_cpt@fpx<|EYe7%BA_Z480RR(MGuivT^zG0$oTdZR|6b^|@o+YXvDDVv!49EZ z9?uwbdyDg6zI&*?^#;=TMx}CEkGN7lq38?H?K>pR-$kYT3F!C}f!cpoC^RYNeBMy( zSt6A&lEuVyspQKu-%P%yC-7CYSXNjjpD*AOuh9^yzanNTAd7S@7$!@_Y8<*(rY*ofLpsF08MyJsk?pC;xEEdSF z=7N!%soC~Hlw03ac(`WQP4Wz`6s3e|g4wsEk@3*!+xTod)>~^N5P&SMb%~D!dP)W^ zZ<)viBUg?s<}OHPQon(Ii9b-23Ck-F)%+DW4z({p0GK+TR zq7S!o-;8k~oift7S$g>mT*?zk+=KB|#a1^JO-~n%3w8;;LAHz+Ia^iWg3UAelr37# zik;|ZOT_=oU@EpSoFQH2Hdd{StyhFSNJ+MDb9BDhcLXx9s~vz$Te;jGK7&+)-QN8m zBx8a_pnlsdnKCM)NOv*$#u$d(aWFer#}FF>u-m4xr(kEFk)&J43;Q@^+3sD~#q2_< zjP7i*-4L#wSM0${WptO5?cT;9-a(sou*;rM?5^L*7~K=?V2^{&9lH*dy$`!5#blb6 zcG(vdyX9?|7rRg@qn|etW^dii7)-0dE~B}Zx?!#k#$Kvg)!HC?X?W}%v{$I3bC0om V5NRAF)0)fejqGOZH3``L{ujxWIHUjo literal 0 HcmV?d00001 diff --git a/test/logic/build/arduino.avr.uno/logic.ino.hex b/test/logic/build/arduino.avr.uno/logic.ino.hex new file mode 100644 index 0000000..6cf1da1 --- /dev/null +++ b/test/logic/build/arduino.avr.uno/logic.ino.hex @@ -0,0 +1,29 @@ +:100000000C9434000C9446000C9446000C9446006A +:100010000C9446000C9446000C9446000C94460048 +:100020000C9446000C9446000C9446000C94460038 +:100030000C9446000C9446000C9446000C94460028 +:100040000C9448000C9446000C9446000C94460016 +:100050000C9446000C9446000C9446000C94460008 +:100060000C9446000C94460011241FBECFEFD8E03C +:10007000DEBFCDBF21E0A0E0B1E001C01D92A930FC +:10008000B207E1F70E9492000C94DC000C9400008F +:100090001F920F920FB60F9211242F933F938F93BD +:1000A0009F93AF93BF938091050190910601A0911A +:1000B0000701B09108013091040123E0230F2D378F +:1000C00058F50196A11DB11D2093040180930501EF +:1000D00090930601A0930701B0930801809100015D +:1000E00090910101A0910201B09103010196A11D1F +:1000F000B11D8093000190930101A0930201B09380 +:100100000301BF91AF919F918F913F912F910F90DC +:100110000FBE0F901F90189526E8230F0296A11D81 +:10012000B11DD2CF789484B5826084BD84B58160DE +:1001300084BD85B5826085BD85B5816085BD8091B2 +:100140006E00816080936E0010928100809181002A +:100150008260809381008091810081608093810022 +:10016000809180008160809380008091B1008460E4 +:100170008093B1008091B00081608093B000809145 +:100180007A00846080937A0080917A008260809304 +:100190007A0080917A00816080937A0080917A0061 +:1001A000806880937A001092C100C0E0D0E0209770 +:0C01B000F1F30E940000FBCFF894FFCF99 +:00000001FF diff --git a/test/logic/build/arduino.avr.uno/logic.ino.with_bootloader.bin b/test/logic/build/arduino.avr.uno/logic.ino.with_bootloader.bin new file mode 100644 index 0000000000000000000000000000000000000000..cadf07efa3289dd70d06686a76b41b6873dcdc9c GIT binary patch literal 32768 zcmeI*L2MgE6b9g#BqT1fvRQX0Ct7aYQjm~xq2*X|8aunG zD?#G%tdl4ll5!}mI3z|&dqBh+gb+xeo%GZL#A8)zQzVE>-8d>O=B<6;iUh}hr5*qC z{N5Zs?R}!&D2sY;{D=3=e>H0-6Pv-_ZL?GUseII|nv&suyl{Qw%bseZ*DKH&Khw)t zqF@!Q8&<(irqyXRuU6EWDk~wM;d$B3S7i@hmk~Z9yZE3Pv`&t{^N258iI?I7s*4Ln zU5dICb*Ts!lF<~WsScXz&(gC-sbKmY;|fB*y_009U< z00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa z0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2teR} z6|j@e&F42W&6;*icwc#zR-fgnLT#~G%HJ?S`CB$;e$X#1&zgZdr}m^7Q7#)$4qNzY z{nNjK`0}-4=Ir&xkI7$>x#WzuVZKORsV=7;nsVwhof&<%zM>=PHQg~`*Z728cj)f- z8S{z0>}N-5SMBuO(Ia)&T-CyN$3Cj(^lqw|bZMr~^rhKQ@A1TOX4#23J;g8hvtvi; zguE7JCvaXpRD0e3P+y?l52*6}VR7$vcdWk8Z*J}ueY0)e)0b8Bg=(W_g2T0YmF`%r z{oj=Cxxt=14X*O=F8UL4#MlcTOM5YImeRSQ?64YsZs9SH@=J7%oqTI@^2`IXI#KR< zyRpwdr&@b@kTxA`Q