This is a python model of the RISC-V ISA. It is intended to be a resource for Python-based automated testing and verification. It is under development and not very useful yet, but can be used to generate random assembler code.
Documentation: https://riscv-python-model.readthedocs.io/en/latest/
Quick Start
First install it:
pip3 install riscv-model
Create random assembler sequences
Create a random assembler sequence:
riscv-random-asm
You can tweak the assembler output:
usage: riscv-random-asm [-h]
[-i {add,sub,sll,slt,sltu,xor,srl,sra,or,and,jalr,addi,slti,sltiu,xori,ori,andi,lb,lh,lw,lbu,lhu,slli,srli,srai,sb,sh,sw,beq,bne,blt,bge,bltu,bgeu,lui,auipc,jal}]
[--version]
[N]
Generate sequence of assembler instructions.
positional arguments:
N Number of assembler instructions
optional arguments:
-h, --help show this help message and exit
-i {add,sub,sll,slt,sltu,xor,srl,sra,or,and,jalr,addi,slti,sltiu,xori,ori,andi,lb,lh,lw,lbu,lhu,slli,srli,srai,sb,sh,sw,beq,bne,blt,bge,bltu,bgeu,lui,auipc,jal}
Restrict to instructions
--version Display version
For example to generate 100 assembler instructions only with add, or and slti instructions:
riscv-random-asm 100 -i add -i or -i slti
Disassemble machine code
You can disassemble a machine code to the assembly code on instruction level:
riscv-machinsn-decode hexstring 0x007938b3 0xc9650993
You can also directly disassemble object files:
riscv-machinsn-decode objfile file.o
Automatically test random assembler sequences
riscv-random-asm-check generates random assembler sequences, compiles them, reads back the machine codes and matches them. You can use that to test your compiler, but it is also used as sanity check for riscv-model itself.
riscv-random-asm-check
It will by default use riscv32-unknown-elf-gcc and riscv32-unknown-elf-objcopy, but you can configure the tools with --compiler and --objcopy.
The automated tests will test all instructions, you can again restrict the number of instructions and the instructions:
riscv-random-asm-check 1000 -i xor
Finally, you can run the checks for the individual instructions seperately (used in combination with the other options:
riscv-random-asm-check -s
Metadata
Release files for riscv-model 0.6.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| riscv-model-0.6.6.tar.gz | 28.3 kB | Without provenance | Details for riscv-model-0.6.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| riscv_model-0.6.6-py3-none-any.whl | Python 3 | none | any | Details for riscv_model-0.6.6-py3-none-any.whl |
Total release size: 54.7 kB
Release files / riscv-model-0.6.6.tar.gz
| Download URL | riscv-model-0.6.6.tar.gz |
|---|---|
| Size | 28.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfff035b75ed36de33a99f95f1098697be308d4c7161a99407b82df22fd54d69
|
|
BLAKE2b-256 checksum How to use checksums |
10c66b3f2b3092681c5d3530455c0b7f737d46c115081df151f4c462ed4bbb7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / riscv_model-0.6.6-py3-none-any.whl
| Download URL | riscv_model-0.6.6-py3-none-any.whl |
|---|---|
| Size | 26.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94fb3c93ac74fd3fa8c82a600a4c0030fdef020a8c81423aa40e4666687349b6
|
|
BLAKE2b-256 checksum How to use checksums |
43eaecec6ebf47fdd9490460d46a9fce02e083274716abbd926c7c3be7b131c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Security for riscv-model 0.6.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.