Skip to main content

A Python-based RISC-V assembler, emulator, disassembler, and debugger

Project description

🖥️ RISC-V Emulator

A simple RISC-V assembler, emulator, and disassembler written in Python.
It can be used both as a command-line tool and as a Python library.


✨ Features

  • Assemble .s RISC-V assembly files into binary machine code
  • Run binary files on a simple RISC-V CPU emulator
  • Disassemble binary files back into readable assembly
  • One-step assemble-and-run mode
  • Works as both CLI tool and importable Python package

📦 Installation

From PyPI:

pip install riscv-emulator

From source:

git clone https://github.com/yourusername/riscv_emulator.git
cd riscv_emulator
pip install .

🚀 Usage

CLI Commands

# Assemble a file
riscv assemble program.s -o program.bin

# Run a binary
riscv run program.bin

# Assemble and run in one step
riscv full program.s

# Disassemble a binary
riscv disassemble program.bin

Python API

from riscv_emulator import assemble, emulator, disassemble

# Assemble
assemble("program.s", "program.bin")

# Run
emu = emulator()
emu.load_program("program.bin")
emu.run()

# Disassemble
disassemble("program.bin")

📂 Project Structure

riscv_emulator/
├── riscv_emulator/
│   ├── __init__.py
│   ├── assembler.py
│   ├── debugger.py
│   ├── disassembler.py
│   ├── emulator.py
│   ├── main.py
├── README.md
├── pyproject.toml
├── LICENSE

📝 License

This project is licensed under the terms of the MIT License.
See the LICENSE file for details.


💡 Example

Example assembly file (program.s):

addi x1, zero, 3
addi x2, zero, 4
add  x3, x1, x2

Run it:

riscv full program.s

🤝 Contributing

Pull requests are welcome!
If you find a bug or have a feature request, please open an issue on GitHub.


🛠 Requirements

  • Python 3.8+
  • No external dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

riscv_emulator-0.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

riscv_emulator-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file riscv_emulator-0.1.0.tar.gz.

File metadata

  • Download URL: riscv_emulator-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for riscv_emulator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1dc91728c8d05c8e67196ab163052fcd9602073a5815d678728bde96a2233fab
MD5 f33b674c433fd3eb6d6f54868249384a
BLAKE2b-256 aed44209579dd4d6c41de5ef4027381b857ccabfd85255d7bc4f8e6c8d43cf1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for riscv_emulator-0.1.0.tar.gz:

Publisher: publish.yml on sadaveek/riscv-emulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file riscv_emulator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: riscv_emulator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for riscv_emulator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b78a9fde4a76f7da194dce45cff38fb5f84eb3b6627c48d4b9b571f86479417a
MD5 5ecd547d2d4fecf0e3d9822227a9b287
BLAKE2b-256 368c8f1200a374f76151ad09af2b47e116221698bd3c3b3de50b28f0ed1dcf00

See more details on using hashes here.

Provenance

The following attestation bundles were made for riscv_emulator-0.1.0-py3-none-any.whl:

Publisher: publish.yml on sadaveek/riscv-emulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page