12.9 步骤 4:定时器 CAL_TON/CAL_TOF/CAL_CTU。

- do_cal:内建布局冻结(TON/TOF: in/pt/q/et、CTU: cu/r/pv/q/cv,字段=槽序号×8)
- TON:in 真 → et+=dt(到 pt 停)、q=et≥pt;假 → 清零
- TOF:in 真 → q=1/et=0;掉电 → et+=dt、et≥pt → q=0
- CTU:cu 上升沿(ctu_prev_ 跨周期)→ cv+1;r 复位;q=cv≥pv
- 抽 slot_get/slot_set 复用(exec_one 的 LOAD/STORE 同步重构)
- 验证:TON 3 周期到 q=1、TOF 掉电延时 2 周期、CTU 交替上升沿到 cv=3、复位;line1 三组 I 组合 Q 正确 + 确定性两遍一致
This commit is contained in:
2026-08-21 20:20:26 +08:00
parent a84a1a62ce
commit ada9e5f99e
2 changed files with 109 additions and 14 deletions
+4
View File
@@ -107,5 +107,9 @@ namespace vm {
Fault do_call(uint32_t fn_id); // 压帧;BadFn 用 BadOp 表示
Fault do_ret(); // 弹帧 / 周期结束
Fault do_cal(uint8_t op, uint16_t slot); // TON/TOF/CTU12.9 步骤 4
// 数据区槽读写(8 字节定宽;越界返回 false)
bool slot_get(uint16_t slot, int64_t* out) const;
bool slot_set(uint16_t slot, int64_t v);
};
}