Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mackieloeffel/avr-vm
VM with JIT-compiler for ATMega32 written in Rust
https://github.com/mackieloeffel/avr-vm
avr jit rust vm
Last synced: about 1 month ago
JSON representation
VM with JIT-compiler for ATMega32 written in Rust
- Host: GitHub
- URL: https://github.com/mackieloeffel/avr-vm
- Owner: MackieLoeffel
- License: mit
- Created: 2017-02-17T10:18:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-28T11:47:34.000Z (about 6 years ago)
- Last Synced: 2024-11-21T22:34:00.958Z (about 1 month ago)
- Topics: avr, jit, rust, vm
- Language: Rust
- Size: 73.2 KB
- Stars: 113
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AVR-VM
[![Build Status](https://travis-ci.org/MackieLoeffel/avr-vm.svg?branch=master)](https://travis-ci.org/MackieLoeffel/avr-vm)This is a VM for the AVR ATmega32 microcontroller written in Rust.
It can handle most of the instructions and has support for I/O, ADC,
timer and button interrupts. It also features a JIT compiler, which
compiles the AVR bytecode to x64 machinecode at runtime. It is quite
fast, about 5x faster than the real microcontroller.This VM was built as part of an university course, so it is not under current
development. But if you want to use it and have a problem, feel free
to open an issue or a PR.Some test programs can be found in `./test`. The VM is only tested to
work with these programs. Only the instructions of these programs
are currently implemented (which are quite a few, but not all).It includes a GUI with some LEDs, buttons, two potentiometers and two
seven segment digits. There are diffent testprograms, which use
these peripherals. The wiring is roughly the one here (JTAG, ISP and
USB is missing): [Wiring](https://www4.cs.fau.de/Lehre/SS16/V_SPIC/Uebungen/Board/spicboard2_sch.pdf). It can be changed by tweaking `main.rs`.An example, how the GUI looks with the `boardtest` program running:
![boardtest](https://mackieloeffel.github.io/boardtest.gif)All characters, which are written to `UDR` by the microcontroller,
are displayed in the console.## Installation
For using this VM you need to do the following steps:
1. Clone this repository.
2. If you want to use the GUI, you need to have at least gtk 3.4
installed.3. **ONLY FOR JIT-COMPILATION:**
This project uses [Dynasm-rs](https://github.com/CensoredUsername/dynasm-rs) for the JIT-compiler, which is a
compiler plugin and needs a nightly version of the Rust compiler. A working
version can be installed using [Rustup](https://rustup.rs/):
`rustup override set nightly-2018-10-09`
Furthermore the JIT-Compiler needs to be enabled using the feature "jit",
see below.4. For running the tests and compiling C-Code and assembler to AVR
bytecode, `gcc-avr` is needed. It can be installed either from
or on Ubuntu / Debian / BashOnWindows using
`sudo apt-get install gcc-avr binutils-avr avr-libc`
If you are using a different distribution, you can probably find
an equivalent packages there.## Usage
You can execute the VM using the following command:
`cargo run --release -- ./test/boardtest/boardtest.bin`You can exucute a different binary by changing `./test/boardtest/boardtest.bin`.
### Without GUI
The GUI can be disabled using
`cargo run --release --no-default-features -- ./test/jump/jump.bin`Only the output on the console is visible then and the program
stops on the first NOP. This is useful for benchmarking the
compiler, see `./tests/jump/jump-time` for an example program used
for benchmarking.### Use the JIT compiler
The JIT-Compiler can be enabled with the following flags:
`cargo run --release --features jit -- ./test/jump/jump.bin`You need to make sure, that you are using a nightly version of the
Rust compiler, if you want to use the JIT-compiler. For
instructions, which version to use, see above.## Material
- [Instruction Set](http://www.atmel.com/images/Atmel-0856-AVR-Instruction-Set-Manual.pdf)
- [Hardware Description](http://www.atmel.com/images/doc2503.pdf)