{"id":20008210,"url":"https://github.com/zigembeddedgroup/aviron","last_synced_at":"2025-05-04T19:34:39.206Z","repository":{"id":189051093,"uuid":"674982669","full_name":"ZigEmbeddedGroup/aviron","owner":"ZigEmbeddedGroup","description":"Configurable AVR simulator","archived":false,"fork":false,"pushed_at":"2024-01-15T10:21:50.000Z","size":1587,"stargazers_count":13,"open_issues_count":6,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-05-17T11:43:14.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZigEmbeddedGroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-08-05T11:35:36.000Z","updated_at":"2023-09-25T22:40:00.000Z","dependencies_parsed_at":"2023-08-27T21:39:05.142Z","dependency_job_id":"6c8e61be-7fea-493f-8c23-127ed4d737d5","html_url":"https://github.com/ZigEmbeddedGroup/aviron","commit_stats":null,"previous_names":["superauguste/aviron","zigembeddedgroup/aviron"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigEmbeddedGroup%2Faviron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigEmbeddedGroup%2Faviron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigEmbeddedGroup%2Faviron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigEmbeddedGroup%2Faviron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZigEmbeddedGroup","download_url":"https://codeload.github.com/ZigEmbeddedGroup/aviron/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224406191,"owners_count":17305725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T07:08:53.814Z","updated_at":"2025-05-04T19:34:39.193Z","avatar_url":"https://github.com/ZigEmbeddedGroup.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AViRon\n\nThis repo is now found [here](https://github.com/ZigEmbeddedGroup/microzig/tree/main/simulators/aviron)\n\nAVR simulator in Zig.\n\n\u003e DISCLAIMER: This is work in project and can currently emulate a good amount of the AVR instruction set without cycle counting.\n\n## Development\n\nUse [Zig 0.14.0](https://ziglang.org/download/#release-0.14.0) to compile AViRon.\n\n### Repo Architecture\n\n```sh\n.\n├── doc                 # Documents for Aviron or AVR \n├── samples             # Source of examples that can be run on the simulator\n├── src                 # Source code\n│   ├── lib             # - Aviron emulator\n│   ├── libtestsuite    # - Source code of the testsuite library\n│   └── shared          # - Shared code between the tools, generated code and simulator\n├── testsuite           # Contains the test suite of Aviron\n│   ├── instructions    # - Tests for single instructions\n│   ├── lib             # - Tests for the libtestsuie  \n│   ├── simulator       # - Tests for the simulator per se \n│   └── testrunner      # - Tests for the test runner (conditions, checks, ...)\n├── testsuite.avr-gcc   # Contains code for the test suite that cannot be built with LLVM right now\n│   └── instructions\n└── tools               # Code for tooling we need during development, but not for deployment\n```\n\n### Tests\n\nRun the test suite by invoking\n\n```sh-session\n[~/projects/aviron]$ zig build test\n[~/projects/aviron]$ \n```\n\nThe `test` step will recursively scan the folder `testsuite` for files of the following types:\n\n- *compile* `.S`\n- *compile* `.c`\n- *compile* `.cpp`\n- *compile* `.zig`\n- *load* `.bin`\n- *load* `.elf`\n\nFile extensions marked *compile* will be compiled or assembled with the Zig compiler, then executed with the test runner. Those files allow embedding a JSON configuration via Zig file documentation comments:\n\n```zig\n//! {\n//!   \"stdout\": \"hello\",\n//!   \"stderr\": \"world\"\n//! }\nconst testsuite = @import(\"testsuite\");\n\nexport fn _start() callconv(.C) noreturn {\n    testsuite.write(.stdout, \"hello\");\n    testsuite.write(.stderr, \"world\");\n    testsuite.exit(0);\n}\n```\n\nFor files marked as *load*, another companion file `.bin.json` or similar contains the configuration for this test.\n\nThe [JSON schema](src/testconfig.zig) allows description of how the file is built and the test runner is executed. It also contains a set of pre- and postconditions that can be used to set up the CPU and validate it after the program exits.\n\nIf you're not sure if your code compiled correctly, you can use the `debug-testsuite` build step to inspect the generated files:\n\n```sh-session\n[~/projects/aviron]$ zig build debug-testsuite\n[~/projects/aviron]$ tree zig-out/\nzig-out/\n├── bin\n│   └── aviron-test-runner\n└── testsuite\n    ├── instructions\n    │   ├── cbi.elf\n    │   ├── in-stdio.elf\n        ├── ...\n    │   ├── out-stdout.elf\n    │   └── sbi.elf\n    ├── lib\n    │   └── write-chan.elf\n    └── simulator\n        ├── scratch-reg0.elf\n        ├── scratch-reg1.elf\n        ├── ...\n        ├── scratch-rege.elf\n        └── scratch-regf.elf\n```\n\nYou can then disassemble those files with either `llvm-objdump` or `avr-objdump`:\n\n```sh-session\n[~/projects/aviron]$ llvm-objdump -d zig-out/testsuite/instructions/out-exit-0.elf \n\nzig-out/testsuite/instructions/out-exit-0.elf:  file format elf32-avr\n\nDisassembly of section .text:\n\n00000000 \u003c_start\u003e:\n       0: 00 27         clr     r16\n       2: 00 b9         out     0x0, r16\n       \n[~/projects/aviron]$ avr-objdump -d zig-out/testsuite/instructions/out-exit-0.elf \n\nzig-out/testsuite/instructions/out-exit-0.elf:     file format elf32-avr\n\nDisassembly of section .text:\n\n00000000 \u003c_start\u003e:\n   0:   00 27           eor     r16, r16\n   2:   00 b9           out     0x00, r16       ; 0\n\n[~/projects/aviron]$ \n```\n\nThe test runner is located at [src/testrunner.zig](src/testrunner.zig) and behaves similar to the main `aviron` executable, but introduces a good amount of checks we can use to inspect and validate the simulation.\n\n### Updating AVR-GCC tests\n\nTo prevent a hard dependency on the `avr-gcc` toolchain, we vendor the binaries for all tests defined in the folder `testsuite.avr-gcc`. To update the files, you need to invoke the `update-testsuite` build step:\n\n```sh-session\n[~/projects/aviron]$ zig build update-testsuite\n[~/projects/aviron]$ \n```\n\nAfter that, `zig build test` will run the regenerated tests.\n\n**NOTE:** The build will not detect changed files, so you have no guarantee that running `zig build update-testsuite test` will actually do the right thing. If you're working on the test suite, just use `zig build update-testsuite \u0026\u0026 zig build test` for this.\n\n## Links\n\n- https://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf\n- http://www.avr-asm-tutorial.net/avr_en/micro_beginner/instructions.html\n- https://github.com/dwelch67/avriss/blob/master/opcodes.txt\n- https://microchipdeveloper.com/8avr:status\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigembeddedgroup%2Faviron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzigembeddedgroup%2Faviron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigembeddedgroup%2Faviron/lists"}