How chipsalliance/rocket-chip works
Main Components
• Core Generator & Infrastructure: Represent the Scala-based generators found under src/main/scala. These include key packages such as:
– rocket: Implements the core Rocket pipeline (ALU, branch predictor, caches, etc).
– tile: Contains components that extend the core with additional functionality (e.g., FPUs, peripherals).
– subsystem & system: Assemble cores, buses, and interconnects into a full system-on-chip (SoC).
– diplomacy & tilelink: Handle parameter negotiation between modules and generate bus protocols.
– util, regmapper, and interrupts: Provide supporting utilities and interface definitions.
• External Submodules: Show the external Git submodules (chisel3, firrtl, hardfloat, rocket-tools, torture) as distinct components that feed into the generator.
• Simulation & Verification Infrastructure: Include directories like bootrom, regression, scripts, and csrc that support simulation (via Verilator, VCS, or other Verilog simulation tools) and testing.
• Build & Configuration Tools: Note files and directories for build scripts (Makefile, build.sc) and environment configuration (flake.lock, flake.nix, overlay.nix, etc).
Out Relationships and Data Flow
• SoC Assembly: Illustrate how individual hardware modules (rocket core, caches, debug units, peripheral devices, bus bridges) are interconnected using the diplomacy and TileLink/AMBA bus infrastructure. Indicate directional data/control flows between these modules.
• Testing & Simulation: Represent the simulation flow—where the generated RTL is passed on to test harnesses (found in directories like regression, unittest, bootrom, and scripts) to run verification through cycle-accurate simulations.
Architectural Patterns and Technologies
• Modularity & Reuse: Emphasize the separation between generator (Scala/Chisel code) and the hardware being generated. The design employs a “generator pattern” where highly parameterized modules get stitched together.
• Negotiation via Diplomacy: Point out that many bus interconnects and adapters (including AMBA, AXI4, AHB-lite, APB, TileLink) are created using a two-phase hardware elaboration pattern provided by the diplomacy package.
• Build & Test Automation: Include CI/CD aspects (GitHub workflows, CI scripts) and explain their integration with regression suites and simulation environments.
• Toolchain Integration: Note that a build system (using tools like Make and mill) coordinates code generation, simulation, and even integration with IDEs (via mill-bsp) and Nix-based environment management.