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/samalneedi/riscv_emulator.git
cd riscv_emulator
pip install .

🚀 Usage

CLI Commands

# Assemble a file
riscv assemble program.s

# Run a binary
riscv run program.bin

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

# Disassemble a hexcode
riscv disassemble [hexcode]

Python API

from riscv_emulator import emulator

emu = emulator()
emu.assemble("program.s")
emu.load_program("program.bin")
emu.run()

📂 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.1.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.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: riscv_emulator-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 125a1344306f3dabf95b5cd076ac4cdfc01b6383d24e63e45ec92e26541d3b5f
MD5 a3f09eff4d9f353559df3334423953df
BLAKE2b-256 bbda620175a7a1071e4be0d585b7482819b7ea85f14c51b9954bfd271e91649d

See more details on using hashes here.

Provenance

The following attestation bundles were made for riscv_emulator-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: riscv_emulator-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2d24de0eab5f860e8239350643db75314be679b887a0e0887863afc9cf5b180
MD5 037d7d34690d035740599b41cd6b8c11
BLAKE2b-256 7e41dc81765783538ed84568e65d9e924cc4c93dea4a346e823a7bbf7401692f

See more details on using hashes here.

Provenance

The following attestation bundles were made for riscv_emulator-0.1.1-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