diff --git a/.github/script/ci/changes.py b/.github/script/ci/changes.py
index 62ddb74fd..04b5f3060 100644
--- a/.github/script/ci/changes.py
+++ b/.github/script/ci/changes.py
@@ -611,6 +611,7 @@ def devkit_extra_areas(path: str) -> set:
("minicpm_v_4_7_moe", "minicpm_v_moe"): ("minicpm-v-4.7-moe",),
("minicpm_v_4_7_bf16", "minicpm_v_bf16"): ("minicpm-v-4.7-bf16",),
("minicpm_ocr",): ("minicpm-ocr",),
+ ("minicpm5_moe", "minicpm5"): ("minicpm5",),
("qwen3_6_moe",): ("qwen3.6-moe",),
# qwen3.8-dflash2 is the same engine with a draft package (Qwen3_8DFlash2 derives from Qwen3_8MTP).
("qwen3_8mtp", "qwen3_8_mtp"): ("qwen3.8-mtp", "qwen3.8-dflash2"),
diff --git a/.github/script/ci/devkit_symbol_clash.py b/.github/script/ci/devkit_symbol_clash.py
index 27b932323..671caf3f4 100755
--- a/.github/script/ci/devkit_symbol_clash.py
+++ b/.github/script/ci/devkit_symbol_clash.py
@@ -51,6 +51,9 @@
# engine. It starts empty. An HRX wait on this thread fills it and the
# completion check on that same thread reads it back.
"flm::npu::ert_failure_detail",
+ # The ELF section-name table of aie2p-launchlib's launch/txn/elf.hpp, a constant every
+ # engine that writes run ELFs (inkling2_npu, minicpm5_moe_npu) compiles from that one header.
+ "launch::txn::elf_of(launch::txn::ElfText const&)::kNames",
}
SKIPPED_LIBS = ("xrt", "boost")
diff --git a/.github/script/ci/test_changes.py b/.github/script/ci/test_changes.py
index 9020216a4..d5bc14fe7 100644
--- a/.github/script/ci/test_changes.py
+++ b/.github/script/ci/test_changes.py
@@ -1241,6 +1241,7 @@ def test_engine_library_maps_to_its_family(self):
"src/lib/xrt/libqwen3vl_flash.so": {"qwen3vl-flash"},
"src/lib/hrx/libhy_mem_npu.so": {"hy-memory"},
"src/lib/xrt/inkling2_npu.dll": {"inkling-2", "inkling-2-dflash2"},
+ "src/lib/hrx/libminicpm5_moe_npu.so": {"minicpm5"},
}
for path, expected in cases.items():
with self.subTest(path=path):
@@ -1763,9 +1764,11 @@ def test_no_source_includes_an_excluded_file(self):
def test_only_known_units_reach_host_outside_host_mk(self):
# make bitstream parses each unit's Makefile and its makefiles/*.mk.
# These name host/ (or -Ihost) outside host.mk, and were checked: the
- # Hy_* prefill_overlay regs and run.exe targets (no bitstream
- # prerequisite), and vision_overlay, which XCLBIN_NO_BITSTREAM leaves out.
- known = {"Hy_MT2_1.8B/prefill_overlay", "Hy_mem_30BA3B/prefill_overlay", "minicpm_ocr/vision_overlay"}
+ # Hy_* and MiniCPM5 prefill_overlay regs and run.exe targets (no
+ # bitstream prerequisite), and vision_overlay, which XCLBIN_NO_BITSTREAM
+ # leaves out.
+ known = {"Hy_MT2_1.8B/prefill_overlay", "Hy_mem_30BA3B/prefill_overlay", "MiniCPM5/prefill_overlay",
+ "minicpm_ocr/vision_overlay"}
seen = set()
for path in tracked(f"{XB}**/Makefile", f"{XB}**/*.mk"):
unit = path[len(XB):].rsplit("/", 1)[0].removesuffix("/makefiles")
diff --git a/docs/_config.yml b/docs/_config.yml
index e2742e9d0..32f623bf4 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -201,6 +201,8 @@ docs_nav:
url: "/docs/benchmarks/hy-memory_results/"
- label: MiniCPM-V 4.7
url: "/docs/benchmarks/minicpm-v-4.7_results/"
+ - label: MiniCPM5
+ url: "/docs/benchmarks/minicpm5_results/"
- label: Nemotron Bolt
url: "/docs/benchmarks/nemotron3.5-bolt_results/"
- label: Nemotron Bolt DFlash
diff --git a/docs/docs/benchmarks/index.md b/docs/docs/benchmarks/index.md
index 107da86a0..b00b78198 100644
--- a/docs/docs/benchmarks/index.md
+++ b/docs/docs/benchmarks/index.md
@@ -28,6 +28,7 @@ Browse detailed NPU benchmark results for each major model family supported by F
- [Hy-MT3](hy-mt3_results/) (FLM v1.0.14 or later)
- [Hy-Memory](hy-memory_results/)
- [MiniCPM-V 4.7](minicpm-v-4.7_results/)
+- [MiniCPM5](minicpm5_results/) (FLM v1.0.15 or later)
- [Nemotron Bolt](nemotron3.5-bolt_results/)
- [Nemotron Bolt DFlash](nemotron3.5-bolt-dflash_results/)
- [Flash Models](flash_results/)
diff --git a/docs/docs/benchmarks/minicpm5_results.md b/docs/docs/benchmarks/minicpm5_results.md
new file mode 100644
index 000000000..aa3c28095
--- /dev/null
+++ b/docs/docs/benchmarks/minicpm5_results.md
@@ -0,0 +1,57 @@
+---
+layout: docs
+title: MiniCPM5
+parent: Benchmarks
+nav_order: 24
+---
+
+## β‘ Performance and Efficiency Benchmarks
+
+This section reports the performance on NPU with FastFlowLM (FLM).
+
+> **Note:**
+> - Results are based on the FastFlowLM release that adds MiniCPM5-15B-A2.5B (v1.0.15).
+> - Under FLM's default NPU power mode (Performance)
+> - Decoding runs every layer (attention, router, the 16 routed experts and the shared expert) and the LM head on the NPU.
+> - Newer versions may deliver improved performance.
+
+---
+
+### **Test System:**
+
+AMD Ryzenβ’ AI MAX+ PRO 395 (Strix Halo) with 128 GB DRAM; performance is comparable to other Strix Halo and Strix Point systems.
+
+---
+
+### π Decoding Speed (TPS, or Tokens per Second, starting @ different context lengths)
+
+| **Model** | **HW** | **1k** | **2k** | **4k** | **8k** | **16k** | **32k** |
+|------------------|--------------------|--------:|--------:|--------:|--------:|---------:|---------:|
+| **MiniCPM5-15B-A2.5B** | XDNA2 | 24.9 | 24.2 | 22.7 | 20.2 | 16.7 | 12.4 |
+
+---
+
+### π Prefill Speed (TPS, or Tokens per Second, with different prompt lengths)
+
+| **Model** | **HW** | **1k** | **2k** | **4k** | **8k** | **16k** | **32k** |
+|------------------|--------------------|--------:|--------:|--------:|--------:|---------:|---------:|
+| **MiniCPM5-15B-A2.5B** | XDNA2 | 1032 | 1267 | 1331 | 1132 | 867 | 594 |
+
+---
+
+## π― Accuracy
+
+The FLM package quantizes the BF16 model to Q4_K throughout (Q8_0 LM head), using the importance matrix published by
+bartowski. KL divergence of the next-token distribution against the BF16 model (100 windows of 512 tokens):
+
+| **Weights** | **WikiText-2** | **Code** |
+|-----------------------------------------------|---------------:|---------:|
+| Official Q4_K_M GGUF (mixed Q4_K / Q6_K) | 0.053 | 0.032 |
+| All Q4_K, no importance matrix | 0.189 | 0.095 |
+| All Q4_K with the importance matrix (FLM) | 0.097 | 0.052 |
+
+> **Note:**
+> - The importance matrix halves the error of a plain all-Q4_K quantization; all-Q4_K keeps every layer on the
+> fast Q4_K NPU kernels.
+> - On the NPU (bf16 compute) the logits match a CPU run of the same Q4_K weights closely: KL 0.005 to 0.020 over
+> short chat, multi-turn, math, code, tool-call and 2.7k-token document prompts.
diff --git a/docs/docs/models/minicpm.md b/docs/docs/models/minicpm.md
index a614eb72d..03e9b4445 100644
--- a/docs/docs/models/minicpm.md
+++ b/docs/docs/models/minicpm.md
@@ -58,3 +58,34 @@ flm run minicpm-v-4.7-moe:35b-a3b
- Video and audio input are not supported. Speculative decoding (DSpark) is not used.
---
+
+## π§© Model Card: [MiniCPM5-15B-A2.5B](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B)
+
+- **Type:** Text-to-Text (Mixture of Experts: 15B parameters, about 2.5B active per token)
+- **Think:** Toggleable (on by default, as in the model's chat template)
+- **Tool Calling Support:** Yes
+- **Prefix cache (server mode):** Yes (see [Prefix Cache (Prompt Reuse)](https://fastflowlm.com/docs/instructions/server/prefix_cache/))
+- **Base Model:** [openbmb/MiniCPM5-15B-A2.5B](https://huggingface.co/openbmb/MiniCPM5-15B-A2.5B) (Apache-2.0)
+- **Quantization:** Q4_K (Q8_0 LM head), with the importance matrix from [bartowski/MiniCPM5-15B-A2.5B-GGUF](https://huggingface.co/bartowski/MiniCPM5-15B-A2.5B-GGUF)
+- **Memory:** about 16 GB at the default 128k context, up to about 21.5 GB while it holds a full 128k prompt
+- **Max Context Length:** 128k tokens
+- **Default Context Length:** 128k tokens ([change default](https://fastflowlm.com/docs/instructions/cli/#-change-default-context-length-max))
+- **[Set Context Length at Launch](https://fastflowlm.com/docs/instructions/cli/#-set-context-length-at-launch)**
+- **Minimum FLM version:** v1.0.15 (first release that supports this model)
+
+βΆοΈ Run with FastFlowLM in PowerShell:
+
+```powershell
+flm run minicpm5:15b-a2.5b
+```
+
+π **Note**
+
+- **Requires FastFlowLM v1.0.15 or later.**
+- Thinking is on unless you turn it off: `think: false` in a request, `"chat_template_kwargs": {"enable_thinking": false}` (OpenAI API), or the interactive toggle.
+- Sampling follows the model card's thinking-mode settings: temperature 1.0, top_p 0.95, min_p 0 (top_k 50).
+- Tool calls use the model's own XML format (`...`); the server returns them as OpenAI `tool_calls`.
+- Text only. Speculative decoding is not used.
+- Speeds: see [MiniCPM5 benchmarks](https://fastflowlm.com/docs/benchmarks/minicpm5_results/).
+
+---
diff --git a/docs/models.md b/docs/models.md
index 0daa5a641..3745ff631 100644
--- a/docs/models.md
+++ b/docs/models.md
@@ -11,7 +11,7 @@ sections:
FastFlowLM curates the most requested families and publishes tuned manifests under `flm pull `.
We validate every build on Ryzenβ’ AI laptops and provide matching cardsβsee them [here](/docs/models/).
The catalog already covers models spanning Qwen3.8 (27B, MTP and DFlash 2 speculative decoding), Qwen3.6 (MoE), Qwen3.5 (Vision), Gemma4 (omni), Nemotron Bolt (DFlash speculative decoding), Qwen3, GPT-OSS-20B (MoE), DeepSeek-R1, Whisper
- (Audio), Hy-MT2, Hy-MT3 (Translation), MiniCPM-V 4.7 (Vision, 1B and 35B-A3B MoE), MedGemma (Medical), Inkling-2 (Vision, 26B-A3B MoE, DFlash 2 speculative decoding), Decision 3.0 (d3-edge, d3-lite, d3-nano, d3-mini, d3-flash, d3-turbo, d3-ultra, the System One
+ (Audio), Hy-MT2, Hy-MT3 (Translation), MiniCPM-V 4.7 (Vision, 1B and 35B-A3B MoE), MiniCPM5 (15B-A2.5B MoE, tool use), MedGemma (Medical), Inkling-2 (Vision, 26B-A3B MoE, DFlash 2 speculative decoding), Decision 3.0 (d3-edge, d3-lite, d3-nano, d3-mini, d3-flash, d3-turbo, d3-ultra, the System One
decision model of vLLM Semantic Router), and other leading open families.
ctas:
- label: "View model docs"
@@ -30,6 +30,7 @@ sections:
- "Qwen3.5 (Vision)"
- "Qwen 3 (Vision)"
- "MiniCPM-V 4.7 (Vision, incl. 35B-A3B MoE)"
+ - "MiniCPM5 (MoE, tool use)"
- "Inkling-2 (Vision, MoE, tool use; DFlash 2 speculative decoding)"
- "GPT-OSS (MoE)"
- "LFM2 / LFM3 (Liquid AI)"
diff --git a/flm-dev-kit/FLM_DLL/build_minicpm5_moe.sh b/flm-dev-kit/FLM_DLL/build_minicpm5_moe.sh
new file mode 100755
index 000000000..4ac5ba816
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/build_minicpm5_moe.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/bash
+# Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+# Portions of this file consist of AI-generated content.
+
+# MiniCPM5-15B-A2.5B. Every stage runs on its own xclbin, so no host compute
+# modules (mha / gemm / dequant / lm_head) are linked; q4nx is the weight reader.
+cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" || exit 1
+failed_dirs=()
+target_dirs=(q4nx minicpm5_moe_npu)
+
+for name in "${target_dirs[@]}"; do
+ dir="detail/${name}"
+ if [ -f "${dir}/Makefile" ]; then
+ if ! (cd "$dir" && make clean && make -j4); then
+ failed_dirs+=("$dir")
+ fi
+ fi
+done
+
+if [ ${#failed_dirs[@]} -ne 0 ]; then
+ echo "Build failures in:"
+ for dir in "${failed_dirs[@]}"; do
+ echo " - $dir"
+ done
+ exit 1
+else
+ echo "All builds succeeded."
+fi
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/CMakeLists.txt b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/CMakeLists.txt
new file mode 100644
index 000000000..b5381995d
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/CMakeLists.txt
@@ -0,0 +1,177 @@
+# Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+# Portions of this file consist of AI-generated content.
+
+cmake_minimum_required(VERSION 3.22)
+project(minicpm5_moe_npu VERSION 1.0.0 LANGUAGES CXX)
+
+# Set build type to Release
+set(CMAKE_BUILD_TYPE Release)
+
+# Set C++ standard
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# Find and enable OpenMP for multi-threading
+find_package(OpenMP)
+if(OpenMP_CXX_FOUND)
+ message(STATUS "OpenMP found - enabling multi-threading support")
+else()
+ message(WARNING "OpenMP not found - optimized functions will run single-threaded")
+endif()
+
+# Force x64 architecture on Windows
+if(WIN32)
+ set(CMAKE_GENERATOR_PLATFORM x64)
+ set(CMAKE_VS_PLATFORM_NAME "x64")
+endif()
+
+# Set output directories
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../../build/minicpm5_moe_npu/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../../build/minicpm5_moe_npu/lib)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../../build/minicpm5_moe_npu/lib)
+
+# Force output directories to be absolute
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
+
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+# User-tweakable XRT settings (override on cmake command-line)
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+option(FLM_USE_HRX "Build FLM engine libs against the HRX amdxdna runtime instead of XRT" OFF)
+if(FLM_USE_HRX)
+ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/flm_hrx.cmake)
+ # Stale CMake cache can leak XRT headers into an HRX reconfigure.
+ set(XRT_INCLUDE_DIR "" CACHE PATH "Where XRT headers live" FORCE)
+ set(XRT_LIB_DIR "" CACHE PATH "Where XRT libs live" FORCE)
+ set(FLM_NPU_CORE_LIB ${HRX_LIBRARIES})
+ set(FLM_NPU_AIEBU_LIB "")
+else()
+ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/flm_xrt_win.cmake)
+ set(HRX_INCLUDE_DIRS "")
+ set(FLM_NPU_CORE_LIB xrt_coreutil)
+ set(FLM_NPU_AIEBU_LIB aiebu_static)
+endif()
+
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+# Gather your sources
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+file(GLOB SOURCES
+ "*.cpp"
+)
+file(GLOB HEADERS "../../include/*.hpp" "*.hpp")
+
+
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+# Define the library
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+add_library(minicpm5_moe_npu SHARED ${SOURCES} ${HEADERS})
+
+
+
+# HRX uses the dynamic CRT, the same one as flm and hrx. std::codecvt::id
+# then stays in msvcp140.dll, so WINDOWS_EXPORT_ALL_SYMBOLS does not publish it.
+# The XRT build links aiebu_static (/MT) and keeps the static CRT.
+if(MSVC)
+ if(FLM_USE_HRX)
+ set_property(TARGET minicpm5_moe_npu PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL")
+ target_compile_options(minicpm5_moe_npu PRIVATE $<$:/MDd>$<$>:/MD>)
+ else()
+ set_property(TARGET minicpm5_moe_npu PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>")
+ target_compile_options(minicpm5_moe_npu PRIVATE /MT$<$:d>)
+ endif()
+endif()
+
+
+set_target_properties(minicpm5_moe_npu PROPERTIES
+ PREFIX ""
+ SUFFIX ".dll"
+ IMPORT_PREFIX ""
+ IMPORT_SUFFIX ".lib"
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/../../build/minicpm5_moe_npu/lib"
+ LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/../../build/minicpm5_moe_npu/lib"
+ ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/../../build/minicpm5_moe_npu/lib"
+ WINDOWS_EXPORT_ALL_SYMBOLS ON
+)
+
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+# Library specific settings
+# βββββββββββββββββββββββββββββββββββββββββββββββ
+target_include_directories(minicpm5_moe_npu PUBLIC
+ ${CMAKE_SOURCE_DIR}/../../include
+ ${CMAKE_SOURCE_DIR}/../../../aie2p-launchlib/launchlib/include
+ ${XRT_INCLUDE_DIR} ${HRX_INCLUDE_DIRS} ${FLM_BOOST_INCLUDE_DIR}
+)
+
+# Prefill backend, same default as the Makefile: OFF = batched prefill (NPU
+# prefill_overlay), ON = the decode overlays one token at a time. See minicpm5_moe_prefill.hpp.
+option(PREFILL_WITH_MV "minicpm5_moe: token-by-token (decode-overlay) prefill" OFF)
+if(PREFILL_WITH_MV)
+ target_compile_definitions(minicpm5_moe_npu PUBLIC PREFILL_WITH_MV)
+endif()
+
+# Add AVX2 specific definitions and flags
+target_compile_definitions(minicpm5_moe_npu PUBLIC
+ DISABLE_ABI_CHECK=1
+ USEAVX2=1
+ USEAVX512=1
+ _WIN32
+ __WINDOWS__
+ _ENABLE_EXTENDED_ALIGNED_STORAGE
+)
+
+# Enhanced compiler options for AVX-512
+target_compile_options(minicpm5_moe_npu PUBLIC
+ $<$:/arch:AVX512 /O2 /fp:fast>
+ $<$>:-mavx512f -mavx512vl -mavx512bw -mavx512dq -mfma -O3>
+)
+
+# Add OpenMP compiler flags if available
+if(OpenMP_CXX_FOUND)
+ target_compile_options(minicpm5_moe_npu PUBLIC
+ $<$:/openmp>
+ $<$>:-fopenmp>
+ )
+endif()
+
+# Link OpenMP if available
+if(OpenMP_CXX_FOUND)
+ target_link_libraries(minicpm5_moe_npu PUBLIC OpenMP::OpenMP_CXX)
+endif()
+
+# Add AVX2 specific link flags for MSVC
+if(MSVC)
+ set_target_properties(minicpm5_moe_npu PROPERTIES
+ LINK_FLAGS "/MACHINE:X64"
+ )
+ # Add C++ standard library for RTTI and other symbols
+ target_link_libraries(minicpm5_moe_npu PUBLIC
+ $<$:msvcrt.lib>
+ )
+endif()
+
+target_link_directories(minicpm5_moe_npu PUBLIC
+ ${XRT_LIB_DIR}
+ ${FLM_AIEBU_LIB_DIR}
+)
+
+# No host compute modules (gemm / mha / dequant). q4_npu_eXpress is still needed:
+# SafeTensors::load_weights lives in q4nx/safe_tensors.cpp, and a DLL must resolve
+# it at link time (the Linux .so picks it up from libq4_npu_eXpress.so at load time)
+set(Q4NPU_EXPRESS_LIB_PATH ${CMAKE_SOURCE_DIR}/../../build/lib/q4_npu_eXpress.lib)
+target_link_libraries(minicpm5_moe_npu PUBLIC
+ ${FLM_NPU_CORE_LIB}
+ ${FLM_NPU_AIEBU_LIB}
+ ${Q4NPU_EXPRESS_LIB_PATH}
+)
+
+# Copy the built library to build/lib directory
+add_custom_command(TARGET minicpm5_moe_npu POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/../../build/lib
+ COMMAND ${CMAKE_COMMAND} -E copy
+ $
+ ${CMAKE_SOURCE_DIR}/../../build/lib/minicpm5_moe_npu.dll
+ COMMAND ${CMAKE_COMMAND} -E copy
+ $
+ ${CMAKE_SOURCE_DIR}/../../build/lib/minicpm5_moe_npu.lib
+)
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/Makefile b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/Makefile
new file mode 100644
index 000000000..b3c25da05
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/Makefile
@@ -0,0 +1,150 @@
+# Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+# Portions of this file consist of AI-generated content.
+
+# =============================================================================
+# MiniCPM5-15B-A2.5B NPU Library Makefile
+# =============================================================================
+#
+# Usage:
+# make - Build libminicpm5_moe_npu.so (copied to ../../build/lib)
+# make clean - Remove all built files
+#
+# The engine has no host compute modules to link (no gemm / mha / dequant /
+# lm_head objects): every layer and the lm_head run on their own xclbins.
+# =============================================================================
+
+# Check if it is in Windows Subsystem for Linux (WSL)
+ifeq ($(shell uname -a | grep -i WSL),)
+ WSL := 0
+else
+ WSL := 1
+endif
+
+BUILD_DIR := ../../build/minicpm5_moe_npu
+LIB_DIR := $(BUILD_DIR)/lib
+BIN_DIR := $(BUILD_DIR)/bin
+FINAL_LIB_DIR := ../../build/lib
+ifeq ($(WSL), 0)
+# Linux build environment
+# Use g++-13 directly without CMake
+
+DEBUG_LEVEL ?= 0
+VERBOSE ?= 0
+
+TARGET = $(LIB_DIR)/libminicpm5_moe_npu.so
+
+CXX := g++-13
+include ../../flags.mk
+CXX_FLAGS := -std=c++20 -fPIC -Wall -O3 -fopenmp
+CXX_FLAGS += $(FLM_MARCH) -ffast-math
+CXX_FLAGS += -fmax-errors=1
+CXX_FLAGS += -I../../include
+CXX_FLAGS += -I../q4nx
+CXX_FLAGS += -I../../../aie2p-launchlib/launchlib/include
+ifeq ($(FLM_USE_HRX),1)
+include ../../hrx.mk
+CXX_FLAGS += $(HRX_INC)
+else
+CXX_FLAGS += -I$(XRT_ROOT)/include
+endif
+CXX_FLAGS += -MMD -MP -DDEBUG_LEVEL=$(DEBUG_LEVEL) -DVERBOSE=$(VERBOSE)
+# make PREFILL_WITH_MV=1: prefill through the decode overlays one token at a time,
+# instead of the batched prefill (minicpm5_moe_prefill.hpp)
+PREFILL_WITH_MV ?= 0
+ifneq ($(PREFILL_WITH_MV), 0)
+CXX_FLAGS += -DPREFILL_WITH_MV
+endif
+# where the batched prefill's heavy stages run: 1 = prefill_overlay.xclbin, 0 = host
+# (MINICPM5_MOE_ATTN_HOST=1 / MINICPM5_MOE_MM_HOST=1 at run time also put them on the host)
+MINICPM5_MOE_ATTN_ON_NPU ?= 1
+CXX_FLAGS += -DMINICPM5_MOE_ATTN_ON_NPU=$(MINICPM5_MOE_ATTN_ON_NPU)
+MINICPM5_MOE_MM_ON_NPU ?= 1
+CXX_FLAGS += -DMINICPM5_MOE_MM_ON_NPU=$(MINICPM5_MOE_MM_ON_NPU)
+
+# Flags for shared library
+LIB_FLAGS := -shared
+LIB_FLAGS += $(CXX_FLAGS)
+# Each engine .so compiles its own copy of the shared runtime (npu_sequence,
+# npu_app_manager, weight_desc_t, bytes/buffer, ...) and exports it with default
+# visibility. flm links every engine at once, so ELF interposition makes all
+# references -- including calls from inside this .so -- bind to whichever engine
+# comes first in DT_NEEDED, silently running another model's implementation.
+# -Bsymbolic-functions binds our internal function calls to our own definitions
+# at link time. Functions only: typeinfo/vtables stay interposable so
+# dynamic_cast across the .so boundary keeps working.
+LIB_FLAGS += -Wl,-Bsymbolic-functions
+
+ifeq ($(FLM_USE_HRX),1)
+LDFLAGS += $(HRX_RPATH)
+else
+LDFLAGS += -L$(XRT_ROOT)/lib
+endif
+
+LDFLAGS += -fopenmp
+LDFLAGS += -L../../../../src/lib/xrt
+LDFLAGS += -L../../build/lib
+ifeq ($(FLM_USE_HRX),1)
+LDFLAGS += $(HRX_LIBS)
+else
+# Link the aiebu that matches ../../include/aiebu by path. With -laiebu, an
+# XRT installed in $(XRT_ROOT)/lib (searched first) supplies its own
+# libaiebu.a, whose assembler prints a "Header version ..." banner to stdout
+# on every _setup_kernel().
+LDFLAGS += -lxrt_coreutil ../../../../src/lib/xrt/libaiebu.a
+endif
+
+# Each source compiles to a flattened object in LIB_DIR so dependency (.d)
+# files are emitted next to the objects and -include picks up header changes.
+LOCAL_SOURCES = $(wildcard *.cpp)
+OBJS = $(patsubst %.cpp,$(LIB_DIR)/%.o,$(LOCAL_SOURCES))
+DEPS := $(OBJS:.o=.d)
+
+all: directories $(TARGET)
+ cp $(TARGET) $(FINAL_LIB_DIR)
+
+directories:
+ mkdir -p $(FINAL_LIB_DIR)
+ mkdir -p $(BIN_DIR)
+ mkdir -p $(LIB_DIR)
+
+$(LIB_DIR)/%.o: %.cpp
+ $(CXX) $(CXX_FLAGS) -c -o $@ $<
+
+$(TARGET): $(OBJS)
+ $(CXX) $(LIB_FLAGS) -o $@ $^ $(LDFLAGS)
+
+clean:
+ rm -rf $(BUILD_DIR)
+
+-include $(DEPS)
+.PHONY: all clean directories
+
+else
+
+# WSL build environment
+# Use CMake to invoke the Visual Studio
+PWSH := powershell.exe
+HRX_CMAKE_ARGS :=
+ifeq ($(FLM_USE_HRX),1)
+HRX_CMAKE_ARGS := -DFLM_USE_HRX=ON
+endif
+
+TARGET = $(BUILD_DIR)/minicpm5_moe_npu.dll
+
+all: directories $(TARGET)
+
+directories:
+ mkdir -p $(BUILD_DIR)
+ mkdir -p $(BIN_DIR)
+ mkdir -p $(LIB_DIR)
+
+$(TARGET): directories
+ cd $(BUILD_DIR) && $(PWSH) -Command "cmake ../../detail/minicpm5_moe_npu $(HRX_CMAKE_ARGS)"
+ cd $(BUILD_DIR) && $(PWSH) -Command "cmake --build . --config Release --target minicpm5_moe_npu --parallel 4"
+
+clean:
+ rm -rf $(BUILD_DIR)
+
+.PHONY: all clean directories
+
+endif
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_cpu_functions.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_cpu_functions.hpp
new file mode 100644
index 000000000..ab082d150
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_cpu_functions.hpp
@@ -0,0 +1,282 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_cpu_functions.hpp
+/// \brief The small per-row prefill steps of MiniCPM5-15B-A2.5B, on the host
+/// \note Norms, RoPE, the K/V rows into the decode cache, the attention output
+/// gate, SiLU-GLU, residual, and the MoE router. Every step reads and
+/// writes bf16, fp32 inside (as the decode overlay does).
+#pragma once
+#include
+#include
+#include
+#include
+#include "minicpm5_moe_prefill_ops.hpp"
+
+namespace minicpm5_moe_cpu {
+
+// =============================================================================
+// bf16 rounding, 16 lanes at a time
+// =============================================================================
+/// \brief the bf16 bits of 16 floats, rounded as bf16(float) rounds them: to nearest
+/// even, zero and subnormals to a signed zero (NaN aside, which never occurs)
+inline __m512i bf16_bits(__m512 v) {
+ const __m512i i = _mm512_castps_si512(v);
+ const __m512i lsb = _mm512_and_si512(_mm512_srli_epi32(i, 16), _mm512_set1_epi32(1));
+ const __m512i r = _mm512_srli_epi32(_mm512_add_epi32(i, _mm512_add_epi32(lsb, _mm512_set1_epi32(0x7FFF))), 16);
+ const __mmask16 tiny = _mm512_testn_epi32_mask(i, _mm512_set1_epi32(0x7F800000));
+ return _mm512_mask_and_epi32(r, tiny, _mm512_srli_epi32(i, 16), _mm512_set1_epi32(0x8000));
+}
+/// \brief (float)(bf16)v per lane
+inline __m512 round_bf16(__m512 v) { return _mm512_castsi512_ps(_mm512_slli_epi32(bf16_bits(v), 16)); }
+/// \brief 16 x (bf16)v
+inline void store_bf16(bf16* p, __m512 v) {
+ _mm256_storeu_si256(reinterpret_cast<__m256i*>(p), _mm512_cvtepi32_epi16(bf16_bits(v)));
+}
+
+/// \brief out[l] = w * bf16(x[l] * rsqrt(mean(x[l]^2) + eps))
+inline void rms_norm(bf16* out, const bf16* x, const bf16* w, int L, int D, float eps) {
+ assert(D % 16 == 0);
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int64_t l = l0; l < l1; l++) {
+ const bf16* xr = x + (size_t)l * D;
+ bf16* o = out + (size_t)l * D;
+ double ss = 0.0;
+ for (int d = 0; d < D; d++) ss += (double)(float)xr[d] * (float)xr[d];
+ const float r = 1.0f / std::sqrt((float)(ss / D) + eps);
+ const __m512 rv = _mm512_set1_ps(r);
+ for (int d = 0; d < D; d += 16) {
+ const __m512 n = round_bf16(_mm512_mul_ps(load_bfloat16_to_m512(xr + d), rv));
+ store_bf16(o + d, _mm512_mul_ps(n, load_bfloat16_to_m512(w + d)));
+ }
+ }
+ });
+}
+
+/// \brief elements of one k|v|q|gate projection row (the decode proj order)
+inline int kvqg_stride(const minicpm5_moe_desc& desc) { return desc.DK + desc.DV + 2 * desc.DQ; }
+
+/// \brief cos / sin of every position of a chunk, [L][RoPE_DIM / 2] each, bf16 values
+/// as in the decode overlay's RoPE table; the angle is fp32 inv_freq * pos.
+/// The same for every layer: built once per chunk.
+struct rope_table {
+ int half = 0;
+ std::vector cos_t, sin_t;
+ void build(int L, const minicpm5_moe_desc& desc, int pos0) {
+ half = desc.RoPE_DIM / 2;
+ cos_t.resize((size_t)L * half);
+ sin_t.resize((size_t)L * half);
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int64_t l = l0; l < l1; l++) {
+ for (int i = 0; i < half; i++) {
+ const float angle = desc.inv_freq[i] * (float)(pos0 + l);
+ cos_t[(size_t)l * half + i] = (float)(bf16)std::cos(angle);
+ sin_t[(size_t)l * half + i] = (float)(bf16)std::sin(angle);
+ }
+ }
+ });
+ }
+};
+
+/// \brief RoPE (NEOX rotate_half, the whole head), in place on one head:
+/// x * cos + rotate_half(x) * sin, rotate_half(x) = [-x2, x1]
+/// \note No q/k norm in this model. half % 16 == 0.
+inline void head_rope(bf16* h, int half, const float* cos_t, const float* sin_t) {
+ for (int i = 0; i < half; i += 16) {
+ const __m512 x1 = load_bfloat16_to_m512(h + i), x2 = load_bfloat16_to_m512(h + i + half);
+ const __m512 c = _mm512_loadu_ps(cos_t + i), s = _mm512_loadu_ps(sin_t + i);
+ store_bf16(h + i, _mm512_fmsub_ps(x1, c, _mm512_mul_ps(x2, s)));
+ store_bf16(h + i + half, _mm512_fmadd_ps(x2, c, _mm512_mul_ps(x1, s)));
+ }
+}
+
+/// \brief RoPE on the k and q heads of the k|v|q|gate projection rows, in place, and the
+/// new K (roped) and V rows into the decode KV cache, rows pos0 .. pos0 + L - 1
+/// \param kvqg [L][kvqg_stride]: k, v, q, gate back to back
+/// \param rope the chunk's table (row l = position pos0 + l)
+inline void rope_store_kv(bf16* kvqg, int L, const minicpm5_moe_desc& desc, const rope_table& rope,
+ const kv_cache_view& kv, int pos0) {
+ const int DH = desc.DH, half = rope.half;
+ assert(half * 2 == DH && half % 16 == 0);
+ const int stride = kvqg_stride(desc);
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int l = (int)l0; l < (int)l1; l++) {
+ const float* c = rope.cos_t.data() + (size_t)l * half;
+ const float* s = rope.sin_t.data() + (size_t)l * half;
+ bf16* row = kvqg + (size_t)l * stride;
+ for (uint32_t h = 0; h < desc.num_kv_heads; h++) {
+ head_rope(row + h * DH, half, c, s);
+ memcpy(kv.row(0, h, pos0 + l), row + h * DH, DH * sizeof(bf16));
+ memcpy(kv.row(1, h, pos0 + l), row + desc.DK + h * DH, DH * sizeof(bf16));
+ }
+ for (uint32_t h = 0; h < desc.num_heads; h++) head_rope(row + desc.DK + desc.DV + h * DH, half, c, s);
+ }
+ });
+}
+
+/// \brief (float)(bf16)sigmoid(g) for every bf16 g, indexed by its bits
+inline const float* sigmoid_bf16_table() {
+ static const std::vector table = [] {
+ std::vector t(65536);
+ for (uint32_t b = 0; b < 65536; b++) {
+ const float g = (float)bf16((uint16_t)b, true);
+ t[b] = (float)(bf16)(1.0f / (1.0f + std::exp(-g)));
+ }
+ return t;
+ }();
+ return table.data();
+}
+
+/// \brief attn[l] *= sigmoid(gate[l]), the gate being the last DQ of each k|v|q|gate row
+inline void attn_gate(bf16* attn, const bf16* kvqg, int L, const minicpm5_moe_desc& desc) {
+ const int stride = kvqg_stride(desc), DQ = desc.DQ;
+ assert(DQ % 16 == 0);
+ const float* sig = sigmoid_bf16_table();
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int64_t l = l0; l < l1; l++) {
+ const bf16* g = kvqg + (size_t)l * stride + desc.DK + desc.DV + DQ;
+ bf16* a = attn + (size_t)l * DQ;
+ for (int i = 0; i < DQ; i += 16) {
+ const __m512i gi = _mm512_cvtepu16_epi32(_mm256_loadu_si256(reinterpret_cast(g + i)));
+ store_bf16(a + i, _mm512_mul_ps(load_bfloat16_to_m512(a + i), _mm512_i32gather_ps(gi, sig, 4)));
+ }
+ }
+ });
+}
+
+/// \brief hid[l] = silu(gate) * up, from rows stored as the decode GLU reads them:
+/// [up slab | gate slab] repeated (minicpm5_moe_model_def.cpp interleave_up_gate)
+/// \param width the MLP width (512, shared and routed experts); fused rows are 2 * width
+inline void silu_glu_row(bf16* o, const bf16* f, int width, int slab) {
+ for (int s = 0; s < width / slab; s++) {
+ const bf16* up = f + (size_t)s * 2 * slab;
+ const bf16* gate = up + slab;
+ for (int i = 0; i < slab; i++) {
+ const float g = (float)gate[i];
+ const float silu = (float)(bf16)(g / (1.0f + std::exp(-g)));
+ o[s * slab + i] = (bf16)(silu * (float)up[i]);
+ }
+ }
+}
+
+/// \brief silu_glu_row over L rows
+inline void silu_glu(bf16* hid, const bf16* fused, int L, int width, int slab) {
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int64_t l = l0; l < l1; l++) silu_glu_row(hid + (size_t)l * width, fused + (size_t)l * 2 * width, width, slab);
+ });
+}
+
+/// \brief x += y, rows of D, rounded to bf16 (the residual stream is bf16)
+inline void add_rows(bf16* x, const bf16* y, size_t n) {
+ assert(n % 16 == 0);
+ prefill_pool().run((int64_t)n / 16, [&](int64_t b, int64_t e, int) {
+ for (int64_t i = b * 16; i < e * 16; i += 16)
+ store_bf16(x + i, _mm512_add_ps(load_bfloat16_to_m512(x + i), load_bfloat16_to_m512(y + i)));
+ });
+}
+
+/// \brief x += bf16(y), y fp32 (the MoE sum is kept in fp32 until it joins the residual)
+inline void add_rows_f32(bf16* x, const float* y, size_t n) {
+ assert(n % 16 == 0);
+ prefill_pool().run((int64_t)n / 16, [&](int64_t b, int64_t e, int) {
+ for (int64_t i = b * 16; i < e * 16; i += 16)
+ store_bf16(x + i, _mm512_add_ps(load_bfloat16_to_m512(x + i), round_bf16(_mm512_loadu_ps(y + i))));
+ });
+}
+
+// =============================================================================
+// MoE router
+// =============================================================================
+/// \brief logits[l][e] = x[l] . W[e] in fp32, W in the router's read order
+/// (minicpm5_moe_model_def.cpp: 32-expert x 256-input blocks, expert-block major,
+/// each block input-major with its 32 experts adjacent)
+/// \note Rows go 8 at a time, so each weight vector is loaded once per 8 rows; every
+/// logit is still one chain of fmas over d in order, as with one row at a time.
+inline void router_logits(float* logits, const bf16* x, const bf16* w, int L, int D, int E) {
+ constexpr int ROW = minicpm5_moe_desc::ROUTER_ROW_BLOCK, COL = minicpm5_moe_desc::ROUTER_COL_BLOCK;
+ static_assert(ROW == 32, "two 16-lane accumulators per expert block");
+ constexpr int R = 8; // rows per step: 16 accumulators
+ const int steps = (L + R - 1) / R;
+ prefill_pool().run(steps, [&](int64_t st0, int64_t st1, int) {
+ std::vector xf((size_t)R * D);
+ for (int st = (int)st0; st < (int)st1; st++) {
+ const int l0 = st * R, rows = std::min(R, L - l0);
+ // fp32 rows (a short last step repeats its last row; those logits are dropped)
+ for (int r = 0; r < R; r++) {
+ const bf16* xr = x + (size_t)(l0 + std::min(r, rows - 1)) * D;
+ for (int d = 0; d < D; d += 16) _mm512_storeu_ps(xf.data() + (size_t)r * D + d, load_bfloat16_to_m512(xr + d));
+ }
+ for (int eb = 0; eb < E; eb += ROW) {
+ // 32 experts = two vectors; each input value scales one row of the block
+ __m512 a0[R], a1[R];
+ for (int r = 0; r < R; r++) a0[r] = a1[r] = _mm512_setzero_ps();
+ for (int db = 0; db < D; db += COL) {
+ const bf16* blk = w + ((size_t)(eb / ROW) * (D / COL) + db / COL) * ROW * COL;
+ for (int d = 0; d < COL; d++) {
+ const __m512 w0 = load_bfloat16_to_m512(blk + d * ROW), w1 = load_bfloat16_to_m512(blk + d * ROW + 16);
+ for (int r = 0; r < R; r++) {
+ const __m512 xv = _mm512_set1_ps(xf[(size_t)r * D + db + d]);
+ a0[r] = _mm512_fmadd_ps(xv, w0, a0[r]);
+ a1[r] = _mm512_fmadd_ps(xv, w1, a1[r]);
+ }
+ }
+ }
+ for (int r = 0; r < rows; r++) {
+ _mm512_storeu_ps(logits + (size_t)(l0 + r) * E + eb, a0[r]);
+ _mm512_storeu_ps(logits + (size_t)(l0 + r) * E + eb + 16, a1[r]);
+ }
+ }
+ }
+ });
+}
+
+/// \brief tokens routed to one expert, with their routing weights
+struct expert_task {
+ int expert;
+ std::vector tokens;
+ std::vector weights;
+};
+
+/// \brief sigmoid scores, top k of (score + bias), weight = score / sum * scaling
+/// (the bias only picks); grouped into one task per used expert
+/// \note Ties in score + bias go to the lower expert index.
+inline std::vector route(const float* logits, const std::vector& bias, int L, int E, int top_k, float scaling) {
+ std::vector ids((size_t)L * top_k);
+ std::vector wts((size_t)L * top_k);
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ std::vector score(E), choice(E);
+ std::vector order(E);
+ for (int64_t l = l0; l < l1; l++) {
+ for (int e = 0; e < E; e++) {
+ score[e] = 1.0f / (1.0f + std::exp(-logits[(size_t)l * E + e]));
+ choice[e] = score[e] + bias[e];
+ }
+ std::iota(order.begin(), order.end(), 0);
+ std::partial_sort(order.begin(), order.begin() + top_k, order.end(), [&](int a, int b) {
+ return choice[a] > choice[b] || (choice[a] == choice[b] && a < b);
+ });
+ float sum = 0.0f;
+ for (int k = 0; k < top_k; k++) sum += score[order[k]];
+ for (int k = 0; k < top_k; k++) {
+ ids[(size_t)l * top_k + k] = order[k];
+ wts[(size_t)l * top_k + k] = score[order[k]] / (sum + 1e-20f) * scaling;
+ }
+ }
+ });
+ // one task per expert, tokens in order
+ std::vector by_expert(E);
+ for (int e = 0; e < E; e++) by_expert[e].expert = e;
+ for (int l = 0; l < L; l++) {
+ for (int k = 0; k < top_k; k++) {
+ expert_task& t = by_expert[ids[(size_t)l * top_k + k]];
+ t.tokens.push_back(l);
+ t.weights.push_back(wts[(size_t)l * top_k + k]);
+ }
+ }
+ std::vector tasks;
+ for (auto& t : by_expert)
+ if (!t.tokens.empty()) tasks.push_back(std::move(t));
+ return tasks;
+}
+
+} // namespace minicpm5_moe_cpu
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_model_def.cpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_model_def.cpp
new file mode 100644
index 000000000..0f98a1240
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_model_def.cpp
@@ -0,0 +1,334 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_model_def.cpp
+/// \brief weight loaders for MiniCPM5-15B-A2.5B
+/// \note Ported from FLM_Xclbin/MiniCPM5/moe_decoding/host/decoding_layer.cpp
+/// and lm_head_npu_bin/host/host.cpp. A Q4_K tensor in model.q4nx is row blocks
+/// of 32 rows, each row block's 256-column blocks back to back, so "rows a..b"
+/// of a tensor is one contiguous byte range.
+#include
+#include
+#include "minicpm5_moe_model_def.hpp"
+
+namespace {
+
+constexpr size_t Q4K_BLOCK = minicpm5_moe_desc::Q4K_BLOCK_BYTES;
+
+/// Lays a quantized weight out in the order the proj engine reads it: rows of
+/// blocks are taken vertical_blocks at a time and interleaved block by block,
+/// so one shim BD streams the blocks of vertical_blocks proj cores together.
+void reorder_cpy(u8* dst, const u8* src, size_t src_bytes, int col, size_t a_block_size, int vertical_blocks = 2) {
+ const int blocks_per_row = col / QXNX_COL_BLOCK_SIZE;
+ const size_t row_bytes = a_block_size * blocks_per_row; // one 32-row block row
+ const int rows = (int)(src_bytes / row_bytes);
+ const u8* src_end = src + src_bytes;
+
+ u8* dst_ptr = dst;
+ std::vector src_ptr(vertical_blocks);
+ for (int i = 0; i < vertical_blocks; i++)
+ src_ptr[i] = src + i * row_bytes;
+
+ for (int r = 0; r < rows; r += vertical_blocks) {
+ for (int c = 0; c < blocks_per_row; c++) {
+ for (int i = 0; i < vertical_blocks; i++) {
+ memcpy(dst_ptr, src_ptr[i], a_block_size);
+ dst_ptr += a_block_size;
+ src_ptr[i] += a_block_size;
+ }
+ }
+ for (int i = 0; i < vertical_blocks; i++) {
+ src_ptr[i] += (vertical_blocks - 1) * row_bytes;
+ if (src_ptr[i] + row_bytes > src_end)
+ src_ptr[i] = src; // useless padding
+ }
+ }
+}
+
+/// Q4_K blocks (32 rows x 256 columns, 4736 B) from the q4nx order into the order
+/// of moe_decoding's int8-mmul kernel (_Q4K_x_int8 in kernels/q4_core.h), in place:
+/// qs [256 columns][16 B] -> [k step 16][half t 2][16 columns][8 B]
+/// (byte b of a column holds rows 2b, 2b + 1; half t = rows 16t .. 16t+15)
+/// scales [group 8][32 rows] -> [h 2][t 2][a 4][16 rows], group = 4h + a
+/// mins, S, M unchanged.
+/// One B matrix of the mmul (16 columns x 16 rows) is then 128 contiguous bytes.
+void q4k_relayout_for_mmul(u8* data, size_t bytes) {
+ constexpr size_t SCALES = 0, QS = 512;
+ assert(bytes % Q4K_BLOCK == 0);
+ const int64_t n_blocks = (int64_t)(bytes / Q4K_BLOCK);
+ // every block is independent: split them over the host cores
+ #pragma omp parallel for schedule(static)
+ for (int64_t b = 0; b < n_blocks; b++) {
+ u8* blk = data + b * Q4K_BLOCK;
+ std::array old;
+ memcpy(old.data(), blk, Q4K_BLOCK);
+ for (int k = 0; k < 16; k++) // 16 columns per k step
+ for (int t = 0; t < 2; t++) // rows 16t .. 16t+15
+ for (int c = 0; c < 16; c++)
+ memcpy(blk + QS + (k * 2 + t) * 128 + c * 8,
+ old.data() + QS + (k * 16 + c) * 16 + t * 8, 8);
+ for (int h = 0; h < 2; h++)
+ for (int t = 0; t < 2; t++)
+ for (int a = 0; a < 4; a++)
+ memcpy(blk + SCALES + ((h * 2 + t) * 4 + a) * 16,
+ old.data() + SCALES + (4 * h + a) * 32 + 16 * t, 16);
+ }
+}
+
+/// bytes of `rows` rows of a Q4_K matrix with `in_dim` columns
+size_t q4k_row_bytes(size_t rows, size_t in_dim) {
+ return rows / QXNX_ROW_BLOCK_SIZE * (in_dim / QXNX_COL_BLOCK_SIZE) * Q4K_BLOCK;
+}
+
+/// [up rows 0..n | gate rows 0..n | up rows n..2n | gate rows n..2n | ...], n = rows_per_piece,
+/// so every proj round holds matching up and gate rows for the GLU
+void interleave_up_gate(u8* out, const u8* up, const u8* gate, size_t rows, size_t rows_per_piece, size_t in_dim) {
+ const size_t piece = q4k_row_bytes(rows_per_piece, in_dim);
+ for (size_t r = 0; r < rows; r += rows_per_piece) {
+ memcpy(out, up, piece); out += piece; up += piece;
+ memcpy(out, gate, piece); out += piece; gate += piece;
+ }
+}
+
+/// load one tensor and check its size against `bytes` (default: the descriptor's)
+buffer load_checked(Q4NX& q4nx, const std::string& name, size_t bytes) {
+ buffer w;
+ q4nx.load_weights(w, name);
+ if (w.size() != bytes) {
+ throw std::runtime_error("minicpm5_moe_npu: " + name + " is " + std::to_string(w.size()) +
+ " bytes, expected " + std::to_string(bytes));
+ }
+ return w;
+}
+buffer load_checked(Q4NX& q4nx, weight_desc_t& desc, int layer_idx) {
+ return load_checked(q4nx, desc.format_name(layer_idx), desc.get_size());
+}
+
+void check_ready(minicpm5_moe_layer_def& L, int layer_idx) {
+ for (weight_desc_t* w : L.all()) {
+ if (!w->ready()) {
+ throw std::runtime_error("minicpm5_moe_npu: weight not loaded: " + w->format_name(layer_idx));
+ }
+ }
+}
+
+} // namespace
+
+void minicpm5_moe_desc::load_layer(int layer_idx, Q4NX& q4nx, buffer& proj, buffer& rms,
+ std::vector& router_bias) {
+ const bool is_dense = layer_kind(layer_idx) == minicpm5_moe_layer_kind::dense;
+ minicpm5_moe_layer_def& W = layer_def(layer_idx);
+ assert(proj.size() >= W.proj_bytes && rms.size() * sizeof(bf16) >= W.rms_bytes);
+ u8* p = proj.data();
+ const std::string prefix = "model.layer." + std::to_string(layer_idx) + ".";
+
+ // ---- routed experts ----
+ // One expert = [channel 0 stream | channel 1 stream], expert e at
+ // e * (its gate/up + down bytes) from the up region's start (the router uses
+ // the same offsets). Each channel stream is that channel's gate/up blocks then
+ // its down blocks, in the order the proj cores read them, so the router starts
+ // one linear BD per channel per expert.
+ // gate/up rows: the 4 cores of a column take 4 row blocks per round; with
+ // 64-row pieces cores 0, 1 make up and cores 2, 3 make gate, so one round
+ // of a column is [up 64 | gate 64]
+ // down rows: in order
+ // channels: reorder_cpy(..., 4) puts the 4 blocks of a group next to each
+ // other; channel 0 feeds cores 0, 1 (the first 2), channel 1 cores 2, 3
+ {
+ weight_desc_t& d_up = W.ffn_up_exps;
+ weight_desc_t& d_gate = W.ffn_gate_exps;
+ weight_desc_t& d_down = W.ffn_down_exps;
+ assert(d_gate.offset == d_up.offset + d_up.get_size());
+ assert(d_down.offset == d_gate.offset + d_gate.get_size());
+ const int experts = (int)W.experts;
+ const size_t up_per_expert = d_up.get_size() / experts;
+ const size_t down_per_expert = d_down.get_size() / experts;
+ assert(up_per_expert == q4k_row_bytes(expert_width, D));
+ buffer w_up, w_gate, w_down;
+ if (is_dense) {
+ // the 8192-wide MLP as 16 experts of 512: up/gate rows e*512.. are
+ // already expert e's bytes; down [D, 8192] gives expert e its column
+ // blocks 2e, 2e+1 of every row block
+ w_up = load_checked(q4nx, prefix + "mlp.up_proj.weight", d_up.get_size());
+ w_gate = load_checked(q4nx, prefix + "mlp.gate_proj.weight", d_gate.get_size());
+ buffer w_down_dense = load_checked(q4nx, prefix + "mlp.down_proj.weight", d_down.get_size());
+ const size_t piece = expert_width / QXNX_COL_BLOCK_SIZE * Q4K_BLOCK; // one expert's part of a row block
+ w_down = buffer(w_down_dense.size());
+ u8* dst = w_down.data();
+ for (int e = 0; e < experts; e++) {
+ for (uint32_t rb = 0; rb < D / QXNX_ROW_BLOCK_SIZE; rb++) {
+ memcpy(dst, w_down_dense.data() + ((size_t)rb * experts + e) * piece, piece);
+ dst += piece;
+ }
+ }
+ }
+ else {
+ w_up = load_checked(q4nx, d_up, layer_idx);
+ w_gate = load_checked(q4nx, d_gate, layer_idx);
+ w_down = load_checked(q4nx, d_down, layer_idx);
+ }
+
+ const size_t gate_up_bytes = 2 * up_per_expert;
+ const size_t expert_bytes = gate_up_bytes + down_per_expert;
+ const size_t channel_bytes = expert_bytes / 2;
+ const size_t group = 4 * Q4K_BLOCK; // the 4 blocks of one group
+
+ // ch0 takes the first 2 blocks of every group of `src`, ch1 the last 2
+ auto split_channels = [&](u8*& ch0, u8*& ch1, const u8* src, size_t bytes) {
+ assert(bytes % group == 0);
+ for (size_t g = 0; g < bytes; g += group) {
+ memcpy(ch0, src + g, group / 2); ch0 += group / 2;
+ memcpy(ch1, src + g + group / 2, group / 2); ch1 += group / 2;
+ }
+ };
+
+ // every expert writes its own byte range: run them on all host cores
+ #pragma omp parallel
+ {
+ std::vector both(gate_up_bytes), gate_up(gate_up_bytes), down(down_per_expert);
+ #pragma omp for schedule(static)
+ for (int e = 0; e < experts; e++) {
+ interleave_up_gate(both.data(), w_up.data() + e * up_per_expert, w_gate.data() + e * up_per_expert,
+ expert_width, EXPERT_ROWS_PER_ROUND, D);
+ reorder_cpy(gate_up.data(), both.data(), gate_up_bytes, D, Q4K_BLOCK, 4);
+ reorder_cpy(down.data(), w_down.data() + e * down_per_expert, down_per_expert, expert_width, Q4K_BLOCK, 4);
+
+ u8* ch0 = p + d_up.offset + e * expert_bytes;
+ u8* ch1 = ch0 + channel_bytes;
+ split_channels(ch0, ch1, gate_up.data(), gate_up_bytes);
+ split_channels(ch0, ch1, down.data(), down_per_expert);
+ assert(ch0 == p + d_up.offset + e * expert_bytes + channel_bytes);
+ }
+ }
+ d_up.load();
+ d_gate.load();
+ d_down.load();
+ }
+
+ // ---- attention: k, v, q, gate back to back (one matrix to the proj engine), then o ----
+ {
+ assert(W.attn_v.offset == W.attn_k.offset + W.attn_k.get_size());
+ assert(W.attn_q.offset == W.attn_v.offset + W.attn_v.get_size());
+ assert(W.attn_gate.offset == W.attn_q.offset + W.attn_q.get_size());
+ // model KV head h -> kernel heads h * dup .. h * dup + dup - 1; rows are
+ // output-major, so a head is one byte range
+ const uint32_t dup = num_kv_heads / model_kv_heads;
+ for (weight_desc_t* w : {&W.attn_k, &W.attn_v}) {
+ buffer src = load_checked(q4nx, w->format_name(layer_idx), w->get_size() / dup);
+ const size_t head_bytes = src.size() / model_kv_heads;
+ buffer heads(w->get_size());
+ for (uint32_t h = 0; h < num_kv_heads; h++)
+ memcpy(heads.data() + h * head_bytes, src.data() + (h / dup) * head_bytes, head_bytes);
+ reorder_cpy(p + w->offset, heads.data(), heads.size(), D, Q4K_BLOCK);
+ w->load();
+ }
+ for (weight_desc_t* w : {&W.attn_q, &W.attn_gate}) {
+ buffer src = load_checked(q4nx, *w, layer_idx);
+ reorder_cpy(p + w->offset, src.data(), src.size(), D, Q4K_BLOCK);
+ w->load();
+ }
+ buffer w_o = load_checked(q4nx, W.attn_output, layer_idx);
+ reorder_cpy(p + W.attn_output.offset, w_o.data(), w_o.size(), DQ, Q4K_BLOCK);
+ W.attn_output.load();
+ }
+
+ // ---- shared expert: up/gate one proj round = [up 256 | gate 256], down in row order ----
+ {
+ weight_desc_t& d_up = W.ffn_up_shexp;
+ weight_desc_t& d_gate = W.ffn_gate_shexp;
+ weight_desc_t& d_down = W.ffn_down_shexp;
+ assert(d_gate.offset == d_up.offset + d_up.get_size());
+ assert(d_down.offset == d_gate.offset + d_gate.get_size());
+ if (is_dense) {
+ // no shared expert: zero Q4_K blocks (scales 0) add nothing
+ memset(p + d_up.offset, 0, d_up.get_size() + d_gate.get_size() + d_down.get_size());
+ }
+ else {
+ buffer w_up = load_checked(q4nx, d_up, layer_idx);
+ buffer w_gate = load_checked(q4nx, d_gate, layer_idx);
+ buffer both(w_up.size() + w_gate.size());
+ interleave_up_gate(both.data(), w_up.data(), w_gate.data(), expert_width, SHARED_ROWS_PER_ROUND, D);
+ reorder_cpy(p + d_up.offset, both.data(), both.size(), D, Q4K_BLOCK);
+ buffer w_down = load_checked(q4nx, d_down, layer_idx);
+ reorder_cpy(p + d_down.offset, w_down.data(), w_down.size(), expert_width, Q4K_BLOCK);
+ }
+ d_up.load();
+ d_gate.load();
+ d_down.load();
+ }
+
+ // every proj weight block into the int8-mmul kernel's order (Q4K_INT8_MMUL 1);
+ // zero blocks stay zero
+ q4k_relayout_for_mmul(p, W.proj_bytes);
+
+ // ---- rms buffer: the two norms, then the router weight ----
+ for (weight_desc_t* w : {&W.input_layer_norm, &W.post_attntion_norm}) {
+ buffer src = load_checked(q4nx, *w, layer_idx);
+ memcpy((u8*)rms.data() + w->offset, src.data(), w->get_size());
+ w->load();
+ }
+ // Router weight, stored in the exact order the router reads it, so its DMA is
+ // two straight reads. model.q4nx holds it as [D][E]; the router takes
+ // 32-expert x 256-input blocks, expert-block major, each block input-major
+ // with the 32 experts adjacent. Layer 0 has no router: the router core still
+ // reads one (zeros) and then picks experts 0..15 itself (FIRST_K_DENSE).
+ {
+ bf16* dst = (bf16*)((u8*)rms.data() + W.ffn_gate_inp.offset);
+ if (is_dense) {
+ memset(dst, 0, W.ffn_gate_inp.get_size());
+ }
+ else {
+ buffer bytes = load_checked(q4nx, W.ffn_gate_inp, layer_idx);
+ const bf16* w_router = (const bf16*)bytes.data();
+ for (uint32_t eb = 0; eb < num_experts; eb += ROUTER_ROW_BLOCK) {
+ for (uint32_t db = 0; db < D; db += ROUTER_COL_BLOCK) {
+ for (uint32_t d = db; d < db + ROUTER_COL_BLOCK; d++) {
+ memcpy(dst, w_router + (size_t)d * num_experts + eb, ROUTER_ROW_BLOCK * sizeof(bf16));
+ dst += ROUTER_ROW_BLOCK;
+ }
+ }
+ }
+ }
+ W.ffn_gate_inp.load();
+ }
+ // router expert bias: fp32, only picks the experts (see route() in minicpm5_moe_cpu_functions.hpp)
+ router_bias.assign(num_experts, 0.0f);
+ if (!is_dense) {
+ buffer bias_bytes = load_checked(q4nx, prefix + "moe_expert_bias", num_experts * sizeof(float));
+ memcpy(router_bias.data(), bias_bytes.data(), bias_bytes.size());
+ }
+ check_ready(W, layer_idx);
+}
+
+/// lm_head.weight, Q8_0 blocks [scales bf16 (8 groups x 32 rows) | q int8 (256 cols x 32 rows)].
+/// A column's weights arrive on two shim channels, one per pair of cores, so each
+/// column-round has to be two contiguous halves in DDR rather than one run with all
+/// four cores' blocks interleaved: rows r+0/r+1 of the group for the stream that
+/// feeds cores 0 and 1, rows r+2/r+3 for the stream that feeds cores 2 and 3. Within
+/// a half the order is still k-major, one block per core, because that is exactly one
+/// memtile slot. See lm_head_memtile in lm_head_npu_bin/iron/q4k_mm.py.
+void minicpm5_moe_desc::load_lm_head(Q4NX& q4nx, buffer& dst) {
+ constexpr int vertical_blocks = 4;
+ constexpr int rows_per_stream = vertical_blocks / 2;
+ buffer src;
+ q4nx.load_weights(src, "lm_head.weight");
+ const int blocks_per_row = D / QXNX_COL_BLOCK_SIZE;
+ const int rows = (int)(src.size() / Q80_BLOCK_BYTES / blocks_per_row);
+ assert(dst.size() >= (size_t)vocab_size_padded / 32 * blocks_per_row * Q80_BLOCK_BYTES);
+
+ u8* dst_ptr = dst.data();
+ for (int r = 0; r < rows; r += vertical_blocks) {
+ for (int half = 0; half < 2; half++) {
+ for (int c = 0; c < blocks_per_row; c++) {
+ for (int i = 0; i < rows_per_stream; i++) {
+ const int row = r + half * rows_per_stream + i;
+ const u8* src_ptr = (row < rows)
+ ? src.data() + (size_t)(row * blocks_per_row + c) * Q80_BLOCK_BYTES
+ : src.data(); // useless padding
+ memcpy(dst_ptr, src_ptr, Q80_BLOCK_BYTES);
+ dst_ptr += Q80_BLOCK_BYTES;
+ }
+ }
+ }
+ }
+}
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_model_def.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_model_def.hpp
new file mode 100644
index 000000000..5a70065ce
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_model_def.hpp
@@ -0,0 +1,281 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_model_def.hpp
+/// \brief weight-shape definition for MiniCPM5-15B-A2.5B (minicpm5_moe)
+/// \author FastFlowLM Team
+/// \date 2026-12-03
+/// \note Every layer runs on one decode overlay, FLM_Xclbin/MiniCPM5/moe_decoding:
+/// * layers 1..27: GQA attention with a sigmoid output gate + 160 experts,
+/// top 16, plus one shared expert, all 512 wide, with a sigmoid router
+/// * layer 0 (first_k_dense_replace = 1): the same attention + an 8192-wide
+/// SwiGLU MLP. SwiGLU is elementwise over its width, so the MLP is the sum
+/// of 16 slices of 512: the host stores them as experts 0..15, the router
+/// picks those with weight 1 for this layer, and the shared expert is zero.
+/// The model has 2 KV heads, the kernels 4 (one per attention CU): every k/v
+/// head is loaded twice, [h0, h0, h1, h1], and the KV cache holds each twice.
+/// Every projection is Q4_K (4736-byte 32x256 blocks), the lm_head is Q8_0.
+/// The layouts and loaders below are ported from moe_decoding's
+/// host/decoding_layer.cpp, which is checked against the Q4_K reference;
+/// keep them in step with the kernels, not with other engines.
+#ifndef __MINICPM5_MOE_MODEL_DEF_HPP__
+#define __MINICPM5_MOE_MODEL_DEF_HPP__
+#include
+#include
+#include
+#include "lm_config.hpp"
+#include "weight_desc.hpp"
+#include "tensor_utils/q4_npu_eXpress.hpp"
+
+/// @brief layer 0 (dense MLP as experts 0..15) or a routed MoE layer
+enum class minicpm5_moe_layer_kind { dense, moe };
+
+/// @brief one layer's buffers, both kinds
+/// @note proj buffer order = device order: routed up, gate, down (one region,
+/// re-cut per expert, see load_layer), k, v, q, gate (one matrix to the
+/// proj engine: RoPE takes K/V first, then Q, the output gate tile the
+/// gate logits), o, shared up|gate, shared down.
+/// rms buffer: [input_layernorm | post_attention_layernorm | router weight].
+/// The two kinds differ only in how many experts the routed region holds
+/// (16 for layer 0, 160 otherwise); the router weight is always 160 wide
+/// (zero for layer 0: the router reads it all the same).
+struct minicpm5_moe_layer_def {
+ uint32_t experts = 0; // experts stored in the routed region
+ weight_desc_t ffn_up_exps, ffn_gate_exps, ffn_down_exps;
+ weight_desc_t attn_k, attn_v, attn_q, attn_gate, attn_output;
+ weight_desc_t ffn_up_shexp, ffn_gate_shexp, ffn_down_shexp;
+ weight_desc_t input_layer_norm, post_attntion_norm, ffn_gate_inp;
+ size_t proj_bytes = 0, rms_bytes = 0;
+
+ std::vector proj_all() {
+ return {&ffn_up_exps, &ffn_gate_exps, &ffn_down_exps,
+ &attn_k, &attn_v, &attn_q, &attn_gate, &attn_output,
+ &ffn_up_shexp, &ffn_gate_shexp, &ffn_down_shexp};
+ }
+ std::vector rms_all() { return {&input_layer_norm, &post_attntion_norm, &ffn_gate_inp}; }
+ std::vector all() {
+ std::vector v = proj_all();
+ for (weight_desc_t* w : rms_all()) v.push_back(w);
+ return v;
+ }
+};
+
+struct minicpm5_moe_desc {
+ // ---- values baked into the xclbins (FLM_Xclbin/MiniCPM5/*/models/*.h) ----
+ // build() refuses a config.json that disagrees: the kernels would not notice.
+ static constexpr uint32_t KERNEL_D = 2048;
+ static constexpr uint32_t KERNEL_DH = 128;
+ static constexpr uint32_t KERNEL_HEADS = 32;
+ static constexpr uint32_t KERNEL_KV_HEADS = 4; // model KV heads, each twice
+ static constexpr uint32_t MODEL_KV_HEADS = 2;
+ static constexpr uint32_t KERNEL_DENSE_WIDTH = 8192; // layer 0 = TOP_K experts
+ static constexpr uint32_t KERNEL_EXPERT_WIDTH = 512;
+ static constexpr uint32_t KERNEL_EXPERTS = 160;
+ static constexpr uint32_t KERNEL_TOP_K = 16;
+ static constexpr uint32_t KERNEL_FIRST_K_DENSE = 1; // FIRST_K_DENSE: the router's fixed-expert layers
+ static constexpr uint32_t KERNEL_MAX_LAYERS = 28; // the router's per-layer address table
+ static constexpr uint32_t KERNEL_VOCAB = 131072; // lm_head.xclbin
+ static constexpr float KERNEL_ROUTER_SCALING = 3.66f; // ROUTER_SCALING
+
+ // up/gate rows per proj round (one round = 16 cores x 32 rows = 512 values):
+ // shared expert [up 256 | gate 256], routed experts [up 64 | gate 64] per column
+ static constexpr int SHARED_ROWS_PER_ROUND = 256;
+ static constexpr int EXPERT_ROWS_PER_ROUND = 64;
+ // router weight blocks: 32 experts x 256 inputs (router_weight_row/col_block)
+ static constexpr int ROUTER_ROW_BLOCK = 32;
+ static constexpr int ROUTER_COL_BLOCK = 256;
+ // the router memtile holds this many experts' weights; the rest go straight
+ // to the router helper (MT_EXPERTS in iron/router_w_memtile.py)
+ static constexpr uint32_t ROUTER_MT_EXPERTS = 128;
+ // attention: 2 array columns, each holding 2 of the 4 KV heads
+ static constexpr int ATTN_COLS = 2;
+ // the attention reads K/V in 16-token chunks, so MAX_L must be whole chunks
+ static constexpr int KV_CHUNK = 16;
+ // largest KV cache the engine allocates (the 128K default context)
+ static constexpr uint32_t MAX_CONTEXT = 131072;
+
+ static constexpr size_t Q4K_BLOCK_BYTES = 4736; // one 32 x 256 Q4_K block
+ static constexpr size_t Q80_BLOCK_BYTES = 8704; // one 32 x 256 Q8_0 block
+
+ uint32_t num_hidden_layers;
+ uint32_t D, DH, DQ, DK, DV, RoPE_DIM;
+ uint32_t num_heads;
+ uint32_t num_kv_heads; // the kernels' (4): model heads duplicated
+ uint32_t model_kv_heads; // config.json's (2)
+ uint32_t dense_width; // intermediate_size, layer 0's MLP
+ uint32_t expert_width; // moe_intermediate_size (routed and shared)
+ uint32_t num_experts, top_k;
+ uint32_t first_k_dense;
+ uint32_t vocab_size, vocab_size_padded;
+ f32 rms_norm_eps;
+ f32 rope_theta;
+ f32 router_scaling; // routed_scaling_factor: weights = score / sum * this
+ std::vector inv_freq; // RoPE_DIM / 2, fp32 like transformers
+
+ minicpm5_moe_layer_def dense; // layer 0: 16 experts
+ minicpm5_moe_layer_def moe; // layers 1..: 160 experts
+
+ inline minicpm5_moe_layer_kind layer_kind(int idx) const {
+ return idx < (int)first_k_dense ? minicpm5_moe_layer_kind::dense : minicpm5_moe_layer_kind::moe;
+ }
+ inline minicpm5_moe_layer_def& layer_def(int idx) {
+ return layer_kind(idx) == minicpm5_moe_layer_kind::dense ? dense : moe;
+ }
+ inline const minicpm5_moe_layer_def& layer_def(int idx) const {
+ return layer_kind(idx) == minicpm5_moe_layer_kind::dense ? dense : moe;
+ }
+
+ /// @brief one layer's KV cache in elements: [K col 0][K col 1][V col 0][V col 1],
+ /// each MAX_L x (2 kernel KV heads x DH)
+ inline size_t get_kv_cache_elems(uint32_t MAX_L) const { return (size_t)MAX_L * (DK + DV); }
+ /// @brief zero rows after the last block (V col 1): the prefill attention reads
+ /// whole 128-row blocks up to ~380 rows past MAX_L for a chunk that ends
+ /// near it (the other blocks' overrun lands in the next block: finite,
+ /// and masked)
+ static constexpr uint32_t KV_TAIL_ROWS = 512;
+ /// @brief elements to allocate per layer: the cache plus its zero tail
+ inline size_t get_kv_cache_alloc_elems(uint32_t MAX_L) const {
+ return get_kv_cache_elems(MAX_L) + (size_t)KV_TAIL_ROWS * kv_col_row();
+ }
+ /// @brief elements per token of one column's K (or V) block
+ inline size_t kv_col_row() const { return (size_t)(num_kv_heads / ATTN_COLS) * DH; }
+ /// @brief element offset of a column's K (kv = 0) or V (kv = 1) block
+ /// (kv_cache_view::row in minicpm5_moe_prefill_ops.hpp has the same rule)
+ inline size_t kv_block_offset(int col, int kv, uint32_t MAX_L) const {
+ return (size_t)(2 * kv + col) * MAX_L * kv_col_row();
+ }
+ /// @brief rope buffer: [cos RoPE_DIM/2 | sin RoPE_DIM/2] (no q/k norm)
+ inline size_t get_rope_rms_elems() const { return RoPE_DIM; }
+ /// @brief lm_head buffer bytes: Q8_0, vocab padded to 1024 rows
+ inline size_t get_lm_head_w_size() const {
+ return (size_t)vocab_size_padded / 32 * (D / 256) * Q80_BLOCK_BYTES;
+ }
+
+ inline void build(LM_Config& config) {
+ num_hidden_layers = config.get("num_hidden_layers");
+ D = config.get("hidden_size");
+ num_heads = config.get("num_attention_heads");
+ model_kv_heads = config.get("num_key_value_heads", num_heads);
+ num_kv_heads = KERNEL_KV_HEADS;
+ DH = config.get("head_dim", D / num_heads);
+ DQ = DH * num_heads;
+ DK = DH * num_kv_heads;
+ DV = DH * num_kv_heads;
+ RoPE_DIM = DH; // full-head rotation (NEOX)
+ dense_width = config.get("intermediate_size");
+ expert_width = config.get("moe_intermediate_size");
+ num_experts = config.get("n_routed_experts");
+ top_k = config.get("num_experts_per_tok");
+ first_k_dense = config.get("first_k_dense_replace", 1);
+ vocab_size = config.get("vocab_size");
+ vocab_size_padded = (vocab_size + 1024 - 1) / 1024 * 1024;
+ // (eos_token_id is a list here; the tokens to stop on are the frontend's)
+ rms_norm_eps = config.get("rms_norm_eps", 1e-6f);
+ router_scaling = config.get("routed_scaling_factor", 1.0f);
+ rope_theta = config.get("rope_theta", 10000.0f);
+ inv_freq.resize(RoPE_DIM / 2);
+ for (uint32_t i = 0; i < RoPE_DIM / 2; i++) {
+ // fp32, as transformers builds it: theta^(-2i / dim)
+ inv_freq[i] = (f32)(1.0 / std::pow((double)rope_theta, (2.0 * i) / RoPE_DIM));
+ }
+
+ DEBUG_BLOCK(1,
+ std::cout << "================ minicpm5_moe_desc ================" << std::endl;
+ std::cout << std::left << std::setw(28) << "num_hidden_layers" << " = " << num_hidden_layers << std::endl;
+ std::cout << std::left << std::setw(28) << "first_k_dense" << " = " << first_k_dense << std::endl;
+ std::cout << std::left << std::setw(28) << "D (hidden_size)" << " = " << D << std::endl;
+ std::cout << std::left << std::setw(28) << "DH (head_dim)" << " = " << DH << std::endl;
+ std::cout << std::left << std::setw(28) << "DQ / DK / DV" << " = " << DQ << " / " << DK << " / " << DV << std::endl;
+ std::cout << std::left << std::setw(28) << "heads / kv (model)" << " = " << num_heads << " / " << num_kv_heads
+ << " (" << model_kv_heads << ")" << std::endl;
+ std::cout << std::left << std::setw(28) << "dense_width" << " = " << dense_width << std::endl;
+ std::cout << std::left << std::setw(28) << "expert_width" << " = " << expert_width << std::endl;
+ std::cout << std::left << std::setw(28) << "experts / top_k" << " = " << num_experts << " / " << top_k << std::endl;
+ std::cout << std::left << std::setw(28) << "rms_norm_eps" << " = " << rms_norm_eps << std::endl;
+ std::cout << std::left << std::setw(28) << "rope_theta" << " = " << rope_theta << std::endl;
+ std::cout << std::left << std::setw(28) << "router_scaling" << " = " << router_scaling << std::endl;
+ std::cout << std::left << std::setw(28) << "vocab (padded)" << " = " << vocab_size << " (" << vocab_size_padded << ")" << std::endl;
+ std::cout << "==============================================" << std::endl;
+ )
+
+ _check_against_kernels();
+ _build_layer(dense, dense_width / expert_width);
+ _build_layer(moe, num_experts);
+ }
+
+ /// @brief one layer's weights; returns nothing, every value is in the buffers
+ /// @param proj Q4_K projections in proj engine order (layer_def(idx).proj_all()),
+ /// relaid for the int8-mmul kernel
+ /// @param rms [input_layernorm | post_attention_layernorm | router weight in read order]
+ /// @param router_bias out: the fp32 expert bias (moe_expert_bias; zero for layer 0),
+ /// sent with RTP writes
+ void load_layer(int layer_idx, Q4NX& q4nx, buffer& proj, buffer& rms, std::vector& router_bias);
+
+ /// @brief lm_head.weight (Q8_0) in lm_head.xclbin's read order
+ void load_lm_head(Q4NX& q4nx, buffer& dst);
+
+private:
+ inline void _check_against_kernels() {
+ struct { const char* name; uint32_t got, want; } checks[] = {
+ {"hidden_size", D, KERNEL_D},
+ {"head_dim", DH, KERNEL_DH},
+ {"num_attention_heads", num_heads, KERNEL_HEADS},
+ {"num_key_value_heads", model_kv_heads, MODEL_KV_HEADS},
+ {"intermediate_size", dense_width, KERNEL_DENSE_WIDTH},
+ {"moe_intermediate_size", expert_width, KERNEL_EXPERT_WIDTH},
+ {"n_routed_experts", num_experts, KERNEL_EXPERTS},
+ {"num_experts_per_tok", top_k, KERNEL_TOP_K},
+ {"first_k_dense_replace", first_k_dense, KERNEL_FIRST_K_DENSE},
+ {"vocab_size (padded)", vocab_size_padded, KERNEL_VOCAB},
+ };
+ for (auto& c : checks) {
+ if (c.got != c.want) {
+ throw std::runtime_error(std::string("minicpm5_moe_npu: config ") + c.name + " = " + std::to_string(c.got) +
+ ", but the xclbins are built for " + std::to_string(c.want));
+ }
+ }
+ if (num_hidden_layers > KERNEL_MAX_LAYERS) {
+ throw std::runtime_error("minicpm5_moe_npu: the MoE router keeps addresses for " +
+ std::to_string(KERNEL_MAX_LAYERS) + " layers only");
+ }
+ if (std::fabs(router_scaling - KERNEL_ROUTER_SCALING) > 1e-6f) {
+ throw std::runtime_error("minicpm5_moe_npu: routed_scaling_factor " + std::to_string(router_scaling) +
+ " differs from the router kernel's");
+ }
+ // layer 0's MLP is exactly the TOP_K experts the router fixes for it
+ if (dense_width != top_k * expert_width) {
+ throw std::runtime_error("minicpm5_moe_npu: intermediate_size must be num_experts_per_tok x moe_intermediate_size");
+ }
+ }
+
+ /// @param experts how many experts the routed region holds
+ inline void _build_layer(minicpm5_moe_layer_def& L, uint32_t experts) {
+ L.experts = experts;
+ L.ffn_up_exps = weight_desc_t(flm_q4k, {D, expert_width, experts}, "model.layer.%d.mlp.up_exps_proj.weight");
+ L.ffn_gate_exps = weight_desc_t(flm_q4k, {D, expert_width, experts}, "model.layer.%d.mlp.gate_exps_proj.weight");
+ L.ffn_down_exps = weight_desc_t(flm_q4k, {expert_width, D, experts}, "model.layer.%d.mlp.down_exps_proj.weight");
+ L.attn_k = weight_desc_t(flm_q4k, {D, DK}, "model.layer.%d.self_attn.k_proj.weight");
+ L.attn_v = weight_desc_t(flm_q4k, {D, DV}, "model.layer.%d.self_attn.v_proj.weight");
+ L.attn_q = weight_desc_t(flm_q4k, {D, DQ}, "model.layer.%d.self_attn.q_proj.weight");
+ L.attn_gate = weight_desc_t(flm_q4k, {D, DQ}, "model.layer.%d.self_attn.gate_proj.weight");
+ L.attn_output = weight_desc_t(flm_q4k, {DQ, D}, "model.layer.%d.self_attn.o_proj.weight");
+ L.ffn_up_shexp = weight_desc_t(flm_q4k, {D, expert_width}, "model.layer.%d.mlp.share_up_exps_proj.weight");
+ L.ffn_gate_shexp = weight_desc_t(flm_q4k, {D, expert_width}, "model.layer.%d.mlp.share_gate_exps_proj.weight");
+ L.ffn_down_shexp = weight_desc_t(flm_q4k, {expert_width, D}, "model.layer.%d.mlp.share_down_exps_proj.weight");
+ L.input_layer_norm = weight_desc_t(flm_bf16, {D}, "model.layer.%d.input_layernorm.weight");
+ L.post_attntion_norm = weight_desc_t(flm_bf16, {D}, "model.layer.%d.post_attention_layernorm.weight");
+ L.ffn_gate_inp = weight_desc_t(flm_bf16, {D, num_experts}, "model.layer.%d.moe_router.weight");
+
+ weight_container proj_c, rms_c;
+ for (weight_desc_t* w : L.proj_all()) proj_c.add_weight(*w);
+ for (weight_desc_t* w : L.rms_all()) rms_c.add_weight(*w);
+ L.proj_bytes = proj_c.get_size();
+ L.rms_bytes = rms_c.get_size();
+ // shim DMA offsets are 32-bit, and one buffer per layer keeps them small
+ if (L.proj_bytes >= 512ull * 1024 * 1024) {
+ throw std::runtime_error("minicpm5_moe_npu: one layer's weights do not fit 512 MB");
+ }
+ }
+};
+
+#endif
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu.cpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu.cpp
new file mode 100644
index 000000000..9d9f195c8
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu.cpp
@@ -0,0 +1,507 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_npu.cpp
+/// \brief minicpm5_moe_npu: MiniCPM5-15B-A2.5B on the NPU2 decode overlays
+/// \note See minicpm5_moe_npu_detail.hpp for what one token runs.
+#include
+#include
+#include "minicpm5_moe_npu_detail.hpp"
+#include "npu_utils/runtime_wait.hpp"
+
+namespace {
+// MC5_TIME_HOST=1: print where each token's host time goes, in microseconds (the
+// same switch as the kernel host test in FLM_Xclbin/MiniCPM5/moe_decoding)
+const bool time_host = std::getenv("MC5_TIME_HOST") != nullptr;
+using host_clock = std::chrono::steady_clock;
+long us_between(host_clock::time_point a, host_clock::time_point b) {
+ return (long)std::chrono::duration_cast(b - a).count();
+}
+} // namespace
+
+minicpm5_moe_npu::Impl::Impl(LM_Config config, npu_xclbin_manager *npu_instance, int MAX_L)
+ : config(config), npu(npu_instance) {
+ current_context_length = 0;
+ checkpoint_context_length = 0;
+ is_checkpoint_valid = false;
+ desc.build(config);
+ pctx = std::make_unique(desc);
+ this->MAX_L = _normalize_max_length(MAX_L > 0 ? (uint32_t)MAX_L : 0);
+
+ // Two decode bitstreams (+ the prefill overlay). The layer overlay's RTP addresses
+ // are constants in minicpm5_moe_npu_sequence.hpp, which has the note about
+ // re-checking them after a kernel rebuild.
+ const std::string xclbin_dir = utils::path_join(config.exec_path, "xclbins", config.model_name);
+ layer_app_manager = npu->register_xclbin(utils::path_join(xclbin_dir, "moe_layer.xclbin"));
+ lm_head_app_manager = npu->register_xclbin(utils::path_join(xclbin_dir, "lm_head.xclbin"));
+#if MINICPM5_MOE_ATTN_ON_NPU || MINICPM5_MOE_MM_ON_NPU
+ // the batched prefill's dequant_mm / attention (one xclbin, see minicpm5_moe_prefill_overlay.hpp)
+ overlay = std::make_unique(npu, utils::path_join(xclbin_dir, "prefill_overlay.xclbin"), desc);
+ pctx->set_overlay(overlay.get());
+#endif
+ sequence = std::make_unique(desc, this->MAX_L);
+
+ dense_layer = layer_app_manager->create_app();
+ moe_layer = layer_app_manager->create_app();
+ lm_head = lm_head_app_manager->create_app();
+ router_rtp.resize(desc.num_hidden_layers);
+ for (uint32_t l = 0; l < desc.num_hidden_layers; l++) {
+ router_rtp[l] = layer_app_manager->create_app();
+ }
+ layer_runlist = layer_app_manager->create_runlist();
+
+ // ---- per-layer buffers; sizes come from desc only ----
+ const uint32_t N = desc.num_hidden_layers;
+ proj_weights.resize(N);
+ rms_weights.resize(N);
+ rope_rms_weights.resize(N);
+ kv_caches.resize(N);
+ router_bias.resize(N);
+ const size_t kv_elems = desc.get_kv_cache_alloc_elems(this->MAX_L);
+ size_t weight_bytes = 0;
+ for (uint32_t l = 0; l < N; l++) {
+ npu_app& app = _layer_app(l);
+ const minicpm5_moe_layer_def& W = desc.layer_def(l);
+ proj_weights[l] = app.create_bo_buffer(W.proj_bytes);
+ rms_weights[l] = app.create_bo_buffer(W.rms_bytes / sizeof(bf16));
+ weight_bytes += W.proj_bytes + W.rms_bytes;
+ rope_rms_weights[l] = app.create_bo_buffer(desc.get_rope_rms_elems());
+ // Zeroed once here: the attention reads whole 16-token chunks, so rows past
+ // L are read (and masked) and only have to be finite. Rows a token has
+ // written stay finite, so nothing has to re-zero them later.
+ kv_caches[l] = app.create_bo_buffer(kv_elems);
+ kv_caches[l].memset((bf16)0.0f);
+ kv_caches[l].sync_to_device();
+ }
+
+ x = moe_layer.create_bo_buffer(X_ELEMS);
+ assert(desc.D + desc.DQ <= X_ELEMS);
+ x.memset((bf16)0.0f);
+ lm_x = lm_head.create_bo_buffer(desc.D * 2);
+ lm_head_weights = lm_head.create_bo_buffer(desc.get_lm_head_w_size());
+ logits = lm_head.create_bo_buffer(desc.vocab_size_padded);
+ logits_valid = buffer(logits.data(), desc.vocab_size);
+ embedding = std::make_unique(desc.vocab_size, desc.D);
+
+ sequence->gen_lm_head_seq(lm_head.seq());
+ lm_head_run = lm_head.create_run(logits, lm_head_weights, lm_x);
+
+ LOG_VERBOSE(1, "minicpm5_moe_npu: MAX_L " << this->MAX_L << ", KV cache " << (kv_elems * sizeof(bf16) * N >> 20) << " MB, weights "
+ << (weight_bytes >> 20) << " MB");
+}
+
+uint32_t minicpm5_moe_npu::Impl::_normalize_max_length(uint32_t requested) {
+ uint32_t L = std::max(requested, 4096);
+ // a power of two is also a whole number of 16-token KV chunks
+ uint32_t pow2 = 1;
+ while (pow2 < L) pow2 <<= 1;
+ if (pow2 > minicpm5_moe_desc::MAX_CONTEXT) {
+ header_print("WARNING", "minicpm5_moe_npu: context " << requested << " capped at " << minicpm5_moe_desc::MAX_CONTEXT
+ << " (the longest KV cache the attention was checked at)");
+ pow2 = minicpm5_moe_desc::MAX_CONTEXT;
+ }
+ return pow2;
+}
+
+void minicpm5_moe_npu::Impl::load_weights(Q4NX& q4nx) {
+ embedding->init_weights(&q4nx, "model.embed_tokens");
+ const bool check_layout = std::getenv("MC5_CHECK_LAYOUT") != nullptr;
+
+ for (uint32_t l = 0; l < desc.num_hidden_layers; l++) {
+ desc.load_layer(l, q4nx, proj_weights[l], rms_weights[l], router_bias[l]);
+ // never changes, so this sequence is built once
+ sequence->gen_router_rtp_seq(router_rtp[l].seq(), l, router_bias[l]);
+ // MC5_CHECK_LAYOUT=1: the prefill's weight views against model.q4nx, byte for byte
+ if (check_layout) {
+ const size_t bad = pctx->check_layout(l, q4nx, proj_weights[l]);
+ const std::string tag = bad ? "ERROR" : "info"; // header_print does not parenthesize its tag
+ header_print(tag, "layout check, layer " << l << ": " << bad << " blocks differ");
+ if (bad) throw std::runtime_error("minicpm5_moe_npu: the prefill weight views do not match the decode layout");
+ }
+ proj_weights[l].sync_to_device();
+ rms_weights[l].sync_to_device();
+ rope_rms_weights[l].sync_to_device();
+ }
+
+ // the lm_head kernel reads the final norm weight from the second half of its x buffer
+ {
+ buffer final_norm;
+ q4nx.load_weights(final_norm, "model.norm.weight");
+ memcpy(lm_x.data() + desc.D, final_norm.data(), desc.D * sizeof(bf16));
+ lm_x.sync_to_device();
+ }
+ desc.load_lm_head(q4nx, lm_head_weights);
+ lm_head_weights.sync_to_device();
+
+ // the prefill's buffers and threads now, not in the first prompt's time to first token
+ const host_clock::time_point t0 = host_clock::now();
+ pctx->prewarm(std::min(PREFILL_CHUNK, (int)MAX_L));
+ if (time_host) std::cout << "[minicpm5_moe time] prefill prewarm " << us_between(t0, host_clock::now()) << " us" << std::endl;
+
+ clear_context();
+}
+
+void minicpm5_moe_npu::Impl::_set_rope(int pos) {
+ const uint32_t half = desc.RoPE_DIM / 2;
+ std::vector cos_sin(desc.RoPE_DIM);
+ for (uint32_t i = 0; i < half; i++) {
+ // fp32 angle, as transformers computes it (inv_freq fp32 * position fp32)
+ const float angle = desc.inv_freq[i] * (float)pos;
+ cos_sin[i] = (bf16)std::cos(angle);
+ cos_sin[i + half] = (bf16)std::sin(angle);
+ }
+ // every layer has its own buffer (a run binds its own BOs)
+ for (uint32_t l = 0; l < desc.num_hidden_layers; l++) {
+ memcpy(rope_rms_weights[l].data(), cos_sin.data(), desc.RoPE_DIM * sizeof(bf16));
+ rope_rms_weights[l].sync_to_device();
+ }
+}
+
+/// L = tokens already in the cache; prepares the runs for the token at position L
+void minicpm5_moe_npu::Impl::set_context_length(int L) {
+ current_context_length = L;
+ // The one rule the rest of this engine leans on: rows at or past the context are
+ // zero. Both attentions read whole rounds, so they reach past the last real key
+ // (prefill a 128-row round, decode a 16-row chunk), and the kernels do not keep
+ // those rows out of the answer -- as every other engine here already documents
+ // (kv_rows_state.hpp, qwen3_6_moe_npu.cpp). qwen3_6 wipes the whole cache on every
+ // clear; we only have to clean what has actually been written, which is what
+ // dirty_rows tracks. Growing the context needs nothing: those rows were zero and
+ // are being filled. Shrinking it (a clear, a restore, a slot written back) is where
+ // another conversation's rows would be left exposed.
+ // Callers set the length after the rows are in place, so afterwards exactly the
+ // first `want` rows hold K/V either way, whether we just grew or just cleaned.
+ const size_t want = (size_t)std::max(L, 0);
+ if (want < dirty_rows) {
+ kv_rows_zero(kv_caches, kv_layout(), want, dirty_rows);
+ }
+ dirty_rows = want;
+ // a full cache has no next call to prepare: that call would write row L, past
+ // the cache. forward() / prefill() refuse to run then.
+ if (L >= (int)MAX_L) return;
+
+ const host_clock::time_point t0 = host_clock::now();
+ sequence->gen_layer_seq(dense_layer.seq(), L + 1, desc.dense);
+ sequence->gen_layer_seq(moe_layer.seq(), L + 1, desc.moe);
+ const host_clock::time_point t1 = host_clock::now();
+ // the runs hold the sequence's kernel object, so they are rebuilt with it
+ // (the first create_run after a sequence change also assembles its ELF)
+ layer_runlist.reset();
+ for (uint32_t l = 0; l < desc.num_hidden_layers; l++) {
+ layer_runlist.add(router_rtp[l].create_run());
+ layer_runlist.add(_layer_app(l).create_run(x, proj_weights[l], rms_weights[l], rope_rms_weights[l], kv_caches[l]));
+ }
+ const host_clock::time_point t2 = host_clock::now();
+ _set_rope(L);
+ if (time_host) {
+ std::cout << "[minicpm5_moe time] L " << L << ": sequences " << us_between(t0, t1) << " us, runs (+ ELF) "
+ << us_between(t1, t2) << " us, rope " << us_between(t2, host_clock::now()) << " us" << std::endl;
+ }
+}
+
+void minicpm5_moe_npu::Impl::_run_layers(int id) {
+ if (current_context_length >= (int)MAX_L) {
+ throw std::runtime_error("minicpm5_moe_npu: the KV cache is full (" + std::to_string(MAX_L) + " tokens)");
+ }
+ const host_clock::time_point t0 = host_clock::now();
+ embedding->forward(id, x);
+ x.sync_to_device();
+ // the two contexts do not order against each other: wait for the layers before the lm_head
+ const host_clock::time_point t1 = host_clock::now();
+ layer_runlist.execute();
+ flm::npu::wait_for_completion(layer_runlist, "minicpm5_moe layer runlist");
+ if (time_host) {
+ std::cout << "[minicpm5_moe time] embed " << us_between(t0, t1) << " us, layer runlist "
+ << us_between(t1, host_clock::now()) << " us" << std::endl;
+ }
+}
+
+void minicpm5_moe_npu::Impl::_start_lm_head() {
+ x.sync_from_device();
+ memcpy(lm_x.data(), x.data(), desc.D * sizeof(bf16));
+ lm_x.sync_to_device();
+ lm_head_run.start();
+}
+
+void minicpm5_moe_npu::Impl::_finish_lm_head() {
+ flm::npu::wait_for_completion(lm_head_run, "minicpm5_moe lm_head");
+ logits.sync_from_device();
+}
+
+buffer minicpm5_moe_npu::Impl::forward(int id) {
+ _run_layers(id);
+ const host_clock::time_point t0 = host_clock::now();
+ _start_lm_head();
+ // the next token's sequences are built while the lm_head runs (it touches none of them)
+ set_context_length(current_context_length + 1);
+ _finish_lm_head();
+ if (time_host) {
+ std::cout << "[minicpm5_moe time] lm_head + next sequences " << us_between(t0, host_clock::now()) << " us" << std::endl;
+ }
+ return logits_valid;
+}
+
+/// Two ways to run the prompt (Makefile PREFILL_WITH_MV picks):
+/// default batched, minicpm5_moe_prefill.hpp: chunks of PREFILL_CHUNK tokens
+/// through all layers at once (dequant_mm + attention on the host
+/// for now), writing the decode KV cache
+/// PREFILL_WITH_MV the decode overlays, one token at a time
+buffer minicpm5_moe_npu::Impl::prefill(std::vector& ids, void* payload) {
+ if (ids.empty()) {
+ throw std::runtime_error("minicpm5_moe_npu: empty prefill");
+ }
+ if (current_context_length + ids.size() > MAX_L) {
+ throw std::runtime_error("minicpm5_moe_npu: prompt of " + std::to_string(ids.size()) + " tokens does not fit the KV cache ("
+ + std::to_string(current_context_length) + " of " + std::to_string(MAX_L) + " used)");
+ }
+#ifdef PREFILL_WITH_MV
+ return _prefill_with_mv(ids);
+#else
+ return _prefill_batched(ids);
+#endif
+}
+
+buffer minicpm5_moe_npu::Impl::_prefill_with_mv(std::vector& ids) {
+ for (size_t i = 0; i + 1 < ids.size(); i++) {
+ _run_layers(ids[i]);
+ set_context_length(current_context_length + 1);
+ }
+ return forward(ids.back());
+}
+
+buffer minicpm5_moe_npu::Impl::_prefill_batched(std::vector& ids) {
+ // the decode buffers, which the prefill reads (weights) and writes (KV cache) in place
+ std::vector layers(desc.num_hidden_layers);
+ for (uint32_t l = 0; l < desc.num_hidden_layers; l++) {
+ layers[l] = {&proj_weights[l], &rms_weights[l], &rope_rms_weights[l], &kv_caches[l], &router_bias[l]};
+ }
+
+ // decode / lm_head ran since the last prefill (or nothing did yet): the overlay's
+ // configuration is gone, its first run writes all of it again
+ if (overlay) overlay->invalidate();
+
+ const int total = (int)ids.size();
+ const int D = desc.D;
+ std::vector x;
+ int last_rows = 0;
+ // Chunks bound the scratch (the dense up|gate rows alone are 27 KB a token); a
+ // later chunk attends to the earlier ones through the KV cache, like a new turn.
+ for (int c0 = 0; c0 < total; c0 += PREFILL_CHUNK) {
+ const int n = std::min(PREFILL_CHUNK, total - c0);
+ x.resize((size_t)n * D);
+ for (int i = 0; i < n; i++) {
+ memcpy(x.data() + (size_t)i * D, embedding->w.data() + (size_t)ids[c0 + i] * D, D * sizeof(bf16));
+ }
+ pctx->forward(x.data(), n, current_context_length, layers, MAX_L);
+ current_context_length += n;
+ last_rows = n;
+ }
+
+ // the last token's hidden state -> lm_head; the decode sequences for the next
+ // position are built while it runs
+ memcpy(lm_x.data(), x.data() + (size_t)(last_rows - 1) * D, D * sizeof(bf16));
+ lm_x.sync_to_device();
+ lm_head_run.start();
+ set_context_length(current_context_length);
+ _finish_lm_head();
+ return logits_valid;
+}
+
+buffer minicpm5_moe_npu::Impl::_gather_kv_row(int layer_idx, int kv, int idx) {
+ assert(idx >= 0 && idx < (int)MAX_L);
+ kv_caches[layer_idx].sync_from_device();
+ const size_t col_row = desc.kv_col_row();
+ buffer row(minicpm5_moe_desc::ATTN_COLS * col_row);
+ for (int col = 0; col < minicpm5_moe_desc::ATTN_COLS; col++) {
+ const bf16* src = kv_caches[layer_idx].data() + desc.kv_block_offset(col, kv, MAX_L) + (size_t)idx * col_row;
+ memcpy(row.data() + col * col_row, src, col_row * sizeof(bf16));
+ }
+ return row;
+}
+
+buffer minicpm5_moe_npu::Impl::get_k_cache(int layer_idx, int idx) { return _gather_kv_row(layer_idx, 0, idx); }
+buffer minicpm5_moe_npu::Impl::get_v_cache(int layer_idx, int idx) { return _gather_kv_row(layer_idx, 1, idx); }
+
+/// Every layer is attention, so the state is only the KV rows, and a later token
+/// only ever writes rows at or past its own position: rows below the checkpoint
+/// stay as they are. A checkpoint is therefore just the context length.
+int minicpm5_moe_npu::Impl::checkpoint() {
+ checkpoint_context_length = current_context_length;
+ is_checkpoint_valid = true;
+ return current_context_length;
+}
+
+/// Rows past the checkpoint keep stale (finite) values; they are masked until a
+/// new token overwrites them.
+int minicpm5_moe_npu::Impl::restore() {
+ if (!is_checkpoint_valid) {
+ header_print_r("FLM", "No valid checkpoint to restore");
+ return -1;
+ }
+ set_context_length(checkpoint_context_length);
+ return current_context_length;
+}
+
+/// Every layer is full attention and nothing else survives a token, so a saved
+/// state is just K/V rows: kv_rows_state.hpp does the copying, and all this has
+/// to say is where the four planes are.
+///
+/// The "striped" layout there means four planes of one row each per position,
+/// stride DK/2. That is exactly our [K c0][K c1][V c0][V c1]: ATTN_COLS is 2 and
+/// DK == DV, so kv_col_row() == DK/2. K c0 sits at 0, the other three at
+/// kv_block_offset().
+kv_row_layout minicpm5_moe_npu::Impl::kv_layout() const {
+ kv_row_layout l;
+ l.DK = desc.DK;
+ l.DV = desc.DV;
+ l.striped = true;
+ l.k47 = desc.kv_block_offset(1, 0, MAX_L); // K column 1
+ l.v03 = desc.kv_block_offset(0, 1, MAX_L); // V column 0
+ l.v47 = desc.kv_block_offset(1, 1, MAX_L); // V column 1
+ return l;
+}
+
+std::unique_ptr minicpm5_moe_npu::Impl::new_state() {
+ return kv_rows_new_state(desc.num_hidden_layers, kv_layout());
+}
+
+int minicpm5_moe_npu::Impl::read_state(hybrid_engine_state& state, int kv_from) {
+ header_print_r("FLM", "Reading state at context length " + std::to_string(current_context_length)
+ + ", K/V rows from " + std::to_string(kv_from));
+ return kv_rows_read(state, kv_caches, kv_layout(), current_context_length, kv_from);
+}
+
+int minicpm5_moe_npu::Impl::write_state_kv(const hybrid_engine_state& state) {
+ return kv_rows_write(state, kv_caches, kv_layout(), MAX_L);
+}
+
+/// Rows past the restored length hold whatever ran since the state was read. They are
+/// not ours to keep: set_context_length() puts the zeros of a fresh context back.
+int minicpm5_moe_npu::Impl::write_state(const hybrid_engine_state& state) {
+ const int length = kv_rows_write(state, kv_caches, kv_layout(), MAX_L);
+ if (length < 0) {
+ header_print_r("FLM", "No valid state to write");
+ return -1;
+ }
+ header_print_r("FLM", "Writing state at context length " + std::to_string(length));
+ // the legacy checkpoint was taken against a context this state replaces
+ is_checkpoint_valid = false;
+ set_context_length(length);
+ return current_context_length;
+}
+
+/// set_context_length(0) does the wiping: it zeroes every row that has been written
+/// since they were last clean, which is qwen3_6_moe_npu::clear_context's full memset
+/// without the part that was never touched.
+void minicpm5_moe_npu::Impl::clear_context() {
+ is_checkpoint_valid = false;
+ set_context_length(0);
+}
+
+/// The KV block offsets scale with MAX_L, so each column's K and V block moves
+/// to its new place (only the rows in use are copied).
+void minicpm5_moe_npu::Impl::update_max_length(uint32_t new_max) {
+ new_max = _normalize_max_length(new_max);
+ if (new_max <= MAX_L) {
+ header_print("FLM", "New length is not longer than the current length, no need to update!");
+ return;
+ }
+ const size_t col_row = desc.kv_col_row();
+ const size_t rows = (size_t)current_context_length;
+ for (uint32_t l = 0; l < desc.num_hidden_layers; l++) {
+ buffer& old_cache = kv_caches[l];
+ old_cache.sync_from_device();
+ npu_app& app = _layer_app(l);
+ buffer new_cache = app.create_bo_buffer(desc.get_kv_cache_alloc_elems(new_max));
+ new_cache.memset((bf16)0.0f);
+ for (int col = 0; col < minicpm5_moe_desc::ATTN_COLS; col++) {
+ for (int kv = 0; kv < 2; kv++) {
+ memcpy(new_cache.data() + desc.kv_block_offset(col, kv, new_max),
+ old_cache.data() + desc.kv_block_offset(col, kv, MAX_L),
+ rows * col_row * sizeof(bf16));
+ }
+ }
+ new_cache.sync_to_device();
+ kv_caches[l] = new_cache;
+ }
+ MAX_L = new_max;
+ sequence->set_max_length(MAX_L);
+ set_context_length(current_context_length); // new sequences, runs bound to the new caches
+}
+
+minicpm5_moe_npu::Impl::~Impl() = default;
+
+// ===============================================
+// Externals for minicpm5_moe_npu
+// ===============================================
+minicpm5_moe_npu::minicpm5_moe_npu(LM_Config config, npu_xclbin_manager *npu_instance, int MAX_L) {
+ this->_impl = new Impl(config, npu_instance, MAX_L);
+}
+
+buffer minicpm5_moe_npu::forward(int ids) {
+ return this->_impl->forward(ids);
+}
+
+buffer minicpm5_moe_npu::prefill(std::vector& ids, void* payload) {
+ return this->_impl->prefill(ids, payload);
+}
+
+void minicpm5_moe_npu::set_context_length(int L) {
+ this->_impl->set_context_length(L);
+}
+
+void minicpm5_moe_npu::load_weights(Q4NX& q4nx) {
+ this->_impl->load_weights(q4nx);
+}
+
+void minicpm5_moe_npu::update_max_length(uint32_t MAX_L) {
+ this->_impl->update_max_length(MAX_L);
+}
+
+void minicpm5_moe_npu::clear_context() {
+ this->_impl->clear_context();
+}
+
+buffer minicpm5_moe_npu::get_k_cache(int layer_idx, int idx) {
+ return this->_impl->get_k_cache(layer_idx, idx);
+}
+
+buffer minicpm5_moe_npu::get_v_cache(int layer_idx, int idx) {
+ return this->_impl->get_v_cache(layer_idx, idx);
+}
+
+int minicpm5_moe_npu::get_current_context_length() {
+ return this->_impl->get_current_context_length();
+}
+
+int minicpm5_moe_npu::checkpoint() {
+ return this->_impl->checkpoint();
+}
+
+int minicpm5_moe_npu::restore() {
+ return this->_impl->restore();
+}
+
+std::unique_ptr minicpm5_moe_npu::new_state() {
+ return this->_impl->new_state();
+}
+
+int minicpm5_moe_npu::read_state(hybrid_engine_state& state, int kv_from) {
+ return this->_impl->read_state(state, kv_from);
+}
+
+int minicpm5_moe_npu::write_state(const hybrid_engine_state& state) {
+ return this->_impl->write_state(state);
+}
+
+int minicpm5_moe_npu::write_state_kv(const hybrid_engine_state& state) {
+ return this->_impl->write_state_kv(state);
+}
+
+minicpm5_moe_npu::~minicpm5_moe_npu() {
+ delete this->_impl;
+}
+
+extern "C" const flm_state_api* minicpm5_moe_npu_state_api(void* engine) {
+ return hybrid_state_api(engine);
+}
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_detail.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_detail.hpp
new file mode 100644
index 000000000..afff0f2a8
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_detail.hpp
@@ -0,0 +1,108 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+#pragma once
+#include "models/minicpm5_moe/minicpm5_moe_npu.hpp"
+#include "minicpm5_moe_model_def.hpp"
+#include "minicpm5_moe_npu_sequence.hpp"
+#include "minicpm5_moe_prefill.hpp"
+#include "utils/kv_rows_state.hpp"
+
+/// @brief everything the engine owns
+/// @note One token = two runs on two hw contexts, in order:
+/// layer_runlist 28 x [router RTP, layer] (moe_layer.xclbin)
+/// lm_head_run final norm + logits (lm_head.xclbin)
+/// The layer runs all read and write the same x buffer on the device, so
+/// nothing goes back to the host between them.
+struct minicpm5_moe_npu::Impl{
+ LM_Config config;
+ npu_xclbin_manager *npu;
+ minicpm5_moe_desc desc;
+ std::unique_ptr sequence;
+ std::unique_ptr pctx; // the batched prefill
+ std::unique_ptr overlay; // its NPU stages (prefill_overlay.xclbin)
+ uint32_t MAX_L;
+ // tokens per batched prefill chunk: bounds the scratch (~100 KB a token, ~400 MB a chunk)
+ static constexpr int PREFILL_CHUNK = 4096;
+
+ npu_app_manager* layer_app_manager;
+ npu_app_manager* lm_head_app_manager;
+
+ // Both on moe_layer.xclbin. The sequences depend on L and are rebuilt per token;
+ // layer 0 has its own because its buffers are laid out for 16 experts, not 160.
+ npu_app dense_layer; // layer 0
+ npu_app moe_layer; // layers 1.., one sequence for all
+ std::vector router_rtp; // per layer: layer number + expert bias, built once
+ npu_app lm_head;
+
+ // per layer
+ std::vector> proj_weights;
+ std::vector> rms_weights;
+ std::vector> rope_rms_weights; // [cos | sin]
+ std::vector> kv_caches; // [K col 0][K col 1][V col 0][V col 1]
+ std::vector> router_bias;
+
+ // x: [0, D) layer input, then layer output; [D, D + DQ) is the attention tap
+ // of a debug (ATTN_TAP) build of the layer overlay
+ static constexpr size_t X_ELEMS = 8192;
+ buffer x;
+ buffer lm_x; // [x | final norm weight]
+ buffer lm_head_weights;
+ buffer logits;
+ buffer logits_valid; // first vocab_size entries of logits
+ std::unique_ptr embedding;
+
+ flm_rt::runlist layer_runlist;
+ flm_rt::run lm_head_run;
+
+ int current_context_length;
+ int checkpoint_context_length;
+ bool is_checkpoint_valid;
+ /// @brief highest context length reached since the rows were last known to be zero
+ /// @note Rows below it hold some conversation's K/V. write_state() zeroes
+ /// [restored length, dirty_rows) so a restored context looks like a fresh
+ /// one; measured, not assumed (check_engine.cpp check 6).
+ size_t dirty_rows = 0;
+
+ Impl(LM_Config config, npu_xclbin_manager *npu_instance, int MAX_L);
+ ~Impl();
+
+ buffer forward(int ids);
+ buffer prefill(std::vector& ids, void* payload = nullptr);
+ buffer _prefill_batched(std::vector& ids); // default
+ buffer _prefill_with_mv(std::vector& ids); // PREFILL_WITH_MV: decode overlays, token by token
+ void set_context_length(int L);
+ void load_weights(Q4NX& q4nx);
+ void update_max_length(uint32_t MAX_L);
+ void clear_context();
+ buffer get_k_cache(int layer_idx, int idx);
+ buffer get_v_cache(int layer_idx, int idx);
+ int get_current_context_length() { return current_context_length; }
+ int checkpoint();
+ int restore();
+
+ /// @brief where this layer's four K/V planes sit, for kv_rows_state.hpp
+ /// @note Rebuilt on every call: the plane offsets scale with MAX_L, which
+ /// update_max_length() can grow under a state that was read earlier.
+ kv_row_layout kv_layout() const;
+ std::unique_ptr new_state();
+ int read_state(hybrid_engine_state& state, int kv_from);
+ int write_state(const hybrid_engine_state& state);
+ int write_state_kv(const hybrid_engine_state& state);
+
+ /// @brief round a requested KV length up to a power of two in [4096, MAX_CONTEXT]
+ static uint32_t _normalize_max_length(uint32_t requested);
+ /// @brief the app layer `l` runs on (layer 0's layout differs, see dense_layer)
+ npu_app& _layer_app(uint32_t l) {
+ return desc.layer_kind(l) == minicpm5_moe_layer_kind::dense ? dense_layer : moe_layer;
+ }
+ /// @brief embedding of `id` into x, then all layers; x holds the last hidden state
+ void _run_layers(int id);
+ /// @brief x -> final norm + logits
+ void _start_lm_head();
+ void _finish_lm_head();
+ /// @brief cos / sin of position `pos` into every layer's rope buffer
+ void _set_rope(int pos);
+ /// @brief K (kv = 0) or V (kv = 1) row `idx` of a layer, all KV heads in head order
+ buffer _gather_kv_row(int layer_idx, int kv, int idx);
+};
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_sequence.cpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_sequence.cpp
new file mode 100644
index 000000000..a2c6185c3
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_sequence.cpp
@@ -0,0 +1,282 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_npu_sequence.cpp
+/// \brief instruction sequences for the MiniCPM5-15B-A2.5B decode overlays
+/// \note See minicpm5_moe_npu_sequence.hpp. The DMA order inside the layer sequence is
+/// the one the kernels were checked with; do not reorder it casually (the
+/// comments say what broke when it was).
+#include "minicpm5_moe_npu_sequence.hpp"
+
+minicpm5_moe_npu_sequence::minicpm5_moe_npu_sequence(minicpm5_moe_desc& desc, uint32_t MAX_L)
+ : desc(desc), MAX_L(MAX_L) {}
+
+// =============================================================================
+// one decoder layer; layer 0 differs only in its buffers (see the model def)
+// =============================================================================
+void minicpm5_moe_npu_sequence::gen_layer_seq(npu_sequence* seq, int L, const minicpm5_moe_layer_def& W) {
+ assert(L > 0 && L <= (int)MAX_L);
+ const size_t kv_col_row = desc.kv_col_row();
+ seq->clear_cmds();
+
+ for (int i = 0; i < attn_cus; i++) {
+ seq->rtp_write(get_tile(attn_qk_rc[i][0], attn_qk_rc[i][1]), l_attn_qk_address, L);
+ seq->rtp_write(get_tile(attn_kv_rc[i][0], attn_kv_rc[i][1]), l_attn_kv_address, L);
+ }
+ for (int i = 0; i < 16; i++) {
+ npu_tiles tile = get_tile(proj_rc[i][0], proj_rc[i][1]);
+ seq->rtp_write(tile, proj_rtp_address, 1);
+ seq->rtp_write(tile, CT_lock_address_base + 16 * proj_rtp_lock_id, 1); // set lock to 1
+ }
+ // (the router's layer number and expert bias: gen_router_rtp_seq, its own run)
+
+ _send_hidden_states(seq);
+ // input_layernorm | post_attention_layernorm (the router weight behind them goes on IT5)
+ seq->npu_dma_memcpy_nd(sizeof(bf16), w_rms_arg_idx, MM2S, xyr_tile, bd_1, it_channel_1,
+ {0, 0, 0, 0}, {1, 1, 1, desc.D * 2}, {0, 0, 0, 1},
+ 0, 0, true, aggressive_cache);
+ seq->npu_dma_wait(xyr_tile, MM2S, it_channel_1);
+ _send_rope_weights(seq);
+
+ // Router weight first, so IT5 sends it while attention runs and the router +
+ // helper start on it as soon as x is there.
+ _send_router_weights(seq, W);
+
+ // receive y
+ seq->npu_dma_memcpy_nd(sizeof(bf16), xy_arg_idx, S2MM, xyr_tile, bd_10, it_channel_1,
+ {0, 0, 0, 0}, {1, 1, 1, desc.D}, {0, 0, 0, 1},
+ -1, 0, true);
+
+ // RoPE sends the new token's K (all KV heads) then V (all KV heads) through
+ // IT3. Write each column's heads into that column's K / V block, row L - 1:
+ // BDs 0..3 = K col 0, K col 1, V col 0, V col 1, in stream order.
+ const uint32_t row_offset = (uint32_t)((L - 1) * kv_col_row);
+ for (int kv = 0; kv < 2; kv++) {
+ for (int col = 0; col < attn_cols; col++) {
+ const uint32_t block_offset = (uint32_t)desc.kv_block_offset(col, kv, MAX_L);
+ seq->npu_dma_memcpy_nd(sizeof(bf16), kv_cache_arg_idx, S2MM, attn_shims[0], npu_bd_id(kv * attn_cols + col), it_channel_0,
+ {0, 0, 0, block_offset + row_offset}, {1, 1, 1, (uint32_t)kv_col_row}, {0, 0, 0, 1},
+ -1, 0, true);
+ }
+ }
+ // k, v, q, gate: one matrix (RoPE takes K, V, Q; the output gate tile the gate)
+ _move_weights_q4k(seq, desc.DK + desc.DV + 2 * desc.DQ, desc.D, W.attn_k.offset);
+
+ // K reads start once both K writes of the new row are done, V reads once both V writes are
+ {
+ const int L_padded = (L + minicpm5_moe_desc::KV_CHUNK - 1) / minicpm5_moe_desc::KV_CHUNK * minicpm5_moe_desc::KV_CHUNK;
+ assert(L_padded <= (int)MAX_L);
+ const uint32_t data2move = (uint32_t)(L_padded * kv_col_row);
+ const npu_bd_id read_bd[2][attn_cols] = {{bd_4, bd_0}, {bd_5, bd_1}}; // IT3 uses BDs 0..3 to write
+ for (int kv = 0; kv < 2; kv++) {
+ for (int col = 0; col < attn_cols; col++) {
+ seq->npu_dma_wait(attn_shims[0], S2MM, it_channel_0);
+ }
+ for (int col = 0; col < attn_cols; col++) {
+ seq->npu_dma_memcpy_nd(sizeof(bf16), kv_cache_arg_idx, MM2S, attn_shims[col], read_bd[kv][col],
+ kv == 0 ? it_channel_0 : it_channel_1,
+ {0, 0, 0, (uint32_t)desc.kv_block_offset(col, kv, MAX_L)}, {1, 1, 1, data2move}, {0, 0, 0, 1},
+ -1, 0, false, aggressive_cache);
+ }
+ }
+ }
+ _move_weights_q4k(seq, desc.D, desc.DQ, W.attn_output.offset);
+
+ // Routed expert weight BDs on shim 0, 1, 6, 7: one linear BD per channel,
+ // 4 / 5 for round 0 and 12 / 13 for round 1. Written here but not started;
+ // the router CT patches in the chosen expert's address and starts them with
+ // control packets.
+ for (int i = 0; i < 4; i++) {
+ _setup_expert_q4k(seq, i, 4, W.ffn_up_exps.offset);
+ _setup_expert_q4k(seq, i, 12, W.ffn_up_exps.offset);
+ }
+
+ // shared expert up-gate, then down (down's last round pushed but not yet waited for)
+ _move_weights_q4k(seq, 2 * desc.expert_width, desc.D, W.ffn_up_shexp.offset);
+ _move_weights_q4k(seq, desc.D, desc.expert_width, W.ffn_down_shexp.offset, false);
+
+ // Tell the router the expert BDs are ready. Only now: the router pushes the
+ // routed-expert weight tasks onto the same shim queues (0, 1, 6, 7) as the
+ // shared-expert ones above, and a router that got here first queued them in
+ // front of the last shared-down weights (wrong output from the 2nd call on).
+ npu_tiles router_CT = get_tile(router_rc[0], router_rc[1]);
+ seq->npu_maskwrite(router_CT, 0x32038, 0x1, 0x1);
+ seq->rtp_write(router_CT, CT_lock_address_base + 16 * router_bd_ready_lock_id, 1); // set lock to 1
+ _wait_proj_weights(seq);
+
+ seq->npu_dma_wait(xyr_tile, S2MM, it_channel_1); // y
+ seq->cmds2seq();
+}
+
+void minicpm5_moe_npu_sequence::gen_router_rtp_seq(npu_sequence* seq, int layer_idx, const std::vector& bias) {
+ assert(bias.size() == desc.num_experts);
+ npu_tiles router_CT = get_tile(router_rc[0], router_rc[1]);
+ seq->clear_cmds();
+ // which layer this is: the router keeps one weight base address per layer
+ seq->rtp_write(router_CT, router_layer_address, (uint32_t)layer_idx);
+ // the expert bias, one write per expert (fp32 bit pattern). The router reads
+ // it only after its logits, i.e. well inside the layer run that follows.
+ for (uint32_t e = 0; e < desc.num_experts; e++) {
+ uint32_t bits;
+ memcpy(&bits, &bias[e], sizeof(bits));
+ seq->rtp_write(router_CT, router_bias_address + 4 * e, bits);
+ }
+ seq->cmds2seq();
+}
+
+// =============================================================================
+// shared helpers of the two layer overlays
+// =============================================================================
+void minicpm5_moe_npu_sequence::_send_hidden_states(npu_sequence* seq) {
+ // packet 0: to the rms tile
+ seq->npu_dma_memcpy_nd(sizeof(bf16), xy_arg_idx, MM2S, xyr_tile, bd_0, it_channel_0,
+ {0, 0, 0, 0}, {1, 1, 1, desc.D}, {0, 0, 0, 1},
+ 0, 0, false, aggressive_cache);
+}
+
+void minicpm5_moe_npu_sequence::_send_rope_weights(npu_sequence* seq) {
+ // cos | sin (packet 1: to the RoPE tile)
+ seq->npu_dma_memcpy_nd(sizeof(bf16), w_rope_rms_arg_idx, MM2S, xyr_tile, bd_2, it_channel_0,
+ {0, 0, 0, 0}, {1, 1, 1, (uint32_t)desc.get_rope_rms_elems()}, {0, 0, 0, 1},
+ 1, 0, true, no_cache);
+ seq->npu_dma_wait(xyr_tile, MM2S, it_channel_0);
+}
+
+/// The host stored the router weight in read order (32-expert x 256-input blocks,
+/// see load_layer), so each part is one straight read. MT5 holds experts 0..127
+/// (channel 0, packets to MT5); experts 128.. do not fit and go straight to the
+/// router helper (channel 1, circuit flow).
+void minicpm5_moe_npu_sequence::_send_router_weights(npu_sequence* seq, const minicpm5_moe_layer_def& W) {
+ constexpr uint32_t mt5_experts = minicpm5_moe_desc::ROUTER_MT_EXPERTS;
+ const uint32_t base = (uint32_t)(W.ffn_gate_inp.offset / sizeof(bf16));
+ assert(desc.num_experts > mt5_experts);
+ seq->npu_dma_memcpy_nd(sizeof(bf16), w_rms_arg_idx, MM2S, IT5, bd_12, it_channel_0,
+ {0, 0, 0, base}, {1, 1, 1, mt5_experts * desc.D}, {0, 0, 0, 1},
+ 10, 0, false, aggressive_cache);
+ seq->npu_dma_memcpy_nd(sizeof(bf16), w_rms_arg_idx, MM2S, IT5, bd_13, it_channel_1,
+ {0, 0, 0, base + mt5_experts * desc.D}, {1, 1, 1, (desc.num_experts - mt5_experts) * desc.D}, {0, 0, 0, 1},
+ -1, 0, false, aggressive_cache);
+}
+
+/// One matrix through the 16 proj cores, 32 rows each per round: channel 0 of a
+/// column's shim feeds its cores 0, 1 and channel 1 cores 2, 3 (reorder_cpy put
+/// those blocks next to each other). Two BD sets ping-pong, so round r + 1 is
+/// queued before round r is waited for.
+/// \param wait_last_round false: the last round's tasks are pushed but not waited for
+void minicpm5_moe_npu_sequence::_move_weights_q4k(npu_sequence* seq, size_t Dout, size_t Din, size_t w_offset, bool wait_last_round) {
+ const uint32_t m = QXNX_ROW_BLOCK_SIZE;
+ const uint32_t a_block_size = minicpm5_moe_desc::Q4K_BLOCK_BYTES / sizeof(bf16); // in bf16 elements
+ const uint32_t blocks_per_row = Din / QXNX_COL_BLOCK_SIZE;
+ const uint32_t cores = 16;
+ const uint32_t w_base = (uint32_t)(w_offset / sizeof(bf16));
+ assert(Dout % (m * cores) == 0);
+ for (size_t round = 0; round < Dout / m / cores; round++) {
+ const uint32_t bd_offset = (round % 2) * 8;
+ for (uint32_t col = 0; col < 4; col++) {
+ const uint32_t first_row = round * cores + col * 4; // this column's first block row
+ seq->npu_dma_memcpy_nd(sizeof(bf16), w_proj_arg_idx, MM2S, mvm_tiles[col], npu_bd_id(bd_1 + bd_offset), it_channel_0,
+ {0, 0, 0, first_row * a_block_size * blocks_per_row + w_base}, {1, 1, 1, 2 * blocks_per_row * a_block_size}, {0, 0, 0, 1},
+ -1, 0, true, aggressive_cache);
+ seq->npu_dma_memcpy_nd(sizeof(bf16), w_proj_arg_idx, MM2S, mvm_tiles[col], npu_bd_id(bd_2 + bd_offset), it_channel_1,
+ {0, 0, 0, (first_row + 2) * a_block_size * blocks_per_row + w_base}, {1, 1, 1, 2 * blocks_per_row * a_block_size}, {0, 0, 0, 1},
+ -1, 0, true, aggressive_cache);
+ }
+ if (round > 0) {
+ _wait_proj_weights(seq);
+ }
+ }
+ if (wait_last_round) {
+ _wait_proj_weights(seq);
+ }
+}
+
+/// Wait for one weight task on both channels of each proj shim (0, 1, 6, 7).
+void minicpm5_moe_npu_sequence::_wait_proj_weights(npu_sequence* seq) {
+ for (uint32_t col = 0; col < 4; col++) {
+ seq->npu_dma_wait(mvm_tiles[col], MM2S, it_channel_0);
+ seq->npu_dma_wait(mvm_tiles[col], MM2S, it_channel_1);
+ }
+}
+
+/// One routed expert's weight BDs on proj shim `col` (0-3): channel 0 gets BD
+/// bd_id, channel 1 BD bd_id + 1, each one linear read of half an expert (see
+/// minicpm5_moe_desc::load_layer). Points at expert 0; the router patches in the
+/// chosen expert's address and pushes the BDs onto the queues.
+void minicpm5_moe_npu_sequence::_setup_expert_q4k(npu_sequence* seq, int col, int bd_id, size_t const_w_byte_offset) {
+ const size_t gate_up_bytes = 2 * (size_t)(desc.expert_width / QXNX_ROW_BLOCK_SIZE) * (desc.D / QXNX_COL_BLOCK_SIZE) * minicpm5_moe_desc::Q4K_BLOCK_BYTES;
+ const size_t down_bytes = (size_t)(desc.D / QXNX_ROW_BLOCK_SIZE) * (desc.expert_width / QXNX_COL_BLOCK_SIZE) * minicpm5_moe_desc::Q4K_BLOCK_BYTES;
+ const uint32_t channel_bytes = (uint32_t)((gate_up_bytes + down_bytes) / 2);
+ constexpr uint32_t SHIM_6_CONTROL_RES_PKT = 30; // the router's control response packet id (kernels)
+ for (int ch = 0; ch < 2; ch++) {
+ seq->npu_dma_memcpy_nd(sizeof(uint8_t), w_proj_arg_idx, MM2S, mvm_tiles[col], npu_bd_id(bd_id + ch),
+ ch == 0 ? it_channel_0 : it_channel_1,
+ {0, 0, 0, (uint32_t)(const_w_byte_offset + (size_t)ch * channel_bytes)}, {1, 1, 1, channel_bytes}, {0, 0, 0, 1},
+ -1, 0, false, aggressive_cache, SHIM_6_CONTROL_RES_PKT, false);
+ }
+}
+
+// =============================================================================
+// LM head (lm_head.xclbin): final RMS norm + Q8_0 logits over 8 columns
+// =============================================================================
+void minicpm5_moe_npu_sequence::gen_lm_head_seq(npu_sequence* seq) {
+ static constexpr npu_tiles ITs[] = {IT0, IT1, IT2, IT3, IT4, IT5, IT6, IT7};
+ static constexpr int COLS = 8;
+ static constexpr int M_PER_COL = 32 * 4; // 4 cores x 32 rows
+ static constexpr int M_PER_ROUND = M_PER_COL * COLS;
+ // the two flows sharing IT0's MM2S 0 (X_PKT_ID / W_PKT_ID in iron/q4k_mm.py);
+ // every other shim MM2S port is circuit-switched
+ static constexpr int X_PKT_ID = 0;
+ static constexpr int W_PKT_ID = 1;
+ static constexpr int NO_PKT = -1;
+ // rounds of shim BD ping-pong; also how far the y waits lag the y issues
+ static constexpr int LOOKAHEAD = 3;
+ const uint32_t vocab = desc.vocab_size_padded;
+ const uint32_t D = desc.D;
+ assert(vocab % M_PER_ROUND == 0);
+ const int rounds = vocab / M_PER_ROUND;
+ // Q8_0: 8.5 bits per weight; in bf16 elements
+ const size_t W_PER_COL = size_t(M_PER_COL * D * 8.5 / 8) / sizeof(bf16);
+ const size_t W_PER_ROUND = W_PER_COL * COLS;
+ // each column's weights are split over two shim MM2S channels, one per pair
+ // of cores; load_lm_head laid the two halves out back to back
+ const size_t W_PER_STREAM = W_PER_COL / 2;
+
+ seq->clear_cmds();
+ // x | final norm weight
+ seq->npu_dma_memcpy_nd(sizeof(bf16), lm_x_arg_idx, MM2S, ITs[0], bd_0, it_channel_0,
+ {0, 0, 0, 0}, {1, 1, 1, D * 2}, {0, 0, 0, 1},
+ X_PKT_ID, 0, false, aggressive_cache);
+
+ for (int r = 0; r < rounds; r++) {
+ const int bd_offset = (r % (LOOKAHEAD + 1)) * 3;
+ const npu_bd_id bd_y = npu_bd_id(bd_1 + bd_offset);
+ const npu_bd_id bd_wa = npu_bd_id(bd_2 + bd_offset);
+ const npu_bd_id bd_wb = npu_bd_id(bd_3 + bd_offset);
+ for (int col = 0; col < COLS; col++) {
+ const size_t w_col_offset = r * W_PER_ROUND + col * W_PER_COL;
+ const uint32_t y_offset = r * M_PER_ROUND + col * M_PER_COL;
+ seq->npu_dma_memcpy_nd(sizeof(bf16), lm_y_arg_idx, S2MM, ITs[col], bd_y, it_channel_0,
+ {0, 0, 0, y_offset}, {1, 1, 1, (uint32_t)M_PER_COL}, {0, 0, 0, 1},
+ -1, 0, true, aggressive_cache);
+ // group a (cores 0/1) on channel 1, group b (cores 2/3) on channel 0;
+ // only IT0's channel 0 is shared with the x broadcast and needs a packet id
+ seq->npu_dma_memcpy_nd(sizeof(bf16), lm_w_arg_idx, MM2S, ITs[col], bd_wa, it_channel_1,
+ {0, 0, 0, (uint32_t)w_col_offset}, {1, 1, 1, (uint32_t)W_PER_STREAM}, {0, 0, 0, 1},
+ NO_PKT, 0, false, aggressive_cache);
+ seq->npu_dma_memcpy_nd(sizeof(bf16), lm_w_arg_idx, MM2S, ITs[col], bd_wb, it_channel_0,
+ {0, 0, 0, (uint32_t)(w_col_offset + W_PER_STREAM)}, {1, 1, 1, (uint32_t)W_PER_STREAM}, {0, 0, 0, 1},
+ col == 0 ? W_PKT_ID : NO_PKT, 0, false, aggressive_cache);
+ // four BD sets in flight: a round waits for the y of three rounds back,
+ // which keeps three rounds of weights queued ahead of the sequencer
+ if (r > LOOKAHEAD - 1) {
+ seq->npu_dma_wait(ITs[col], S2MM, it_channel_0);
+ }
+ }
+ }
+ for (int col = 0; col < COLS; col++) {
+ for (int i = 0; i < LOOKAHEAD; i++) {
+ seq->npu_dma_wait(ITs[col], S2MM, it_channel_0);
+ }
+ }
+ seq->cmds2seq();
+}
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_sequence.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_sequence.hpp
new file mode 100644
index 000000000..ec93eb800
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_npu_sequence.hpp
@@ -0,0 +1,94 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_npu_sequence.hpp
+/// \brief instruction sequences for the MiniCPM5-15B-A2.5B decode overlays
+/// \author FastFlowLM Team
+/// \date 2026-12-03
+/// \note Two bitstreams:
+/// moe_layer.xclbin gen_layer_seq (every layer; one sequence per
+/// layer kind, since the two kinds'
+/// buffers differ in size)
+/// gen_router_rtp_seq (one per layer, built once)
+/// lm_head.xclbin gen_lm_head_seq
+/// The layer sequences depend on the context length and are rebuilt once per
+/// token; the router one only carries the layer's number and expert bias,
+/// which never change, so it runs as its own small run in front of every
+/// layer (the router reads both long after the layer run has started).
+/// Ported from FLM_Xclbin/MiniCPM5/moe_decoding/host/decoding_layer.cpp
+/// and lm_head_npu_bin/host/host.cpp.
+#pragma once
+#include
+#include
+#include "npu_utils/npu_utils.hpp"
+#include "minicpm5_moe_model_def.hpp"
+
+class minicpm5_moe_npu_sequence {
+public:
+ // kernel argument order of the layer overlay: (x, proj, rms, rope_rms, kv_cache)
+ static constexpr int xy_arg_idx = 0;
+ static constexpr int w_proj_arg_idx = 1;
+ static constexpr int w_rms_arg_idx = 2;
+ static constexpr int w_rope_rms_arg_idx = 3;
+ static constexpr int kv_cache_arg_idx = 4;
+ // lm_head overlay: (y, w, x)
+ static constexpr int lm_y_arg_idx = 0;
+ static constexpr int lm_w_arg_idx = 1;
+ static constexpr int lm_x_arg_idx = 2;
+
+ minicpm5_moe_npu_sequence(minicpm5_moe_desc& desc, uint32_t MAX_L);
+
+ /// \brief the KV block offsets depend on MAX_L; call before regenerating
+ void set_max_length(uint32_t MAX_L) { this->MAX_L = MAX_L; }
+
+ /// \param L tokens in the cache after this call (the new token is row L - 1)
+ /// \param W the layer kind's buffer layout (desc.dense or desc.moe)
+ void gen_layer_seq(npu_sequence* seq, int L, const minicpm5_moe_layer_def& W);
+ /// \brief the router's layer number and fp32 expert bias, for one layer
+ void gen_router_rtp_seq(npu_sequence* seq, int layer_idx, const std::vector& bias);
+ void gen_lm_head_seq(npu_sequence* seq);
+
+private:
+ minicpm5_moe_desc& desc;
+ uint32_t MAX_L;
+
+ // ---- floorplan ----
+ static constexpr npu_tiles xyr_tile = IT2; // x / y / rms / rope
+ static constexpr npu_tiles mvm_tiles[4] = {IT0, IT1, IT6, IT7}; // proj weight shims
+ static constexpr int attn_cus = 4; // CU i holds kernel KV head i
+ static constexpr int attn_cols = minicpm5_moe_desc::ATTN_COLS;
+ static constexpr int attn_qk_rc[attn_cus][2] = {{2, 3}, {4, 3}, {2, 4}, {4, 4}};
+ static constexpr int attn_kv_rc[attn_cus][2] = {{3, 3}, {5, 3}, {3, 4}, {5, 4}};
+ static constexpr npu_tiles attn_shims[attn_cols] = {IT3, IT4};
+ // proj cores wait on lock 6 for their RTP every call
+ static constexpr int proj_rc[16][2] = {{2, 0}, {3, 0}, {4, 0}, {5, 0},
+ {2, 1}, {3, 1}, {4, 1}, {5, 1},
+ {2, 6}, {3, 6}, {4, 6}, {5, 6},
+ {2, 7}, {3, 7}, {4, 7}, {5, 7}};
+ static constexpr int router_rc[2] = {4, 5}; // router CT
+ static constexpr size_t CT_lock_address_base = 0x000001F000;
+ static constexpr int proj_rtp_lock_id = 6;
+ static constexpr int router_bd_ready_lock_id = 10; // expert BDs written
+ static constexpr uint32_t proj_rtp_address = 17408; // proj cores' RTP word
+
+ // ---- RTP addresses of moe_layer.xclbin ----
+ // The xclbin build writes these to its xclbins/rtp_addresses.txt; they are
+ // copied here as constants, the way every other engine keeps them. Every core
+ // of a kind holds its RTP at the same offset inside its own data memory, so
+ // one value covers all of them -- the file lists it once per core, all identical.
+ //
+ // RE-CHECK THESE AFTER REBUILDING MiniCPM5/moe_decoding. If a rebuild moves an
+ // RTP, the host writes to a stale address and the result is wrong output or a
+ // hang, not an error. Diff the new rtp_addresses.txt against the values below.
+ static constexpr uint32_t l_attn_qk_address = 5120; // RTP_L_attn_qk_core_*
+ static constexpr uint32_t l_attn_kv_address = 34816; // RTP_L_attn_kv_core_*
+ static constexpr uint32_t router_bias_address = 53248; // RTP_router_expert_bias
+ static constexpr uint32_t router_layer_address = 53888; // RTP_router_layer
+
+ void _send_hidden_states(npu_sequence* seq);
+ void _send_rope_weights(npu_sequence* seq);
+ void _send_router_weights(npu_sequence* seq, const minicpm5_moe_layer_def& W);
+ void _move_weights_q4k(npu_sequence* seq, size_t Dout, size_t Din, size_t w_offset, bool wait_last_round = true);
+ void _wait_proj_weights(npu_sequence* seq);
+ void _setup_expert_q4k(npu_sequence* seq, int col, int bd_id, size_t const_w_byte_offset);
+};
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_overlay_configs.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_overlay_configs.hpp
new file mode 100644
index 000000000..1a16eba37
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_overlay_configs.hpp
@@ -0,0 +1,3149 @@
+// Generated by tools/extract_txn2.py from aiecc --aie-generate-txn. Do not edit.
+#pragma once
+#include
+#include
+
+struct reg_write { uint32_t col, row, offset, value; };
+struct mask_write { uint32_t col, row, offset, mask, value; };
+// shared: another op uses this BD register too -> rewrite it at every switch;
+// otherwise it can stay loaded (write it once after the xclbin is loaded)
+struct reg_block { uint32_t col, row, offset; bool shared; std::vector words; };
+struct chain_start { uint32_t col, row, ctrl_offset, queue_offset, queue_value, ctrl_value; };
+struct op_config {
+ std::vector sw;
+ std::vector mux;
+ std::vector bds;
+ std::vector locks;
+ std::vector starts;
+};
+
+
+// all DMA channel control registers used by any op: (col, row, offset)
+inline const std::vector all_channels = {
+ {0, 1, 0xA0600, 0},
+ {0, 1, 0xA0608, 0},
+ {0, 1, 0xA0610, 0},
+ {0, 1, 0xA0618, 0},
+ {0, 1, 0xA0620, 0},
+ {0, 1, 0xA0628, 0},
+ {0, 1, 0xA0630, 0},
+ {0, 1, 0xA0638, 0},
+ {0, 1, 0xA0640, 0},
+ {0, 1, 0xA0648, 0},
+ {0, 1, 0xA0658, 0},
+ {0, 2, 0x1DE00, 0},
+ {0, 2, 0x1DE08, 0},
+ {0, 2, 0x1DE10, 0},
+ {0, 2, 0x1DE18, 0},
+ {0, 3, 0x1DE00, 0},
+ {0, 3, 0x1DE08, 0},
+ {0, 3, 0x1DE10, 0},
+ {0, 3, 0x1DE18, 0},
+ {0, 4, 0x1DE00, 0},
+ {0, 4, 0x1DE08, 0},
+ {0, 4, 0x1DE10, 0},
+ {0, 4, 0x1DE18, 0},
+ {0, 5, 0x1DE00, 0},
+ {0, 5, 0x1DE08, 0},
+ {0, 5, 0x1DE10, 0},
+ {0, 5, 0x1DE18, 0},
+ {1, 1, 0xA0600, 0},
+ {1, 1, 0xA0608, 0},
+ {1, 1, 0xA0610, 0},
+ {1, 1, 0xA0618, 0},
+ {1, 1, 0xA0620, 0},
+ {1, 1, 0xA0628, 0},
+ {1, 1, 0xA0630, 0},
+ {1, 1, 0xA0638, 0},
+ {1, 1, 0xA0640, 0},
+ {1, 1, 0xA0658, 0},
+ {1, 2, 0x1DE00, 0},
+ {1, 2, 0x1DE08, 0},
+ {1, 2, 0x1DE10, 0},
+ {1, 2, 0x1DE18, 0},
+ {1, 3, 0x1DE00, 0},
+ {1, 3, 0x1DE08, 0},
+ {1, 3, 0x1DE10, 0},
+ {1, 3, 0x1DE18, 0},
+ {1, 4, 0x1DE00, 0},
+ {1, 4, 0x1DE08, 0},
+ {1, 4, 0x1DE10, 0},
+ {1, 4, 0x1DE18, 0},
+ {1, 5, 0x1DE00, 0},
+ {1, 5, 0x1DE08, 0},
+ {1, 5, 0x1DE10, 0},
+ {1, 5, 0x1DE18, 0},
+ {2, 1, 0xA0600, 0},
+ {2, 1, 0xA0608, 0},
+ {2, 1, 0xA0610, 0},
+ {2, 1, 0xA0618, 0},
+ {2, 1, 0xA0620, 0},
+ {2, 1, 0xA0628, 0},
+ {2, 1, 0xA0630, 0},
+ {2, 1, 0xA0638, 0},
+ {2, 1, 0xA0640, 0},
+ {2, 1, 0xA0648, 0},
+ {2, 1, 0xA0658, 0},
+ {2, 2, 0x1DE00, 0},
+ {2, 2, 0x1DE08, 0},
+ {2, 2, 0x1DE10, 0},
+ {2, 2, 0x1DE18, 0},
+ {2, 3, 0x1DE00, 0},
+ {2, 3, 0x1DE08, 0},
+ {2, 3, 0x1DE10, 0},
+ {2, 3, 0x1DE18, 0},
+ {2, 4, 0x1DE00, 0},
+ {2, 4, 0x1DE08, 0},
+ {2, 4, 0x1DE10, 0},
+ {2, 4, 0x1DE18, 0},
+ {2, 5, 0x1DE00, 0},
+ {2, 5, 0x1DE08, 0},
+ {2, 5, 0x1DE10, 0},
+ {2, 5, 0x1DE18, 0},
+ {3, 1, 0xA0600, 0},
+ {3, 1, 0xA0608, 0},
+ {3, 1, 0xA0610, 0},
+ {3, 1, 0xA0618, 0},
+ {3, 1, 0xA0620, 0},
+ {3, 1, 0xA0628, 0},
+ {3, 1, 0xA0630, 0},
+ {3, 1, 0xA0638, 0},
+ {3, 1, 0xA0640, 0},
+ {3, 1, 0xA0658, 0},
+ {3, 2, 0x1DE00, 0},
+ {3, 2, 0x1DE08, 0},
+ {3, 2, 0x1DE10, 0},
+ {3, 2, 0x1DE18, 0},
+ {3, 3, 0x1DE00, 0},
+ {3, 3, 0x1DE08, 0},
+ {3, 3, 0x1DE10, 0},
+ {3, 3, 0x1DE18, 0},
+ {3, 4, 0x1DE00, 0},
+ {3, 4, 0x1DE08, 0},
+ {3, 4, 0x1DE10, 0},
+ {3, 4, 0x1DE18, 0},
+ {3, 5, 0x1DE00, 0},
+ {3, 5, 0x1DE08, 0},
+ {3, 5, 0x1DE10, 0},
+ {3, 5, 0x1DE18, 0},
+ {4, 1, 0xA0600, 0},
+ {4, 1, 0xA0608, 0},
+ {4, 1, 0xA0610, 0},
+ {4, 1, 0xA0618, 0},
+ {4, 1, 0xA0620, 0},
+ {4, 1, 0xA0628, 0},
+ {4, 1, 0xA0630, 0},
+ {4, 1, 0xA0638, 0},
+ {4, 1, 0xA0640, 0},
+ {4, 1, 0xA0648, 0},
+ {4, 1, 0xA0658, 0},
+ {4, 2, 0x1DE00, 0},
+ {4, 2, 0x1DE08, 0},
+ {4, 2, 0x1DE10, 0},
+ {4, 2, 0x1DE18, 0},
+ {4, 3, 0x1DE00, 0},
+ {4, 3, 0x1DE08, 0},
+ {4, 3, 0x1DE10, 0},
+ {4, 3, 0x1DE18, 0},
+ {4, 4, 0x1DE00, 0},
+ {4, 4, 0x1DE08, 0},
+ {4, 4, 0x1DE10, 0},
+ {4, 4, 0x1DE18, 0},
+ {4, 5, 0x1DE00, 0},
+ {4, 5, 0x1DE08, 0},
+ {4, 5, 0x1DE10, 0},
+ {4, 5, 0x1DE18, 0},
+ {5, 1, 0xA0600, 0},
+ {5, 1, 0xA0608, 0},
+ {5, 1, 0xA0610, 0},
+ {5, 1, 0xA0618, 0},
+ {5, 1, 0xA0620, 0},
+ {5, 1, 0xA0628, 0},
+ {5, 1, 0xA0630, 0},
+ {5, 1, 0xA0638, 0},
+ {5, 1, 0xA0640, 0},
+ {5, 1, 0xA0658, 0},
+ {5, 2, 0x1DE00, 0},
+ {5, 2, 0x1DE08, 0},
+ {5, 2, 0x1DE10, 0},
+ {5, 2, 0x1DE18, 0},
+ {5, 3, 0x1DE00, 0},
+ {5, 3, 0x1DE08, 0},
+ {5, 3, 0x1DE10, 0},
+ {5, 3, 0x1DE18, 0},
+ {5, 4, 0x1DE00, 0},
+ {5, 4, 0x1DE08, 0},
+ {5, 4, 0x1DE10, 0},
+ {5, 4, 0x1DE18, 0},
+ {5, 5, 0x1DE00, 0},
+ {5, 5, 0x1DE08, 0},
+ {5, 5, 0x1DE10, 0},
+ {5, 5, 0x1DE18, 0},
+ {6, 1, 0xA0600, 0},
+ {6, 1, 0xA0608, 0},
+ {6, 1, 0xA0610, 0},
+ {6, 1, 0xA0618, 0},
+ {6, 1, 0xA0620, 0},
+ {6, 1, 0xA0628, 0},
+ {6, 1, 0xA0630, 0},
+ {6, 1, 0xA0638, 0},
+ {6, 1, 0xA0640, 0},
+ {6, 1, 0xA0648, 0},
+ {6, 1, 0xA0658, 0},
+ {6, 2, 0x1DE00, 0},
+ {6, 2, 0x1DE08, 0},
+ {6, 2, 0x1DE10, 0},
+ {6, 2, 0x1DE18, 0},
+ {6, 3, 0x1DE00, 0},
+ {6, 3, 0x1DE08, 0},
+ {6, 3, 0x1DE10, 0},
+ {6, 3, 0x1DE18, 0},
+ {6, 4, 0x1DE00, 0},
+ {6, 4, 0x1DE08, 0},
+ {6, 4, 0x1DE10, 0},
+ {6, 4, 0x1DE18, 0},
+ {6, 5, 0x1DE00, 0},
+ {6, 5, 0x1DE08, 0},
+ {6, 5, 0x1DE10, 0},
+ {6, 5, 0x1DE18, 0},
+ {7, 1, 0xA0600, 0},
+ {7, 1, 0xA0608, 0},
+ {7, 1, 0xA0610, 0},
+ {7, 1, 0xA0618, 0},
+ {7, 1, 0xA0620, 0},
+ {7, 1, 0xA0628, 0},
+ {7, 1, 0xA0630, 0},
+ {7, 1, 0xA0638, 0},
+ {7, 1, 0xA0640, 0},
+ {7, 1, 0xA0658, 0},
+ {7, 2, 0x1DE00, 0},
+ {7, 2, 0x1DE08, 0},
+ {7, 2, 0x1DE10, 0},
+ {7, 2, 0x1DE18, 0},
+ {7, 3, 0x1DE00, 0},
+ {7, 3, 0x1DE08, 0},
+ {7, 3, 0x1DE10, 0},
+ {7, 3, 0x1DE18, 0},
+ {7, 4, 0x1DE00, 0},
+ {7, 4, 0x1DE08, 0},
+ {7, 4, 0x1DE10, 0},
+ {7, 4, 0x1DE18, 0},
+ {7, 5, 0x1DE00, 0},
+ {7, 5, 0x1DE08, 0},
+ {7, 5, 0x1DE10, 0},
+ {7, 5, 0x1DE18, 0},
+};
+
+inline const op_config op_dq = {
+ // stream switch registers: (col, row, offset, value)
+ {
+ {0, 0, 0x3F008, 0xC0000045},
+ {0, 0, 0x3F010, 0x80000010},
+ {0, 0, 0x3F03C, 0x80000009},
+ {0, 0, 0x3F044, 0x80000005},
+ {0, 0, 0x3F100, 0xC0000000},
+ {0, 0, 0x3F114, 0x80000000},
+ {0, 0, 0x3F124, 0x80000000},
+ {0, 0, 0x3F140, 0x80000000},
+ {0, 0, 0x3F200, 0x0F1F0135},
+ {0, 1, 0xB0000, 0x8000000C},
+ {0, 1, 0xB0004, 0x8000000E},
+ {0, 1, 0xB0008, 0x8000000D},
+ {0, 1, 0xB000C, 0x8000000F},
+ {0, 1, 0xB0010, 0x80000010},
+ {0, 1, 0xB0014, 0x8000000A},
+ {0, 1, 0xB0024, 0x80000001},
+ {0, 1, 0xB0030, 0x80000002},
+ {0, 1, 0xB0040, 0x80000000},
+ {0, 1, 0xB0100, 0x80000000},
+ {0, 1, 0xB0104, 0x80000000},
+ {0, 1, 0xB0108, 0x80000000},
+ {0, 1, 0xB0128, 0x80000000},
+ {0, 1, 0xB0130, 0x80000000},
+ {0, 1, 0xB0134, 0x80000000},
+ {0, 1, 0xB0138, 0x80000000},
+ {0, 1, 0xB013C, 0x80000000},
+ {0, 1, 0xB0140, 0x80000000},
+ {0, 2, 0x3F004, 0x8000000A},
+ {0, 2, 0x3F008, 0x80000006},
+ {0, 2, 0x3F014, 0x80000013},
+ {0, 2, 0x3F018, 0x80000001},
+ {0, 2, 0x3F01C, 0x80000015},
+ {0, 2, 0x3F020, 0x80000014},
+ {0, 2, 0x3F038, 0x80000006},
+ {0, 2, 0x3F044, 0x80000016},
+ {0, 2, 0x3F050, 0x80000010},
+ {0, 2, 0x3F054, 0x8000000A},
+ {0, 2, 0x3F104, 0x80000000},
+ {0, 2, 0x3F118, 0x80000000},
+ {0, 2, 0x3F128, 0x80000000},
+ {0, 2, 0x3F140, 0x80000000},
+ {0, 2, 0x3F14C, 0x80000000},
+ {0, 2, 0x3F150, 0x80000000},
+ {0, 2, 0x3F154, 0x80000000},
+ {0, 2, 0x3F158, 0x80000000},
+ {0, 3, 0x3F004, 0x80000009},
+ {0, 3, 0x3F018, 0x80000010},
+ {0, 3, 0x3F034, 0x80000006},
+ {0, 3, 0x3F03C, 0x80000013},
+ {0, 3, 0x3F04C, 0x80000001},
+ {0, 3, 0x3F104, 0x80000000},
+ {0, 3, 0x3F118, 0x80000000},
+ {0, 3, 0x3F124, 0x80000000},
+ {0, 3, 0x3F140, 0x80000000},
+ {0, 3, 0x3F14C, 0x80000000},
+ {0, 4, 0x3F004, 0x80000007},
+ {0, 4, 0x3F008, 0x80000005},
+ {0, 4, 0x3F018, 0x80000001},
+ {0, 4, 0x3F104, 0x80000000},
+ {0, 4, 0x3F114, 0x80000000},
+ {0, 4, 0x3F11C, 0x80000000},
+ {0, 5, 0x3F004, 0x80000013},
+ {0, 5, 0x3F058, 0x80000001},
+ {0, 5, 0x3F104, 0x80000000},
+ {0, 5, 0x3F14C, 0x80000000},
+ {1, 0, 0x3F008, 0xC0000045},
+ {1, 0, 0x3F010, 0x80000010},
+ {1, 0, 0x3F034, 0x80000009},
+ {1, 0, 0x3F100, 0xC0000000},
+ {1, 0, 0x3F124, 0x80000000},
+ {1, 0, 0x3F140, 0x80000000},
+ {1, 0, 0x3F200, 0x0F1F0135},
+ {1, 1, 0xB0004, 0x8000000D},
+ {1, 1, 0xB0008, 0x80000010},
+ {1, 1, 0xB000C, 0x8000000E},
+ {1, 1, 0xB0010, 0x8000000F},
+ {1, 1, 0xB0014, 0x80000008},
+ {1, 1, 0xB0024, 0x80000001},
+ {1, 1, 0xB0030, 0x80000002},
+ {1, 1, 0xB0104, 0x80000000},
+ {1, 1, 0xB0108, 0x80000000},
+ {1, 1, 0xB0120, 0x80000000},
+ {1, 1, 0xB0134, 0x80000000},
+ {1, 1, 0xB0138, 0x80000000},
+ {1, 1, 0xB013C, 0x80000000},
+ {1, 1, 0xB0140, 0x80000000},
+ {1, 2, 0x3F004, 0x8000000D},
+ {1, 2, 0x3F008, 0x80000006},
+ {1, 2, 0x3F014, 0x80000010},
+ {1, 2, 0x3F018, 0x8000000F},
+ {1, 2, 0x3F01C, 0x80000011},
+ {1, 2, 0x3F020, 0x80000012},
+ {1, 2, 0x3F024, 0x80000001},
+ {1, 2, 0x3F028, 0x80000013},
+ {1, 2, 0x3F02C, 0x80000016},
+ {1, 2, 0x3F030, 0x80000015},
+ {1, 2, 0x3F034, 0x80000015},
+ {1, 2, 0x3F038, 0x80000014},
+ {1, 2, 0x3F040, 0x80000006},
+ {1, 2, 0x3F04C, 0x8000000C},
+ {1, 2, 0x3F054, 0x8000000D},
+ {1, 2, 0x3F104, 0x80000000},
+ {1, 2, 0x3F118, 0x80000000},
+ {1, 2, 0x3F130, 0x80000000},
+ {1, 2, 0x3F134, 0x80000000},
+ {1, 2, 0x3F13C, 0x80000000},
+ {1, 2, 0x3F140, 0x80000000},
+ {1, 2, 0x3F144, 0x80000000},
+ {1, 2, 0x3F148, 0x80000000},
+ {1, 2, 0x3F14C, 0x80000000},
+ {1, 2, 0x3F150, 0x80000000},
+ {1, 2, 0x3F154, 0x80000000},
+ {1, 2, 0x3F158, 0x80000000},
+ {1, 3, 0x3F004, 0x80000005},
+ {1, 3, 0x3F014, 0x80000013},
+ {1, 3, 0x3F018, 0x8000000B},
+ {1, 3, 0x3F01C, 0x80000015},
+ {1, 3, 0x3F020, 0x80000001},
+ {1, 3, 0x3F024, 0x80000016},
+ {1, 3, 0x3F03C, 0x80000006},
+ {1, 3, 0x3F044, 0x80000008},
+ {1, 3, 0x3F058, 0x80000010},
+ {1, 3, 0x3F104, 0x80000000},
+ {1, 3, 0x3F114, 0x80000000},
+ {1, 3, 0x3F118, 0x80000000},
+ {1, 3, 0x3F120, 0x80000000},
+ {1, 3, 0x3F12C, 0x80000000},
+ {1, 3, 0x3F140, 0x80000000},
+ {1, 3, 0x3F14C, 0x80000000},
+ {1, 3, 0x3F154, 0x80000000},
+ {1, 3, 0x3F158, 0x80000000},
+ {1, 4, 0x3F004, 0x80000015},
+ {1, 4, 0x3F008, 0x80000009},
+ {1, 4, 0x3F018, 0x80000001},
+ {1, 4, 0x3F048, 0x80000007},
+ {1, 4, 0x3F104, 0x80000000},
+ {1, 4, 0x3F11C, 0x80000000},
+ {1, 4, 0x3F124, 0x80000000},
+ {1, 4, 0x3F154, 0x80000000},
+ {1, 5, 0x3F004, 0x8000000A},
+ {1, 5, 0x3F024, 0x8000000A},
+ {1, 5, 0x3F050, 0x8000000E},
+ {1, 5, 0x3F058, 0x80000001},
+ {1, 5, 0x3F104, 0x80000000},
+ {1, 5, 0x3F128, 0x80000000},
+ {1, 5, 0x3F138, 0x80000000},
+ {2, 0, 0x3F008, 0xC0000045},
+ {2, 0, 0x3F010, 0x80000010},
+ {2, 0, 0x3F034, 0x80000009},
+ {2, 0, 0x3F044, 0x80000005},
+ {2, 0, 0x3F100, 0xC0000000},
+ {2, 0, 0x3F114, 0x80000000},
+ {2, 0, 0x3F124, 0x80000000},
+ {2, 0, 0x3F140, 0x80000000},
+ {2, 0, 0x3F200, 0x0F1F0135},
+ {2, 1, 0xB0000, 0x8000000C},
+ {2, 1, 0xB0004, 0x8000000D},
+ {2, 1, 0xB0008, 0x80000010},
+ {2, 1, 0xB000C, 0x8000000F},
+ {2, 1, 0xB0010, 0x8000000E},
+ {2, 1, 0xB0014, 0x80000008},
+ {2, 1, 0xB0024, 0x80000001},
+ {2, 1, 0xB0030, 0x80000002},
+ {2, 1, 0xB0040, 0x80000000},
+ {2, 1, 0xB0100, 0x80000000},
+ {2, 1, 0xB0104, 0x80000000},
+ {2, 1, 0xB0108, 0x80000000},
+ {2, 1, 0xB0120, 0x80000000},
+ {2, 1, 0xB0130, 0x80000000},
+ {2, 1, 0xB0134, 0x80000000},
+ {2, 1, 0xB0138, 0x80000000},
+ {2, 1, 0xB013C, 0x80000000},
+ {2, 1, 0xB0140, 0x80000000},
+ {2, 2, 0x3F004, 0x8000000D},
+ {2, 2, 0x3F008, 0x80000006},
+ {2, 2, 0x3F014, 0x8000000B},
+ {2, 2, 0x3F018, 0x80000011},
+ {2, 2, 0x3F01C, 0x8000000F},
+ {2, 2, 0x3F020, 0x80000012},
+ {2, 2, 0x3F024, 0x80000013},
+ {2, 2, 0x3F028, 0x80000016},
+ {2, 2, 0x3F02C, 0x8000000A},
+ {2, 2, 0x3F030, 0x80000001},
+ {2, 2, 0x3F038, 0x8000000A},
+ {2, 2, 0x3F040, 0x80000006},
+ {2, 2, 0x3F04C, 0x8000000D},
+ {2, 2, 0x3F050, 0x80000010},
+ {2, 2, 0x3F054, 0x8000000A},
+ {2, 2, 0x3F104, 0x80000000},
+ {2, 2, 0x3F118, 0x80000000},
+ {2, 2, 0x3F128, 0x80000000},
+ {2, 2, 0x3F12C, 0x80000000},
+ {2, 2, 0x3F134, 0x80000000},
+ {2, 2, 0x3F13C, 0x80000000},
+ {2, 2, 0x3F140, 0x80000000},
+ {2, 2, 0x3F144, 0x80000000},
+ {2, 2, 0x3F148, 0x80000000},
+ {2, 2, 0x3F14C, 0x80000000},
+ {2, 2, 0x3F158, 0x80000000},
+ {2, 3, 0x3F004, 0x80000006},
+ {2, 3, 0x3F014, 0x80000010},
+ {2, 3, 0x3F018, 0x80000011},
+ {2, 3, 0x3F01C, 0x80000014},
+ {2, 3, 0x3F020, 0x8000000E},
+ {2, 3, 0x3F024, 0x80000001},
+ {2, 3, 0x3F02C, 0x80000016},
+ {2, 3, 0x3F030, 0x80000013},
+ {2, 3, 0x3F034, 0x80000008},
+ {2, 3, 0x3F050, 0x80000012},
+ {2, 3, 0x3F104, 0x80000000},
+ {2, 3, 0x3F118, 0x80000000},
+ {2, 3, 0x3F120, 0x80000000},
+ {2, 3, 0x3F138, 0x80000000},
+ {2, 3, 0x3F140, 0x80000000},
+ {2, 3, 0x3F144, 0x80000000},
+ {2, 3, 0x3F148, 0x80000000},
+ {2, 3, 0x3F14C, 0x80000000},
+ {2, 3, 0x3F150, 0x80000000},
+ {2, 3, 0x3F158, 0x80000000},
+ {2, 4, 0x3F004, 0x80000015},
+ {2, 4, 0x3F008, 0x80000005},
+ {2, 4, 0x3F018, 0x80000001},
+ {2, 4, 0x3F01C, 0x80000012},
+ {2, 4, 0x3F020, 0x8000000F},
+ {2, 4, 0x3F02C, 0x80000015},
+ {2, 4, 0x3F104, 0x80000000},
+ {2, 4, 0x3F114, 0x80000000},
+ {2, 4, 0x3F13C, 0x80000000},
+ {2, 4, 0x3F148, 0x80000000},
+ {2, 4, 0x3F154, 0x80000000},
+ {2, 5, 0x3F004, 0x80000014},
+ {2, 5, 0x3F014, 0x8000000E},
+ {2, 5, 0x3F020, 0x80000001},
+ {2, 5, 0x3F054, 0x8000000C},
+ {2, 5, 0x3F104, 0x80000000},
+ {2, 5, 0x3F130, 0x80000000},
+ {2, 5, 0x3F138, 0x80000000},
+ {2, 5, 0x3F150, 0x80000000},
+ {3, 0, 0x3F008, 0xC0000045},
+ {3, 0, 0x3F010, 0x80000010},
+ {3, 0, 0x3F034, 0x80000009},
+ {3, 0, 0x3F100, 0xC0000000},
+ {3, 0, 0x3F124, 0x80000000},
+ {3, 0, 0x3F140, 0x80000000},
+ {3, 0, 0x3F200, 0x0F1F0135},
+ {3, 1, 0xB0004, 0x8000000F},
+ {3, 1, 0xB0008, 0x8000000D},
+ {3, 1, 0xB000C, 0x80000010},
+ {3, 1, 0xB0010, 0x8000000E},
+ {3, 1, 0xB0014, 0x80000008},
+ {3, 1, 0xB0024, 0x80000001},
+ {3, 1, 0xB0030, 0x80000002},
+ {3, 1, 0xB0104, 0x80000000},
+ {3, 1, 0xB0108, 0x80000000},
+ {3, 1, 0xB0120, 0x80000000},
+ {3, 1, 0xB0134, 0x80000000},
+ {3, 1, 0xB0138, 0x80000000},
+ {3, 1, 0xB013C, 0x80000000},
+ {3, 1, 0xB0140, 0x80000000},
+ {3, 2, 0x3F004, 0x8000000B},
+ {3, 2, 0x3F008, 0x80000006},
+ {3, 2, 0x3F014, 0x80000012},
+ {3, 2, 0x3F018, 0x80000010},
+ {3, 2, 0x3F01C, 0x8000000F},
+ {3, 2, 0x3F020, 0x8000000C},
+ {3, 2, 0x3F024, 0x80000001},
+ {3, 2, 0x3F030, 0x80000013},
+ {3, 2, 0x3F034, 0x80000015},
+ {3, 2, 0x3F03C, 0x8000000D},
+ {3, 2, 0x3F040, 0x80000006},
+ {3, 2, 0x3F04C, 0x8000000B},
+ {3, 2, 0x3F104, 0x80000000},
+ {3, 2, 0x3F118, 0x80000000},
+ {3, 2, 0x3F12C, 0x80000000},
+ {3, 2, 0x3F130, 0x80000000},
+ {3, 2, 0x3F134, 0x80000000},
+ {3, 2, 0x3F13C, 0x80000000},
+ {3, 2, 0x3F140, 0x80000000},
+ {3, 2, 0x3F148, 0x80000000},
+ {3, 2, 0x3F14C, 0x80000000},
+ {3, 2, 0x3F154, 0x80000000},
+ {3, 3, 0x3F004, 0x80000007},
+ {3, 3, 0x3F014, 0x8000000F},
+ {3, 3, 0x3F018, 0x80000012},
+ {3, 3, 0x3F020, 0x8000000C},
+ {3, 3, 0x3F024, 0x80000005},
+ {3, 3, 0x3F028, 0x80000010},
+ {3, 3, 0x3F030, 0x80000001},
+ {3, 3, 0x3F034, 0x80000008},
+ {3, 3, 0x3F058, 0x80000007},
+ {3, 3, 0x3F104, 0x80000000},
+ {3, 3, 0x3F114, 0x80000000},
+ {3, 3, 0x3F11C, 0x80000000},
+ {3, 3, 0x3F120, 0x80000000},
+ {3, 3, 0x3F130, 0x80000000},
+ {3, 3, 0x3F13C, 0x80000000},
+ {3, 3, 0x3F140, 0x80000000},
+ {3, 3, 0x3F148, 0x80000000},
+ {3, 4, 0x3F004, 0x80000016},
+ {3, 4, 0x3F008, 0x80000005},
+ {3, 4, 0x3F014, 0x80000012},
+ {3, 4, 0x3F018, 0x80000001},
+ {3, 4, 0x3F020, 0x8000000F},
+ {3, 4, 0x3F02C, 0x80000016},
+ {3, 4, 0x3F038, 0x80000013},
+ {3, 4, 0x3F104, 0x80000000},
+ {3, 4, 0x3F114, 0x80000000},
+ {3, 4, 0x3F13C, 0x80000000},
+ {3, 4, 0x3F148, 0x80000000},
+ {3, 4, 0x3F14C, 0x80000000},
+ {3, 4, 0x3F158, 0x80000000},
+ {3, 5, 0x3F004, 0x80000006},
+ {3, 5, 0x3F014, 0x80000001},
+ {3, 5, 0x3F020, 0x8000000D},
+ {3, 5, 0x3F028, 0x80000006},
+ {3, 5, 0x3F104, 0x80000000},
+ {3, 5, 0x3F118, 0x80000000},
+ {3, 5, 0x3F134, 0x80000000},
+ {4, 0, 0x3F008, 0xC0000045},
+ {4, 0, 0x3F010, 0x80000010},
+ {4, 0, 0x3F034, 0x80000009},
+ {4, 0, 0x3F044, 0x80000005},
+ {4, 0, 0x3F100, 0xC0000000},
+ {4, 0, 0x3F114, 0x80000000},
+ {4, 0, 0x3F124, 0x80000000},
+ {4, 0, 0x3F140, 0x80000000},
+ {4, 0, 0x3F200, 0x0F1F0135},
+ {4, 1, 0xB0000, 0x8000000C},
+ {4, 1, 0xB0004, 0x8000000E},
+ {4, 1, 0xB0008, 0x80000010},
+ {4, 1, 0xB000C, 0x8000000D},
+ {4, 1, 0xB0010, 0x8000000F},
+ {4, 1, 0xB0014, 0x80000008},
+ {4, 1, 0xB0024, 0x80000001},
+ {4, 1, 0xB0030, 0x80000002},
+ {4, 1, 0xB0040, 0x80000000},
+ {4, 1, 0xB0100, 0x80000000},
+ {4, 1, 0xB0104, 0x80000000},
+ {4, 1, 0xB0108, 0x80000000},
+ {4, 1, 0xB0120, 0x80000000},
+ {4, 1, 0xB0130, 0x80000000},
+ {4, 1, 0xB0134, 0x80000000},
+ {4, 1, 0xB0138, 0x80000000},
+ {4, 1, 0xB013C, 0x80000000},
+ {4, 1, 0xB0140, 0x80000000},
+ {4, 2, 0x3F004, 0x8000000B},
+ {4, 2, 0x3F008, 0x80000006},
+ {4, 2, 0x3F014, 0x80000014},
+ {4, 2, 0x3F018, 0x80000001},
+ {4, 2, 0x3F01C, 0x80000015},
+ {4, 2, 0x3F020, 0x80000013},
+ {4, 2, 0x3F024, 0x80000016},
+ {4, 2, 0x3F02C, 0x8000000A},
+ {4, 2, 0x3F038, 0x8000000A},
+ {4, 2, 0x3F040, 0x80000006},
+ {4, 2, 0x3F04C, 0x80000010},
+ {4, 2, 0x3F054, 0x8000000A},
+ {4, 2, 0x3F058, 0x8000000B},
+ {4, 2, 0x3F104, 0x80000000},
+ {4, 2, 0x3F118, 0x80000000},
+ {4, 2, 0x3F128, 0x80000000},
+ {4, 2, 0x3F12C, 0x80000000},
+ {4, 2, 0x3F140, 0x80000000},
+ {4, 2, 0x3F14C, 0x80000000},
+ {4, 2, 0x3F150, 0x80000000},
+ {4, 2, 0x3F154, 0x80000000},
+ {4, 2, 0x3F158, 0x80000000},
+ {4, 3, 0x3F004, 0x8000000E},
+ {4, 3, 0x3F018, 0x80000001},
+ {4, 3, 0x3F034, 0x80000008},
+ {4, 3, 0x3F040, 0x80000006},
+ {4, 3, 0x3F04C, 0x80000012},
+ {4, 3, 0x3F050, 0x8000000E},
+ {4, 3, 0x3F058, 0x80000010},
+ {4, 3, 0x3F104, 0x80000000},
+ {4, 3, 0x3F118, 0x80000000},
+ {4, 3, 0x3F120, 0x80000000},
+ {4, 3, 0x3F138, 0x80000000},
+ {4, 3, 0x3F140, 0x80000000},
+ {4, 3, 0x3F148, 0x80000000},
+ {4, 4, 0x3F004, 0x80000008},
+ {4, 4, 0x3F008, 0x80000005},
+ {4, 4, 0x3F018, 0x80000001},
+ {4, 4, 0x3F020, 0x8000000F},
+ {4, 4, 0x3F024, 0x80000013},
+ {4, 4, 0x3F030, 0x80000008},
+ {4, 4, 0x3F050, 0x80000008},
+ {4, 4, 0x3F104, 0x80000000},
+ {4, 4, 0x3F114, 0x80000000},
+ {4, 4, 0x3F120, 0x80000000},
+ {4, 4, 0x3F13C, 0x80000000},
+ {4, 4, 0x3F14C, 0x80000000},
+ {4, 5, 0x3F004, 0x80000016},
+ {4, 5, 0x3F014, 0x80000001},
+ {4, 5, 0x3F104, 0x80000000},
+ {4, 5, 0x3F158, 0x80000000},
+ {5, 0, 0x3F008, 0xC0000045},
+ {5, 0, 0x3F010, 0x80000010},
+ {5, 0, 0x3F034, 0x80000009},
+ {5, 0, 0x3F100, 0xC0000000},
+ {5, 0, 0x3F124, 0x80000000},
+ {5, 0, 0x3F140, 0x80000000},
+ {5, 0, 0x3F200, 0x0F1F0135},
+ {5, 1, 0xB0004, 0x8000000F},
+ {5, 1, 0xB0008, 0x80000010},
+ {5, 1, 0xB000C, 0x8000000E},
+ {5, 1, 0xB0010, 0x8000000D},
+ {5, 1, 0xB0014, 0x80000008},
+ {5, 1, 0xB0024, 0x80000001},
+ {5, 1, 0xB0030, 0x80000002},
+ {5, 1, 0xB0104, 0x80000000},
+ {5, 1, 0xB0108, 0x80000000},
+ {5, 1, 0xB0120, 0x80000000},
+ {5, 1, 0xB0134, 0x80000000},
+ {5, 1, 0xB0138, 0x80000000},
+ {5, 1, 0xB013C, 0x80000000},
+ {5, 1, 0xB0140, 0x80000000},
+ {5, 2, 0x3F004, 0x8000000E},
+ {5, 2, 0x3F008, 0x80000006},
+ {5, 2, 0x3F014, 0x8000000F},
+ {5, 2, 0x3F018, 0x80000013},
+ {5, 2, 0x3F01C, 0x8000000B},
+ {5, 2, 0x3F020, 0x80000010},
+ {5, 2, 0x3F024, 0x80000001},
+ {5, 2, 0x3F028, 0x80000016},
+ {5, 2, 0x3F02C, 0x80000014},
+ {5, 2, 0x3F030, 0x80000015},
+ {5, 2, 0x3F040, 0x80000006},
+ {5, 2, 0x3F04C, 0x8000000D},
+ {5, 2, 0x3F050, 0x80000012},
+ {5, 2, 0x3F054, 0x80000011},
+ {5, 2, 0x3F058, 0x8000000E},
+ {5, 2, 0x3F104, 0x80000000},
+ {5, 2, 0x3F118, 0x80000000},
+ {5, 2, 0x3F12C, 0x80000000},
+ {5, 2, 0x3F134, 0x80000000},
+ {5, 2, 0x3F138, 0x80000000},
+ {5, 2, 0x3F13C, 0x80000000},
+ {5, 2, 0x3F140, 0x80000000},
+ {5, 2, 0x3F144, 0x80000000},
+ {5, 2, 0x3F148, 0x80000000},
+ {5, 2, 0x3F14C, 0x80000000},
+ {5, 2, 0x3F150, 0x80000000},
+ {5, 2, 0x3F154, 0x80000000},
+ {5, 2, 0x3F158, 0x80000000},
+ {5, 3, 0x3F004, 0x8000000C},
+ {5, 3, 0x3F014, 0x80000016},
+ {5, 3, 0x3F018, 0x80000001},
+ {5, 3, 0x3F01C, 0x80000010},
+ {5, 3, 0x3F020, 0x8000000E},
+ {5, 3, 0x3F034, 0x80000008},
+ {5, 3, 0x3F040, 0x80000015},
+ {5, 3, 0x3F050, 0x80000012},
+ {5, 3, 0x3F054, 0x8000000C},
+ {5, 3, 0x3F058, 0x8000000B},
+ {5, 3, 0x3F104, 0x80000000},
+ {5, 3, 0x3F120, 0x80000000},
+ {5, 3, 0x3F12C, 0x80000000},
+ {5, 3, 0x3F130, 0x80000000},
+ {5, 3, 0x3F138, 0x80000000},
+ {5, 3, 0x3F140, 0x80000000},
+ {5, 3, 0x3F148, 0x80000000},
+ {5, 3, 0x3F154, 0x80000000},
+ {5, 3, 0x3F158, 0x80000000},
+ {5, 4, 0x3F004, 0x8000000C},
+ {5, 4, 0x3F008, 0x80000005},
+ {5, 4, 0x3F018, 0x80000001},
+ {5, 4, 0x3F020, 0x8000000F},
+ {5, 4, 0x3F024, 0x80000008},
+ {5, 4, 0x3F03C, 0x80000008},
+ {5, 4, 0x3F104, 0x80000000},
+ {5, 4, 0x3F114, 0x80000000},
+ {5, 4, 0x3F120, 0x80000000},
+ {5, 4, 0x3F130, 0x80000000},
+ {5, 4, 0x3F13C, 0x80000000},
+ {5, 5, 0x3F004, 0x80000007},
+ {5, 5, 0x3F014, 0x80000001},
+ {5, 5, 0x3F030, 0x80000007},
+ {5, 5, 0x3F104, 0x80000000},
+ {5, 5, 0x3F11C, 0x80000000},
+ {6, 0, 0x3F008, 0xC0000045},
+ {6, 0, 0x3F010, 0x80000010},
+ {6, 0, 0x3F034, 0x80000009},
+ {6, 0, 0x3F044, 0x80000005},
+ {6, 0, 0x3F100, 0xC0000000},
+ {6, 0, 0x3F114, 0x80000000},
+ {6, 0, 0x3F124, 0x80000000},
+ {6, 0, 0x3F140, 0x80000000},
+ {6, 0, 0x3F200, 0x0F1F0135},
+ {6, 1, 0xB0000, 0x8000000C},
+ {6, 1, 0xB0004, 0x80000010},
+ {6, 1, 0xB0008, 0x8000000F},
+ {6, 1, 0xB000C, 0x8000000E},
+ {6, 1, 0xB0010, 0x8000000D},
+ {6, 1, 0xB0014, 0x80000008},
+ {6, 1, 0xB0024, 0x80000001},
+ {6, 1, 0xB0030, 0x80000002},
+ {6, 1, 0xB0040, 0x80000000},
+ {6, 1, 0xB0100, 0x80000000},
+ {6, 1, 0xB0104, 0x80000000},
+ {6, 1, 0xB0108, 0x80000000},
+ {6, 1, 0xB0120, 0x80000000},
+ {6, 1, 0xB0130, 0x80000000},
+ {6, 1, 0xB0134, 0x80000000},
+ {6, 1, 0xB0138, 0x80000000},
+ {6, 1, 0xB013C, 0x80000000},
+ {6, 1, 0xB0140, 0x80000000},
+ {6, 2, 0x3F004, 0x8000000E},
+ {6, 2, 0x3F008, 0x80000006},
+ {6, 2, 0x3F014, 0x80000014},
+ {6, 2, 0x3F018, 0x8000000F},
+ {6, 2, 0x3F01C, 0x8000000D},
+ {6, 2, 0x3F020, 0x8000000C},
+ {6, 2, 0x3F024, 0x80000010},
+ {6, 2, 0x3F028, 0x80000016},
+ {6, 2, 0x3F02C, 0x8000000A},
+ {6, 2, 0x3F030, 0x80000001},
+ {6, 2, 0x3F034, 0x8000000B},
+ {6, 2, 0x3F038, 0x8000000A},
+ {6, 2, 0x3F040, 0x80000006},
+ {6, 2, 0x3F050, 0x80000011},
+ {6, 2, 0x3F054, 0x8000000E},
+ {6, 2, 0x3F058, 0x8000000A},
+ {6, 2, 0x3F104, 0x80000000},
+ {6, 2, 0x3F118, 0x80000000},
+ {6, 2, 0x3F128, 0x80000000},
+ {6, 2, 0x3F12C, 0x80000000},
+ {6, 2, 0x3F130, 0x80000000},
+ {6, 2, 0x3F134, 0x80000000},
+ {6, 2, 0x3F138, 0x80000000},
+ {6, 2, 0x3F13C, 0x80000000},
+ {6, 2, 0x3F140, 0x80000000},
+ {6, 2, 0x3F144, 0x80000000},
+ {6, 2, 0x3F150, 0x80000000},
+ {6, 2, 0x3F158, 0x80000000},
+ {6, 3, 0x3F004, 0x8000000D},
+ {6, 3, 0x3F014, 0x80000010},
+ {6, 3, 0x3F018, 0x80000001},
+ {6, 3, 0x3F01C, 0x8000000C},
+ {6, 3, 0x3F02C, 0x80000006},
+ {6, 3, 0x3F030, 0x80000016},
+ {6, 3, 0x3F03C, 0x80000006},
+ {6, 3, 0x3F040, 0x80000005},
+ {6, 3, 0x3F048, 0x80000008},
+ {6, 3, 0x3F04C, 0x8000000E},
+ {6, 3, 0x3F050, 0x8000000D},
+ {6, 3, 0x3F104, 0x80000000},
+ {6, 3, 0x3F114, 0x80000000},
+ {6, 3, 0x3F118, 0x80000000},
+ {6, 3, 0x3F120, 0x80000000},
+ {6, 3, 0x3F130, 0x80000000},
+ {6, 3, 0x3F134, 0x80000000},
+ {6, 3, 0x3F138, 0x80000000},
+ {6, 3, 0x3F140, 0x80000000},
+ {6, 3, 0x3F158, 0x80000000},
+ {6, 4, 0x3F004, 0x80000008},
+ {6, 4, 0x3F008, 0x8000000A},
+ {6, 4, 0x3F018, 0x80000001},
+ {6, 4, 0x3F044, 0x80000007},
+ {6, 4, 0x3F050, 0x80000008},
+ {6, 4, 0x3F054, 0x8000000F},
+ {6, 4, 0x3F104, 0x80000000},
+ {6, 4, 0x3F11C, 0x80000000},
+ {6, 4, 0x3F120, 0x80000000},
+ {6, 4, 0x3F128, 0x80000000},
+ {6, 4, 0x3F13C, 0x80000000},
+ {6, 5, 0x3F004, 0x80000009},
+ {6, 5, 0x3F014, 0x80000001},
+ {6, 5, 0x3F104, 0x80000000},
+ {6, 5, 0x3F124, 0x80000000},
+ {7, 0, 0x3F008, 0xC0000045},
+ {7, 0, 0x3F010, 0x80000010},
+ {7, 0, 0x3F030, 0x80000009},
+ {7, 0, 0x3F100, 0xC0000000},
+ {7, 0, 0x3F124, 0x80000000},
+ {7, 0, 0x3F140, 0x80000000},
+ {7, 0, 0x3F200, 0x0F1F0135},
+ {7, 1, 0xB0004, 0x8000000F},
+ {7, 1, 0xB0008, 0x80000010},
+ {7, 1, 0xB000C, 0x8000000D},
+ {7, 1, 0xB0010, 0x8000000E},
+ {7, 1, 0xB0014, 0x80000007},
+ {7, 1, 0xB0024, 0x80000001},
+ {7, 1, 0xB0030, 0x80000002},
+ {7, 1, 0xB0104, 0x80000000},
+ {7, 1, 0xB0108, 0x80000000},
+ {7, 1, 0xB011C, 0x80000000},
+ {7, 1, 0xB0134, 0x80000000},
+ {7, 1, 0xB0138, 0x80000000},
+ {7, 1, 0xB013C, 0x80000000},
+ {7, 1, 0xB0140, 0x80000000},
+ {7, 2, 0x3F004, 0x8000000D},
+ {7, 2, 0x3F008, 0x80000006},
+ {7, 2, 0x3F014, 0x8000000F},
+ {7, 2, 0x3F018, 0x80000012},
+ {7, 2, 0x3F01C, 0x80000011},
+ {7, 2, 0x3F020, 0x8000000C},
+ {7, 2, 0x3F028, 0x80000010},
+ {7, 2, 0x3F030, 0x80000001},
+ {7, 2, 0x3F034, 0x8000000E},
+ {7, 2, 0x3F044, 0x80000006},
+ {7, 2, 0x3F104, 0x80000000},
+ {7, 2, 0x3F118, 0x80000000},
+ {7, 2, 0x3F130, 0x80000000},
+ {7, 2, 0x3F134, 0x80000000},
+ {7, 2, 0x3F138, 0x80000000},
+ {7, 2, 0x3F13C, 0x80000000},
+ {7, 2, 0x3F140, 0x80000000},
+ {7, 2, 0x3F144, 0x80000000},
+ {7, 2, 0x3F148, 0x80000000},
+ {7, 3, 0x3F004, 0x8000000C},
+ {7, 3, 0x3F014, 0x80000010},
+ {7, 3, 0x3F018, 0x80000012},
+ {7, 3, 0x3F01C, 0x8000000B},
+ {7, 3, 0x3F020, 0x80000011},
+ {7, 3, 0x3F030, 0x80000001},
+ {7, 3, 0x3F040, 0x80000009},
+ {7, 3, 0x3F048, 0x80000005},
+ {7, 3, 0x3F104, 0x80000000},
+ {7, 3, 0x3F114, 0x80000000},
+ {7, 3, 0x3F124, 0x80000000},
+ {7, 3, 0x3F12C, 0x80000000},
+ {7, 3, 0x3F130, 0x80000000},
+ {7, 3, 0x3F140, 0x80000000},
+ {7, 3, 0x3F144, 0x80000000},
+ {7, 3, 0x3F148, 0x80000000},
+ {7, 4, 0x3F004, 0x8000000C},
+ {7, 4, 0x3F008, 0x80000008},
+ {7, 4, 0x3F018, 0x8000000D},
+ {7, 4, 0x3F01C, 0x8000000F},
+ {7, 4, 0x3F020, 0x80000001},
+ {7, 4, 0x3F03C, 0x8000000A},
+ {7, 4, 0x3F104, 0x80000000},
+ {7, 4, 0x3F120, 0x80000000},
+ {7, 4, 0x3F128, 0x80000000},
+ {7, 4, 0x3F130, 0x80000000},
+ {7, 4, 0x3F134, 0x80000000},
+ {7, 4, 0x3F13C, 0x80000000},
+ {7, 5, 0x3F004, 0x80000007},
+ {7, 5, 0x3F014, 0x80000001},
+ {7, 5, 0x3F104, 0x80000000},
+ {7, 5, 0x3F11C, 0x80000000},
+ },
+ // shim mux / demux mask writes: (col, row, offset, mask, value)
+ {
+ {0, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {0, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {0, 0, 0x1F004, 0x00000030, 0x00000010},
+ {1, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {1, 0, 0x1F004, 0x00000030, 0x00000010},
+ {2, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {2, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {2, 0, 0x1F004, 0x00000030, 0x00000010},
+ {3, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {3, 0, 0x1F004, 0x00000030, 0x00000010},
+ {4, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {4, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {4, 0, 0x1F004, 0x00000030, 0x00000010},
+ {5, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {5, 0, 0x1F004, 0x00000030, 0x00000010},
+ {6, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {6, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {6, 0, 0x1F004, 0x00000030, 0x00000010},
+ {7, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {7, 0, 0x1F004, 0x00000030, 0x00000010},
+ },
+ // BD registers: (col, row, offset, shared, words)
+ {
+ {0, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {0, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {0, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {0, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {0, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {0, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {0, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {0, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {0, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {0, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {0, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {0, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {0, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {0, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {0, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {0, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {0, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {0, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {0, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {0, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {1, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {1, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {1, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {1, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {1, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {1, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {1, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {1, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {1, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {1, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {1, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {1, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {1, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {1, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {1, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {1, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {1, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {1, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {1, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {1, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {2, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {2, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {2, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {2, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {2, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {2, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {2, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {2, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {2, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {2, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {2, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {2, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {2, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {2, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {2, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {2, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {2, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {2, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {2, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {2, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {3, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {3, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {3, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {3, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {3, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {3, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {3, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {3, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {3, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {3, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {3, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {3, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {3, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {3, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {3, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {3, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {3, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {3, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {3, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {3, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {4, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {4, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {4, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {4, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {4, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {4, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {4, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {4, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {4, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {4, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {4, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {4, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {4, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {4, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {4, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {4, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {4, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {4, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {4, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {4, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {5, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {5, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {5, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {5, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {5, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {5, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {5, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {5, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {5, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {5, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {5, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {5, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {5, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {5, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {5, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {5, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {5, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {5, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {5, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {5, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {6, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {6, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {6, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {6, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {6, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {6, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {6, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {6, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {6, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {6, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {6, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {6, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {6, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {6, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {6, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {6, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {6, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {6, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {6, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {6, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {7, 2, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {7, 2, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {7, 2, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {7, 2, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {7, 2, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {7, 2, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {7, 3, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {7, 3, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {7, 3, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {7, 3, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {7, 4, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {7, 4, 0x1D040, false, {0x0B0004A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E087FC2}},
+ {7, 4, 0x1D080, false, {0x0D500080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2E049FE5}},
+ {7, 4, 0x1D0A0, false, {0x0D700080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x26049FE5}},
+ {7, 4, 0x1D060, false, {0x0C2804A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16087FC2}},
+ {7, 4, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {7, 5, 0x1D000, false, {0x01000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x0E043FE0}},
+ {7, 5, 0x1D040, false, {0x0F800080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1E049FE5}},
+ {7, 5, 0x1D060, false, {0x0FA00080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16049FE5}},
+ {7, 5, 0x1D020, false, {0x02000400, 0x00000000, 0x0007E000, 0x02008003, 0x00000000, 0x06043FE0}},
+ {0, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {0, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {0, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {0, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {0, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {0, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {0, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {0, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {0, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {0, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {0, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {0, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {0, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {0, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {0, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {0, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {0, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {0, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {0, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {0, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {1, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {1, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {1, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {1, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {1, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {1, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {1, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {1, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {1, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {1, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {1, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {1, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {1, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {1, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {1, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {1, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {1, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {1, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {1, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {1, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {2, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {2, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {2, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {2, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {2, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {2, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {2, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {2, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {2, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {2, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {2, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {2, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {2, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {2, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {2, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {2, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {2, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {2, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {2, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {2, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {3, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {3, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {3, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {3, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {3, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {3, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {3, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {3, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {3, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {3, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {3, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {3, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {3, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {3, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {3, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {3, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {3, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {3, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {3, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {3, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {4, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {4, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {4, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {4, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {4, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {4, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {4, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {4, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {4, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {4, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {4, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {4, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {4, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {4, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {4, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {4, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {4, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {4, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {4, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {4, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {5, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {5, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {5, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {5, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {5, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {5, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {5, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {5, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {5, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {5, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {5, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {5, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {5, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {5, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {5, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {5, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {5, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {5, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {5, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {5, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {6, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {6, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {6, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {6, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {6, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {6, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {6, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {6, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {6, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {6, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {6, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {6, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {6, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {6, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {6, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {6, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {6, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {6, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {6, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {6, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {7, 1, 0xA0000, false, {0x00008000, 0x001A0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {7, 1, 0xA0040, false, {0x00004000, 0x003A0000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {7, 1, 0xA0300, false, {0x00001000, 0x019B0000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {7, 1, 0xA00C0, false, {0x00001000, 0x007B1000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {7, 1, 0xA0340, false, {0x00001000, 0x01BB2000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {7, 1, 0xA0100, false, {0x00001000, 0x009B3000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8147FF45}},
+ {7, 1, 0xA0380, false, {0x00004000, 0x01DB0000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8445FC47}},
+ {7, 1, 0xA03C0, false, {0x000004A0, 0x01FB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {7, 1, 0xA0140, false, {0x000004A0, 0x00BB8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {7, 1, 0xA0160, false, {0x000004A0, 0x00AB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814AFF4B}},
+ {7, 1, 0xA03E0, false, {0x000004A0, 0x01EB84A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x814BFF4A}},
+ {7, 1, 0xA03A0, false, {0x00004000, 0x01CB4000, 0x00400000, 0x00080FFF, 0x0100001F, 0x00000000, 0x00000000, 0x8446FC48}},
+ {7, 1, 0xA0120, false, {0x00001000, 0x008B7000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {7, 1, 0xA0360, false, {0x00001000, 0x01AB6000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {7, 1, 0xA00E0, false, {0x00001000, 0x006B5000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {7, 1, 0xA0320, false, {0x00001000, 0x018B4000, 0x00080000, 0x0010001F, 0x00100003, 0x000000FF, 0x00000000, 0x8148FF46}},
+ {7, 1, 0xA0060, false, {0x00004000, 0x004A0080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {7, 1, 0xA0080, false, {0x00004000, 0x005A8000, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8142FF41}},
+ {7, 1, 0xA00A0, false, {0x00004000, 0x002A8080, 0x00800000, 0x002000FF, 0x0004003F, 0x00000FFF, 0x00000000, 0x8140FF42}},
+ {7, 1, 0xA0020, false, {0x00008000, 0x000A8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ },
+ // lock values: (col, row, offset, value)
+ {
+ {0, 1, 0xC0000, 2},
+ {0, 1, 0xC0010, 0},
+ {0, 1, 0xC0020, 0},
+ {0, 1, 0xC0030, 0},
+ {0, 1, 0xC0040, 0},
+ {0, 1, 0xC0050, 4},
+ {0, 1, 0xC0060, 4},
+ {0, 1, 0xC0070, 0},
+ {0, 1, 0xC0080, 0},
+ {0, 1, 0xC00A0, 2},
+ {0, 1, 0xC00B0, 0},
+ {0, 2, 0x1F000, 2},
+ {0, 2, 0x1F010, 0},
+ {0, 2, 0x1F020, 4},
+ {0, 2, 0x1F030, 0},
+ {0, 2, 0x1F040, 2},
+ {0, 2, 0x1F050, 0},
+ {0, 2, 0x1F060, 0},
+ {0, 2, 0x1F0F0, 0},
+ {0, 3, 0x1F000, 2},
+ {0, 3, 0x1F010, 0},
+ {0, 3, 0x1F040, 2},
+ {0, 3, 0x1F050, 0},
+ {0, 3, 0x1F060, 0},
+ {0, 3, 0x1F0F0, 0},
+ {0, 4, 0x1F000, 2},
+ {0, 4, 0x1F010, 0},
+ {0, 4, 0x1F020, 4},
+ {0, 4, 0x1F030, 0},
+ {0, 4, 0x1F040, 2},
+ {0, 4, 0x1F050, 0},
+ {0, 4, 0x1F060, 0},
+ {0, 4, 0x1F0F0, 0},
+ {0, 5, 0x1F000, 2},
+ {0, 5, 0x1F010, 0},
+ {0, 5, 0x1F040, 2},
+ {0, 5, 0x1F050, 0},
+ {0, 5, 0x1F060, 0},
+ {0, 5, 0x1F0F0, 0},
+ {1, 1, 0xC0000, 2},
+ {1, 1, 0xC0010, 0},
+ {1, 1, 0xC0020, 0},
+ {1, 1, 0xC0030, 0},
+ {1, 1, 0xC0040, 0},
+ {1, 1, 0xC0050, 4},
+ {1, 1, 0xC0060, 4},
+ {1, 1, 0xC0070, 0},
+ {1, 1, 0xC0080, 0},
+ {1, 1, 0xC00A0, 2},
+ {1, 1, 0xC00B0, 0},
+ {1, 2, 0x1F000, 2},
+ {1, 2, 0x1F010, 0},
+ {1, 2, 0x1F020, 4},
+ {1, 2, 0x1F030, 0},
+ {1, 2, 0x1F040, 2},
+ {1, 2, 0x1F050, 0},
+ {1, 2, 0x1F060, 0},
+ {1, 2, 0x1F0F0, 0},
+ {1, 3, 0x1F000, 2},
+ {1, 3, 0x1F010, 0},
+ {1, 3, 0x1F040, 2},
+ {1, 3, 0x1F050, 0},
+ {1, 3, 0x1F060, 0},
+ {1, 3, 0x1F0F0, 0},
+ {1, 4, 0x1F000, 2},
+ {1, 4, 0x1F010, 0},
+ {1, 4, 0x1F020, 4},
+ {1, 4, 0x1F030, 0},
+ {1, 4, 0x1F040, 2},
+ {1, 4, 0x1F050, 0},
+ {1, 4, 0x1F060, 0},
+ {1, 4, 0x1F0F0, 0},
+ {1, 5, 0x1F000, 2},
+ {1, 5, 0x1F010, 0},
+ {1, 5, 0x1F040, 2},
+ {1, 5, 0x1F050, 0},
+ {1, 5, 0x1F060, 0},
+ {1, 5, 0x1F0F0, 0},
+ {2, 1, 0xC0000, 2},
+ {2, 1, 0xC0010, 0},
+ {2, 1, 0xC0020, 0},
+ {2, 1, 0xC0030, 0},
+ {2, 1, 0xC0040, 0},
+ {2, 1, 0xC0050, 4},
+ {2, 1, 0xC0060, 4},
+ {2, 1, 0xC0070, 0},
+ {2, 1, 0xC0080, 0},
+ {2, 1, 0xC00A0, 2},
+ {2, 1, 0xC00B0, 0},
+ {2, 2, 0x1F000, 2},
+ {2, 2, 0x1F010, 0},
+ {2, 2, 0x1F020, 4},
+ {2, 2, 0x1F030, 0},
+ {2, 2, 0x1F040, 2},
+ {2, 2, 0x1F050, 0},
+ {2, 2, 0x1F060, 0},
+ {2, 2, 0x1F0F0, 0},
+ {2, 3, 0x1F000, 2},
+ {2, 3, 0x1F010, 0},
+ {2, 3, 0x1F040, 2},
+ {2, 3, 0x1F050, 0},
+ {2, 3, 0x1F060, 0},
+ {2, 3, 0x1F0F0, 0},
+ {2, 4, 0x1F000, 2},
+ {2, 4, 0x1F010, 0},
+ {2, 4, 0x1F020, 4},
+ {2, 4, 0x1F030, 0},
+ {2, 4, 0x1F040, 2},
+ {2, 4, 0x1F050, 0},
+ {2, 4, 0x1F060, 0},
+ {2, 4, 0x1F0F0, 0},
+ {2, 5, 0x1F000, 2},
+ {2, 5, 0x1F010, 0},
+ {2, 5, 0x1F040, 2},
+ {2, 5, 0x1F050, 0},
+ {2, 5, 0x1F060, 0},
+ {2, 5, 0x1F0F0, 0},
+ {3, 1, 0xC0000, 2},
+ {3, 1, 0xC0010, 0},
+ {3, 1, 0xC0020, 0},
+ {3, 1, 0xC0030, 0},
+ {3, 1, 0xC0040, 0},
+ {3, 1, 0xC0050, 4},
+ {3, 1, 0xC0060, 4},
+ {3, 1, 0xC0070, 0},
+ {3, 1, 0xC0080, 0},
+ {3, 1, 0xC00A0, 2},
+ {3, 1, 0xC00B0, 0},
+ {3, 2, 0x1F000, 2},
+ {3, 2, 0x1F010, 0},
+ {3, 2, 0x1F020, 4},
+ {3, 2, 0x1F030, 0},
+ {3, 2, 0x1F040, 2},
+ {3, 2, 0x1F050, 0},
+ {3, 2, 0x1F060, 0},
+ {3, 2, 0x1F0F0, 0},
+ {3, 3, 0x1F000, 2},
+ {3, 3, 0x1F010, 0},
+ {3, 3, 0x1F040, 2},
+ {3, 3, 0x1F050, 0},
+ {3, 3, 0x1F060, 0},
+ {3, 3, 0x1F0F0, 0},
+ {3, 4, 0x1F000, 2},
+ {3, 4, 0x1F010, 0},
+ {3, 4, 0x1F020, 4},
+ {3, 4, 0x1F030, 0},
+ {3, 4, 0x1F040, 2},
+ {3, 4, 0x1F050, 0},
+ {3, 4, 0x1F060, 0},
+ {3, 4, 0x1F0F0, 0},
+ {3, 5, 0x1F000, 2},
+ {3, 5, 0x1F010, 0},
+ {3, 5, 0x1F040, 2},
+ {3, 5, 0x1F050, 0},
+ {3, 5, 0x1F060, 0},
+ {3, 5, 0x1F0F0, 0},
+ {4, 1, 0xC0000, 2},
+ {4, 1, 0xC0010, 0},
+ {4, 1, 0xC0020, 0},
+ {4, 1, 0xC0030, 0},
+ {4, 1, 0xC0040, 0},
+ {4, 1, 0xC0050, 4},
+ {4, 1, 0xC0060, 4},
+ {4, 1, 0xC0070, 0},
+ {4, 1, 0xC0080, 0},
+ {4, 1, 0xC00A0, 2},
+ {4, 1, 0xC00B0, 0},
+ {4, 2, 0x1F000, 2},
+ {4, 2, 0x1F010, 0},
+ {4, 2, 0x1F020, 4},
+ {4, 2, 0x1F030, 0},
+ {4, 2, 0x1F040, 2},
+ {4, 2, 0x1F050, 0},
+ {4, 2, 0x1F060, 0},
+ {4, 2, 0x1F0F0, 0},
+ {4, 3, 0x1F000, 2},
+ {4, 3, 0x1F010, 0},
+ {4, 3, 0x1F040, 2},
+ {4, 3, 0x1F050, 0},
+ {4, 3, 0x1F060, 0},
+ {4, 3, 0x1F0F0, 0},
+ {4, 4, 0x1F000, 2},
+ {4, 4, 0x1F010, 0},
+ {4, 4, 0x1F020, 4},
+ {4, 4, 0x1F030, 0},
+ {4, 4, 0x1F040, 2},
+ {4, 4, 0x1F050, 0},
+ {4, 4, 0x1F060, 0},
+ {4, 4, 0x1F0F0, 0},
+ {4, 5, 0x1F000, 2},
+ {4, 5, 0x1F010, 0},
+ {4, 5, 0x1F040, 2},
+ {4, 5, 0x1F050, 0},
+ {4, 5, 0x1F060, 0},
+ {4, 5, 0x1F0F0, 0},
+ {5, 1, 0xC0000, 2},
+ {5, 1, 0xC0010, 0},
+ {5, 1, 0xC0020, 0},
+ {5, 1, 0xC0030, 0},
+ {5, 1, 0xC0040, 0},
+ {5, 1, 0xC0050, 4},
+ {5, 1, 0xC0060, 4},
+ {5, 1, 0xC0070, 0},
+ {5, 1, 0xC0080, 0},
+ {5, 1, 0xC00A0, 2},
+ {5, 1, 0xC00B0, 0},
+ {5, 2, 0x1F000, 2},
+ {5, 2, 0x1F010, 0},
+ {5, 2, 0x1F020, 4},
+ {5, 2, 0x1F030, 0},
+ {5, 2, 0x1F040, 2},
+ {5, 2, 0x1F050, 0},
+ {5, 2, 0x1F060, 0},
+ {5, 2, 0x1F0F0, 0},
+ {5, 3, 0x1F000, 2},
+ {5, 3, 0x1F010, 0},
+ {5, 3, 0x1F040, 2},
+ {5, 3, 0x1F050, 0},
+ {5, 3, 0x1F060, 0},
+ {5, 3, 0x1F0F0, 0},
+ {5, 4, 0x1F000, 2},
+ {5, 4, 0x1F010, 0},
+ {5, 4, 0x1F020, 4},
+ {5, 4, 0x1F030, 0},
+ {5, 4, 0x1F040, 2},
+ {5, 4, 0x1F050, 0},
+ {5, 4, 0x1F060, 0},
+ {5, 4, 0x1F0F0, 0},
+ {5, 5, 0x1F000, 2},
+ {5, 5, 0x1F010, 0},
+ {5, 5, 0x1F040, 2},
+ {5, 5, 0x1F050, 0},
+ {5, 5, 0x1F060, 0},
+ {5, 5, 0x1F0F0, 0},
+ {6, 1, 0xC0000, 2},
+ {6, 1, 0xC0010, 0},
+ {6, 1, 0xC0020, 0},
+ {6, 1, 0xC0030, 0},
+ {6, 1, 0xC0040, 0},
+ {6, 1, 0xC0050, 4},
+ {6, 1, 0xC0060, 4},
+ {6, 1, 0xC0070, 0},
+ {6, 1, 0xC0080, 0},
+ {6, 1, 0xC00A0, 2},
+ {6, 1, 0xC00B0, 0},
+ {6, 2, 0x1F000, 2},
+ {6, 2, 0x1F010, 0},
+ {6, 2, 0x1F020, 4},
+ {6, 2, 0x1F030, 0},
+ {6, 2, 0x1F040, 2},
+ {6, 2, 0x1F050, 0},
+ {6, 2, 0x1F060, 0},
+ {6, 2, 0x1F0F0, 0},
+ {6, 3, 0x1F000, 2},
+ {6, 3, 0x1F010, 0},
+ {6, 3, 0x1F040, 2},
+ {6, 3, 0x1F050, 0},
+ {6, 3, 0x1F060, 0},
+ {6, 3, 0x1F0F0, 0},
+ {6, 4, 0x1F000, 2},
+ {6, 4, 0x1F010, 0},
+ {6, 4, 0x1F020, 4},
+ {6, 4, 0x1F030, 0},
+ {6, 4, 0x1F040, 2},
+ {6, 4, 0x1F050, 0},
+ {6, 4, 0x1F060, 0},
+ {6, 4, 0x1F0F0, 0},
+ {6, 5, 0x1F000, 2},
+ {6, 5, 0x1F010, 0},
+ {6, 5, 0x1F040, 2},
+ {6, 5, 0x1F050, 0},
+ {6, 5, 0x1F060, 0},
+ {6, 5, 0x1F0F0, 0},
+ {7, 1, 0xC0000, 2},
+ {7, 1, 0xC0010, 0},
+ {7, 1, 0xC0020, 0},
+ {7, 1, 0xC0030, 0},
+ {7, 1, 0xC0040, 0},
+ {7, 1, 0xC0050, 4},
+ {7, 1, 0xC0060, 4},
+ {7, 1, 0xC0070, 0},
+ {7, 1, 0xC0080, 0},
+ {7, 1, 0xC00A0, 2},
+ {7, 1, 0xC00B0, 0},
+ {7, 2, 0x1F000, 2},
+ {7, 2, 0x1F010, 0},
+ {7, 2, 0x1F020, 4},
+ {7, 2, 0x1F030, 0},
+ {7, 2, 0x1F040, 2},
+ {7, 2, 0x1F050, 0},
+ {7, 2, 0x1F060, 0},
+ {7, 2, 0x1F0F0, 0},
+ {7, 3, 0x1F000, 2},
+ {7, 3, 0x1F010, 0},
+ {7, 3, 0x1F040, 2},
+ {7, 3, 0x1F050, 0},
+ {7, 3, 0x1F060, 0},
+ {7, 3, 0x1F0F0, 0},
+ {7, 4, 0x1F000, 2},
+ {7, 4, 0x1F010, 0},
+ {7, 4, 0x1F020, 4},
+ {7, 4, 0x1F030, 0},
+ {7, 4, 0x1F040, 2},
+ {7, 4, 0x1F050, 0},
+ {7, 4, 0x1F060, 0},
+ {7, 4, 0x1F0F0, 0},
+ {7, 5, 0x1F000, 2},
+ {7, 5, 0x1F010, 0},
+ {7, 5, 0x1F040, 2},
+ {7, 5, 0x1F050, 0},
+ {7, 5, 0x1F060, 0},
+ {7, 5, 0x1F0F0, 0},
+ },
+ // channels: (col, row, control offset, start queue offset, queue value, control value)
+ {
+ {0, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {0, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {0, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {0, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {0, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {0, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {0, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {0, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {0, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {0, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {1, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {1, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {1, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {1, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {1, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {1, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {1, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {1, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {1, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {1, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {2, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {2, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {2, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {2, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {2, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {2, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {2, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {2, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {2, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {2, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {3, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {3, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {3, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {3, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {3, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {3, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {3, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {3, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {3, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {3, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {4, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {4, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {4, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {4, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {4, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {4, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {4, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {4, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {4, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {4, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {5, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {5, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {5, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {5, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {5, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {5, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {5, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {5, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {5, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {5, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {6, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {6, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {6, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {6, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {6, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {6, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {6, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {6, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {6, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {6, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {7, 2, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {7, 2, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {7, 2, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {7, 3, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {7, 3, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {7, 4, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {7, 4, 0x1DE08, 0x1DE0C, 0x00000002, 1},
+ {7, 4, 0x1DE10, 0x1DE14, 0x00000004, 1},
+ {7, 5, 0x1DE00, 0x1DE04, 0x00000000, 1},
+ {7, 5, 0x1DE10, 0x1DE14, 0x00000002, 1},
+ {0, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {0, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {0, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {0, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {0, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {0, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {0, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {0, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {0, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {1, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {1, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {1, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {1, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {1, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {1, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {1, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {1, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {1, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {2, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {2, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {2, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {2, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {2, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {2, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {2, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {2, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {2, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {3, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {3, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {3, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {3, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {3, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {3, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {3, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {3, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {3, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {4, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {4, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {4, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {4, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {4, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {4, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {4, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {4, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {4, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {5, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {5, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {5, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {5, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {5, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {5, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {5, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {5, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {5, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {6, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {6, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {6, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {6, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {6, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {6, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {6, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {6, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {6, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ {7, 1, 0xA0600, 0xA0604, 0x00000000, 1},
+ {7, 1, 0xA0630, 0xA0634, 0x00000002, 1},
+ {7, 1, 0xA0608, 0xA060C, 0x00000018, 1},
+ {7, 1, 0xA0610, 0xA0614, 0x00000006, 1},
+ {7, 1, 0xA0618, 0xA061C, 0x0000001A, 1},
+ {7, 1, 0xA0620, 0xA0624, 0x00000008, 1},
+ {7, 1, 0xA0638, 0xA063C, 0x0000001C, 1},
+ {7, 1, 0xA0628, 0xA062C, 0x0000001E, 1},
+ {7, 1, 0xA0640, 0xA0644, 0x0000000A, 1},
+ },
+};
+
+inline const op_config op_attn = {
+ // stream switch registers: (col, row, offset, value)
+ {
+ {0, 0, 0x3F008, 0xC0000045},
+ {0, 0, 0x3F010, 0x80000010},
+ {0, 0, 0x3F03C, 0x80000009},
+ {0, 0, 0x3F044, 0x80000005},
+ {0, 0, 0x3F100, 0xC0000000},
+ {0, 0, 0x3F114, 0x80000000},
+ {0, 0, 0x3F124, 0x80000000},
+ {0, 0, 0x3F140, 0x80000000},
+ {0, 0, 0x3F200, 0x0F1F0135},
+ {0, 1, 0xB0000, 0x8000000C},
+ {0, 1, 0xB0004, 0x8000000A},
+ {0, 1, 0xB0008, 0x8000000E},
+ {0, 1, 0xB000C, 0x8000000F},
+ {0, 1, 0xB0010, 0x80000010},
+ {0, 1, 0xB0014, 0x8000000D},
+ {0, 1, 0xB0024, 0x80000005},
+ {0, 1, 0xB002C, 0x80000000},
+ {0, 1, 0xB0030, 0x80000003},
+ {0, 1, 0xB0038, 0x80000001},
+ {0, 1, 0xB0040, 0x80000002},
+ {0, 1, 0xB0100, 0x80000000},
+ {0, 1, 0xB0104, 0x80000000},
+ {0, 1, 0xB0108, 0x80000000},
+ {0, 1, 0xB010C, 0x80000000},
+ {0, 1, 0xB0114, 0x80000000},
+ {0, 1, 0xB0128, 0x80000000},
+ {0, 1, 0xB0130, 0x80000000},
+ {0, 1, 0xB0134, 0x80000000},
+ {0, 1, 0xB0138, 0x80000000},
+ {0, 1, 0xB013C, 0x80000000},
+ {0, 1, 0xB0140, 0x80000000},
+ {0, 2, 0x3F004, 0x80000005},
+ {0, 2, 0x3F008, 0x80000014},
+ {0, 2, 0x3F014, 0x80000011},
+ {0, 2, 0x3F018, 0x80000001},
+ {0, 2, 0x3F01C, 0x80000016},
+ {0, 2, 0x3F020, 0x80000010},
+ {0, 2, 0x3F040, 0x80000006},
+ {0, 2, 0x3F044, 0x80000008},
+ {0, 2, 0x3F048, 0x8000000A},
+ {0, 2, 0x3F050, 0x80000005},
+ {0, 2, 0x3F058, 0x80000008},
+ {0, 2, 0x3F104, 0x80000000},
+ {0, 2, 0x3F114, 0x80000000},
+ {0, 2, 0x3F118, 0x80000000},
+ {0, 2, 0x3F120, 0x80000000},
+ {0, 2, 0x3F128, 0x80000000},
+ {0, 2, 0x3F140, 0x80000000},
+ {0, 2, 0x3F144, 0x80000000},
+ {0, 2, 0x3F150, 0x80000000},
+ {0, 2, 0x3F158, 0x80000000},
+ {0, 3, 0x3F004, 0x80000009},
+ {0, 3, 0x3F008, 0x80000014},
+ {0, 3, 0x3F018, 0x80000001},
+ {0, 3, 0x3F01C, 0x80000016},
+ {0, 3, 0x3F034, 0x80000008},
+ {0, 3, 0x3F038, 0x8000000A},
+ {0, 3, 0x3F04C, 0x8000000F},
+ {0, 3, 0x3F104, 0x80000000},
+ {0, 3, 0x3F120, 0x80000000},
+ {0, 3, 0x3F124, 0x80000000},
+ {0, 3, 0x3F128, 0x80000000},
+ {0, 3, 0x3F13C, 0x80000000},
+ {0, 3, 0x3F150, 0x80000000},
+ {0, 3, 0x3F158, 0x80000000},
+ {0, 4, 0x3F004, 0x80000006},
+ {0, 4, 0x3F008, 0x80000014},
+ {0, 4, 0x3F014, 0x8000000F},
+ {0, 4, 0x3F03C, 0x80000005},
+ {0, 4, 0x3F04C, 0x80000006},
+ {0, 4, 0x3F050, 0x80000001},
+ {0, 4, 0x3F054, 0x80000005},
+ {0, 4, 0x3F104, 0x80000000},
+ {0, 4, 0x3F114, 0x80000000},
+ {0, 4, 0x3F118, 0x80000000},
+ {0, 4, 0x3F13C, 0x80000000},
+ {0, 4, 0x3F150, 0x80000000},
+ {0, 5, 0x3F004, 0x80000007},
+ {0, 5, 0x3F008, 0x80000015},
+ {0, 5, 0x3F014, 0x80000001},
+ {0, 5, 0x3F104, 0x80000000},
+ {0, 5, 0x3F11C, 0x80000000},
+ {0, 5, 0x3F154, 0x80000000},
+ {1, 0, 0x3F008, 0xC0000045},
+ {1, 0, 0x3F010, 0x80000010},
+ {1, 0, 0x3F100, 0xC0000000},
+ {1, 0, 0x3F140, 0x80000000},
+ {1, 0, 0x3F200, 0x0F1F0135},
+ {1, 1, 0xB0008, 0x8000000D},
+ {1, 1, 0xB000C, 0x8000000F},
+ {1, 1, 0xB0010, 0x80000010},
+ {1, 1, 0xB0014, 0x8000000E},
+ {1, 1, 0xB0024, 0x80000005},
+ {1, 1, 0xB0114, 0x80000000},
+ {1, 1, 0xB0134, 0x80000000},
+ {1, 1, 0xB0138, 0x80000000},
+ {1, 1, 0xB013C, 0x80000000},
+ {1, 1, 0xB0140, 0x80000000},
+ {1, 2, 0x3F004, 0x8000000C},
+ {1, 2, 0x3F008, 0x80000014},
+ {1, 2, 0x3F014, 0x8000000F},
+ {1, 2, 0x3F018, 0x80000012},
+ {1, 2, 0x3F01C, 0x80000010},
+ {1, 2, 0x3F020, 0x80000011},
+ {1, 2, 0x3F028, 0x80000014},
+ {1, 2, 0x3F030, 0x80000001},
+ {1, 2, 0x3F038, 0x8000000E},
+ {1, 2, 0x3F104, 0x80000000},
+ {1, 2, 0x3F130, 0x80000000},
+ {1, 2, 0x3F138, 0x80000000},
+ {1, 2, 0x3F13C, 0x80000000},
+ {1, 2, 0x3F140, 0x80000000},
+ {1, 2, 0x3F144, 0x80000000},
+ {1, 2, 0x3F148, 0x80000000},
+ {1, 2, 0x3F150, 0x80000000},
+ {1, 3, 0x3F004, 0x80000006},
+ {1, 3, 0x3F008, 0x80000013},
+ {1, 3, 0x3F014, 0x8000000F},
+ {1, 3, 0x3F018, 0x80000011},
+ {1, 3, 0x3F01C, 0x8000000B},
+ {1, 3, 0x3F020, 0x80000012},
+ {1, 3, 0x3F028, 0x80000013},
+ {1, 3, 0x3F030, 0x80000001},
+ {1, 3, 0x3F048, 0x80000013},
+ {1, 3, 0x3F104, 0x80000000},
+ {1, 3, 0x3F118, 0x80000000},
+ {1, 3, 0x3F12C, 0x80000000},
+ {1, 3, 0x3F13C, 0x80000000},
+ {1, 3, 0x3F144, 0x80000000},
+ {1, 3, 0x3F148, 0x80000000},
+ {1, 3, 0x3F14C, 0x80000000},
+ {1, 4, 0x3F004, 0x8000000B},
+ {1, 4, 0x3F008, 0x8000000A},
+ {1, 4, 0x3F014, 0x8000000C},
+ {1, 4, 0x3F01C, 0x80000001},
+ {1, 4, 0x3F020, 0x8000000F},
+ {1, 4, 0x3F028, 0x8000000A},
+ {1, 4, 0x3F03C, 0x8000000D},
+ {1, 4, 0x3F104, 0x80000000},
+ {1, 4, 0x3F128, 0x80000000},
+ {1, 4, 0x3F12C, 0x80000000},
+ {1, 4, 0x3F130, 0x80000000},
+ {1, 4, 0x3F134, 0x80000000},
+ {1, 4, 0x3F13C, 0x80000000},
+ {1, 5, 0x3F004, 0x80000007},
+ {1, 5, 0x3F008, 0x80000013},
+ {1, 5, 0x3F014, 0x80000001},
+ {1, 5, 0x3F02C, 0x80000013},
+ {1, 5, 0x3F104, 0x80000000},
+ {1, 5, 0x3F11C, 0x80000000},
+ {1, 5, 0x3F14C, 0x80000000},
+ {2, 0, 0x3F008, 0xC0000045},
+ {2, 0, 0x3F010, 0x80000010},
+ {2, 0, 0x3F034, 0x80000005},
+ {2, 0, 0x3F044, 0x80000009},
+ {2, 0, 0x3F100, 0xC0000000},
+ {2, 0, 0x3F114, 0x80000000},
+ {2, 0, 0x3F124, 0x80000000},
+ {2, 0, 0x3F140, 0x80000000},
+ {2, 0, 0x3F200, 0x0F1F0135},
+ {2, 1, 0xB0000, 0x80000008},
+ {2, 1, 0xB0004, 0x8000000C},
+ {2, 1, 0xB0008, 0x8000000F},
+ {2, 1, 0xB000C, 0x80000010},
+ {2, 1, 0xB0010, 0x8000000E},
+ {2, 1, 0xB0014, 0x8000000D},
+ {2, 1, 0xB0024, 0x80000005},
+ {2, 1, 0xB002C, 0x80000002},
+ {2, 1, 0xB0030, 0x80000003},
+ {2, 1, 0xB0038, 0x80000001},
+ {2, 1, 0xB0040, 0x80000000},
+ {2, 1, 0xB0100, 0x80000000},
+ {2, 1, 0xB0104, 0x80000000},
+ {2, 1, 0xB0108, 0x80000000},
+ {2, 1, 0xB010C, 0x80000000},
+ {2, 1, 0xB0114, 0x80000000},
+ {2, 1, 0xB0120, 0x80000000},
+ {2, 1, 0xB0130, 0x80000000},
+ {2, 1, 0xB0134, 0x80000000},
+ {2, 1, 0xB0138, 0x80000000},
+ {2, 1, 0xB013C, 0x80000000},
+ {2, 1, 0xB0140, 0x80000000},
+ {2, 2, 0x3F004, 0x8000000A},
+ {2, 2, 0x3F008, 0x80000013},
+ {2, 2, 0x3F014, 0x8000000F},
+ {2, 2, 0x3F018, 0x80000011},
+ {2, 2, 0x3F01C, 0x80000001},
+ {2, 2, 0x3F020, 0x80000014},
+ {2, 2, 0x3F028, 0x80000013},
+ {2, 2, 0x3F034, 0x80000006},
+ {2, 2, 0x3F03C, 0x80000005},
+ {2, 2, 0x3F048, 0x80000008},
+ {2, 2, 0x3F04C, 0x80000008},
+ {2, 2, 0x3F050, 0x8000000A},
+ {2, 2, 0x3F054, 0x80000010},
+ {2, 2, 0x3F104, 0x80000000},
+ {2, 2, 0x3F114, 0x80000000},
+ {2, 2, 0x3F118, 0x80000000},
+ {2, 2, 0x3F120, 0x80000000},
+ {2, 2, 0x3F128, 0x80000000},
+ {2, 2, 0x3F13C, 0x80000000},
+ {2, 2, 0x3F140, 0x80000000},
+ {2, 2, 0x3F144, 0x80000000},
+ {2, 2, 0x3F14C, 0x80000000},
+ {2, 2, 0x3F150, 0x80000000},
+ {2, 3, 0x3F004, 0x8000000A},
+ {2, 3, 0x3F008, 0x80000014},
+ {2, 3, 0x3F014, 0x80000016},
+ {2, 3, 0x3F018, 0x80000012},
+ {2, 3, 0x3F01C, 0x80000001},
+ {2, 3, 0x3F024, 0x80000014},
+ {2, 3, 0x3F038, 0x80000007},
+ {2, 3, 0x3F040, 0x80000014},
+ {2, 3, 0x3F048, 0x80000005},
+ {2, 3, 0x3F058, 0x8000000F},
+ {2, 3, 0x3F104, 0x80000000},
+ {2, 3, 0x3F114, 0x80000000},
+ {2, 3, 0x3F11C, 0x80000000},
+ {2, 3, 0x3F128, 0x80000000},
+ {2, 3, 0x3F13C, 0x80000000},
+ {2, 3, 0x3F148, 0x80000000},
+ {2, 3, 0x3F150, 0x80000000},
+ {2, 3, 0x3F158, 0x80000000},
+ {2, 4, 0x3F004, 0x80000006},
+ {2, 4, 0x3F008, 0x80000008},
+ {2, 4, 0x3F014, 0x8000000F},
+ {2, 4, 0x3F020, 0x80000001},
+ {2, 4, 0x3F040, 0x8000000A},
+ {2, 4, 0x3F044, 0x80000008},
+ {2, 4, 0x3F050, 0x80000006},
+ {2, 4, 0x3F104, 0x80000000},
+ {2, 4, 0x3F118, 0x80000000},
+ {2, 4, 0x3F120, 0x80000000},
+ {2, 4, 0x3F128, 0x80000000},
+ {2, 4, 0x3F13C, 0x80000000},
+ {2, 5, 0x3F004, 0x80000008},
+ {2, 5, 0x3F008, 0x80000009},
+ {2, 5, 0x3F014, 0x80000001},
+ {2, 5, 0x3F024, 0x80000009},
+ {2, 5, 0x3F050, 0x80000008},
+ {2, 5, 0x3F104, 0x80000000},
+ {2, 5, 0x3F120, 0x80000000},
+ {2, 5, 0x3F124, 0x80000000},
+ {3, 0, 0x3F008, 0xC0000045},
+ {3, 0, 0x3F010, 0x80000010},
+ {3, 0, 0x3F034, 0x80000005},
+ {3, 0, 0x3F044, 0x80000009},
+ {3, 0, 0x3F100, 0xC0000000},
+ {3, 0, 0x3F114, 0x80000000},
+ {3, 0, 0x3F124, 0x80000000},
+ {3, 0, 0x3F140, 0x80000000},
+ {3, 0, 0x3F200, 0x0F1F0135},
+ {3, 1, 0xB0000, 0x80000008},
+ {3, 1, 0xB0004, 0x8000000C},
+ {3, 1, 0xB0008, 0x8000000E},
+ {3, 1, 0xB000C, 0x8000000F},
+ {3, 1, 0xB0010, 0x80000010},
+ {3, 1, 0xB0014, 0x8000000D},
+ {3, 1, 0xB0024, 0x80000005},
+ {3, 1, 0xB0030, 0x80000000},
+ {3, 1, 0xB0100, 0x80000000},
+ {3, 1, 0xB0114, 0x80000000},
+ {3, 1, 0xB0120, 0x80000000},
+ {3, 1, 0xB0130, 0x80000000},
+ {3, 1, 0xB0134, 0x80000000},
+ {3, 1, 0xB0138, 0x80000000},
+ {3, 1, 0xB013C, 0x80000000},
+ {3, 1, 0xB0140, 0x80000000},
+ {3, 2, 0x3F004, 0x8000000C},
+ {3, 2, 0x3F008, 0x80000006},
+ {3, 2, 0x3F014, 0x8000000F},
+ {3, 2, 0x3F018, 0x8000000D},
+ {3, 2, 0x3F01C, 0x80000010},
+ {3, 2, 0x3F020, 0x80000012},
+ {3, 2, 0x3F024, 0x80000006},
+ {3, 2, 0x3F028, 0x80000001},
+ {3, 2, 0x3F038, 0x8000000B},
+ {3, 2, 0x3F044, 0x80000006},
+ {3, 2, 0x3F104, 0x80000000},
+ {3, 2, 0x3F118, 0x80000000},
+ {3, 2, 0x3F12C, 0x80000000},
+ {3, 2, 0x3F130, 0x80000000},
+ {3, 2, 0x3F134, 0x80000000},
+ {3, 2, 0x3F13C, 0x80000000},
+ {3, 2, 0x3F140, 0x80000000},
+ {3, 2, 0x3F148, 0x80000000},
+ {3, 3, 0x3F004, 0x80000006},
+ {3, 3, 0x3F008, 0x80000009},
+ {3, 3, 0x3F014, 0x80000012},
+ {3, 3, 0x3F018, 0x80000010},
+ {3, 3, 0x3F020, 0x8000000E},
+ {3, 3, 0x3F028, 0x80000009},
+ {3, 3, 0x3F030, 0x80000001},
+ {3, 3, 0x3F044, 0x80000009},
+ {3, 3, 0x3F104, 0x80000000},
+ {3, 3, 0x3F118, 0x80000000},
+ {3, 3, 0x3F124, 0x80000000},
+ {3, 3, 0x3F138, 0x80000000},
+ {3, 3, 0x3F140, 0x80000000},
+ {3, 3, 0x3F148, 0x80000000},
+ {3, 4, 0x3F004, 0x8000000C},
+ {3, 4, 0x3F008, 0x80000009},
+ {3, 4, 0x3F018, 0x80000001},
+ {3, 4, 0x3F020, 0x8000000F},
+ {3, 4, 0x3F038, 0x80000009},
+ {3, 4, 0x3F104, 0x80000000},
+ {3, 4, 0x3F124, 0x80000000},
+ {3, 4, 0x3F130, 0x80000000},
+ {3, 4, 0x3F13C, 0x80000000},
+ {3, 5, 0x3F004, 0x8000000C},
+ {3, 5, 0x3F008, 0x80000006},
+ {3, 5, 0x3F014, 0x80000001},
+ {3, 5, 0x3F104, 0x80000000},
+ {3, 5, 0x3F118, 0x80000000},
+ {3, 5, 0x3F130, 0x80000000},
+ {4, 0, 0x3F008, 0xC0000045},
+ {4, 0, 0x3F010, 0x80000010},
+ {4, 0, 0x3F034, 0x80000005},
+ {4, 0, 0x3F044, 0x80000009},
+ {4, 0, 0x3F100, 0xC0000000},
+ {4, 0, 0x3F114, 0x80000000},
+ {4, 0, 0x3F124, 0x80000000},
+ {4, 0, 0x3F140, 0x80000000},
+ {4, 0, 0x3F200, 0x0F1F0135},
+ {4, 1, 0xB0000, 0x80000008},
+ {4, 1, 0xB0004, 0x8000000C},
+ {4, 1, 0xB0008, 0x8000000F},
+ {4, 1, 0xB000C, 0x8000000E},
+ {4, 1, 0xB0010, 0x8000000D},
+ {4, 1, 0xB0014, 0x80000010},
+ {4, 1, 0xB0024, 0x80000005},
+ {4, 1, 0xB002C, 0x80000000},
+ {4, 1, 0xB0030, 0x80000003},
+ {4, 1, 0xB0038, 0x80000001},
+ {4, 1, 0xB0040, 0x80000002},
+ {4, 1, 0xB0100, 0x80000000},
+ {4, 1, 0xB0104, 0x80000000},
+ {4, 1, 0xB0108, 0x80000000},
+ {4, 1, 0xB010C, 0x80000000},
+ {4, 1, 0xB0114, 0x80000000},
+ {4, 1, 0xB0120, 0x80000000},
+ {4, 1, 0xB0130, 0x80000000},
+ {4, 1, 0xB0134, 0x80000000},
+ {4, 1, 0xB0138, 0x80000000},
+ {4, 1, 0xB013C, 0x80000000},
+ {4, 1, 0xB0140, 0x80000000},
+ {4, 2, 0x3F004, 0x80000005},
+ {4, 2, 0x3F008, 0x80000013},
+ {4, 2, 0x3F014, 0x80000012},
+ {4, 2, 0x3F018, 0x80000015},
+ {4, 2, 0x3F01C, 0x80000001},
+ {4, 2, 0x3F020, 0x80000010},
+ {4, 2, 0x3F034, 0x80000008},
+ {4, 2, 0x3F038, 0x80000006},
+ {4, 2, 0x3F03C, 0x8000000A},
+ {4, 2, 0x3F04C, 0x80000008},
+ {4, 2, 0x3F050, 0x80000005},
+ {4, 2, 0x3F054, 0x8000000A},
+ {4, 2, 0x3F058, 0x80000011},
+ {4, 2, 0x3F104, 0x80000000},
+ {4, 2, 0x3F114, 0x80000000},
+ {4, 2, 0x3F118, 0x80000000},
+ {4, 2, 0x3F120, 0x80000000},
+ {4, 2, 0x3F128, 0x80000000},
+ {4, 2, 0x3F140, 0x80000000},
+ {4, 2, 0x3F144, 0x80000000},
+ {4, 2, 0x3F148, 0x80000000},
+ {4, 2, 0x3F14C, 0x80000000},
+ {4, 2, 0x3F154, 0x80000000},
+ {4, 3, 0x3F004, 0x80000005},
+ {4, 3, 0x3F008, 0x80000014},
+ {4, 3, 0x3F018, 0x80000016},
+ {4, 3, 0x3F01C, 0x80000012},
+ {4, 3, 0x3F020, 0x80000001},
+ {4, 3, 0x3F038, 0x80000006},
+ {4, 3, 0x3F040, 0x80000007},
+ {4, 3, 0x3F104, 0x80000000},
+ {4, 3, 0x3F114, 0x80000000},
+ {4, 3, 0x3F118, 0x80000000},
+ {4, 3, 0x3F11C, 0x80000000},
+ {4, 3, 0x3F148, 0x80000000},
+ {4, 3, 0x3F150, 0x80000000},
+ {4, 3, 0x3F158, 0x80000000},
+ {4, 4, 0x3F004, 0x80000008},
+ {4, 4, 0x3F008, 0x80000014},
+ {4, 4, 0x3F020, 0x80000001},
+ {4, 4, 0x3F03C, 0x80000006},
+ {4, 4, 0x3F044, 0x80000014},
+ {4, 4, 0x3F04C, 0x80000006},
+ {4, 4, 0x3F104, 0x80000000},
+ {4, 4, 0x3F118, 0x80000000},
+ {4, 4, 0x3F120, 0x80000000},
+ {4, 4, 0x3F150, 0x80000000},
+ {4, 5, 0x3F004, 0x80000007},
+ {4, 5, 0x3F008, 0x80000009},
+ {4, 5, 0x3F058, 0x80000001},
+ {4, 5, 0x3F104, 0x80000000},
+ {4, 5, 0x3F11C, 0x80000000},
+ {4, 5, 0x3F124, 0x80000000},
+ {5, 0, 0x3F008, 0xC0000045},
+ {5, 0, 0x3F010, 0x80000010},
+ {5, 0, 0x3F100, 0xC0000000},
+ {5, 0, 0x3F140, 0x80000000},
+ {5, 0, 0x3F200, 0x0F1F0135},
+ {5, 1, 0xB0008, 0x80000010},
+ {5, 1, 0xB000C, 0x8000000F},
+ {5, 1, 0xB0010, 0x8000000E},
+ {5, 1, 0xB0014, 0x8000000D},
+ {5, 1, 0xB0024, 0x80000005},
+ {5, 1, 0xB0114, 0x80000000},
+ {5, 1, 0xB0134, 0x80000000},
+ {5, 1, 0xB0138, 0x80000000},
+ {5, 1, 0xB013C, 0x80000000},
+ {5, 1, 0xB0140, 0x80000000},
+ {5, 2, 0x3F004, 0x8000000C},
+ {5, 2, 0x3F008, 0x80000013},
+ {5, 2, 0x3F014, 0x80000011},
+ {5, 2, 0x3F018, 0x80000010},
+ {5, 2, 0x3F01C, 0x8000000F},
+ {5, 2, 0x3F020, 0x8000000E},
+ {5, 2, 0x3F024, 0x80000013},
+ {5, 2, 0x3F02C, 0x80000001},
+ {5, 2, 0x3F034, 0x8000000B},
+ {5, 2, 0x3F038, 0x8000000D},
+ {5, 2, 0x3F044, 0x80000013},
+ {5, 2, 0x3F104, 0x80000000},
+ {5, 2, 0x3F12C, 0x80000000},
+ {5, 2, 0x3F130, 0x80000000},
+ {5, 2, 0x3F134, 0x80000000},
+ {5, 2, 0x3F138, 0x80000000},
+ {5, 2, 0x3F13C, 0x80000000},
+ {5, 2, 0x3F140, 0x80000000},
+ {5, 2, 0x3F144, 0x80000000},
+ {5, 2, 0x3F14C, 0x80000000},
+ {5, 3, 0x3F004, 0x80000005},
+ {5, 3, 0x3F008, 0x80000009},
+ {5, 3, 0x3F014, 0x80000012},
+ {5, 3, 0x3F018, 0x80000010},
+ {5, 3, 0x3F01C, 0x80000011},
+ {5, 3, 0x3F028, 0x80000009},
+ {5, 3, 0x3F030, 0x80000001},
+ {5, 3, 0x3F038, 0x80000009},
+ {5, 3, 0x3F048, 0x80000006},
+ {5, 3, 0x3F104, 0x80000000},
+ {5, 3, 0x3F114, 0x80000000},
+ {5, 3, 0x3F118, 0x80000000},
+ {5, 3, 0x3F124, 0x80000000},
+ {5, 3, 0x3F140, 0x80000000},
+ {5, 3, 0x3F144, 0x80000000},
+ {5, 3, 0x3F148, 0x80000000},
+ {5, 4, 0x3F004, 0x8000000A},
+ {5, 4, 0x3F008, 0x80000006},
+ {5, 4, 0x3F018, 0x80000011},
+ {5, 4, 0x3F01C, 0x8000000F},
+ {5, 4, 0x3F020, 0x80000001},
+ {5, 4, 0x3F028, 0x80000006},
+ {5, 4, 0x3F044, 0x8000000B},
+ {5, 4, 0x3F048, 0x80000006},
+ {5, 4, 0x3F104, 0x80000000},
+ {5, 4, 0x3F118, 0x80000000},
+ {5, 4, 0x3F128, 0x80000000},
+ {5, 4, 0x3F12C, 0x80000000},
+ {5, 4, 0x3F13C, 0x80000000},
+ {5, 4, 0x3F144, 0x80000000},
+ {5, 5, 0x3F004, 0x80000009},
+ {5, 5, 0x3F008, 0x8000000A},
+ {5, 5, 0x3F014, 0x80000001},
+ {5, 5, 0x3F01C, 0x8000000E},
+ {5, 5, 0x3F104, 0x80000000},
+ {5, 5, 0x3F124, 0x80000000},
+ {5, 5, 0x3F128, 0x80000000},
+ {5, 5, 0x3F138, 0x80000000},
+ {6, 0, 0x3F008, 0xC0000045},
+ {6, 0, 0x3F010, 0x80000010},
+ {6, 0, 0x3F034, 0x80000005},
+ {6, 0, 0x3F044, 0x80000009},
+ {6, 0, 0x3F100, 0xC0000000},
+ {6, 0, 0x3F114, 0x80000000},
+ {6, 0, 0x3F124, 0x80000000},
+ {6, 0, 0x3F140, 0x80000000},
+ {6, 0, 0x3F200, 0x0F1F0135},
+ {6, 1, 0xB0000, 0x80000008},
+ {6, 1, 0xB0004, 0x8000000C},
+ {6, 1, 0xB0008, 0x8000000F},
+ {6, 1, 0xB000C, 0x80000010},
+ {6, 1, 0xB0010, 0x8000000E},
+ {6, 1, 0xB0014, 0x8000000D},
+ {6, 1, 0xB0024, 0x80000005},
+ {6, 1, 0xB002C, 0x80000002},
+ {6, 1, 0xB0030, 0x80000001},
+ {6, 1, 0xB0034, 0x80000003},
+ {6, 1, 0xB0038, 0x80000000},
+ {6, 1, 0xB0100, 0x80000000},
+ {6, 1, 0xB0104, 0x80000000},
+ {6, 1, 0xB0108, 0x80000000},
+ {6, 1, 0xB010C, 0x80000000},
+ {6, 1, 0xB0114, 0x80000000},
+ {6, 1, 0xB0120, 0x80000000},
+ {6, 1, 0xB0130, 0x80000000},
+ {6, 1, 0xB0134, 0x80000000},
+ {6, 1, 0xB0138, 0x80000000},
+ {6, 1, 0xB013C, 0x80000000},
+ {6, 1, 0xB0140, 0x80000000},
+ {6, 2, 0x3F004, 0x80000008},
+ {6, 2, 0x3F008, 0x80000014},
+ {6, 2, 0x3F014, 0x80000010},
+ {6, 2, 0x3F018, 0x8000000F},
+ {6, 2, 0x3F01C, 0x80000001},
+ {6, 2, 0x3F020, 0x80000016},
+ {6, 2, 0x3F024, 0x80000014},
+ {6, 2, 0x3F034, 0x80000007},
+ {6, 2, 0x3F03C, 0x80000005},
+ {6, 2, 0x3F048, 0x80000006},
+ {6, 2, 0x3F054, 0x80000012},
+ {6, 2, 0x3F058, 0x80000008},
+ {6, 2, 0x3F104, 0x80000000},
+ {6, 2, 0x3F114, 0x80000000},
+ {6, 2, 0x3F118, 0x80000000},
+ {6, 2, 0x3F11C, 0x80000000},
+ {6, 2, 0x3F120, 0x80000000},
+ {6, 2, 0x3F13C, 0x80000000},
+ {6, 2, 0x3F140, 0x80000000},
+ {6, 2, 0x3F148, 0x80000000},
+ {6, 2, 0x3F150, 0x80000000},
+ {6, 2, 0x3F158, 0x80000000},
+ {6, 3, 0x3F004, 0x8000000A},
+ {6, 3, 0x3F008, 0x80000014},
+ {6, 3, 0x3F014, 0x80000001},
+ {6, 3, 0x3F018, 0x80000015},
+ {6, 3, 0x3F020, 0x8000000F},
+ {6, 3, 0x3F040, 0x80000005},
+ {6, 3, 0x3F048, 0x80000007},
+ {6, 3, 0x3F050, 0x8000000A},
+ {6, 3, 0x3F104, 0x80000000},
+ {6, 3, 0x3F114, 0x80000000},
+ {6, 3, 0x3F11C, 0x80000000},
+ {6, 3, 0x3F128, 0x80000000},
+ {6, 3, 0x3F13C, 0x80000000},
+ {6, 3, 0x3F150, 0x80000000},
+ {6, 3, 0x3F154, 0x80000000},
+ {6, 4, 0x3F004, 0x8000000A},
+ {6, 4, 0x3F008, 0x80000014},
+ {6, 4, 0x3F014, 0x8000000F},
+ {6, 4, 0x3F038, 0x80000008},
+ {6, 4, 0x3F04C, 0x80000001},
+ {6, 4, 0x3F050, 0x8000000A},
+ {6, 4, 0x3F104, 0x80000000},
+ {6, 4, 0x3F120, 0x80000000},
+ {6, 4, 0x3F128, 0x80000000},
+ {6, 4, 0x3F13C, 0x80000000},
+ {6, 4, 0x3F150, 0x80000000},
+ {6, 5, 0x3F004, 0x80000006},
+ {6, 5, 0x3F008, 0x80000015},
+ {6, 5, 0x3F014, 0x80000001},
+ {6, 5, 0x3F054, 0x80000006},
+ {6, 5, 0x3F104, 0x80000000},
+ {6, 5, 0x3F118, 0x80000000},
+ {6, 5, 0x3F154, 0x80000000},
+ {7, 0, 0x3F008, 0xC0000045},
+ {7, 0, 0x3F010, 0x80000010},
+ {7, 0, 0x3F030, 0x80000005},
+ {7, 0, 0x3F034, 0x80000009},
+ {7, 0, 0x3F100, 0xC0000000},
+ {7, 0, 0x3F114, 0x80000000},
+ {7, 0, 0x3F124, 0x80000000},
+ {7, 0, 0x3F140, 0x80000000},
+ {7, 0, 0x3F200, 0x0F1F0135},
+ {7, 1, 0xB0000, 0x80000007},
+ {7, 1, 0xB0004, 0x80000008},
+ {7, 1, 0xB0008, 0x8000000D},
+ {7, 1, 0xB000C, 0x8000000F},
+ {7, 1, 0xB0010, 0x8000000E},
+ {7, 1, 0xB0014, 0x80000010},
+ {7, 1, 0xB0024, 0x80000005},
+ {7, 1, 0xB0030, 0x80000000},
+ {7, 1, 0xB0100, 0x80000000},
+ {7, 1, 0xB0114, 0x80000000},
+ {7, 1, 0xB011C, 0x80000000},
+ {7, 1, 0xB0120, 0x80000000},
+ {7, 1, 0xB0134, 0x80000000},
+ {7, 1, 0xB0138, 0x80000000},
+ {7, 1, 0xB013C, 0x80000000},
+ {7, 1, 0xB0140, 0x80000000},
+ {7, 2, 0x3F004, 0x8000000E},
+ {7, 2, 0x3F008, 0x80000006},
+ {7, 2, 0x3F014, 0x8000000F},
+ {7, 2, 0x3F018, 0x8000000D},
+ {7, 2, 0x3F01C, 0x80000011},
+ {7, 2, 0x3F020, 0x80000012},
+ {7, 2, 0x3F028, 0x80000006},
+ {7, 2, 0x3F030, 0x80000001},
+ {7, 2, 0x3F048, 0x80000006},
+ {7, 2, 0x3F104, 0x80000000},
+ {7, 2, 0x3F118, 0x80000000},
+ {7, 2, 0x3F134, 0x80000000},
+ {7, 2, 0x3F138, 0x80000000},
+ {7, 2, 0x3F13C, 0x80000000},
+ {7, 2, 0x3F144, 0x80000000},
+ {7, 2, 0x3F148, 0x80000000},
+ {7, 3, 0x3F004, 0x8000000C},
+ {7, 3, 0x3F008, 0x8000000A},
+ {7, 3, 0x3F014, 0x80000010},
+ {7, 3, 0x3F01C, 0x80000011},
+ {7, 3, 0x3F020, 0x80000012},
+ {7, 3, 0x3F028, 0x8000000A},
+ {7, 3, 0x3F02C, 0x80000001},
+ {7, 3, 0x3F044, 0x8000000A},
+ {7, 3, 0x3F104, 0x80000000},
+ {7, 3, 0x3F128, 0x80000000},
+ {7, 3, 0x3F130, 0x80000000},
+ {7, 3, 0x3F140, 0x80000000},
+ {7, 3, 0x3F144, 0x80000000},
+ {7, 3, 0x3F148, 0x80000000},
+ {7, 4, 0x3F004, 0x8000000C},
+ {7, 4, 0x3F008, 0x80000009},
+ {7, 4, 0x3F018, 0x8000000B},
+ {7, 4, 0x3F01C, 0x80000001},
+ {7, 4, 0x3F020, 0x8000000F},
+ {7, 4, 0x3F028, 0x80000009},
+ {7, 4, 0x3F03C, 0x80000009},
+ {7, 4, 0x3F104, 0x80000000},
+ {7, 4, 0x3F124, 0x80000000},
+ {7, 4, 0x3F12C, 0x80000000},
+ {7, 4, 0x3F130, 0x80000000},
+ {7, 4, 0x3F13C, 0x80000000},
+ {7, 5, 0x3F004, 0x8000000D},
+ {7, 5, 0x3F008, 0x80000007},
+ {7, 5, 0x3F014, 0x80000001},
+ {7, 5, 0x3F02C, 0x80000007},
+ {7, 5, 0x3F104, 0x80000000},
+ {7, 5, 0x3F11C, 0x80000000},
+ {7, 5, 0x3F134, 0x80000000},
+ },
+ // shim mux / demux mask writes: (col, row, offset, mask, value)
+ {
+ {0, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {0, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {0, 0, 0x1F004, 0x00000030, 0x00000010},
+ {2, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {2, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {2, 0, 0x1F004, 0x00000030, 0x00000010},
+ {4, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {4, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {4, 0, 0x1F004, 0x00000030, 0x00000010},
+ {6, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {6, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {6, 0, 0x1F004, 0x00000030, 0x00000010},
+ {3, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {3, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {3, 0, 0x1F004, 0x00000030, 0x00000010},
+ {7, 0, 0x1F000, 0x00000C00, 0x00000400},
+ {7, 0, 0x1F000, 0x0000C000, 0x00004000},
+ {7, 0, 0x1F004, 0x00000030, 0x00000010},
+ {1, 0, 0x1F004, 0x00000030, 0x00000010},
+ {5, 0, 0x1F004, 0x00000030, 0x00000010},
+ },
+ // BD registers: (col, row, offset, shared, words)
+ {
+ {0, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {0, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {0, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {0, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {0, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {0, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {0, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {0, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {0, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {0, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {0, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {0, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {0, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {0, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {0, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {0, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {0, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {0, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {0, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {0, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {1, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {1, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {1, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {1, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {1, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {1, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {1, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {1, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {1, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {1, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {1, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {1, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {1, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {1, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {1, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {1, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {1, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {1, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {1, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {1, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {2, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {2, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {2, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {2, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {2, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {2, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {2, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {2, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {2, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {2, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {2, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {2, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {2, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {2, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {2, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {2, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {2, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {2, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {2, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {2, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {3, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {3, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {3, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {3, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {3, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {3, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {3, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {3, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {3, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {3, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {3, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {3, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {3, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {3, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {3, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {3, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {3, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {3, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {3, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {3, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {4, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {4, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {4, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {4, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {4, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {4, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {4, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {4, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {4, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {4, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {4, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {4, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {4, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {4, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {4, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {4, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {4, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {4, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {4, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {4, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {5, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {5, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {5, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {5, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {5, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {5, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {5, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {5, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {5, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {5, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {5, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {5, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {5, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {5, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {5, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {5, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {5, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {5, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {5, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {5, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {6, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {6, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {6, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {6, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {6, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {6, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {6, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {6, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {6, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {6, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {6, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {6, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {6, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {6, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {6, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {6, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {6, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {6, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {6, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {6, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {7, 2, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {7, 2, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {7, 2, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {7, 2, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {7, 2, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {7, 3, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {7, 3, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {7, 3, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {7, 3, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {7, 3, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {7, 4, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {7, 4, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {7, 4, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {7, 4, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {7, 4, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {7, 5, 0x1D100, false, {0x01000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46043FE0}},
+ {7, 5, 0x1D120, false, {0x08000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56047FE2}},
+ {7, 5, 0x1D160, false, {0x09000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66049FE5}},
+ {7, 5, 0x1D180, false, {0x0D000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E049FE5}},
+ {7, 5, 0x1D140, false, {0x0C000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4E047FE2}},
+ {0, 1, 0xA01C0, false, {0x00001000, 0x00FA0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {0, 1, 0xA0480, false, {0x00001000, 0x025A1000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {0, 1, 0xA0200, false, {0x00000800, 0x011A0000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {0, 1, 0xA04C0, false, {0x00000800, 0x027A0800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {0, 1, 0xA0240, false, {0x00000800, 0x013A1000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {0, 1, 0xA0500, false, {0x00000800, 0x029A1800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {0, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {0, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {0, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {0, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {0, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {0, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {0, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {0, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {0, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {0, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {0, 1, 0xA0520, false, {0x00000800, 0x028A5800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {0, 1, 0xA0260, false, {0x00000800, 0x012A5000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {0, 1, 0xA04E0, false, {0x00000800, 0x026A4800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {0, 1, 0xA0220, false, {0x00000800, 0x010A4000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {0, 1, 0xA04A0, false, {0x00001000, 0x024A5000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {0, 1, 0xA01E0, false, {0x00001000, 0x00EA4000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {1, 1, 0xA0200, false, {0x00002000, 0x011A0000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {1, 1, 0xA0500, false, {0x00002000, 0x029A2000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {1, 1, 0xA0240, false, {0x00004000, 0x013A0000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {1, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {1, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {1, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {1, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {1, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {1, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {1, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {1, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {1, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {1, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {1, 1, 0xA0260, false, {0x00004000, 0x012A4000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {1, 1, 0xA0520, false, {0x00002000, 0x028A6000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {1, 1, 0xA0220, false, {0x00002000, 0x010A4000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {2, 1, 0xA01C0, false, {0x00001000, 0x00FA0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {2, 1, 0xA0480, false, {0x00001000, 0x025A1000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {2, 1, 0xA0200, false, {0x00000800, 0x011A0000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {2, 1, 0xA04C0, false, {0x00000800, 0x027A0800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {2, 1, 0xA0240, false, {0x00000800, 0x013A1000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {2, 1, 0xA0500, false, {0x00000800, 0x029A1800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {2, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {2, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {2, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {2, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {2, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {2, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {2, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {2, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {2, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {2, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {2, 1, 0xA0520, false, {0x00000800, 0x028A5800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {2, 1, 0xA0260, false, {0x00000800, 0x012A5000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {2, 1, 0xA04E0, false, {0x00000800, 0x026A4800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {2, 1, 0xA0220, false, {0x00000800, 0x010A4000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {2, 1, 0xA04A0, false, {0x00001000, 0x024A5000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {2, 1, 0xA01E0, false, {0x00001000, 0x00EA4000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {3, 1, 0xA0200, false, {0x00002000, 0x011A0000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {3, 1, 0xA0500, false, {0x00002000, 0x029A2000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {3, 1, 0xA0240, false, {0x00004000, 0x013A0000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {3, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {3, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {3, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {3, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {3, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {3, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {3, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {3, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {3, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {3, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {3, 1, 0xA0260, false, {0x00004000, 0x012A4000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {3, 1, 0xA0520, false, {0x00002000, 0x028A6000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {3, 1, 0xA0220, false, {0x00002000, 0x010A4000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {4, 1, 0xA01C0, false, {0x00001000, 0x00FA0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {4, 1, 0xA0480, false, {0x00001000, 0x025A1000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {4, 1, 0xA0200, false, {0x00000800, 0x011A0000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {4, 1, 0xA04C0, false, {0x00000800, 0x027A0800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {4, 1, 0xA0240, false, {0x00000800, 0x013A1000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {4, 1, 0xA0500, false, {0x00000800, 0x029A1800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {4, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {4, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {4, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {4, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {4, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {4, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {4, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {4, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {4, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {4, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {4, 1, 0xA0520, false, {0x00000800, 0x028A5800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {4, 1, 0xA0260, false, {0x00000800, 0x012A5000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {4, 1, 0xA04E0, false, {0x00000800, 0x026A4800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {4, 1, 0xA0220, false, {0x00000800, 0x010A4000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {4, 1, 0xA04A0, false, {0x00001000, 0x024A5000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {4, 1, 0xA01E0, false, {0x00001000, 0x00EA4000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {5, 1, 0xA0200, false, {0x00002000, 0x011A0000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {5, 1, 0xA0500, false, {0x00002000, 0x029A2000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {5, 1, 0xA0240, false, {0x00004000, 0x013A0000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {5, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {5, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {5, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {5, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {5, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {5, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {5, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {5, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {5, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {5, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {5, 1, 0xA0260, false, {0x00004000, 0x012A4000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {5, 1, 0xA0520, false, {0x00002000, 0x028A6000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {5, 1, 0xA0220, false, {0x00002000, 0x010A4000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {6, 1, 0xA01C0, false, {0x00001000, 0x00FA0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {6, 1, 0xA0480, false, {0x00001000, 0x025A1000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {6, 1, 0xA0200, false, {0x00000800, 0x011A0000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {6, 1, 0xA04C0, false, {0x00000800, 0x027A0800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {6, 1, 0xA0240, false, {0x00000800, 0x013A1000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {6, 1, 0xA0500, false, {0x00000800, 0x029A1800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {6, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {6, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {6, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {6, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {6, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {6, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8147FF4B}},
+ {6, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814BFF4A}},
+ {6, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x814AFF49}},
+ {6, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8149FF48}},
+ {6, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8148FF47}},
+ {6, 1, 0xA0520, false, {0x00000800, 0x028A5800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF46}},
+ {6, 1, 0xA0260, false, {0x00000800, 0x012A5000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {6, 1, 0xA04E0, false, {0x00000800, 0x026A4800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8140FF43}},
+ {6, 1, 0xA0220, false, {0x00000800, 0x010A4000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF41}},
+ {6, 1, 0xA04A0, false, {0x00001000, 0x024A5000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8145FF44}},
+ {6, 1, 0xA01E0, false, {0x00001000, 0x00EA4000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8141FF40}},
+ {7, 1, 0xA0200, false, {0x00002000, 0x011A0000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {7, 1, 0xA0500, false, {0x00002000, 0x029A2000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {7, 1, 0xA0240, false, {0x00004000, 0x013A0000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {7, 1, 0xA0280, false, {0x00000400, 0x015A8000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {7, 1, 0xA0540, false, {0x00000400, 0x02BA8400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {7, 1, 0xA02C0, false, {0x00000400, 0x017A8800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {7, 1, 0xA0580, false, {0x00000400, 0x02DA8C00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {7, 1, 0xA05C0, false, {0x00001000, 0x02FA8000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {7, 1, 0xA05E0, false, {0x00001000, 0x02EAC000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8142FF46}},
+ {7, 1, 0xA05A0, false, {0x00000400, 0x02CACC00, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8146FF45}},
+ {7, 1, 0xA02E0, false, {0x00000400, 0x016AC800, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8145FF44}},
+ {7, 1, 0xA0560, false, {0x00000400, 0x02AAC400, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8144FF43}},
+ {7, 1, 0xA02A0, false, {0x00000400, 0x014AC000, 0x00080000, 0x0010003F, 0x00200003, 0x000001FF, 0x00000000, 0x8143FF42}},
+ {7, 1, 0xA0260, false, {0x00004000, 0x012A4000, 0x00800000, 0x0020003F, 0x002003FF, 0x00000000, 0x00000000, 0x8240FE41}},
+ {7, 1, 0xA0520, false, {0x00002000, 0x028A6000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ {7, 1, 0xA0220, false, {0x00002000, 0x010A4000, 0x00080000, 0x0020003F, 0x00200003, 0x000003FF, 0x00000000, 0x8141FF40}},
+ },
+ // lock values: (col, row, offset, value)
+ {
+ {0, 1, 0xC0000, 2},
+ {0, 1, 0xC0010, 0},
+ {0, 1, 0xC0030, 0},
+ {0, 1, 0xC0040, 2},
+ {0, 1, 0xC0050, 0},
+ {0, 1, 0xC0060, 0},
+ {0, 1, 0xC0070, 2},
+ {0, 1, 0xC0080, 0},
+ {0, 1, 0xC0090, 0},
+ {0, 1, 0xC00A0, 0},
+ {0, 1, 0xC00B0, 0},
+ {0, 2, 0x1F000, 1},
+ {0, 2, 0x1F010, 0},
+ {0, 2, 0x1F020, 2},
+ {0, 2, 0x1F030, 0},
+ {0, 2, 0x1F040, 2},
+ {0, 2, 0x1F050, 0},
+ {0, 2, 0x1F0F0, 0},
+ {0, 3, 0x1F000, 1},
+ {0, 3, 0x1F010, 0},
+ {0, 3, 0x1F020, 2},
+ {0, 3, 0x1F030, 0},
+ {0, 3, 0x1F040, 2},
+ {0, 3, 0x1F050, 0},
+ {0, 3, 0x1F0F0, 0},
+ {0, 4, 0x1F000, 1},
+ {0, 4, 0x1F010, 0},
+ {0, 4, 0x1F020, 2},
+ {0, 4, 0x1F030, 0},
+ {0, 4, 0x1F040, 2},
+ {0, 4, 0x1F050, 0},
+ {0, 4, 0x1F0F0, 0},
+ {0, 5, 0x1F000, 1},
+ {0, 5, 0x1F010, 0},
+ {0, 5, 0x1F020, 2},
+ {0, 5, 0x1F030, 0},
+ {0, 5, 0x1F040, 2},
+ {0, 5, 0x1F050, 0},
+ {0, 5, 0x1F0F0, 0},
+ {1, 1, 0xC0000, 4},
+ {1, 1, 0xC0010, 0},
+ {1, 1, 0xC0020, 2},
+ {1, 1, 0xC0030, 0},
+ {1, 1, 0xC0040, 0},
+ {1, 1, 0xC0050, 0},
+ {1, 1, 0xC0060, 0},
+ {1, 2, 0x1F000, 1},
+ {1, 2, 0x1F010, 0},
+ {1, 2, 0x1F020, 2},
+ {1, 2, 0x1F030, 0},
+ {1, 2, 0x1F040, 2},
+ {1, 2, 0x1F050, 0},
+ {1, 2, 0x1F0F0, 0},
+ {1, 3, 0x1F000, 1},
+ {1, 3, 0x1F010, 0},
+ {1, 3, 0x1F020, 2},
+ {1, 3, 0x1F030, 0},
+ {1, 3, 0x1F040, 2},
+ {1, 3, 0x1F050, 0},
+ {1, 3, 0x1F0F0, 0},
+ {1, 4, 0x1F000, 1},
+ {1, 4, 0x1F010, 0},
+ {1, 4, 0x1F020, 2},
+ {1, 4, 0x1F030, 0},
+ {1, 4, 0x1F040, 2},
+ {1, 4, 0x1F050, 0},
+ {1, 4, 0x1F0F0, 0},
+ {1, 5, 0x1F000, 1},
+ {1, 5, 0x1F010, 0},
+ {1, 5, 0x1F020, 2},
+ {1, 5, 0x1F030, 0},
+ {1, 5, 0x1F040, 2},
+ {1, 5, 0x1F050, 0},
+ {1, 5, 0x1F0F0, 0},
+ {2, 1, 0xC0000, 2},
+ {2, 1, 0xC0010, 0},
+ {2, 1, 0xC0030, 0},
+ {2, 1, 0xC0040, 2},
+ {2, 1, 0xC0050, 0},
+ {2, 1, 0xC0060, 0},
+ {2, 1, 0xC0070, 2},
+ {2, 1, 0xC0080, 0},
+ {2, 1, 0xC0090, 0},
+ {2, 1, 0xC00A0, 0},
+ {2, 1, 0xC00B0, 0},
+ {2, 2, 0x1F000, 1},
+ {2, 2, 0x1F010, 0},
+ {2, 2, 0x1F020, 2},
+ {2, 2, 0x1F030, 0},
+ {2, 2, 0x1F040, 2},
+ {2, 2, 0x1F050, 0},
+ {2, 2, 0x1F0F0, 0},
+ {2, 3, 0x1F000, 1},
+ {2, 3, 0x1F010, 0},
+ {2, 3, 0x1F020, 2},
+ {2, 3, 0x1F030, 0},
+ {2, 3, 0x1F040, 2},
+ {2, 3, 0x1F050, 0},
+ {2, 3, 0x1F0F0, 0},
+ {2, 4, 0x1F000, 1},
+ {2, 4, 0x1F010, 0},
+ {2, 4, 0x1F020, 2},
+ {2, 4, 0x1F030, 0},
+ {2, 4, 0x1F040, 2},
+ {2, 4, 0x1F050, 0},
+ {2, 4, 0x1F0F0, 0},
+ {2, 5, 0x1F000, 1},
+ {2, 5, 0x1F010, 0},
+ {2, 5, 0x1F020, 2},
+ {2, 5, 0x1F030, 0},
+ {2, 5, 0x1F040, 2},
+ {2, 5, 0x1F050, 0},
+ {2, 5, 0x1F0F0, 0},
+ {3, 1, 0xC0000, 4},
+ {3, 1, 0xC0010, 0},
+ {3, 1, 0xC0020, 2},
+ {3, 1, 0xC0030, 0},
+ {3, 1, 0xC0040, 0},
+ {3, 1, 0xC0050, 0},
+ {3, 1, 0xC0060, 0},
+ {3, 2, 0x1F000, 1},
+ {3, 2, 0x1F010, 0},
+ {3, 2, 0x1F020, 2},
+ {3, 2, 0x1F030, 0},
+ {3, 2, 0x1F040, 2},
+ {3, 2, 0x1F050, 0},
+ {3, 2, 0x1F0F0, 0},
+ {3, 3, 0x1F000, 1},
+ {3, 3, 0x1F010, 0},
+ {3, 3, 0x1F020, 2},
+ {3, 3, 0x1F030, 0},
+ {3, 3, 0x1F040, 2},
+ {3, 3, 0x1F050, 0},
+ {3, 3, 0x1F0F0, 0},
+ {3, 4, 0x1F000, 1},
+ {3, 4, 0x1F010, 0},
+ {3, 4, 0x1F020, 2},
+ {3, 4, 0x1F030, 0},
+ {3, 4, 0x1F040, 2},
+ {3, 4, 0x1F050, 0},
+ {3, 4, 0x1F0F0, 0},
+ {3, 5, 0x1F000, 1},
+ {3, 5, 0x1F010, 0},
+ {3, 5, 0x1F020, 2},
+ {3, 5, 0x1F030, 0},
+ {3, 5, 0x1F040, 2},
+ {3, 5, 0x1F050, 0},
+ {3, 5, 0x1F0F0, 0},
+ {4, 1, 0xC0000, 2},
+ {4, 1, 0xC0010, 0},
+ {4, 1, 0xC0030, 0},
+ {4, 1, 0xC0040, 2},
+ {4, 1, 0xC0050, 0},
+ {4, 1, 0xC0060, 0},
+ {4, 1, 0xC0070, 2},
+ {4, 1, 0xC0080, 0},
+ {4, 1, 0xC0090, 0},
+ {4, 1, 0xC00A0, 0},
+ {4, 1, 0xC00B0, 0},
+ {4, 2, 0x1F000, 1},
+ {4, 2, 0x1F010, 0},
+ {4, 2, 0x1F020, 2},
+ {4, 2, 0x1F030, 0},
+ {4, 2, 0x1F040, 2},
+ {4, 2, 0x1F050, 0},
+ {4, 2, 0x1F0F0, 0},
+ {4, 3, 0x1F000, 1},
+ {4, 3, 0x1F010, 0},
+ {4, 3, 0x1F020, 2},
+ {4, 3, 0x1F030, 0},
+ {4, 3, 0x1F040, 2},
+ {4, 3, 0x1F050, 0},
+ {4, 3, 0x1F0F0, 0},
+ {4, 4, 0x1F000, 1},
+ {4, 4, 0x1F010, 0},
+ {4, 4, 0x1F020, 2},
+ {4, 4, 0x1F030, 0},
+ {4, 4, 0x1F040, 2},
+ {4, 4, 0x1F050, 0},
+ {4, 4, 0x1F0F0, 0},
+ {4, 5, 0x1F000, 1},
+ {4, 5, 0x1F010, 0},
+ {4, 5, 0x1F020, 2},
+ {4, 5, 0x1F030, 0},
+ {4, 5, 0x1F040, 2},
+ {4, 5, 0x1F050, 0},
+ {4, 5, 0x1F0F0, 0},
+ {5, 1, 0xC0000, 4},
+ {5, 1, 0xC0010, 0},
+ {5, 1, 0xC0020, 2},
+ {5, 1, 0xC0030, 0},
+ {5, 1, 0xC0040, 0},
+ {5, 1, 0xC0050, 0},
+ {5, 1, 0xC0060, 0},
+ {5, 2, 0x1F000, 1},
+ {5, 2, 0x1F010, 0},
+ {5, 2, 0x1F020, 2},
+ {5, 2, 0x1F030, 0},
+ {5, 2, 0x1F040, 2},
+ {5, 2, 0x1F050, 0},
+ {5, 2, 0x1F0F0, 0},
+ {5, 3, 0x1F000, 1},
+ {5, 3, 0x1F010, 0},
+ {5, 3, 0x1F020, 2},
+ {5, 3, 0x1F030, 0},
+ {5, 3, 0x1F040, 2},
+ {5, 3, 0x1F050, 0},
+ {5, 3, 0x1F0F0, 0},
+ {5, 4, 0x1F000, 1},
+ {5, 4, 0x1F010, 0},
+ {5, 4, 0x1F020, 2},
+ {5, 4, 0x1F030, 0},
+ {5, 4, 0x1F040, 2},
+ {5, 4, 0x1F050, 0},
+ {5, 4, 0x1F0F0, 0},
+ {5, 5, 0x1F000, 1},
+ {5, 5, 0x1F010, 0},
+ {5, 5, 0x1F020, 2},
+ {5, 5, 0x1F030, 0},
+ {5, 5, 0x1F040, 2},
+ {5, 5, 0x1F050, 0},
+ {5, 5, 0x1F0F0, 0},
+ {6, 1, 0xC0000, 2},
+ {6, 1, 0xC0010, 0},
+ {6, 1, 0xC0030, 0},
+ {6, 1, 0xC0040, 2},
+ {6, 1, 0xC0050, 0},
+ {6, 1, 0xC0060, 0},
+ {6, 1, 0xC0070, 2},
+ {6, 1, 0xC0080, 0},
+ {6, 1, 0xC0090, 0},
+ {6, 1, 0xC00A0, 0},
+ {6, 1, 0xC00B0, 0},
+ {6, 2, 0x1F000, 1},
+ {6, 2, 0x1F010, 0},
+ {6, 2, 0x1F020, 2},
+ {6, 2, 0x1F030, 0},
+ {6, 2, 0x1F040, 2},
+ {6, 2, 0x1F050, 0},
+ {6, 2, 0x1F0F0, 0},
+ {6, 3, 0x1F000, 1},
+ {6, 3, 0x1F010, 0},
+ {6, 3, 0x1F020, 2},
+ {6, 3, 0x1F030, 0},
+ {6, 3, 0x1F040, 2},
+ {6, 3, 0x1F050, 0},
+ {6, 3, 0x1F0F0, 0},
+ {6, 4, 0x1F000, 1},
+ {6, 4, 0x1F010, 0},
+ {6, 4, 0x1F020, 2},
+ {6, 4, 0x1F030, 0},
+ {6, 4, 0x1F040, 2},
+ {6, 4, 0x1F050, 0},
+ {6, 4, 0x1F0F0, 0},
+ {6, 5, 0x1F000, 1},
+ {6, 5, 0x1F010, 0},
+ {6, 5, 0x1F020, 2},
+ {6, 5, 0x1F030, 0},
+ {6, 5, 0x1F040, 2},
+ {6, 5, 0x1F050, 0},
+ {6, 5, 0x1F0F0, 0},
+ {7, 1, 0xC0000, 4},
+ {7, 1, 0xC0010, 0},
+ {7, 1, 0xC0020, 2},
+ {7, 1, 0xC0030, 0},
+ {7, 1, 0xC0040, 0},
+ {7, 1, 0xC0050, 0},
+ {7, 1, 0xC0060, 0},
+ {7, 2, 0x1F000, 1},
+ {7, 2, 0x1F010, 0},
+ {7, 2, 0x1F020, 2},
+ {7, 2, 0x1F030, 0},
+ {7, 2, 0x1F040, 2},
+ {7, 2, 0x1F050, 0},
+ {7, 2, 0x1F0F0, 0},
+ {7, 3, 0x1F000, 1},
+ {7, 3, 0x1F010, 0},
+ {7, 3, 0x1F020, 2},
+ {7, 3, 0x1F030, 0},
+ {7, 3, 0x1F040, 2},
+ {7, 3, 0x1F050, 0},
+ {7, 3, 0x1F0F0, 0},
+ {7, 4, 0x1F000, 1},
+ {7, 4, 0x1F010, 0},
+ {7, 4, 0x1F020, 2},
+ {7, 4, 0x1F030, 0},
+ {7, 4, 0x1F040, 2},
+ {7, 4, 0x1F050, 0},
+ {7, 4, 0x1F0F0, 0},
+ {7, 5, 0x1F000, 1},
+ {7, 5, 0x1F010, 0},
+ {7, 5, 0x1F020, 2},
+ {7, 5, 0x1F030, 0},
+ {7, 5, 0x1F040, 2},
+ {7, 5, 0x1F050, 0},
+ {7, 5, 0x1F0F0, 0},
+ },
+ // channels: (col, row, control offset, start queue offset, queue value, control value)
+ {
+ {0, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {0, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {0, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {0, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {0, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {0, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {0, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {0, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {0, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {0, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {0, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {0, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {1, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {1, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {1, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {1, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {1, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {1, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {1, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {1, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {1, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {1, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {1, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {1, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {2, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {2, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {2, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {2, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {2, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {2, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {2, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {2, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {2, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {2, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {2, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {2, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {3, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {3, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {3, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {3, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {3, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {3, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {3, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {3, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {3, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {3, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {3, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {3, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {4, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {4, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {4, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {4, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {4, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {4, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {4, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {4, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {4, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {4, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {4, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {4, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {5, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {5, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {5, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {5, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {5, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {5, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {5, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {5, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {5, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {5, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {5, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {5, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {6, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {6, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {6, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {6, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {6, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {6, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {6, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {6, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {6, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {6, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {6, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {6, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {7, 2, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {7, 2, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {7, 2, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {7, 3, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {7, 3, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {7, 3, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {7, 4, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {7, 4, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {7, 4, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {7, 5, 0x1DE00, 0x1DE04, 0x00000008, 1},
+ {7, 5, 0x1DE08, 0x1DE0C, 0x00000009, 1},
+ {7, 5, 0x1DE10, 0x1DE14, 0x0000000B, 1},
+ {0, 1, 0xA0600, 0xA0604, 0x0000000E, 1},
+ {0, 1, 0xA0608, 0xA060C, 0x00000024, 1},
+ {0, 1, 0xA0630, 0xA0634, 0x00000010, 1},
+ {0, 1, 0xA0638, 0xA063C, 0x00000026, 1},
+ {0, 1, 0xA0640, 0xA0644, 0x00000012, 1},
+ {0, 1, 0xA0648, 0xA064C, 0x00000028, 1},
+ {0, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {0, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {0, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {0, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {0, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {1, 1, 0xA0600, 0xA0604, 0x00000010, 1},
+ {1, 1, 0xA0608, 0xA060C, 0x00000028, 1},
+ {1, 1, 0xA0630, 0xA0634, 0x00000012, 1},
+ {1, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {1, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {1, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {1, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {1, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {2, 1, 0xA0600, 0xA0604, 0x0000000E, 1},
+ {2, 1, 0xA0608, 0xA060C, 0x00000024, 1},
+ {2, 1, 0xA0630, 0xA0634, 0x00000010, 1},
+ {2, 1, 0xA0638, 0xA063C, 0x00000026, 1},
+ {2, 1, 0xA0640, 0xA0644, 0x00000012, 1},
+ {2, 1, 0xA0648, 0xA064C, 0x00000028, 1},
+ {2, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {2, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {2, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {2, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {2, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {3, 1, 0xA0600, 0xA0604, 0x00000010, 1},
+ {3, 1, 0xA0608, 0xA060C, 0x00000028, 1},
+ {3, 1, 0xA0630, 0xA0634, 0x00000012, 1},
+ {3, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {3, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {3, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {3, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {3, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {4, 1, 0xA0600, 0xA0604, 0x0000000E, 1},
+ {4, 1, 0xA0608, 0xA060C, 0x00000024, 1},
+ {4, 1, 0xA0630, 0xA0634, 0x00000010, 1},
+ {4, 1, 0xA0638, 0xA063C, 0x00000026, 1},
+ {4, 1, 0xA0640, 0xA0644, 0x00000012, 1},
+ {4, 1, 0xA0648, 0xA064C, 0x00000028, 1},
+ {4, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {4, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {4, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {4, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {4, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {5, 1, 0xA0600, 0xA0604, 0x00000010, 1},
+ {5, 1, 0xA0608, 0xA060C, 0x00000028, 1},
+ {5, 1, 0xA0630, 0xA0634, 0x00000012, 1},
+ {5, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {5, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {5, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {5, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {5, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {6, 1, 0xA0600, 0xA0604, 0x0000000E, 1},
+ {6, 1, 0xA0608, 0xA060C, 0x00000024, 1},
+ {6, 1, 0xA0630, 0xA0634, 0x00000010, 1},
+ {6, 1, 0xA0638, 0xA063C, 0x00000026, 1},
+ {6, 1, 0xA0640, 0xA0644, 0x00000012, 1},
+ {6, 1, 0xA0648, 0xA064C, 0x00000028, 1},
+ {6, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {6, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {6, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {6, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {6, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ {7, 1, 0xA0600, 0xA0604, 0x00000010, 1},
+ {7, 1, 0xA0608, 0xA060C, 0x00000028, 1},
+ {7, 1, 0xA0630, 0xA0634, 0x00000012, 1},
+ {7, 1, 0xA0610, 0xA0614, 0x00000014, 1},
+ {7, 1, 0xA0618, 0xA061C, 0x0000002A, 1},
+ {7, 1, 0xA0620, 0xA0624, 0x00000016, 1},
+ {7, 1, 0xA0628, 0xA062C, 0x0000002C, 1},
+ {7, 1, 0xA0658, 0xA065C, 0x0000002E, 1},
+ },
+};
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill.cpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill.cpp
new file mode 100644
index 000000000..8ed4349ff
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill.cpp
@@ -0,0 +1,760 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_prefill.cpp
+/// \brief Batched prefill of MiniCPM5-15B-A2.5B, see minicpm5_moe_prefill.hpp
+#include
+#include
+#include
+#include "minicpm5_moe_prefill.hpp"
+
+using namespace minicpm5_moe_cpu;
+
+namespace {
+const bool time_host = std::getenv("MC5_TIME_HOST") != nullptr;
+// MINICPM5_MOE_ATTN_HOST / MINICPM5_MOE_MM_HOST = 1: that stage on the host instead (for comparisons)
+const bool attn_forced_host = std::getenv("MINICPM5_MOE_ATTN_HOST") != nullptr;
+const bool mm_forced_host = std::getenv("MINICPM5_MOE_MM_HOST") != nullptr;
+// MC5_MM_CHECK=1: every NPU dequant_mm also on the host, cosine printed
+const int mm_check = std::getenv("MC5_MM_CHECK") ? std::atoi(std::getenv("MC5_MM_CHECK")) : 0;
+// MINICPM5_MOE_HOST_GLU=1: the batched experts' GLU on the host (up|gate out of the
+// NPU) instead of fused into the up_gate run; MC5_BATCH_CHECK=1: every batched run
+// checked against the host, cosine printed
+const bool host_glu = std::getenv("MINICPM5_MOE_HOST_GLU") != nullptr;
+const bool batch_check = std::getenv("MC5_BATCH_CHECK") != nullptr;
+// Shortest prompt chunk whose routed experts go to the overlay (MINICPM5_MOE_MM_NPU_MIN).
+// 0 = always, which is the default: the prefill is meant to run on the NPU, and a
+// size-dependent fallback would also make the path depend on how a prompt was
+// chunked. Set it to e.g. 1024 to put short chunks' experts back on the host.
+const int mm_npu_min = std::getenv("MINICPM5_MOE_MM_NPU_MIN") ? std::atoi(std::getenv("MINICPM5_MOE_MM_NPU_MIN")) : 0;
+using host_clock = std::chrono::steady_clock;
+
+/// \brief adds the time since `t` to `acc` and moves `t` on
+void lap(double& acc, host_clock::time_point& t) {
+ const host_clock::time_point now = host_clock::now();
+ acc += std::chrono::duration(now - t).count();
+ t = now;
+}
+
+/// \brief bytes of one routed expert in the proj buffer: its up and gate (512 rows
+/// each, D columns) and its down (D rows, 512 columns)
+size_t expert_gate_up_bytes(const minicpm5_moe_desc& d) { return 2 * (size_t)(d.expert_width / 32) * (d.D / 256) * Q4K_BLOCK; }
+size_t expert_down_bytes(const minicpm5_moe_desc& d) { return (size_t)(d.D / 32) * (d.expert_width / 256) * Q4K_BLOCK; }
+
+/// the batched experts' buffer sets, as overlay batch_buffer() indices: x (and the
+/// down output) 3, the up_gate output (host GLU only) 2, the GLU output 2
+enum { X_SET = 0, F_SET = 3, H_SET = 5, SETS = 7 };
+} // namespace
+
+// =============================================================================
+// weight views
+// =============================================================================
+q4k_matrix minicpm5_moe_prefill_context::kvqg(int layer, const buffer& proj) const {
+ q4k_matrix m;
+ m.base = proj.data() + desc.layer_def(layer).attn_k.offset;
+ m.K = desc.D;
+ m.N = kvqg_stride(desc); // k, v, q, gate back to back, each reorder_cpy(.., 2) on its own
+ m.relaid = true;
+ return m;
+}
+
+q4k_matrix minicpm5_moe_prefill_context::o(int layer, const buffer& proj) const {
+ q4k_matrix m;
+ m.base = proj.data() + desc.layer_def(layer).attn_output.offset;
+ m.K = desc.DQ;
+ m.N = desc.D;
+ m.relaid = true;
+ return m;
+}
+
+q4k_matrix minicpm5_moe_prefill_context::up_gate(int layer, const buffer& proj) const {
+ q4k_matrix m;
+ m.base = proj.data() + desc.layer_def(layer).ffn_up_shexp.offset;
+ m.K = desc.D;
+ m.N = 2 * desc.expert_width; // [up 256 | gate 256] per round
+ m.relaid = true;
+ return m;
+}
+
+q4k_matrix minicpm5_moe_prefill_context::down(int layer, const buffer& proj) const {
+ q4k_matrix m;
+ m.base = proj.data() + desc.layer_def(layer).ffn_down_shexp.offset;
+ m.K = desc.expert_width;
+ m.N = desc.D;
+ m.relaid = true;
+ return m;
+}
+
+q4k_matrix minicpm5_moe_prefill_context::expert_up_gate(int layer, int expert, const buffer& proj) const {
+ const size_t expert_bytes = expert_gate_up_bytes(desc) + expert_down_bytes(desc);
+ q4k_matrix m;
+ m.base = proj.data() + desc.layer_def(layer).ffn_up_exps.offset + expert * expert_bytes;
+ m.K = desc.D;
+ m.N = 2 * desc.expert_width; // [up 64 | gate 64] per round
+ m.kind = q4k_matrix::expert_channels;
+ m.relaid = true;
+ m.channel_bytes = expert_bytes / 2;
+ m.part_offset = 0; // each stream starts with its gate/up blocks
+ return m;
+}
+
+q4k_matrix minicpm5_moe_prefill_context::expert_down(int layer, int expert, const buffer& proj) const {
+ q4k_matrix m = expert_up_gate(layer, expert, proj);
+ m.K = desc.expert_width;
+ m.N = desc.D;
+ m.part_offset = expert_gate_up_bytes(desc) / 2; // ... then its down blocks
+ return m;
+}
+
+// =============================================================================
+// forward
+// =============================================================================
+void minicpm5_moe_prefill_context::_reserve(int L) {
+ if (L <= capacity) return;
+ capacity = L;
+ const size_t D = desc.D;
+ const size_t W = desc.expert_width;
+ xn.resize((size_t)L * D);
+ kvq_out.resize((size_t)L * kvqg_stride(desc));
+ attn_out.resize((size_t)L * desc.DQ);
+ proj_out.resize((size_t)L * D);
+ fused.resize((size_t)L * 2 * W);
+ hid.resize((size_t)L * W);
+ logits.resize((size_t)L * desc.num_experts);
+ moe_sum.resize((size_t)L * D);
+}
+
+void minicpm5_moe_prefill_context::prewarm(int L) {
+ _reserve(L);
+ prefill_pool(); // its threads start here
+ if (!overlay || !MINICPM5_MOE_MM_ON_NPU || mm_forced_host) return;
+
+ // A MoE layer's batch rows (the dense layer has fewer): the shared expert's, then
+ // every routed expert's at an even share of the L * top_k routed tokens. A group
+ // closes on the job that reaches its share of them, the shared expert's at most.
+ using overlay_t = minicpm5_moe_prefill_overlay;
+ const int per_expert = (int)(((size_t)L * desc.top_k + desc.num_experts - 1) / desc.num_experts);
+ const size_t total = overlay_t::dq_rows(L) + (size_t)desc.num_experts * overlay_t::dq_rows(per_expert);
+ const int G = std::max(1, batch_groups);
+ const size_t rows = (total + G - 1) / G + overlay_t::dq_rows(L);
+ for (int g = 0; g < std::min(G, 3); g++) overlay->batch_buffer(X_SET + g, rows * desc.D);
+ for (int g = 0; g < std::min(G, 2); g++) {
+ if (host_glu) overlay->batch_buffer(F_SET + g, rows * 2 * desc.expert_width);
+ overlay->batch_buffer(H_SET + g, rows * desc.expert_width);
+ }
+ overlay->batch_slots(2 * G);
+}
+
+void minicpm5_moe_prefill_context::forward(bf16* x, int L, int pos0, std::vector& layers, uint32_t MAX_L) {
+ _reserve(L);
+ std::fill(std::begin(stage_us), std::end(stage_us), 0.0);
+ if (overlay) {
+ overlay->seq_us = overlay->elf_us = overlay->run_us = 0.0;
+ overlay->sync_us = overlay->copy_us = overlay->mm_us = overlay->attn_us = 0.0;
+ }
+ const host_clock::time_point t0 = host_clock::now();
+
+ // the attention run is the same for every layer of this chunk (each on its own cache)
+ attn_on_npu = MINICPM5_MOE_ATTN_ON_NPU && overlay && !attn_forced_host;
+ mm_on_npu = MINICPM5_MOE_MM_ON_NPU && overlay && !mm_forced_host;
+ // The routed experts run on the overlay like everything else (mm_npu_min 0).
+ // A run is a whole number of 256-token rounds and an expert only sees about
+ // L * top_k / num_experts = L / 10 of a chunk's tokens, so short chunks are
+ // mostly padding; the knob exists to measure that.
+ //
+ // If the knob is set, the test is the CHUNK, not the expert's own token count:
+ // routing is skewed, so a hot expert could clear a per-expert threshold in one
+ // prefill and miss it when the same prompt arrives in two halves, and the same
+ // tokens would then take different code paths.
+ experts_on_npu = mm_on_npu && L >= mm_npu_min;
+ if (attn_on_npu) overlay->prepare_attention(L, pos0, MAX_L);
+ rope.build(L, desc, pos0);
+
+ for (uint32_t layer = 0; layer < desc.num_hidden_layers; layer++) {
+ _attention_block(layer, x, L, pos0, layers[layer], MAX_L);
+ _moe(layer, x, L, layers[layer]);
+ }
+
+ if (time_host) {
+ static const char* names[S_COUNT] = {"rms norm", "dequant_mm k|v|q|gate, o", "rope + kv store + gate",
+ "attention", "dequant_mm shared expert", "router",
+ "dequant_mm routed experts", "glu + residual + gather", "kv cache sync",
+ "batched experts: gather", "batched experts: weighted sum"};
+ const double total = std::chrono::duration(host_clock::now() - t0).count();
+ std::cout << "[minicpm5_moe prefill] " << L << " tokens at " << pos0 << ": " << total / 1000.0 << " ms ("
+ << total / L / 1000.0 << " ms/token), attention on " << (attn_on_npu ? "NPU" : "host")
+ << ", dequant_mm on " << (mm_on_npu ? "NPU" : "host")
+ << ", routed experts on " << (experts_on_npu ? "NPU" : "host")
+ << " (chunk " << L << (L >= mm_npu_min ? " >= " : " < ") << mm_npu_min << ")" << std::endl;
+ for (int s = 0; s < S_COUNT; s++) {
+ std::cout << " " << names[s] << ": " << stage_us[s] / 1000.0 << " ms" << std::endl;
+ }
+ if (overlay) {
+ std::cout << " (of the routed experts: writing batched runs " << overlay->seq_us / 1000.0 << " ms, their ELF "
+ << overlay->elf_us / 1000.0 << " ms, the runs " << overlay->run_us / 1000.0 << " ms)" << std::endl;
+ std::cout << " (overlay: BO syncs " << overlay->sync_us / 1000.0 << " ms, copies " << overlay->copy_us / 1000.0
+ << " ms, dequant_mm runs " << overlay->mm_us / 1000.0 << " ms, attention runs "
+ << overlay->attn_us / 1000.0 << " ms)" << std::endl;
+ }
+ }
+}
+
+/// A routed expert's blocks alternate between two channel streams; the run walks
+/// them from the same start, so only the stride goes with it (channel_bytes).
+/// part_offset picks the expert's up|gate or down part inside each stream.
+size_t minicpm5_moe_prefill_context::_w_offset(const q4k_matrix& w, const minicpm5_moe_layer_buffers& buf) const {
+ const bool experts = w.kind == q4k_matrix::expert_channels;
+ return (size_t)(w.base - buf.proj->data()) + (experts ? w.part_offset : 0);
+}
+
+void minicpm5_moe_prefill_context::_mm(bf16* y, const q4k_matrix& w, const bf16* x, int L, minicpm5_moe_layer_buffers& buf) {
+ const bool experts = w.kind == q4k_matrix::expert_channels;
+ if (!mm_on_npu || (experts && !experts_on_npu) || !minicpm5_moe_prefill_overlay::fits(w.K, w.N)) {
+ dequant_mm(y, w, x, L);
+ return;
+ }
+ overlay->dequant_mm(y, x, L, *buf.proj, _w_offset(w, buf), w.K, w.N,
+ experts ? w.channel_bytes : 0);
+
+ // MC5_MM_CHECK=1: the same product on the host, reported per shape
+ if (mm_check) {
+ std::vector ref((size_t)L * w.N);
+ dequant_mm(ref.data(), w, x, L);
+ double dot = 0, na = 0, nb = 0;
+ for (size_t i = 0; i < ref.size(); i++) {
+ const double a = (double)y[i], b = (double)ref[i];
+ dot += a * b; na += a * a; nb += b * b;
+ }
+ const double cos = (na > 0 && nb > 0) ? dot / std::sqrt(na * nb) : 0.0;
+ // a biased rounding shows up as a non-zero mean difference; plain noise does not
+ double sum_d = 0, sum_abs = 0, sum_ref_abs = 0;
+ for (size_t i = 0; i < ref.size(); i++) {
+ const double d = (double)y[i] - (double)ref[i];
+ sum_d += d; sum_abs += std::fabs(d); sum_ref_abs += std::fabs((double)ref[i]);
+ }
+ const double n = (double)ref.size();
+ std::cout << "[minicpm5_moe mm] L " << L << ", " << w.K << " -> " << w.N << ", w_offset " << _w_offset(w, buf)
+ << ": cos " << cos << " mean_diff " << sum_d / n
+ << " mean_|diff| " << sum_abs / n << " mean_|ref| " << sum_ref_abs / n
+ << (cos > 0.99 ? " OK" : " BAD") << std::endl;
+ // MC5_MM_CHECK=2: run the NPU but carry the host's numbers forward, so a
+ // failure here means the run disturbs something else, not its own answer
+ if (mm_check > 1) memcpy(y, ref.data(), ref.size() * sizeof(bf16));
+ }
+}
+
+void minicpm5_moe_prefill_context::_attention_block(int layer, bf16* x, int L, int pos0, minicpm5_moe_layer_buffers& buf, uint32_t MAX_L) {
+ const minicpm5_moe_layer_def& W = desc.layer_def(layer);
+ const int D = desc.D;
+ host_clock::time_point t = host_clock::now();
+
+ const bf16* in_norm = reinterpret_cast((const u8*)buf.rms->data() + W.input_layer_norm.offset);
+ rms_norm(xn.data(), x, in_norm, L, D, desc.rms_norm_eps);
+ lap(stage_us[S_NORM], t);
+
+ _mm(kvq_out.data(), kvqg(layer, *buf.proj), xn.data(), L, buf);
+ lap(stage_us[S_MM_ATTN], t);
+
+ kv_cache_view kv;
+ kv.base = buf.kv_cache->data();
+ kv.MAX_L = MAX_L;
+ kv.DH = desc.DH;
+ kv.heads_per_col = desc.num_kv_heads / minicpm5_moe_desc::ATTN_COLS;
+ // rows before pos0 may have come from the NPU: see them before writing ours
+ if (pos0 > 0) buf.kv_cache->sync_from_device();
+ lap(stage_us[S_SYNC], t);
+ rope_store_kv(kvq_out.data(), L, desc, rope, kv, pos0);
+ // Nothing to clean up past our rows: the engine keeps everything at or past the
+ // context length zero (minicpm5_moe_npu::Impl::set_context_length), so the round the
+ // attention reads beyond this chunk is already zeros.
+ lap(stage_us[S_ROPE_KV], t);
+ buf.kv_cache->sync_to_device(); // the decode overlay reads them next
+ lap(stage_us[S_SYNC], t);
+
+ // q is the third part of each k|v|q|gate row
+ const int stride = kvqg_stride(desc);
+ if (attn_on_npu) {
+ overlay->attention(attn_out.data(), kvq_out.data() + desc.DK + desc.DV, stride, *buf.kv_cache);
+ } else {
+ attention(attn_out.data(), kvq_out.data() + desc.DK + desc.DV, stride, kv, L, pos0, desc.num_heads, desc.num_kv_heads);
+ }
+ lap(stage_us[S_ATTN], t);
+ attn_gate(attn_out.data(), kvq_out.data(), L, desc);
+ lap(stage_us[S_ROPE_KV], t);
+
+ _mm(proj_out.data(), o(layer, *buf.proj), attn_out.data(), L, buf);
+ lap(stage_us[S_MM_ATTN], t);
+ add_rows(x, proj_out.data(), (size_t)L * D);
+ lap(stage_us[S_GLU_ADD], t);
+}
+
+void minicpm5_moe_prefill_context::_moe(int layer, bf16* x, int L, minicpm5_moe_layer_buffers& buf) {
+ const minicpm5_moe_layer_def& Wd = desc.layer_def(layer);
+ const bool dense = desc.layer_kind(layer) == minicpm5_moe_layer_kind::dense;
+ const int D = desc.D, W = desc.expert_width;
+ host_clock::time_point t = host_clock::now();
+ const u8* rms = (const u8*)buf.rms->data();
+ rms_norm(xn.data(), x, reinterpret_cast(rms + Wd.post_attntion_norm.offset), L, D, desc.rms_norm_eps);
+ lap(stage_us[S_NORM], t);
+
+ std::vector tasks;
+ if (dense) {
+ // layer 0: its MLP is experts 0..15, every token, weight 1; no router and
+ // no shared expert (the decode router fixes the same experts)
+ for (uint32_t e = 0; e < Wd.experts; e++) {
+ expert_task task;
+ task.expert = (int)e;
+ task.tokens.resize(L);
+ std::iota(task.tokens.begin(), task.tokens.end(), 0);
+ task.weights.assign(L, 1.0f);
+ tasks.push_back(std::move(task));
+ }
+ std::fill(moe_sum.begin(), moe_sum.begin() + (size_t)L * D, 0.0f);
+ lap(stage_us[S_ROUTER], t);
+ } else {
+ // router on the host: fp32 logits, sigmoid, top 16 of score + bias
+ router_logits(logits.data(), xn.data(), reinterpret_cast(rms + Wd.ffn_gate_inp.offset),
+ L, D, desc.num_experts);
+ tasks = route(logits.data(), *buf.router_bias, L, desc.num_experts, desc.top_k, desc.router_scaling);
+ lap(stage_us[S_ROUTER], t);
+ }
+
+ if (experts_on_npu && !mm_check) {
+ _moe_batched(layer, L, tasks, dense, buf); // times its own stages
+ t = host_clock::now();
+ add_rows_f32(x, moe_sum.data(), (size_t)L * D);
+ lap(stage_us[S_GLU_ADD], t);
+ return;
+ }
+
+ if (!dense) {
+ // shared expert: every token, weight 1; starts the fp32 sum
+ _mm(fused.data(), up_gate(layer, *buf.proj), xn.data(), L, buf);
+ lap(stage_us[S_MM_MLP], t);
+ silu_glu(hid.data(), fused.data(), L, W, minicpm5_moe_desc::SHARED_ROWS_PER_ROUND);
+ lap(stage_us[S_GLU_ADD], t);
+ _mm(proj_out.data(), down(layer, *buf.proj), hid.data(), L, buf);
+ lap(stage_us[S_MM_MLP], t);
+ for (size_t i = 0; i < (size_t)L * D; i++) moe_sum[i] = (float)proj_out[i];
+ lap(stage_us[S_GLU_ADD], t);
+ }
+
+ // routed experts, one at a time (the host path, and MC5_MM_CHECK): each runs on
+ // its own tokens only, gathered into a dense block, then scattered back with its
+ // weight. _moe_batched is the same arithmetic with all experts in two NPU runs.
+ std::vector xe, fe, he, ye;
+ for (const expert_task& task : tasks) {
+ const int n = (int)task.tokens.size();
+ // layer 0 sends every token: its input block is xn itself
+ const bool all_tokens = n == L;
+ const bf16* xin = xn.data();
+ if (!all_tokens) {
+ xe.resize((size_t)n * D);
+ for (int i = 0; i < n; i++) {
+ memcpy(xe.data() + (size_t)i * D, xn.data() + (size_t)task.tokens[i] * D, D * sizeof(bf16));
+ }
+ xin = xe.data();
+ }
+ fe.resize((size_t)n * 2 * W);
+ he.resize((size_t)n * W);
+ ye.resize((size_t)n * D);
+ lap(stage_us[S_GLU_ADD], t);
+ _mm(fe.data(), expert_up_gate(layer, task.expert, *buf.proj), xin, n, buf);
+ lap(stage_us[S_MM_EXPERT], t);
+ silu_glu(he.data(), fe.data(), n, W, minicpm5_moe_desc::EXPERT_ROWS_PER_ROUND);
+ lap(stage_us[S_GLU_ADD], t);
+ _mm(ye.data(), expert_down(layer, task.expert, *buf.proj), he.data(), n, buf);
+ lap(stage_us[S_MM_EXPERT], t);
+ // a token appears once per expert, so rows never collide inside one task
+ prefill_pool().run(n, [&](int64_t i0, int64_t i1, int) {
+ for (int64_t i = i0; i < i1; i++) {
+ float* acc = moe_sum.data() + (size_t)task.tokens[i] * D;
+ const bf16* y = ye.data() + (size_t)i * D;
+ for (int d = 0; d < D; d++) acc[d] += task.weights[i] * (float)y[d];
+ }
+ });
+ lap(stage_us[S_GLU_ADD], t);
+ }
+ add_rows_f32(x, moe_sum.data(), (size_t)L * D);
+ lap(stage_us[S_GLU_ADD], t);
+}
+
+void minicpm5_moe_prefill_context::_moe_batched(int layer, int L, const std::vector& tasks, bool dense,
+ minicpm5_moe_layer_buffers& buf) {
+ using overlay_t = minicpm5_moe_prefill_overlay;
+ const int D = desc.D, W = desc.expert_width;
+ host_clock::time_point t = host_clock::now();
+
+ // One job per matrix: the shared expert first (MoE layers; every token), then the
+ // routed experts in task order. Each job owns overlay_t::dq_rows(n) rows of the batch
+ // buffers; its padding rows hold whatever was there (their outputs are never read).
+ struct job_t {
+ int task; // index into tasks, -1: the shared expert
+ int n; // its tokens
+ int row; // first row in the batch buffers
+ q4k_matrix ug, dn;
+ };
+ std::vector jobs;
+ if (!dense) jobs.push_back({-1, L, 0, up_gate(layer, *buf.proj), down(layer, *buf.proj)});
+ for (int k = 0; k < (int)tasks.size(); k++) {
+ jobs.push_back({k, (int)tasks[k].tokens.size(), 0, expert_up_gate(layer, tasks[k].expert, *buf.proj),
+ expert_down(layer, tasks[k].expert, *buf.proj)});
+ }
+ auto glu_piece = [](const job_t& job) {
+ return job.task < 0 ? minicpm5_moe_desc::SHARED_ROWS_PER_ROUND : minicpm5_moe_desc::EXPERT_ROWS_PER_ROUND;
+ };
+
+ // each token's routed rows, in task order: the order the per-expert path adds them in
+ std::vector first(L + 1, 0), at(L);
+ for (const expert_task& task : tasks)
+ for (int tok : task.tokens) first[tok + 1]++;
+ for (int l = 0; l < L; l++) first[l + 1] += first[l];
+ std::vector> entry(first[L]); // (job, row within the job)
+ std::copy(first.begin(), first.end() - 1, at.begin());
+ for (int j = 0; j < (int)jobs.size(); j++) {
+ if (jobs[j].task < 0) continue;
+ const expert_task& task = tasks[jobs[j].task];
+ for (int i = 0; i < (int)task.tokens.size(); i++) entry[at[task.tokens[i]]++] = {j, i};
+ }
+ std::copy(first.begin(), first.end() - 1, at.begin()); // now each token's next entry
+ lap(stage_us[S_GATHER], t);
+
+ // Jobs go in about batch_groups groups of equal rows, consecutive in task order
+ // (so every token still adds its experts in the same order), pipelined: while
+ // the NPU runs one group's projection, the host works on another group.
+ // NPU: U0 U1 D0 U2 D1 .. U(G-1) D(G-2) D(G-1) (U: up_gate + GLU, D: down)
+ // host: during D(g) scatter(g-1), then gather(g+2)
+ // U writes the GLU's output itself (y = silu(gate) * up). MINICPM5_MOE_HOST_GLU=1:
+ // U writes up|gate and the host does the GLU during U(g+1), as the per-expert path.
+ // x (and the down output) has 3 buffer sets (g % 3), the up_gate and GLU
+ // outputs 2 (g % 2): no run touches a buffer the host is using.
+ struct group_t {
+ int j0, j1, rows;
+ std::vector> rows_of; // (job, row within the job) per real row
+ std::vector ug, dn;
+ };
+ std::vector groups;
+ {
+ int total = 0;
+ for (const job_t& job : jobs) total += overlay_t::dq_rows(job.n);
+ const int target = (total + batch_groups - 1) / std::max(1, batch_groups);
+ for (int j0 = 0; j0 < (int)jobs.size();) {
+ group_t g{j0, j0, 0, {}, {}, {}};
+ while (g.j1 < (int)jobs.size() && (g.j1 == j0 || g.rows < target)) {
+ const int j = g.j1++;
+ job_t& job = jobs[j];
+ const bool experts = job.task >= 0;
+ job.row = g.rows;
+ g.ug.push_back({g.rows, job.n, _w_offset(job.ug, buf), experts ? job.ug.channel_bytes : 0,
+ host_glu ? 0 : glu_piece(job)});
+ g.dn.push_back({g.rows, job.n, _w_offset(job.dn, buf), experts ? job.dn.channel_bytes : 0});
+ for (int i = 0; i < job.n; i++) g.rows_of.push_back({j, i});
+ g.rows += overlay_t::dq_rows(job.n);
+ }
+ j0 = g.j1;
+ groups.push_back(std::move(g));
+ }
+ }
+ const int G = (int)groups.size();
+
+ // buffers: grown here, before any run uses them
+ std::vector*> xs(G), fs(G, nullptr), hs(G);
+ {
+ size_t need[SETS] = {};
+ for (int g = 0; g < G; g++) {
+ const size_t rows = groups[g].rows;
+ need[X_SET + g % 3] = std::max(need[X_SET + g % 3], rows * D);
+ if (host_glu) need[F_SET + g % 2] = std::max(need[F_SET + g % 2], rows * 2 * W);
+ need[H_SET + g % 2] = std::max(need[H_SET + g % 2], rows * W);
+ }
+ for (int i = 0; i < SETS; i++)
+ if (need[i]) overlay->batch_buffer(i, need[i]);
+ for (int g = 0; g < G; g++) {
+ xs[g] = &overlay->batch_buffer(X_SET + g % 3, 0);
+ if (host_glu) fs[g] = &overlay->batch_buffer(F_SET + g % 2, 0);
+ hs[g] = &overlay->batch_buffer(H_SET + g % 2, 0);
+ }
+ }
+
+ // every run (U(g): slot 2g, D(g): 2g + 1) is written on one thread, in NPU order,
+ // from the start; each run waits for its own
+ overlay->batch_slots(2 * G);
+ std::vector order{0};
+ for (int g = 0; g < G; g++) {
+ if (g + 1 < G) order.push_back(2 * (g + 1));
+ order.push_back(2 * g + 1);
+ }
+ std::vector> prepared(2 * G);
+ std::vector> ready;
+ for (std::promise& p : prepared) ready.push_back(p.get_future().share());
+ const int first_op = overlay->current_op();
+ std::future writer = std::async(std::launch::async, [&] {
+ for (size_t k = 0; k < order.size(); k++) {
+ const int id = order[k];
+ try {
+ const group_t& gr = groups[id / 2];
+ if (id % 2 == 0) {
+ overlay->prepare_batch(id, gr.ug, D, 2 * W, id == 0 ? first_op : overlay_t::after(overlay_t::OP_DQ),
+ !host_glu);
+ } else {
+ overlay->prepare_batch(id, gr.dn, W, D, overlay_t::after(overlay_t::OP_DQ));
+ }
+ prepared[id].set_value();
+ } catch (...) {
+ for (; k < order.size(); k++) prepared[order[k]].set_exception(std::current_exception());
+ return;
+ }
+ }
+ });
+
+ // Syncs: x is flushed by gather and the down output invalidated by scatter, on
+ // this thread while the NPU runs another projection; the hidden rows are the
+ // NPU's alone (fused GLU), so they are never synced (host GLU: by the runs).
+ std::future npu; // the run in flight
+ auto launch = [&](int id, buffer* y, buffer* x, unsigned sync) {
+ npu = std::async(std::launch::async, [&, id, y, x, sync] {
+ ready[id].get();
+ overlay->run_batch(id, *y, *x, *buf.proj, sync);
+ });
+ };
+ const unsigned up_sync = host_glu ? overlay_t::SYNC_Y : overlay_t::SYNC_NONE;
+ const unsigned down_sync = host_glu ? overlay_t::SYNC_X : overlay_t::SYNC_NONE;
+ auto wait_npu = [&] {
+ npu.get();
+ lap(stage_us[S_MM_EXPERT], t);
+ };
+
+ // gather: each real row is its token's normed input. Streaming stores: the host
+ // never reads these rows back, and the flush then finds no dirty line
+ assert((D * sizeof(bf16)) % 64 == 0);
+ auto gather = [&](int g) {
+ const group_t& gr = groups[g];
+ bf16* xd = xs[g]->data();
+ assert(reinterpret_cast(xd) % 64 == 0);
+ prefill_pool().run((int64_t)gr.rows_of.size(), [&](int64_t r0, int64_t r1, int) {
+ for (int64_t r = r0; r < r1; r++) {
+ const job_t& job = jobs[gr.rows_of[r].first];
+ const int i = gr.rows_of[r].second;
+ const int tok = job.task < 0 ? i : tasks[job.task].tokens[i];
+ const __m512i* src = reinterpret_cast(xn.data() + (size_t)tok * D);
+ __m512i* dst = reinterpret_cast<__m512i*>(xd + (size_t)(job.row + i) * D);
+ for (size_t k = 0; k < D * sizeof(bf16) / 64; k++) _mm512_stream_si512(dst + k, _mm512_loadu_si512(src + k));
+ }
+ _mm_sfence();
+ });
+ xs[g]->sync_to_device((size_t)gr.rows * D);
+ lap(stage_us[S_GATHER], t);
+ };
+ // host GLU per row (MINICPM5_MOE_HOST_GLU); the shared expert's up|gate slabs are
+ // wider than a routed one's
+ auto glu = [&](int g) {
+ if (!host_glu) return;
+ const group_t& gr = groups[g];
+ const bf16* fd = fs[g]->data();
+ bf16* hd = hs[g]->data();
+ prefill_pool().run((int64_t)gr.rows_of.size(), [&](int64_t r0, int64_t r1, int) {
+ for (int64_t r = r0; r < r1; r++) {
+ const job_t& job = jobs[gr.rows_of[r].first];
+ const size_t row = (size_t)job.row + gr.rows_of[r].second;
+ silu_glu_row(hd + row * W, fd + row * 2 * W, W, glu_piece(job));
+ }
+ });
+ lap(stage_us[S_GLU_ADD], t);
+ };
+ // scatter: the shared expert (if in this group) starts each token's fp32 sum,
+ // then the token's routed rows of this group, weighted, in task order
+ auto scatter = [&](int g) {
+ const group_t& gr = groups[g];
+ xs[g]->sync_from_device((size_t)gr.rows * D);
+ const bf16* yd = xs[g]->data();
+ const bool shared_here = jobs[gr.j0].task < 0;
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int64_t l = l0; l < l1; l++) {
+ float* acc = moe_sum.data() + (size_t)l * D;
+ if (shared_here) {
+ const bf16* y = yd + (size_t)(jobs[gr.j0].row + l) * D;
+ for (int d = 0; d < D; d += 16) _mm512_storeu_ps(acc + d, load_bfloat16_to_m512(y + d));
+ }
+ for (; at[l] < first[l + 1] && entry[at[l]].first < gr.j1; at[l]++) {
+ const job_t& job = jobs[entry[at[l]].first];
+ const int i = entry[at[l]].second;
+ const __m512 w = _mm512_set1_ps(tasks[job.task].weights[i]);
+ const bf16* y = yd + (size_t)(job.row + i) * D;
+ for (int d = 0; d < D; d += 16)
+ _mm512_storeu_ps(acc + d, _mm512_fmadd_ps(w, load_bfloat16_to_m512(y + d), _mm512_loadu_ps(acc + d)));
+ }
+ }
+ });
+ lap(stage_us[S_SCATTER], t);
+ };
+ // MC5_BATCH_CHECK=1: a finished run against the host (dequant_mm, silu_glu) on
+ // the same inputs, cosine per group; U(g) while xs[g] is still its input, D(g)
+ // while hs[g] still is
+ auto check = [&](int g, bool up) {
+ if (!batch_check) return;
+ const group_t& gr = groups[g];
+ for (buffer* b : {xs[g], fs[g], hs[g]}) // the runs leave some unsynced
+ if (b) b->sync_from_device();
+ double dot = 0, na = 0, nb = 0;
+ std::vector ref, f;
+ for (int j = gr.j0; j < gr.j1; j++) {
+ const job_t& job = jobs[j];
+ const size_t n = job.n;
+ const bf16* got;
+ size_t cols;
+ if (up) {
+ f.resize(n * 2 * W);
+ dequant_mm(f.data(), job.ug, xs[g]->data() + (size_t)job.row * D, job.n);
+ if (host_glu) {
+ ref = f;
+ cols = 2 * W;
+ got = fs[g]->data() + (size_t)job.row * cols;
+ } else {
+ ref.resize(n * W);
+ silu_glu(ref.data(), f.data(), job.n, W, glu_piece(job));
+ cols = W;
+ got = hs[g]->data() + (size_t)job.row * cols;
+ }
+ } else {
+ ref.resize(n * D);
+ dequant_mm(ref.data(), job.dn, hs[g]->data() + (size_t)job.row * W, job.n);
+ cols = D;
+ got = xs[g]->data() + (size_t)job.row * cols;
+ }
+ for (size_t i = 0; i < n * cols; i++) {
+ const double a = (double)got[i], b = (double)ref[i];
+ dot += a * b; na += a * a; nb += b * b;
+ }
+ }
+ const double cos = (na > 0 && nb > 0) ? dot / std::sqrt(na * nb) : 0.0;
+ std::cout << "[minicpm5_moe batch] layer " << layer << " group " << g << (up ? " up_gate" : " down")
+ << (up && !host_glu ? "+glu" : "") << ", " << gr.j1 - gr.j0 << " matrices, " << gr.rows
+ << " rows: cos " << cos << (cos > 0.99 ? " OK" : " BAD") << std::endl;
+ t = host_clock::now();
+ };
+
+ // U(g) writes the hidden rows (fused GLU) or the up|gate rows (host GLU)
+ auto up_out = [&](int g) { return host_glu ? fs[g] : hs[g]; };
+ gather(0);
+ launch(0, up_out(0), xs[0], up_sync);
+ if (G > 1) gather(1);
+ wait_npu();
+ check(0, true);
+ for (int g = 0; g < G; g++) {
+ if (g + 1 < G) launch(2 * (g + 1), up_out(g + 1), xs[g + 1], up_sync);
+ glu(g);
+ if (g + 1 < G) {
+ wait_npu();
+ check(g + 1, true);
+ }
+ launch(2 * g + 1, xs[g], hs[g], down_sync); // down into the x buffer, which up_gate is done with
+ if (g >= 1) scatter(g - 1);
+ if (g + 2 < G) gather(g + 2);
+ wait_npu();
+ check(g, false);
+ }
+ scatter(G - 1);
+ writer.get();
+}
+
+// =============================================================================
+// layout self-check (MC5_CHECK_LAYOUT=1)
+// =============================================================================
+namespace {
+/// \brief compares every block of `view` with the q4nx blocks it came from
+/// \param map logical row block -> (source tensor [row block][column block], its row block)
+template
+size_t compare_view(const q4k_matrix& view, Map map) {
+ size_t bad = 0;
+ alignas(64) u8 plain[Q4K_BLOCK];
+ for (int rb = 0; rb < view.row_blocks(); rb++) {
+ const auto [src, src_rb] = map(rb);
+ for (int cb = 0; cb < view.blocks_per_row(); cb++) {
+ const u8* got = view.block(rb, cb);
+ if (view.relaid) {
+ q4k_unrelayout(plain, got);
+ got = plain;
+ }
+ const u8* want = src->data() + ((size_t)src_rb * view.blocks_per_row() + cb) * Q4K_BLOCK;
+ bad += memcmp(got, want, Q4K_BLOCK) != 0;
+ }
+ }
+ return bad;
+}
+
+/// \brief row block rb of an [up slab | gate slab]-interleaved matrix -> (up or gate, row block)
+std::pair*, int> interleaved(int rb, int slab_rows, const buffer* up, const buffer* gate, int first_rb) {
+ const int per = slab_rows / Q4K_ROWS; // row blocks per slab
+ const int piece = rb / (2 * per), within = rb % (2 * per);
+ return within < per ? std::make_pair(up, first_rb + piece * per + within)
+ : std::make_pair(gate, first_rb + piece * per + within - per);
+}
+} // namespace
+
+size_t minicpm5_moe_prefill_context::check_layout(int layer, Q4NX& q4nx, const buffer& proj) const {
+ const bool dense = desc.layer_kind(layer) == minicpm5_moe_layer_kind::dense;
+ const minicpm5_moe_layer_def& W = desc.layer_def(layer);
+ const std::string prefix = "model.layer." + std::to_string(layer) + ".";
+ auto load = [&](const std::string& name) {
+ buffer b;
+ q4nx.load_weights(b, name);
+ return b;
+ };
+ auto load_w = [&](const weight_desc_t& w) { return load(const_cast(w).format_name(layer)); };
+ size_t bad = 0;
+
+ // k | v | q | gate; k and v hold each model KV head twice
+ buffer k = load_w(W.attn_k), v = load_w(W.attn_v), q = load_w(W.attn_q), g = load_w(W.attn_gate);
+ const int head_rbs = desc.DH / Q4K_ROWS;
+ const int dup = desc.num_kv_heads / desc.model_kv_heads;
+ const int k_rbs = desc.DK / Q4K_ROWS, v_rbs = desc.DV / Q4K_ROWS, q_rbs = desc.DQ / Q4K_ROWS;
+ auto kv_rb = [&](int rb) { return (rb / head_rbs) / dup * head_rbs + rb % head_rbs; };
+ bad += compare_view(kvqg(layer, proj), [&](int rb) {
+ if (rb < k_rbs) return std::make_pair(&k, kv_rb(rb));
+ if (rb < k_rbs + v_rbs) return std::make_pair(&v, kv_rb(rb - k_rbs));
+ if (rb < k_rbs + v_rbs + q_rbs) return std::make_pair(&q, rb - k_rbs - v_rbs);
+ return std::make_pair(&g, rb - k_rbs - v_rbs - q_rbs);
+ });
+ buffer wo = load_w(W.attn_output);
+ bad += compare_view(o(layer, proj), [&](int rb) { return std::make_pair(&wo, rb); });
+
+ // shared expert (layer 0 has none)
+ if (!dense) {
+ buffer up = load_w(W.ffn_up_shexp), gate = load_w(W.ffn_gate_shexp), dn = load_w(W.ffn_down_shexp);
+ bad += compare_view(up_gate(layer, proj), [&](int rb) {
+ return interleaved(rb, minicpm5_moe_desc::SHARED_ROWS_PER_ROUND, &up, &gate, 0);
+ });
+ bad += compare_view(down(layer, proj), [&](int rb) { return std::make_pair(&dn, rb); });
+ }
+
+ // routed experts: stacked in the q4nx tensors, expert e = row blocks e * (rows / 32) ..
+ // Layer 0's MLP is cut the same way: up / gate rows e * 512 .. are expert e, and its
+ // down [D][8192] is re-cut here into per-expert [D][512] matrices, stacked.
+ buffer eu, eg, ed;
+ if (dense) {
+ eu = load(prefix + "mlp.up_proj.weight");
+ eg = load(prefix + "mlp.gate_proj.weight");
+ buffer dd = load(prefix + "mlp.down_proj.weight");
+ const size_t piece = (size_t)desc.expert_width / Q4K_COLS * Q4K_BLOCK;
+ ed = buffer(dd.size());
+ u8* dst = ed.data();
+ for (uint32_t e = 0; e < W.experts; e++) {
+ for (uint32_t rb = 0; rb < desc.D / Q4K_ROWS; rb++) {
+ memcpy(dst, dd.data() + ((size_t)rb * W.experts + e) * piece, piece);
+ dst += piece;
+ }
+ }
+ } else {
+ eu = load_w(W.ffn_up_exps);
+ eg = load_w(W.ffn_gate_exps);
+ ed = load_w(W.ffn_down_exps);
+ }
+ const int ug_rbs = desc.expert_width / Q4K_ROWS, d_rbs = desc.D / Q4K_ROWS;
+ for (int e = 0; e < (int)W.experts; e++) {
+ bad += compare_view(expert_up_gate(layer, e, proj), [&](int rb) {
+ return interleaved(rb, minicpm5_moe_desc::EXPERT_ROWS_PER_ROUND, &eu, &eg, e * ug_rbs);
+ });
+ bad += compare_view(expert_down(layer, e, proj), [&](int rb) { return std::make_pair(&ed, e * d_rbs + rb); });
+ }
+ return bad;
+}
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill.hpp
new file mode 100644
index 000000000..65b44072b
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill.hpp
@@ -0,0 +1,133 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_prefill.hpp
+/// \brief Batched prefill of MiniCPM5-15B-A2.5B: a chunk of prompt tokens through all
+/// 28 layers at once, writing the decode KV cache as it goes
+/// \note Per layer:
+/// x -> rms_norm -> dequant_mm(k|v|q|gate) -> rope -> store_kv
+/// -> attention -> * sigmoid(gate) -> dequant_mm(o) -> +x
+/// -> rms_norm -> layer 0: experts 0..15 on every token, weight 1 (its
+/// 8192-wide MLP, stored as 16 experts of 512)
+/// MoE: router_logits -> route
+/// shared expert (512 wide), every token
+/// per used expert: its tokens only, same three steps,
+/// times the routing weight, summed in fp32 -> +x
+/// The heavy steps are dequant_mm and attention (minicpm5_moe_prefill_ops.hpp); the
+/// switches below say where each runs. The NPU versions run on the prefill
+/// overlay (minicpm5_moe_prefill_overlay.hpp), reading the same decode weight
+/// buffers and KV cache.
+///
+/// The other prefill, PREFILL_WITH_MV (Makefile PREFILL_WITH_MV=1), feeds the
+/// prompt through the decode overlays one token at a time instead.
+#pragma once
+#include
+#include
+#include
+#include
+#include
+#include "minicpm5_moe_model_def.hpp"
+#include "minicpm5_moe_prefill_ops.hpp"
+#include "minicpm5_moe_cpu_functions.hpp"
+#include "minicpm5_moe_prefill_overlay.hpp"
+
+// Where the two heavy prefill stages run (1 = the prefill overlay, 0 = the host).
+// A chunk is zero-padded to a whole number of rounds: 128 rows for the attention,
+// 256 for dequant_mm. At run time MINICPM5_MOE_ATTN_HOST=1 / MINICPM5_MOE_MM_HOST=1 put either
+// back on the host (for comparisons), and MINICPM5_MOE_MM_NPU_MIN (1024) is the shortest
+// chunk whose routed experts are worth the overlay rather than the host.
+#ifndef MINICPM5_MOE_MM_ON_NPU
+#define MINICPM5_MOE_MM_ON_NPU 1
+#endif
+#ifndef MINICPM5_MOE_ATTN_ON_NPU
+#define MINICPM5_MOE_ATTN_ON_NPU 1
+#endif
+
+/// \brief the decode buffers of one layer, which the prefill reads (weights) and
+/// writes (KV cache) in place
+struct minicpm5_moe_layer_buffers {
+ buffer* proj;
+ buffer* rms;
+ buffer* rope_rms;
+ buffer* kv_cache;
+ const std::vector* router_bias; // MoE layers only
+};
+
+class minicpm5_moe_prefill_context {
+public:
+ explicit minicpm5_moe_prefill_context(minicpm5_moe_desc& desc) : desc(desc) {}
+
+ /// \brief the prefill overlay the NPU stages run on (nullptr: all on the host)
+ void set_overlay(minicpm5_moe_prefill_overlay* ovl) { overlay = ovl; }
+
+ /// \brief L tokens at positions pos0 .. pos0 + L - 1 through every layer
+ /// \param x in: the embeddings [L][D]; out: the last layer's output [L][D]
+ /// \param layers the decode buffers, one entry per layer
+ /// \param MAX_L the KV cache length the caches were allocated with
+ void forward(bf16* x, int L, int pos0, std::vector& layers, uint32_t MAX_L);
+
+ /// \brief at load: what the first forward() of up to L tokens would otherwise
+ /// set up itself (scratch, the host pool's threads, the batch runs and
+ /// buffers), ~0.2 s of a cold 2K prefill. The batch buffers are sized for an
+ /// even routing; a skewed one grows them on the way, as without this.
+ void prewarm(int L);
+
+ // ---- where each weight is in a layer's proj buffer (see minicpm5_moe_model_def.cpp) ----
+ // (every block is in the int8-mmul order; both layer kinds share the offsets
+ // up to the routed region's size, so the views take the layer)
+ minicpm5_moe_cpu::q4k_matrix kvqg(int layer, const buffer& proj) const; // k | v | q | gate
+ minicpm5_moe_cpu::q4k_matrix o(int layer, const buffer& proj) const;
+ minicpm5_moe_cpu::q4k_matrix up_gate(int layer, const buffer& proj) const; // shared expert
+ minicpm5_moe_cpu::q4k_matrix down(int layer, const buffer& proj) const; // shared expert
+ minicpm5_moe_cpu::q4k_matrix expert_up_gate(int layer, int expert, const buffer& proj) const;
+ minicpm5_moe_cpu::q4k_matrix expert_down(int layer, int expert, const buffer& proj) const;
+
+ /// \brief MC5_CHECK_LAYOUT=1: every block the views above point at, compared byte
+ /// for byte (relayout undone) with the tensors in model.q4nx
+ /// \return the number of blocks that differ (0 = the views are right)
+ size_t check_layout(int layer, Q4NX& q4nx, const buffer& proj) const;
+
+private:
+ minicpm5_moe_desc& desc;
+ minicpm5_moe_prefill_overlay* overlay = nullptr;
+ bool attn_on_npu = false; // this forward()'s attention runs on the overlay
+ bool mm_on_npu = false; // ... and so do its dequant_mm calls
+ bool experts_on_npu = false;// ... including the routed experts (long chunks only)
+
+ /// \brief y[L][w.N] = x[L][w.K] W^T, on the overlay when it can take it
+ /// \note The overlay reads the weights straight from `buf.proj` at the view's
+ /// byte offset: the decode and prefill kernels take the same block order.
+ void _mm(bf16* y, const minicpm5_moe_cpu::q4k_matrix& w, const bf16* x, int L, minicpm5_moe_layer_buffers& buf);
+
+ /// \brief where a weight view starts in the layer's projection buffer
+ size_t _w_offset(const minicpm5_moe_cpu::q4k_matrix& w, const minicpm5_moe_layer_buffers& buf) const;
+
+
+ // scratch, grown to the largest chunk seen
+ int capacity = 0;
+ std::vector xn, kvq_out, attn_out, proj_out, fused, hid;
+ std::vector logits, moe_sum;
+ minicpm5_moe_cpu::rope_table rope; // this chunk's positions, every layer
+ void _reserve(int L);
+
+ void _attention_block(int layer, bf16* x, int L, int pos0, minicpm5_moe_layer_buffers& buf, uint32_t MAX_L);
+ /// \brief the MLP of either layer kind (layer 0: fixed experts, no router or shared expert)
+ void _moe(int layer, bf16* x, int L, minicpm5_moe_layer_buffers& buf);
+ /// \brief moe_sum += the shared expert (MoE layers; it starts the sum) and every
+ /// routed expert, all of a group of experts in one overlay run per
+ /// projection (the GLU fused into the up_gate run). With
+ /// MINICPM5_MOE_HOST_GLU=1 bit for bit the per-expert path's result
+ /// \note moe_sum must be zero for a dense layer (it has no shared expert)
+ void _moe_batched(int layer, int L, const std::vector& tasks, bool dense,
+ minicpm5_moe_layer_buffers& buf);
+ /// \brief groups a layer's experts are split into, pipelined against each other
+ /// (MC5_BATCH_GROUPS). 2K warm: 2 groups 1.50 s, 3: 1.50, 4: 1.49 (more
+ /// groups hide more of the gather / scatter but add dispatches, and short
+ /// chunks get small groups)
+ int batch_groups = std::max(1, std::getenv("MC5_BATCH_GROUPS") ? std::atoi(std::getenv("MC5_BATCH_GROUPS")) : 2);
+
+ // MC5_TIME_HOST=1: time per stage, summed over a forward() and printed at its end
+ enum stage_t { S_NORM, S_MM_ATTN, S_ROPE_KV, S_ATTN, S_MM_MLP, S_ROUTER, S_MM_EXPERT, S_GLU_ADD, S_SYNC,
+ S_GATHER, S_SCATTER, S_COUNT };
+ double stage_us[S_COUNT] = {};
+};
diff --git a/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill_ops.hpp b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill_ops.hpp
new file mode 100644
index 000000000..4d388c863
--- /dev/null
+++ b/flm-dev-kit/FLM_DLL/detail/minicpm5_moe_npu/minicpm5_moe_prefill_ops.hpp
@@ -0,0 +1,399 @@
+// Copyright Β© Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
+// Portions of this file consist of AI-generated content.
+
+/// \file minicpm5_moe_prefill_ops.hpp
+/// \brief The two heavy prefill operations, on the host: dequant_mm and attention
+/// \note These are the stages a prefill overlay will take over later, so their
+/// signatures are what such an overlay would take: whole tensors in, whole
+/// tensors out, bf16 activations, the weights read in place from the decode
+/// buffers (no second copy), the K/V read in place from the decode KV cache.
+/// minicpm5_moe_prefill.cpp calls them through MINICPM5_MOE_MM_ON_NPU / MINICPM5_MOE_ATTN_ON_NPU,
+/// which are 0 for now.
+///
+/// The small per-row steps (norms, RoPE, GLU, router, residual) are in
+/// minicpm5_moe_cpu_functions.hpp.
+#pragma once
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#ifdef _OPENMP
+#include
+#endif
+#include "typedef.hpp"
+#include "utils/avx512_util.hpp"
+#include "minicpm5_moe_model_def.hpp"
+
+namespace minicpm5_moe_cpu {
+
+/// \brief threads for the host prefill: the whole machine (these kernels are the
+/// whole cost of a CPU prefill). Override with FLM_PREFILL_THREADS.
+inline int prefill_threads() {
+ static const int nt = [] {
+#ifdef _OPENMP
+ int n = omp_get_max_threads();
+#else
+ int n = 1;
+#endif
+ if (const char* env = std::getenv("FLM_PREFILL_THREADS")) {
+ const int v = std::atoi(env);
+ if (v > 0) n = v;
+ }
+ return n < 1 ? 1 : n;
+ }();
+ return nt;
+}
+
+/// \brief threads for the host steps between NPU runs, which sleep when idle
+/// \note Not OpenMP: libgomp's default team keeps spinning for a while after each
+/// region, and here every region is followed by an NPU run: 31 spinning cores
+/// then starve the threads that feed the NPU (the batch writer, the run
+/// thread, the driver) and spend the power budget, so the host steps around
+/// the runs slow down too (pf2048 1747 ms with OMP_WAIT_POLICY=passive, 2137
+/// with the default). The policy is read at process start, before this
+/// library loads, so it cannot be set from here; this pool sleeps instead.
+class host_pool {
+public:
+ explicit host_pool(int threads) : T(std::max(1, threads)) {
+ for (int t = 1; t < T; t++) workers.emplace_back([this, t] { _work(t); });
+ }
+ ~host_pool() {
+ stop.store(true);
+ gen.fetch_add(1, std::memory_order_release);
+ gen.notify_all();
+ for (std::thread& w : workers) w.join();
+ }
+ host_pool(const host_pool&) = delete;
+ host_pool& operator=(const host_pool&) = delete;
+ int threads() const { return T; }
+
+ /// \brief f(begin, end, part) over [0, n) in threads() contiguous parts (part 0
+ /// on the caller), like an OpenMP static schedule; returns when all are done
+ /// \note One job at a time: callers on other threads wait; f must not call run().
+ template
+ void run(int64_t n, F&& f) {
+ using Fn = std::remove_reference_t;
+ if (n <= 0) return;
+ if (T == 1 || n == 1) {
+ f((int64_t)0, n, 0);
+ return;
+ }
+ std::lock_guard lock(busy);
+ job_fn = [](void* ctx, int64_t b, int64_t e, int p) { (*static_cast(ctx))(b, e, p); };
+ job_ctx = (void*)std::addressof(f);
+ job_n = n;
+ pending.store(T - 1, std::memory_order_relaxed);
+ gen.fetch_add(1, std::memory_order_release);
+ gen.notify_all();
+ _part(0);
+ for (int left; (left = pending.load(std::memory_order_acquire)) != 0;) pending.wait(left, std::memory_order_acquire);
+ }
+
+private:
+ void _part(int p) const {
+ const int64_t b = job_n * p / T, e = job_n * (p + 1) / T;
+ if (b < e) job_fn(job_ctx, b, e, p);
+ }
+ void _work(int t) {
+ uint32_t seen = 0;
+ for (;;) {
+ gen.wait(seen, std::memory_order_acquire);
+ seen = gen.load(std::memory_order_acquire);
+ if (stop.load()) return;
+ _part(t);
+ if (pending.fetch_sub(1, std::memory_order_acq_rel) == 1) pending.notify_one();
+ }
+ }
+
+ const int T;
+ std::vector workers;
+ std::atomic gen{0};
+ std::atomic pending{0};
+ std::atomic stop{false};
+ std::mutex busy;
+ // the job of generation gen; every worker takes part, so none is read while written
+ void (*job_fn)(void*, int64_t, int64_t, int) = nullptr;
+ void* job_ctx = nullptr;
+ int64_t job_n = 0;
+};
+
+/// \brief the prefill's pool, prefill_threads() wide, made on first use
+/// \note One prefill runs at a time (the engine's lock), so one pool serves them all.
+inline host_pool& prefill_pool() {
+ static host_pool pool(prefill_threads());
+ return pool;
+}
+
+/// \brief rows of `bytes` from src (row stride src_stride elements) to dst (dst_stride),
+/// on the prefill pool (one thread copies well below the memory bandwidth)
+template
+inline void copy_rows(T* dst, size_t dst_stride, const T* src, size_t src_stride, int64_t rows, size_t bytes) {
+ prefill_pool().run(rows, [&](int64_t r0, int64_t r1, int) {
+ for (int64_t r = r0; r < r1; r++) memcpy(dst + (size_t)r * dst_stride, src + (size_t)r * src_stride, bytes);
+ });
+}
+
+// =============================================================================
+// Q4_K blocks
+// =============================================================================
+// One block = 32 rows x 256 columns, 4736 bytes, as in model.q4nx
+// (FLM_Q4NX_Converter/verify_minicpm5_moe_q4nx.py::decode_q4k):
+// uint8 s8 [8 groups][32 rows] per-group scale
+// uint8 m8 [8 groups][32 rows] per-group min
+// uint4 q [256 cols][16 bytes] byte b of a column = rows 2b (low nibble), 2b + 1 (high)
+// bf16 S [32 rows] super-block scale
+// bf16 M [32 rows] super-block min, stored negated
+// w[r][c] = S[r] * s8[g][r] * q[r][c] + M[r] * m8[g][r], g = c / 32
+constexpr int Q4K_ROWS = 32;
+constexpr int Q4K_COLS = 256;
+constexpr int Q4K_GROUPS = 8;
+constexpr size_t Q4K_BLOCK = minicpm5_moe_desc::Q4K_BLOCK_BYTES;
+constexpr size_t Q4K_S8 = 0, Q4K_M8 = 256, Q4K_QS = 512, Q4K_S = 4608, Q4K_M = 4672;
+
+/// \brief undo minicpm5_moe_model_def.cpp's q4k_relayout_for_mmul (the MoE overlay's
+/// int8-mmul order) back into the plain q4nx order above
+/// \note relaid qs: [k step 16][half t 2][16 columns][8 B], column = 16k + c
+/// relaid scales: [h 2][t 2][a 4][16 rows], group = 4h + a, row = 16t + i
+/// mins, S, M were not moved
+inline void q4k_unrelayout(u8* plain, const u8* relaid) {
+ memcpy(plain + Q4K_M8, relaid + Q4K_M8, Q4K_QS - Q4K_M8); // mins
+ memcpy(plain + Q4K_S, relaid + Q4K_S, Q4K_BLOCK - Q4K_S); // S, M
+ for (int k = 0; k < 16; k++)
+ for (int t = 0; t < 2; t++)
+ for (int c = 0; c < 16; c++)
+ memcpy(plain + Q4K_QS + (k * 16 + c) * 16 + t * 8,
+ relaid + Q4K_QS + (k * 2 + t) * 128 + c * 8, 8);
+ for (int h = 0; h < 2; h++)
+ for (int t = 0; t < 2; t++)
+ for (int a = 0; a < 4; a++)
+ memcpy(plain + Q4K_S8 + (4 * h + a) * 32 + 16 * t,
+ relaid + Q4K_S8 + ((h * 2 + t) * 4 + a) * 16, 16);
+}
+
+/// \brief one plain block into a fp32 tile: tile[r * ld + col0 + c]
+inline void q4k_decode_block(float* tile, int ld, int col0, const u8* blk) {
+ const u8* s8 = blk + Q4K_S8;
+ const u8* m8 = blk + Q4K_M8;
+ const u8* qs = blk + Q4K_QS;
+ const bf16* S = reinterpret_cast(blk + Q4K_S);
+ const bf16* M = reinterpret_cast(blk + Q4K_M);
+ for (int r = 0; r < Q4K_ROWS; r++) {
+ float* row = tile + (size_t)r * ld + col0;
+ const float S_r = (float)S[r], M_r = (float)M[r];
+ const int byte = r / 2, shift = (r & 1) * 4; // this row's nibble in a column
+ for (int g = 0; g < Q4K_GROUPS; g++) {
+ const float scale = S_r * (float)s8[g * Q4K_ROWS + r];
+ const float min = M_r * (float)m8[g * Q4K_ROWS + r];
+ for (int c = g * 32; c < g * 32 + 32; c++) {
+ const int q = (qs[c * 16 + byte] >> shift) & 0x0F;
+ row[c] = scale * (float)q + min;
+ }
+ }
+ }
+}
+
+// =============================================================================
+// Where a weight's blocks are in the decode buffers
+// =============================================================================
+/// \brief one weight matrix [N rows][K cols] inside a layer's proj buffer, as the
+/// decode overlays laid it out (minicpm5_moe_model_def.cpp). block() is the
+/// executable spec of those layouts: minicpm5_moe_desc::check_layer_layout tests
+/// it byte for byte against model.q4nx.
+struct q4k_matrix {
+ enum kind_t {
+ pairs, // reorder_cpy(..., 2): row blocks in pairs, interleaved block by block
+ expert_channels, // one routed expert's [channel 0 | channel 1] streams (reorder_cpy(..., 4) + split)
+ };
+ const u8* base = nullptr; // pairs: the matrix; expert_channels: the expert's start
+ int K = 0, N = 0; // columns (input), rows (output)
+ kind_t kind = pairs;
+ bool relaid = false; // blocks in the int8-mmul order (every MoE-layer block)
+ size_t channel_bytes = 0; // expert_channels: one channel stream
+ size_t part_offset = 0; // expert_channels: where this matrix starts in each stream
+
+ int blocks_per_row() const { return K / Q4K_COLS; }
+ int row_blocks() const { return N / Q4K_ROWS; }
+
+ /// \brief the block of row block rb (rows 32 rb ..), column block cb
+ const u8* block(int rb, int cb) const {
+ const size_t bpr = (size_t)blocks_per_row();
+ if (kind == pairs) {
+ // [pair rb / 2][cb][rb % 2]
+ return base + (((size_t)(rb / 2) * bpr + cb) * 2 + rb % 2) * Q4K_BLOCK;
+ }
+ // groups of 4 row blocks, [group rb / 4][cb][rb % 4]; of each 4, the first
+ // 2 went to channel 0 and the last 2 to channel 1
+ const size_t group = (size_t)(rb / 4) * bpr + cb;
+ const int i = rb % 4;
+ return base + (size_t)(i / 2) * channel_bytes + part_offset + (group * 2 + i % 2) * Q4K_BLOCK;
+ }
+
+ /// \brief rows 32 rb .. 32 rb + 31, all K columns, as fp32: tile[r * K + col]
+ void dequant_row_block(float* tile, int rb) const {
+ alignas(64) u8 plain[Q4K_BLOCK];
+ for (int cb = 0; cb < blocks_per_row(); cb++) {
+ const u8* blk = block(rb, cb);
+ if (relaid) {
+ q4k_unrelayout(plain, blk);
+ blk = plain;
+ }
+ q4k_decode_block(tile, K, cb * Q4K_COLS, blk);
+ }
+ }
+};
+
+// =============================================================================
+// dequant_mm: y[L][N] = x[L][K] W^T
+// =============================================================================
+/// \brief y[l][r0 .. r0 + 31] = x[l] . tile[r], for one 32-row tile and all L rows
+/// \note Register blocking: 4 rows of x by 4 rows of the tile at a time, so each
+/// pair of loads feeds 16 FMAs and the tile (in L2) is read L / 4 times
+/// instead of L times. A tail of fewer than 4 x rows points the missing
+/// ones at the last real row and does not store them.
+inline void mm_tile(bf16* y, int ldy, const float* tile, const float* xf, int L, int K) {
+ for (int l = 0; l < L; l += 4) {
+ const float* xr[4];
+ for (int i = 0; i < 4; i++) xr[i] = xf + (size_t)std::min(l + i, L - 1) * K;
+ for (int r = 0; r < Q4K_ROWS; r += 4) {
+ __m512 acc[4][4];
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++) acc[i][j] = _mm512_setzero_ps();
+ const float* wr = tile + (size_t)r * K;
+ for (int k = 0; k < K; k += 16) {
+ const __m512 w0 = _mm512_loadu_ps(wr + k);
+ const __m512 w1 = _mm512_loadu_ps(wr + K + k);
+ const __m512 w2 = _mm512_loadu_ps(wr + 2 * (size_t)K + k);
+ const __m512 w3 = _mm512_loadu_ps(wr + 3 * (size_t)K + k);
+ for (int i = 0; i < 4; i++) {
+ const __m512 xv = _mm512_loadu_ps(xr[i] + k);
+ acc[i][0] = _mm512_fmadd_ps(xv, w0, acc[i][0]);
+ acc[i][1] = _mm512_fmadd_ps(xv, w1, acc[i][1]);
+ acc[i][2] = _mm512_fmadd_ps(xv, w2, acc[i][2]);
+ acc[i][3] = _mm512_fmadd_ps(xv, w3, acc[i][3]);
+ }
+ }
+ for (int i = 0; i < 4 && l + i < L; i++)
+ for (int j = 0; j < 4; j++)
+ y[(size_t)(l + i) * ldy + r + j] = (bf16)_mm512_reduce_add_ps(acc[i][j]);
+ }
+ }
+}
+
+/// \brief y[L][N] = x[L][K] W^T, W read in place from the decode buffer
+/// \param y [L][N] bf16, row major
+/// \param x [L][K] bf16, row major
+/// \note Each 32-row block of W is dequantized once and used for all L rows, so
+/// the weight traffic is the weight size whatever L is. fp32 inside, bf16
+/// out (what a dequant_mm overlay would return).
+inline void dequant_mm(bf16* y, const q4k_matrix& w, const bf16* x, int L) {
+ if (L <= 0) return;
+ const int K = w.K, N = w.N;
+ assert(K % Q4K_COLS == 0 && N % Q4K_ROWS == 0);
+
+ // x to fp32 once, not once per tile
+ std::vector xf((size_t)L * K);
+ prefill_pool().run(L, [&](int64_t l0, int64_t l1, int) {
+ for (int64_t l = l0; l < l1; l++)
+ for (int k = 0; k < K; k += 16)
+ _mm512_storeu_ps(xf.data() + (size_t)l * K + k, load_bfloat16_to_m512(x + (size_t)l * K + k));
+ });
+
+ std::vector