> For the complete documentation index, see [llms.txt](https://kingfish404.github.io/raptor-chip/llms.txt).

# Ecosystem

Simulators, FPGA boards, ASIC flow, software stack, and memory maps.

## Supported Targets

| Target      | Purpose                           | Entry                                                         |
| ----------- | --------------------------------- | ------------------------------------------------------------- |
| NEMU        | Software ISS (difftest reference) | `nemu/README.md`                                              |
| NPC         | Verilator simulator               | `sim/`                                                        |
| FPGA        | Board builds and LiteX SoCs | [FPGA support](https://github.com/Kingfish404/raptor-chip/blob/master/fpga/README.md) |
| ASIC (open) | Yosys + OpenSTA flow              | [yosys-opensta](https://github.com/Kingfish404/yosys-opensta) |

## Simulators

| Simulator   | Role                                     | Entry                      |
| ----------- | ---------------------------------------- | -------------------------- |
| **NEMU**    | Software ISS, reference model            | `make run-nemu32`, `nemu/` |
| **NPC**     | Verilator, cycle-accurate, waveform      | `make run-rv32`, `sim/`    |
| **raptSoC** | SystemVerilog NPC top + AXI memory model | `sim/rtl/rapt_npc_soc.sv`  |

NPC is the primary RTL simulator. With `DIFFTEST=1` (the default), NEMU checks
retired architectural state, including all 32 vector registers and seven vector
CSRs on vector-enabled builds. The default RV64 configuration also compares
hypervisor and virtual-supervisor CSR state. The differential-test protocol
handles MMIO and interrupt skip paths. The RVV reference matches the default
VLEN of 128 bits.

## FPGA Targets

| Board / Flow                   | Status                                                                  | Entry                                        |
| ------------------------------ | ----------------------------------------------------------------------- | -------------------------------------------- |
| **MLK-CU08-KU15P** | RV32/RV64, UART boot, BRAM or DDR4 MIG | `fpga/mlk-cu08-ku15p/` |
| **RK-XCKU5P-F V1.2** | RV32/RV64, UART boot, BRAM or 32-bit DDR4 | `fpga/rk-xcku5p-f/` |
| **MLK-CU08-KU15P / LiteX**     | Primary: Vivado, MIG DDR4, SD, CM005 Ethernet, RV32/RV64 Linux/netboot  | `fpga/litex/`                                |
| **MLK-CU07-KU15P / LiteX**     | Vivado, BIOS, MIG DDR4, SDCard, RV32 Linux boot                         | `fpga/litex/`                                |
| **Alinx AXAU15 / LiteX**       | Vivado AU15P, auto-detected when that part is on the cable              | `fpga/litex/`                                |
| **Xilinx VCU118 / LiteX**      | Vivado VU9P, auto-detected when that part is on the cable               | `fpga/litex/`                                |
| **Tang Mega 138K Pro / LiteX** | Gowin LiteX FPGA flow                                                   | `fpga/litex/`                                |
| **OOC partitions**             | Frontend/backend/cache checkpoints, not a board flow                    | `fpga/ooc/README.md`                         |

Root `make fpga-synth` and `make fpga-build` select CU08-KU15P by default;
use `FPGA_BOARD=rk-xcku5p-f` for RK. For Linux over Ethernet on either board,
follow the [netboot instructions](https://kingfish404.github.io/raptor-chip/linux_kernel.html.md#fpga-netboot).
For RVV, select `default`, `default-*` or `large`. Use the routed timing report
for the chosen preset and board. The board build options are in the
[FPGA guide](https://github.com/Kingfish404/raptor-chip/blob/master/fpga/README.md).

The native KU5P and CU08-KU15P SoCs provide an RV64 Ubuntu flow over TFTP
and NFS. Optional native I/O adds a VirtIO-MMIO NIC and host-backed block
devices. See [Ubuntu on native FPGA SoCs](https://kingfish404.github.io/raptor-chip/linux_kernel.html.md#ubuntu-on-native-fpga-socs).

## ASIC Flow

- **Synthesis**: [Yosys](https://github.com/YosysHQ/yosys) with
  [yosys-slang](https://github.com/povik/yosys-slang) front-end for SystemVerilog.
- **STA**: [yosys-opensta](https://github.com/Kingfish404/yosys-opensta) - open-source
  static timing analysis (`make sta`).
- **PDK**: open-source cell libraries; PPA results published under
  [openppa](https://github.com/Kingfish404/openppa).

See **[REFERENCE.md](https://kingfish404.github.io/raptor-chip/REFERENCE.html.md)** for the PPA benchmark framework.
Record the source revision, configuration, XLEN, memory model, and constraints
with each timing or area measurement.

## Software Stack

| Layer      | Component                                                    | Notes                                              |
| ---------- | ------------------------------------------------------------ | -------------------------------------------------- |
| App        | CoreMark, MicroBench, Embench-IoT, busybox, demos            | `app/`, `abstract-machine/app/`                    |
| User OS    | nanos-lite (simple OS), Linux v6.18 userspace                | `abstract-machine/app/nanos-lite`                  |
| ABI / libc | riscv-pk (proxy kernel), AM runtime, newlib, glibc           | `app/pk/`, `abstract-machine/`                     |
| Kernel     | Linux v6.18.51 prebuilt by default (`linux/vars.mk`)         | `linux/`, see [linux_kernel.md](https://kingfish404.github.io/raptor-chip/linux_kernel.html.md) |
| Firmware   | OpenSBI v1.8 (in-tree `third_party/.../opensbi`)             | `linux/opensbi/`                                   |
| Bootrom    | NPC / raptSoC reset vector                                   | `nemu/src/memory/rom/`                             |

## Physical Address Contract

The default physical address width is 32 bits for both XLEN modes. RV64 permits
`RAPT_PADDR_BITS=32..38` (`default-pa38` selects 38); RV32 requires 32. The
architectural Sv39 PPN encoding stays intact, and unsupported addresses fault
before cache lookup can alias. RV64 stores PCs/fetch targets in 40 bits and
sign-extends them to XLEN; `RAPT_PC_FULL_WIDTH` retains full-width storage.
These storage choices do not enlarge the platform PMA windows below.

[`rtl/configs/memory_map.json`](https://github.com/Kingfish404/raptor-chip/blob/master/rtl/configs/memory_map.json) records the shared 32-bit physical addresses and the main RAM
capacity of each board or simulator profile. The window starts at `0x80000000`.
KU15P CU07/CU08 with MIG map 2 GiB through `0xffffffff`; RV32 and RV64 use
the same hardware map. RV32 Linux advertises only the lower 1 GiB in its device
tree until high-memory support is validated. KU15P LiteDRAM and AXAU15 MIG
map 1 GiB. Other board capacities are listed in the JSON file.

`make memory-map-check` cross-checks the contract against RTL, LiteX, firmware,
NPC and NEMU constants, and that the generated [`app/lib/raptor_platform.h`](https://github.com/Kingfish404/raptor-chip/blob/master/app/lib/raptor_platform.h) is current.
Guest test programs include that header (`RAPTOR_<REGION>_BASE`/`_SIZE`,
`RAPTOR_PTE()`) instead of copying addresses; the verify Makefile adds
`-I app/lib` to every guest compile. The generator and checker live in
`verification/scripts/`. After editing the JSON, run
`make memory-map-header`. The FPGA build also validates the selected hardware
and Linux RAM sizes. When changing a region or capacity, update the JSON and
the affected implementation together, then rerun the checker and focused
regressions.

The optional `SIM_MEM_PROFILE=large` NPC profile and matching NEMU
`riscv32_ref_2g_defconfig` / `riscv64_ref_2g_defconfig` map 2 GiB of sparse
RAM. Their default profiles use smaller RAM windows. In the
large profile, `0xa0000000` is RAM, not a separate SDRAM or software
MMIO region. LiteX UART is at `0x11001800`; high addresses within the large-profile RAM window access memory.

The RV32/RV64 boundary test in `app/tests/baremetal/pmem_2g_boundaries.S`
checks the upper RAM windows and that high RAM addresses do not alias UART.
See the [simulation guide](https://github.com/Kingfish404/raptor-chip/blob/master/sim/README.md)
for running the large-memory profile. Board DDR validation and routed timing
remain separate from simulator checks.

## NPC Memory Map

`npc_soc` peripherals and address ranges for the default memory profile:

| Device             | Range                       |
| ------------------ | --------------------------- |
| Finisher           | `0x0010_0000 - 0x0010_0fff` |
| CLINT              | `0x0200_0000 - 0x020b_ffff` |
| PLIC               | `0x0c00_0000 - 0x0cff_ffff` |
| SRAM               | `0x0f00_0000 - 0x0f00_1fff` |
| UART / peripherals | `0x1000_0000 - 0x1001_1fff` |
| MROM               | `0x2000_0000 - 0x2000_ffff` |
| Flash              | `0x3000_0000 - 0x3fff_ffff` |
| PMEM (main memory) | `0x8000_0000 - 0x8fff_ffff` |
| SDRAM              | `0xa000_0000 - 0xa1ff_ffff` |

Reset vector `PC_INIT` = `0x2000_0000` (MROM).

## Random Memory-Delay Simulation

Use `make microbench-rv32 SIM_RANDOM_DELAY=31` or `make coremark-rv64 SIM_RANDOM_DELAY=31` with
`SIM_RANDOM_DELAY=31 SIM_RANDOM_SEED=42` to exercise reproducible AXI memory
wait states. `cpu-tests-rv32` / `cpu-tests-rv64` run AM CPU tests
under the same delay model. These targets use the NPC memory map above.

## Upstream & Related Projects

- [NJU-ProjectN/NEMU](https://github.com/NJU-ProjectN/nemu) - reference ISS.
- [NJU-ProjectN/abstract-machine](https://github.com/NJU-ProjectN/abstract-machine) - AM runtime.
- [riscv-software-src/opensbi](https://github.com/riscv-software-src/opensbi) - SBI firmware.
- [enjoy-digital/litex](https://github.com/enjoy-digital/litex) - FPGA SoC framework.
- [OpenXiangShan/XiangShan](https://github.com/OpenXiangShan/XiangShan) - inspirational reference.
