feat(nutshell-uc): implement all Cache behavior tests and fix mock burst protocol
Implement the boundary, flush, forward, handshake and MMIO test suites as real transactions with data and state assertions; the full suite is now 55 passed.
Completing them required fixing the testbench: MockMemory spoke the wrong SimpleBus protocol (cmd 0/1, single beat) so every refill deadlocked in s3 — rewritten as a critical-word-first burst (read cmd 2/6, writeback cmd 3/7) with handshake gating and active-instance guards. Poll req_ready after the ~128-cycle SRAM reset and drive downstream ready every cycle. No NCache RTL was changed; details in NCache_bug_analysis.md.
Signed-off-by: 林晨 (Leo Cheng) leo-cheng@vip.qq.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
NutShell Cache 验证(nutshell-uc)
用 UCAgent + toffee + picker 对 NutShell(果壳)处理器的 Cache 做功能验证。UCAgent 生成验证原型,再在其上做人工定制与补全。
被验证对象(DUT)
NCache 取自 NutShell 的
Cache.scalaelaborate 产物(NCache_RTL/NCache.v与NCache/NCache.v),4 路组相联、写回、meta/data SRAM 片内内联。对外端口:io_inio_out_memio_mmioio_flush/io_emptyio_out_coh主存在
io_out_mem上,是 refill/写回能否闭环的关键,因此挂了行为化主存 Mock,而不是把 meta/data SRAM 当外置端口。工具链
_UT_NCache.so+libUT_NCache.py),make init_NCache重新生成。验证架构
unity_test/tests/NCache_bundle_defs.py— 8 个 Bundle(Req/Resp、MemReq/MemResp、MMIO 收发、Coherence 收发),把 DUT 扁平信号封装成握手接口。unity_test/tests/NCache_api.py— env fixture 与驱动层:send_request/wait_resp/read/write/Step/reset,以及内存/寄存器预置。unity_test/tests/NCache_mock_basic.py— 三个行为 Mock:MockMemory(主存 refill/写回、可预置数据、带统计)、MockMMIO(寄存器读写)、MockCoherence(一致性 tie-off)。unity_test/tests/NCache_function_coverage_def.py— 功能覆盖组(funcov),覆盖点绑定到用例。测试计划
unity_test/NCache_functions_and_checks.md定义 11 个功能组(FG) / 30 个功能点(FC) / 84 个检查点(CK),覆盖:读写命中/缺失、4 路及同组替换、脏行写回(触发/时序/完整性)、写后读前递、flush、MMIO 隔离、访问粒度 1/2/4/8B、请求/响应握手与背压、参考模型与主存 Mock 自检。当前状态
test_NCache_{boundary,flush,forward,handshake,mmio}.py)都做真实事务并对数据/状态断言,不是只检查返回类型。unity_test/NCache_bug_analysis.md:MockMemory主存 Mock 的 SimpleBus 协议原本是错的——只认cmd=0/1、只回单拍,而 DUT 的 refill 走突发读(cmd=2,末拍cmd=6)、写回走突发写(cmd=3/7)。协议不匹配时每次缺失都在s3阶段死等。已重写为临界字优先的 8 拍突发协议 + 握手门控 + 写回应答,refill/writeback 闭环才真正跑通。metaArray逐 set 清零),复位后须轮询req_ready再驱动;下游io_out_mem/io_mmio的ready须每拍驱动;多 Mock 共享 session 级 DUT 回调需活跃实例门控以免累积死锁。io_flush[1](整行 flush)在本 DCache 实例会触发 RTL 断言(NutShell 里整行 flush 仅允许 icache),故 flush 用例只驱动io_flushbit0(冲刷 stage2)。诚实说明:这是 UCAgent 生成原型 + 人工深度定制的结果——框架由 UCAgent 生成,用例的驱动时序与 Mock 协议由人工核对 DUT 逐拍行为后补全/修正。
复现
需要 Linux(或 WSL2)、python3、verilator ≥ 5.008、picker、toffee/toffee-test。
目录
后续
code_coverage.json与数值化 HTML 覆盖报告。io_flush[1]RTL 断言限制而暂未覆盖的整行 flush 路径(或按 icache 配置单独验证)。NCache.v复跑,与仓库现有 DUT 对照。