@mica-js/simulator 2.2.0 → 2.4.0
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 +15 -9
- package/dist/device.d.ts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +258 -277
- package/dist/index.js.map +1 -1
- package/dist/rpc-BB5wM0QN.js +289 -0
- package/dist/rpc-BB5wM0QN.js.map +1 -0
- package/dist/sandbox.js +2 -2
- package/package.json +4 -3
- package/dist/rpc-D-9O3TZf.js +0 -108
- package/dist/rpc-D-9O3TZf.js.map +0 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ 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 区域(偏移可动态计算)、正耗时(常量或动态计算,动态值在执行处校验)和分支;不支持的指令、观察者、中断条件依赖写入及代码写入形成逐指令屏障,其余指令继续直接执行。按守卫集合复用最多 8 份程序,代码失效时一起清除,避免 IRQ 分支切换导致重复编译。挂起后缀保留读取结果,实际写入用可复用脏位集提交;外部改码也不重放当前前缀。
|
|
62
62
|
|
|
63
63
|
直接执行守卫缓存资源的观察订阅版本:资源首次被观察或最后一个观察订阅移除时更新版本,动态观察分支切换和共享订阅遵守同一规则。订阅版本未变且中断条件没有新增实际读取依赖时,复用已有守卫集合,省去每次交接对全部状态与内存的扫描;普通资源值变化仍使用原有数据版本和通知机制。
|
|
64
64
|
|
|
@@ -324,14 +324,20 @@ pnpm --filter @mica-js/simulator bench:workloads --workloads=sram --sizes=1 --sa
|
|
|
324
324
|
pnpm --filter @mica-js/simulator bench:workloads --workloads=uart,sram --sizes=1,16 --samples=20 --cpu-profile-dir=C:\temp\mica-profiles
|
|
325
325
|
```
|
|
326
326
|
|
|
327
|
-
| 负载 | size 含义 | 吞吐单位与验证
|
|
328
|
-
| ------------------------ | ------------------------ |
|
|
329
|
-
| `uart` | 独立双 UART 电气连线对数 | 帧;逐帧核对字节、顺序、标志、时刻与零丢弃
|
|
330
|
-
| `cpu-irq` | 处理器数 | 已处理中断;真实 WAIT/ADDI/IRET/JMP 路径,检查累加器回绕与返回等待
|
|
331
|
-
| `sram` | SRAM 数 | 写入/读回对;真实地址、控制与八位数据总线,校验所有读回值
|
|
332
|
-
| `pwm` | PWM 计数器数 | 计数 tick;检查缓冲占空比、寄存器、电平与 wrap 通知
|
|
333
|
-
| `electrical-chain` | 未知节点数除以 8 | 节点更新;相连电阻链切换末端电阻,逐节点核对闭式电压
|
|
334
|
-
| `electrical-independent` | 未知节点数除以 8 | 节点更新;独立分压器切换电阻,与相连网络对照
|
|
327
|
+
| 负载 | size 含义 | 吞吐单位与验证 |
|
|
328
|
+
| ------------------------ | ------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
329
|
+
| `uart` | 独立双 UART 电气连线对数 | 帧;逐帧核对字节、顺序、标志、时刻与零丢弃 |
|
|
330
|
+
| `cpu-irq` | 处理器数 | 已处理中断;真实 WAIT/ADDI/IRET/JMP 路径,检查累加器回绕与返回等待 |
|
|
331
|
+
| `sram` | SRAM 数 | 写入/读回对;真实地址、控制与八位数据总线,校验所有读回值 |
|
|
332
|
+
| `pwm` | PWM 计数器数 | 计数 tick;检查缓冲占空比、寄存器、电平与 wrap 通知 |
|
|
333
|
+
| `electrical-chain` | 未知节点数除以 8 | 节点更新;相连电阻链切换末端电阻,逐节点核对闭式电压 |
|
|
334
|
+
| `electrical-independent` | 未知节点数除以 8 | 节点更新;独立分压器切换电阻,与相连网络对照 |
|
|
335
|
+
| `port-model` | 建模端口数除以 4 | 端口写;`bytes`/`index`/`resistor`/`combineIntents`/`writeIntent` 全走直接后端,按意图形状核对采样电平 |
|
|
336
|
+
| `topology-churn` | 驱动网络组数除以 2 | 网络更新;VCC 与 GND 经负载连通时每步换拓扑键,校验节点闭式电压与 leaf 电压等于目标节点 |
|
|
337
|
+
| `observer-churn` | 被观察 state 数除以 2 | 块执行;订阅集合每块迁移,断言 `directStateGuards` 抖动且投递不重不漏 |
|
|
338
|
+
| `wide-memory` | 内存窗口数除以 2 | 访存;`store32`/`load32`/`store16` 混合端序,整块内存镜像对参考模型逐字节校验 |
|
|
339
|
+
|
|
340
|
+
板级负载的 `size` 只表达端口数、网络组数、被观察 state 数或内存窗口数,不表达器件实例数:`runDirect` 要求同一块板只有一个 JIT 器件。
|
|
335
341
|
|
|
336
342
|
默认规模为 1、4、16,每组预热 5 批、测量 100 批。CPU、SRAM 和 PWM 包含公开证据存储或引脚观察器的成本;SRAM 包含宿主总线刺激,UART 包含适配器收集。输出单位不同,不能把各项吞吐直接横向比较,也不能当作完整芯片性能承诺。
|
|
337
343
|
|
package/dist/device.d.ts
CHANGED
|
@@ -61,6 +61,15 @@ export declare interface InstructionHook {
|
|
|
61
61
|
readonly call: string;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* 一条忙等延时环的声明:入口 `pc` 每轮把 number 状态 `counter` 减一,消耗 `cycles` ps。
|
|
66
|
+
* 环内不得产生其他可观察效果,因此跳过多轮只推进时间、只留下最后一轮的效果。
|
|
67
|
+
*/
|
|
68
|
+
declare interface JitDelay {
|
|
69
|
+
readonly counter: string;
|
|
70
|
+
readonly cycles: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
export declare interface JitHost {
|
|
65
74
|
attachJit(options: JitOptions): Disposable;
|
|
66
75
|
loadBytes(memory: string, bytes: Uint8Array, offset?: number): void;
|
|
@@ -75,6 +84,7 @@ export declare interface JitOptions {
|
|
|
75
84
|
readonly pc: number;
|
|
76
85
|
readonly predicate: string;
|
|
77
86
|
}[];
|
|
87
|
+
readonly delays?: ReadonlyMap<number, JitDelay>;
|
|
78
88
|
readonly translate: JitTranslate;
|
|
79
89
|
}
|
|
80
90
|
|
|
@@ -100,7 +110,18 @@ declare const snapshotTag: unique symbol;
|
|
|
100
110
|
|
|
101
111
|
export declare interface TopicBridge {
|
|
102
112
|
readonly onDidReceive: Event_2<TopicMessage>;
|
|
113
|
+
/**
|
|
114
|
+
* 未携带 owner 的监听者数量,即宿主对板级根 bridge 的直连订阅数;实例作用域包装注册的
|
|
115
|
+
* 监听者不计入。计数覆盖整块板共享的话题分发集合,因此器件 `ctx.topics` 读到的是同一个
|
|
116
|
+
* 宿主订阅数。只读视图,随订阅创建与释放实时变化。
|
|
117
|
+
*/
|
|
118
|
+
readonly hostListenerCount: number;
|
|
103
119
|
publish(topic: string, payload: unknown): void;
|
|
120
|
+
/**
|
|
121
|
+
* 按 `publish` 相同的失效、非法阶段与故障规则校验,但不复制载荷、不组装消息、不派发。
|
|
122
|
+
* 发布者可在确认无人接收时先校验再跳过复制与扇出。
|
|
123
|
+
*/
|
|
124
|
+
assertCanPublish(): void;
|
|
104
125
|
}
|
|
105
126
|
|
|
106
127
|
export declare interface TopicMessage {
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,15 @@ export declare interface ISimulationTickReport {
|
|
|
227
227
|
readonly executed: number;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* 一条忙等延时环的声明:入口 `pc` 每轮把 number 状态 `counter` 减一,消耗 `cycles` ps。
|
|
232
|
+
* 环内不得产生其他可观察效果,因此跳过多轮只推进时间、只留下最后一轮的效果。
|
|
233
|
+
*/
|
|
234
|
+
export declare interface JitDelay {
|
|
235
|
+
readonly counter: string;
|
|
236
|
+
readonly cycles: number;
|
|
237
|
+
}
|
|
238
|
+
|
|
230
239
|
export declare interface JitHost {
|
|
231
240
|
attachJit(options: JitOptions): Disposable;
|
|
232
241
|
loadBytes(memory: string, bytes: Uint8Array, offset?: number): void;
|
|
@@ -241,6 +250,7 @@ export declare interface JitOptions {
|
|
|
241
250
|
readonly pc: number;
|
|
242
251
|
readonly predicate: string;
|
|
243
252
|
}[];
|
|
253
|
+
readonly delays?: ReadonlyMap<number, JitDelay>;
|
|
244
254
|
readonly translate: JitTranslate;
|
|
245
255
|
}
|
|
246
256
|
|
|
@@ -349,7 +359,18 @@ export declare function startSimulationRuntimeGuest(port: MessagePort, options?:
|
|
|
349
359
|
|
|
350
360
|
export declare interface TopicBridge {
|
|
351
361
|
readonly onDidReceive: Event_2<TopicMessage>;
|
|
362
|
+
/**
|
|
363
|
+
* 未携带 owner 的监听者数量,即宿主对板级根 bridge 的直连订阅数;实例作用域包装注册的
|
|
364
|
+
* 监听者不计入。计数覆盖整块板共享的话题分发集合,因此器件 `ctx.topics` 读到的是同一个
|
|
365
|
+
* 宿主订阅数。只读视图,随订阅创建与释放实时变化。
|
|
366
|
+
*/
|
|
367
|
+
readonly hostListenerCount: number;
|
|
352
368
|
publish(topic: string, payload: unknown): void;
|
|
369
|
+
/**
|
|
370
|
+
* 按 `publish` 相同的失效、非法阶段与故障规则校验,但不复制载荷、不组装消息、不派发。
|
|
371
|
+
* 发布者可在确认无人接收时先校验再跳过复制与扇出。
|
|
372
|
+
*/
|
|
373
|
+
assertCanPublish(): void;
|
|
353
374
|
}
|
|
354
375
|
|
|
355
376
|
export declare interface TopicMessage {
|