@celox-sim/celox 0.1.16 → 0.1.17
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/package.json +2 -2
- package/src/e2e.test.ts +56 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celox-sim/celox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "TypeScript runtime for Celox HDL simulation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@celox-sim/celox-napi": "0.1.
|
|
32
|
+
"@celox-sim/celox-napi": "0.1.17"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"vitest": ">=1.0.0"
|
package/src/e2e.test.ts
CHANGED
|
@@ -1516,6 +1516,62 @@ module Top (
|
|
|
1516
1516
|
}
|
|
1517
1517
|
`;
|
|
1518
1518
|
|
|
1519
|
+
const FOR_LOOP_INSTANCE_SOURCE = `
|
|
1520
|
+
module Sub (
|
|
1521
|
+
clk: input '_ clock,
|
|
1522
|
+
i_data: input logic<8>,
|
|
1523
|
+
o_data: output logic<8>,
|
|
1524
|
+
) {
|
|
1525
|
+
always_comb {
|
|
1526
|
+
o_data = i_data + 8'h01;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
module Top (
|
|
1531
|
+
clk: input '_ clock,
|
|
1532
|
+
rst: input reset,
|
|
1533
|
+
top_in: input logic<8>,
|
|
1534
|
+
top_out: output logic<8>[2],
|
|
1535
|
+
) {
|
|
1536
|
+
for i in 0..2: g {
|
|
1537
|
+
inst u_sub: Sub (
|
|
1538
|
+
clk,
|
|
1539
|
+
i_data: top_in,
|
|
1540
|
+
o_data: top_out[i],
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
`;
|
|
1545
|
+
|
|
1546
|
+
describe("E2E: for-loop instance DUT access", () => {
|
|
1547
|
+
test("Simulator: for-loop instances are arrays, values accessible", () => {
|
|
1548
|
+
const sim = Simulator.fromSource(FOR_LOOP_INSTANCE_SOURCE, "Top");
|
|
1549
|
+
|
|
1550
|
+
sim.dut.top_in = 0x10n;
|
|
1551
|
+
sim.tick();
|
|
1552
|
+
|
|
1553
|
+
// For-loop instances should be accessible as an array
|
|
1554
|
+
const children = (sim.dut as any).u_sub;
|
|
1555
|
+
expect(children).toBeDefined();
|
|
1556
|
+
expect(Array.isArray(children)).toBe(true);
|
|
1557
|
+
expect(children.length).toBe(2);
|
|
1558
|
+
|
|
1559
|
+
// Each instance should expose its ports
|
|
1560
|
+
expect(children[0].o_data).toBe(0x11n);
|
|
1561
|
+
expect(children[1].o_data).toBe(0x11n);
|
|
1562
|
+
expect(children[0].i_data).toBe(0x10n);
|
|
1563
|
+
expect(children[1].i_data).toBe(0x10n);
|
|
1564
|
+
|
|
1565
|
+
// Change input and verify both instances update
|
|
1566
|
+
sim.dut.top_in = 0xffn;
|
|
1567
|
+
sim.tick();
|
|
1568
|
+
expect(children[0].o_data).toBe(0x00n); // 0xFF + 1 = 0x00 (8-bit wrap)
|
|
1569
|
+
expect(children[1].o_data).toBe(0x00n);
|
|
1570
|
+
|
|
1571
|
+
sim.dispose();
|
|
1572
|
+
});
|
|
1573
|
+
});
|
|
1574
|
+
|
|
1519
1575
|
// ---------------------------------------------------------------------------
|
|
1520
1576
|
// Parameter override: DUT correctness tests
|
|
1521
1577
|
// ---------------------------------------------------------------------------
|