Skip to content

Latest commit

 

History

History
91 lines (62 loc) · 1.48 KB

File metadata and controls

91 lines (62 loc) · 1.48 KB

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