Files
Palladium_Z2-ice_top-demo/README_ICE对比_中文教程.md

62 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Palladium Z2 Demo(ICE 版):与 SA 版的流程对比
同一个 DUT(`z2_demo_top`,寄存器型定时器外设),两种模式各跑一遍——这是理解 Palladium Z2 的 ICE 与 SA 区别最快的方法。本目录是 ICE 版,SA 版在包根目录(`rtl/`、`tb/`、`scripts/compile_sa.sh`)。
> 本地验证状态:ICE 顶层的硬件激励 FSM + DUT 已在 Icarus Verilog 下实际跑过:序列在约定的周期内完成、`led_pass=1`、`led_gpio=0x02`(日志 `ice/sim_local/ice_run.log`)。Palladium 侧脚本按《Palladium Z2 Emulator》教程中有明确出处的命令编写(`emulatorConfiguration`、`debug/host/download/run <cycles>/getCycleNum`);xeCompile 的具体调用方式各现场封装不同,`compile_ice.sh` 中已明确标为模板,首次上机按你们的标准 ICE 流程核对。
## 1. ICE 版的结构差异:没有软件 TB
ICE(In-Circuit Emulation)是纯硬件仿真,**没有留在 host 上的 testbench**。SA 版里由 TB 做的事——发 APB 读写、等中断、比对结果——在 ICE 里必须全部变成硬件。所以 ICE 版多了一个顶层 `z2_demo_ice_top.v`:
- 内置一个可综合的**激励/检查 FSM**,上电后自动执行与 SA 版 TB 相同的检查序列(写 LOAD/CMP → 读 ID 比对 → 使能 → 等 irq(200 周期超时保护)→ 查 STATUS 双标志 → 查 GPIO 旋转 → 关使能、W1C 清标志、复查);
- 结果用顶层引脚输出:`led_done / led_pass / led_fail / led_gpio / led_irq`,在 xeDebug GUI/波形里直接看这几个信号就是测试结论;
- DUT 本体与 SA 版**逐字节相同**(`ice/rtl/z2_demo_top.v` 是同一份文件的副本),对比的变量只有"模式",没有"设计"。
本地验证 ICE 顶层(不需要硬件):
```bash
./ice/scripts/run_local_ice.sh # 预期: ICE LOCAL TEST PASSED
```
注意这个本地 TB 只是给时钟和复位、盯 LED 的脚手架,真实 ICE 运行时它不存在——时钟来自 target 或 emulator 的时钟配置,复位来自外部引脚。
## 2. 全流程对比(同一 DUT)
| 环节 | SA 模式(包根目录) | ICE 模式(本目录) |
|---|---|---|
| 编译工具 | IXCOM:`ixcom -ua +dut+z2_demo_top -f rtl.f -f tb.f` | HDL-ICE 编译器(xeCompile),编译脚本含 `emulatorConfiguration` |
| 谁留在 host | TB 留在 host 仿真器(Xcelium)侧,与硬件协同 | 没有软件侧;激励 FSM 与 DUT 一起进 emulator |
| 指定 emulator | 环境变量 `XE_HOST` / `XE_BOARDS`(编译+运行) | 编译时 `emulatorConfiguration -add {host <h>} {boards 0.0+0.1}`,生成 `dbFiles/z2_demo_ice_top.et3confg`;运行时再用 `host` 命令 |
| target 连接 | IXCOM 的 `+targetTop` 指定(本 demo 无 target,可略) | HDL-ICE 的用户数据命令 `cableConnection` / `terminalAssign` / `terminalTiming`(本 demo 无 target,可略) |
| xeDebug 运行位置 | **必须在 SA host 上** | 任意工作站 |
| 运行命令 | `host` → `xc on -run`(热交换下载并启动协同仿真) | `debug` → `host <h> -path [pwd]` → `download` → `run <cycles>`(如 `run 100000`),`getCycleNum` 查进度 |
| 时钟来源 | TB 中的时钟(host 侧产生,DUT 侧被加速) | target 或 emulator 时钟配置驱动 `clk_in`,`run` 推进的是设计时钟 |
| 结果判读 | TB 打印 `CHECK OK / TEST PASSED`,合并在 `xeDebug.log` 里 grep | 看顶层引脚:`led_pass/led_done/led_gpio`(GUI/波形),没有打印输出 |
| 出错定位 | TB 检查行 + 波形;注意 xmsim 无独立日志 | FSM 状态 `z2_demo_ice_top.state` 停在哪一步、 `rd_latched` 最后读回值 + 波形 |
| 挂起/恢复 | `+allowSuspend` + 触碰 `tmp/suspend` 文件,或 xeDebug 命令式 | `xeset suspendEnable 1` 后 `suspend` / `resume`(快照另存 `dbFiles/suspendSession.qt<PID>`) |
| 适合场景 | 有复杂 TB/参考模型、要跑软件式验证、回归 | 接真实 target、整机上电时序、长时间 free-running、性能/功耗观察 |
## 3. ICE 版上机步骤
```bash
# 1) 编译(先按 compile_ice.sh 里的说明把 emulatorConfiguration 填好)
XE_HOSTNAME=<emulator主机名> ICE_BOARDS="0.0+0.1" ./ice/scripts/compile_ice.sh
# 然后按你们现场的标准 xeCompile 流程完成编译(脚本里有清单),
# 编完确认 dbFiles/z2_demo_ice_top.et3confg 已生成,可用 hwInfo 复查资源。
# 2) 运行(任意工作站,设计目录下)
xeDebug
# 在 xeDebug 里: source ice/scripts/run_xedebug_ice.tcl
# (脚本里 <XE_HOST_NAME> 先替换成实际主机名)
# 3) 判读: 波形/GUI 看 z2_demo_ice_top 的 led_done=1、led_pass=1、led_gpio=0x02
```
编译前建议先按教程做可行性检查:`ConfigCheck -file <host>.et3confg -domains 0.0+0.1`,红色/橙色告警先处理再编,省一轮编译时间。本 demo 门数很小,`boards *` 自动配置(`emulatorConfiguration -add {host <h>} {boards *}`)也能用。
## 4. 选型一句话
- **验证逻辑对不对** → SA:TB 能写多复杂写多复杂,改 TB 不用重编硬件。
- **接真实世界跑起来** → ICE:没有软件 TB 这回事,一切激励要么是硬件 FSM,要么来自 target 本身——这也是为什么 ICE 版要多写一个 `ice_top`。
- 两边共用同一个 DUT,是 Palladium 项目常见的组织方式:功能验证在 SA 完成,系统级联调切 ICE,RTL 只维护一份。