How thethirdone/rars works
Main Components
• Assembler Module:
• Components: Tokenizer, parser, macro processor (see src/rars/assembler with classes like Assembler.java, Macro.java, Tokenizer.java, etc.), and support for multiple file assembly.
• Inputs: Assembly source code (from examples/ and test/ directories).
• Outputs: Machine code / intermediate representations that feed into the simulation engine.
• Simulator / Runtime Engine:
• Components: Simulation core in src/rars/simulator (Simulator.java and its supporting classes) that emulates program execution.
• Interactions: Communicates with the hardware simulation module to manipulate memory, registers, and interrupts.
• RISC-V Instruction Set & Hardware Simulation:
• Components: Packages under src/rars/riscv including:
• Instructions (classes for ADD, SUB, Branch, etc. under src/rars/riscv/instructions).
• System call definitions (in src/rars/riscv/syscalls).
• Hardware emulation components (in src/rars/riscv/hardware such as Memory.java, RegisterFile.java, and InterruptController.java).
• Role: Defines the behavior of individual instructions and low-level hardware mimicking.
• Graphical User Interface (GUI) & Debugger:
• Components: Located in the src/rars/venus package, the ‘venus’ module handles editor windows, registers display (src/rars/venus/registers), and simulation controls.
• Features: Editing, debugging (breakpoints, stepping), visualizations of memory segments, and user interaction panels.
• Plug-in Tools & Extensions:
• Components: src/rars/tools contains various simulators and visualization tools (e.g., CacheSimulator, TimerTool, BitmapDisplay).
• Interactions: They may hook into the simulation runtime showing modularity and extensibility.
• API and Configuration:
• Components: src/rars/api (to expose programmatic access) and configuration files (e.g., Config.properties, Settings.properties, Syscall.properties) that manage runtime and system configurations.
• Role: Allow integration and customization of the simulator’s behavior.
Interactions & Relationships
• The user interacts (via the GUI or CLI launcher like Launch.java) with the front-end.
• Front-end modules (from the venus package) send assembly source and simulation commands to the core assembler and simulator.
• The Assembler module (scanner, parser, macro expansion) converts code into machine-level instructions.
• The Simulator executes these instructions by invoking the RISC-V instruction classes, which in turn interact with the hardware simulation layer.
• The hardware layer manages memory, registers, and device simulation, ensuring that system calls (found in the syscalls module) correctly mimic operating system behavior.
• Tools and utilities are available as plug-ins, visible in their own module (src/rars/tools), and can be hot-loaded to extend the instruction set or functionality.
• The API provides programmatic control and extension points, and the configuration files set parameters for various components at runtime.
Architectural Patterns and Design Principles
• Modular Design: Clear separation into modules for assembling, running, and interacting with programs.
• Extensibility: The Tools package indicates use of plug-in architecture, and instructions being hot-loaded shows dynamic compenents.
• Configuration Driven: The presence of many properties files signals that runtime behavior is heavily configurable.