Skip to content

WaMathias/InstructionSetSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InstructionSetSimulator

Ein kleiner, einfacher RV32I Instruction Set Simulator (ISS) in Rust.

Aktuell unterstuetzte Instruktionen:

  • add, sub
  • addi
  • lw, sw
  • beq, bne
  • jal, jalr
  • lui, auipc
  • ecall (als Halt)

Das Projekt ist absichtlich kompakt gehalten: mit minimalem ELF-Loader und alternativem Textformat mit 32-Bit-Maschinenwoertern.

Ausfuehren

Ohne Argument startet ein kleines Demo-Programm:

cargo run

Mit Programmdatei:

cargo run -- program.txt

Explizit mit Flag:

cargo run -- --program program.txt

Mit Trace-Logging (pro Schritt):

cargo run -- --program program.txt --trace

Trace als JSON-Lines (eine JSON-Zeile pro Schritt):

cargo run -- --program program.txt --trace --trace-format json

Mit ELF32-Datei (RISC-V, little-endian):

cargo run -- --elf program.elf

Schrittlimit anpassen:

cargo run -- --elf program.elf --max-steps 500000

Format der Programmdatei

Eine Instruktion pro Zeile, entweder dezimal oder hex (0x...). Kommentare mit # sind erlaubt.

Beispiel:

# addi x1, x0, 5
0x00500093
# ecall
0x00000073

ELF-Loader (minimal)

Der Loader unterstuetzt absichtlich nur einen kleinen, verstaendlichen Kern:

  • ELF32
  • little-endian
  • EM_RISCV
  • PT_LOAD-Segmente

p_vaddr wird als Zieladresse in den Simulator-Speicher geladen. Der Bereich p_memsz - p_filesz wird mit 0 aufgefuellt (BSS-Verhalten).

Tests

cargo test

About

Small Instruction Set Simulator in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages