@mica-js/simulator 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/device.d.ts +33 -4
- package/dist/index.d.ts +37 -4
- package/dist/index.js +410 -156
- package/dist/index.js.map +1 -1
- package/dist/rpc-BB5wM0QN.js.map +1 -1
- package/dist/sandbox.d.ts +10 -0
- package/dist/sandbox.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -58,13 +58,13 @@ JIT 在翻译并校验整个块后,将各 PC 直接绑定到已编译的指令
|
|
|
58
58
|
|
|
59
59
|
板默认使用 `execution: 'throughput'`,可切换 `execution: 'precise'`。`cpuQuantum` 为整数皮秒,范围 1 到 10,000,000,默认 10 μs;精确模式仍校验该值但不使用它。吞吐模式允许 CPU 观察、轮询退出和 IRQ 响应的额外延迟不超过该预算;固有的指令耗时、中断屏蔽和模型等待另计。外设、通信边沿、FIFO 和已锁存事件不按该预算合并。
|
|
60
60
|
|
|
61
|
-
吞吐模式将支持的缓存指令编译为紧凑 JS 执行循环,使用标量状态槽和原始 RAM 字节区,减少逐指令生成器、对象分配和通用派发。每段截止于下一普通事件或推进终点;资源屏障已排除中间可观察变化时,不因时间量子额外返回通用调度器。`cpuQuantum` 是额外可见性延迟的上界而非固定步长,当前实现保持精确事件期限,不故意引入延迟。直接执行目前只用于单 JIT 板上的标量运算、固定 RAM
|
|
61
|
+
吞吐模式将支持的缓存指令编译为紧凑 JS 执行循环,使用标量状态槽和原始 RAM 字节区,减少逐指令生成器、对象分配和通用派发。每段截止于下一普通事件或推进终点;资源屏障已排除中间可观察变化时,不因时间量子额外返回通用调度器。`cpuQuantum` 是额外可见性延迟的上界而非固定步长,当前实现保持精确事件期限,不故意引入延迟。直接执行目前只用于单 JIT 板上的标量运算、固定 RAM 区域(偏移可动态计算)、正耗时(常量或动态计算,动态值在执行处校验)和分支;不支持的指令、观察者、中断条件依赖写入及代码写入形成逐指令屏障,其余指令继续直接执行。同一 JIT 复用一份直接程序;观察者变化由块入口守卫处理,代码失效时清除缓存,避免 IRQ 分支切换导致重复编译。已生成的 shard 函数跨程序修订常驻,程序修订只重建小型 dispatcher 与受影响的开放尾 shard。挂起后缀保留读取结果,实际写入用可复用脏位集提交;外部改码也不重放当前前缀。
|
|
62
62
|
|
|
63
63
|
直接执行守卫缓存资源的观察订阅版本:资源首次被观察或最后一个观察订阅移除时更新版本,动态观察分支切换和共享订阅遵守同一规则。订阅版本未变且中断条件没有新增实际读取依赖时,复用已有守卫集合,省去每次交接对全部状态与内存的扫描;普通资源值变化仍使用原有数据版本和通知机制。
|
|
64
64
|
|
|
65
65
|
批次交接跳过空输入队列的排空与清理,并在创建器件时预绑定输入清理、输出通道和输出通知的布局。完全空的输出复用该器件预建的冻结对象;首次出现消息或通知时才按原字段顺序复制布局并生成新快照,空输出通道复用冻结空数组。全部器件的批次仍在任何 `sync` 回调之前捕获,每个器件逐次收到新的冻结批次,所有输出字段、通知复位、非空消息快照与冻结合同保持不变;空输出对象及数组身份不保证逐批唯一。
|
|
66
66
|
|
|
67
|
-
`waitUntil` 保持按依赖唤醒的 WFI 等待。单 JIT 板上的无副作用自循环可自动证明并跳过重复执行,依赖变化后沿原循环相位恢复,不提前读到外部变化;多 JIT 保留原交错顺序。模型也可在 `attachJit` 声明 `polling: [{ pc, predicate }]`:吞吐模式在该 PC 开始前检查本实例无参 bool 纯函数,返回 false
|
|
67
|
+
`waitUntil` 保持按依赖唤醒的 WFI 等待。单 JIT 板上的无副作用自循环可自动证明并跳过重复执行,依赖变化后沿原循环相位恢复,不提前读到外部变化;多 JIT 保留原交错顺序。模型也可在 `attachJit` 声明 `polling: [{ pc, predicate, consume?, wait? }]`:吞吐模式在该 PC 开始前检查本实例无参 bool 纯函数,返回 false 时停在循环头等待实际依赖或设备时间事件,循环体不执行;返回 true 时先执行可选的 `consume`,再正常执行指令。`wait.delay` 给出到下一设备事件的 ps,`wait.advance` 在事件到期后推进设备状态并可把 PC 转入服务块。该声明是模型的等待语义承诺,精确模式校验它并实际执行循环。参见[吞吐合同](../../docs/spec/jit/throughput.rst)。
|
|
68
68
|
|
|
69
69
|
旧 `Circuit`、`compileCircuit`、原理图宿主和 `/sandbox` 入口已移除;编辑器与 playground 的接入需迁移到新的库/板合同。
|
|
70
70
|
|
package/dist/device.d.ts
CHANGED
|
@@ -64,10 +64,21 @@ export declare interface InstructionHook {
|
|
|
64
64
|
/**
|
|
65
65
|
* 一条忙等延时环的声明:入口 `pc` 每轮把 number 状态 `counter` 减一,消耗 `cycles` ps。
|
|
66
66
|
* 环内不得产生其他可观察效果,因此跳过多轮只推进时间、只留下最后一轮的效果。
|
|
67
|
+
*
|
|
68
|
+
* `pending` 给按累加器计时的外设(SysTick、USART 位时钟):折算必须停在下一次服务边界,
|
|
69
|
+
* 并把折叠掉的时间记进 `state`,否则跳过轮次会让这些外设永远等不到自己的节拍。
|
|
67
70
|
*/
|
|
68
71
|
declare interface JitDelay {
|
|
69
72
|
readonly counter: string;
|
|
70
73
|
readonly cycles: number;
|
|
74
|
+
readonly pending?: {
|
|
75
|
+
/** 已累积的节拍时长(ps)。 */
|
|
76
|
+
readonly state: string;
|
|
77
|
+
/** 一次服务的粒度(ps)。 */
|
|
78
|
+
readonly period: string;
|
|
79
|
+
/** 是否需要按时间推进外设。 */
|
|
80
|
+
readonly active: string;
|
|
81
|
+
};
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
export declare interface JitHost {
|
|
@@ -80,14 +91,32 @@ export declare interface JitOptions {
|
|
|
80
91
|
readonly code: string;
|
|
81
92
|
readonly pc: string;
|
|
82
93
|
readonly beforeInstruction?: InstructionHook;
|
|
83
|
-
readonly polling?: readonly
|
|
84
|
-
readonly pc: number;
|
|
85
|
-
readonly predicate: string;
|
|
86
|
-
}[];
|
|
94
|
+
readonly polling?: readonly JitPolling[];
|
|
87
95
|
readonly delays?: ReadonlyMap<number, JitDelay>;
|
|
88
96
|
readonly translate: JitTranslate;
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
/**
|
|
100
|
+
* A throughput-only wait point. When `predicate` is false the JIT parks until a dependency
|
|
101
|
+
* changes. If `wait` is present, `delay` supplies the picoseconds to the next device time
|
|
102
|
+
* event and `advance` applies that elapsed interval before the JIT is re-queued.
|
|
103
|
+
*
|
|
104
|
+
* `consume` runs once after `predicate` becomes true, allowing a one-shot wake token to be
|
|
105
|
+
* cleared before the guest instruction executes. These functions take zero or one
|
|
106
|
+
* argument; only `predicate` and `delay` must be pure.
|
|
107
|
+
*/
|
|
108
|
+
declare interface JitPolling {
|
|
109
|
+
readonly pc: number;
|
|
110
|
+
readonly predicate: string;
|
|
111
|
+
readonly consume?: string;
|
|
112
|
+
readonly wait?: {
|
|
113
|
+
/** Pure zero-argument function returning the delay in picoseconds, or zero to park. */
|
|
114
|
+
readonly delay: string;
|
|
115
|
+
/** Function receiving the elapsed picoseconds and applying the device time event. */
|
|
116
|
+
readonly advance: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
91
120
|
export declare type JitTranslate = (input: JitTranslateInput, builder: JitBlockBuilder) => BlockIR;
|
|
92
121
|
|
|
93
122
|
export declare interface JitTranslateInput {
|
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,8 @@ export declare interface InstructionHook {
|
|
|
124
124
|
export declare interface IPreparedSimulation {
|
|
125
125
|
readonly schematic: SchematicDocument;
|
|
126
126
|
readonly devices: readonly IPreparedSimulationDevice[];
|
|
127
|
+
/** Board CPU execution mode; omitted to retain the Board default. */
|
|
128
|
+
readonly execution?: BoardOptions['execution'];
|
|
127
129
|
/** Fixed board voltages by exact schematic net name; ignored for empty sheets. Ground stays zero. */
|
|
128
130
|
readonly voltageReferences?: Readonly<Record<string, number>>;
|
|
129
131
|
/** assets[symbolId][src]; required for every effective image/binary resource reference. */
|
|
@@ -219,6 +221,8 @@ export declare interface ISimulationRuntimeRpc {
|
|
|
219
221
|
export declare interface ISimulationRuntimeTopicRpc {
|
|
220
222
|
deliver(message: ISimulationMessage): Promise<void>;
|
|
221
223
|
onDidPublish(listener: (message: ISimulationMessage) => void): () => void;
|
|
224
|
+
/** Resolves after earlier publish notifications have crossed this port. */
|
|
225
|
+
flushPublishes(): Promise<void>;
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
export declare interface ISimulationTickReport {
|
|
@@ -230,10 +234,21 @@ export declare interface ISimulationTickReport {
|
|
|
230
234
|
/**
|
|
231
235
|
* 一条忙等延时环的声明:入口 `pc` 每轮把 number 状态 `counter` 减一,消耗 `cycles` ps。
|
|
232
236
|
* 环内不得产生其他可观察效果,因此跳过多轮只推进时间、只留下最后一轮的效果。
|
|
237
|
+
*
|
|
238
|
+
* `pending` 给按累加器计时的外设(SysTick、USART 位时钟):折算必须停在下一次服务边界,
|
|
239
|
+
* 并把折叠掉的时间记进 `state`,否则跳过轮次会让这些外设永远等不到自己的节拍。
|
|
233
240
|
*/
|
|
234
241
|
export declare interface JitDelay {
|
|
235
242
|
readonly counter: string;
|
|
236
243
|
readonly cycles: number;
|
|
244
|
+
readonly pending?: {
|
|
245
|
+
/** 已累积的节拍时长(ps)。 */
|
|
246
|
+
readonly state: string;
|
|
247
|
+
/** 一次服务的粒度(ps)。 */
|
|
248
|
+
readonly period: string;
|
|
249
|
+
/** 是否需要按时间推进外设。 */
|
|
250
|
+
readonly active: string;
|
|
251
|
+
};
|
|
237
252
|
}
|
|
238
253
|
|
|
239
254
|
export declare interface JitHost {
|
|
@@ -246,14 +261,32 @@ export declare interface JitOptions {
|
|
|
246
261
|
readonly code: string;
|
|
247
262
|
readonly pc: string;
|
|
248
263
|
readonly beforeInstruction?: InstructionHook;
|
|
249
|
-
readonly polling?: readonly
|
|
250
|
-
readonly pc: number;
|
|
251
|
-
readonly predicate: string;
|
|
252
|
-
}[];
|
|
264
|
+
readonly polling?: readonly JitPolling[];
|
|
253
265
|
readonly delays?: ReadonlyMap<number, JitDelay>;
|
|
254
266
|
readonly translate: JitTranslate;
|
|
255
267
|
}
|
|
256
268
|
|
|
269
|
+
/**
|
|
270
|
+
* A throughput-only wait point. When `predicate` is false the JIT parks until a dependency
|
|
271
|
+
* changes. If `wait` is present, `delay` supplies the picoseconds to the next device time
|
|
272
|
+
* event and `advance` applies that elapsed interval before the JIT is re-queued.
|
|
273
|
+
*
|
|
274
|
+
* `consume` runs once after `predicate` becomes true, allowing a one-shot wake token to be
|
|
275
|
+
* cleared before the guest instruction executes. These functions take zero or one
|
|
276
|
+
* argument; only `predicate` and `delay` must be pure.
|
|
277
|
+
*/
|
|
278
|
+
export declare interface JitPolling {
|
|
279
|
+
readonly pc: number;
|
|
280
|
+
readonly predicate: string;
|
|
281
|
+
readonly consume?: string;
|
|
282
|
+
readonly wait?: {
|
|
283
|
+
/** Pure zero-argument function returning the delay in picoseconds, or zero to park. */
|
|
284
|
+
readonly delay: string;
|
|
285
|
+
/** Function receiving the elapsed picoseconds and applying the device time event. */
|
|
286
|
+
readonly advance: string;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
257
290
|
export declare type JitTranslate = (input: JitTranslateInput, builder: JitBlockBuilder) => BlockIR;
|
|
258
291
|
|
|
259
292
|
export declare interface JitTranslateInput {
|