Mermaid 图集
flowchart LR GGUF[GGUF 模型] --> Inspect[结构检查] Inspect --> Tok[Tokenizer 导出] Inspect --> Payload[Tensor payload 导出] Tok --> Bundle[PS bundle] Bundle --> Image[Q25TOKRT image] Payload --> Golden[Host gol
1. 项目总流程
flowchart LR
GGUF[GGUF 模型] --> Inspect[结构检查]
Inspect --> Tok[Tokenizer 导出]
Inspect --> Payload[Tensor payload 导出]
Tok --> Bundle[PS bundle]
Bundle --> Image[Q25TOKRT image]
Payload --> Golden[Host golden]
Payload --> Fixture[HLS fixture]
Fixture --> HLS[CSim / cosim / csynth]
Image --> PS[PS/A53 UART]
PS --> Board[ZCU106 transcript]
Board --> Archive[Validator / archive]2. transformer 算子链
flowchart LR
Token[token id] --> Emb[Embedding]
Emb --> Norm1[RMSNorm]
Norm1 --> QKV[Q / K / V projection]
QKV --> RoPE[RoPE on Q/K]
RoPE --> Score[masked score + softmax]
Score --> Context[value mix]
Context --> OutProj[attention output projection]
OutProj --> Add1[attention residual]
Add1 --> Norm2[RMSNorm]
Norm2 --> Gate[FFN gate]
Norm2 --> Up[FFN up]
Gate --> SwiGLU[SiLU(gate) * up]
Up --> SwiGLU
SwiGLU --> Down[FFN down]
Down --> Add2[MLP residual]
Add2 --> Final[final norm]
Final --> LM[lm_head + top-k]3. PS UART 命令分发
flowchart TD
UART[UART line] --> Dispatch{命令}
Dispatch -->|TEXT_PROMPT| Encode[BPE image 或 byte fallback]
Dispatch -->|TEXT_GENERATE| Suffix[固定后缀编码 + detokenize]
Dispatch -->|NL_PROMPT_IDS| Store[保存 token ids]
Dispatch -->|NL_GENERATE| Demo[递增 token 演示]
Dispatch -->|MODEL_LOAD / TOKEN_STEP / TEXT_STEP| Stub[P4 command stub]
Dispatch -->|INFO / STATUS / PING| Meta[状态或 PONG]
Encode --> Response[UART response]
Suffix --> Response
Store --> Response
Demo --> Response
Stub --> Response
Meta --> Response4. HLS 的外部接口
flowchart LR
PS[PS scheduler 或 HLS testbench] -->|DDR pointer + AXI-Lite scalar| Kernel[HLS kernel]
Kernel -->|m_axi read| Weight[quantized weights in DDR]
Kernel -->|m_axi read| Act[activation / fixture in DDR]
Kernel -->|m_axi write| Result[vector / scores / top-k in DDR]
Kernel -->|ap_done / status| PS