@modular-circuit/perc 0.1.1 → 0.1.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/dist/index.d.mts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +67 -27
- package/dist/index.mjs +84 -30
- package/package.json +5 -6
package/dist/index.d.mts
CHANGED
|
@@ -445,16 +445,14 @@ declare class ConnectionGraphsBuilder implements CC_Visitor {
|
|
|
445
445
|
private readonly connection_node_map;
|
|
446
446
|
private net_count;
|
|
447
447
|
private connection_graph;
|
|
448
|
-
private
|
|
448
|
+
private bundle_consumed_port_count;
|
|
449
449
|
constructor(connection_node_map: ConnectionNodeMap);
|
|
450
450
|
end_visit_component(cc: string[]): void;
|
|
451
451
|
resolve_net_drive(nodes: ConnectionNode[], sub_graph: ConnectionSubgraph): void;
|
|
452
452
|
get_connection_graph(): ConnectionGraph;
|
|
453
|
-
get_item_graphs(): Record<string, ConnectionSubgraph>;
|
|
454
453
|
}
|
|
455
454
|
declare function build_connection_graph(ctx: CONNECTION_GRAPH_BUILDER_CTX): Promise<{
|
|
456
455
|
connection_graph: ConnectionGraph;
|
|
457
|
-
item_graphs: Record<string, ConnectionSubgraph>;
|
|
458
456
|
cg_schematics: Record<string, CG_SCHEMATIC>;
|
|
459
457
|
pin_name_table: Record<string, string>;
|
|
460
458
|
pin_module_name_table: Record<string, string>;
|
|
@@ -465,7 +463,6 @@ declare function graph_ecr(ctx: Omit<ERC_INPUT, 'schematics'> & {
|
|
|
465
463
|
schematics: Record<string, IR_Graph>;
|
|
466
464
|
}): Promise<{
|
|
467
465
|
connection_graph: _modular_circuit_electronics_model.ConnectionGraph;
|
|
468
|
-
item_graphs: Record<string, _modular_circuit_electronics_model.ConnectionSubgraph>;
|
|
469
466
|
cg_schematics: Record<string, CG_SCHEMATIC>;
|
|
470
467
|
pin_name_table: Record<string, string>;
|
|
471
468
|
pin_module_name_table: Record<string, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -445,16 +445,14 @@ declare class ConnectionGraphsBuilder implements CC_Visitor {
|
|
|
445
445
|
private readonly connection_node_map;
|
|
446
446
|
private net_count;
|
|
447
447
|
private connection_graph;
|
|
448
|
-
private
|
|
448
|
+
private bundle_consumed_port_count;
|
|
449
449
|
constructor(connection_node_map: ConnectionNodeMap);
|
|
450
450
|
end_visit_component(cc: string[]): void;
|
|
451
451
|
resolve_net_drive(nodes: ConnectionNode[], sub_graph: ConnectionSubgraph): void;
|
|
452
452
|
get_connection_graph(): ConnectionGraph;
|
|
453
|
-
get_item_graphs(): Record<string, ConnectionSubgraph>;
|
|
454
453
|
}
|
|
455
454
|
declare function build_connection_graph(ctx: CONNECTION_GRAPH_BUILDER_CTX): Promise<{
|
|
456
455
|
connection_graph: ConnectionGraph;
|
|
457
|
-
item_graphs: Record<string, ConnectionSubgraph>;
|
|
458
456
|
cg_schematics: Record<string, CG_SCHEMATIC>;
|
|
459
457
|
pin_name_table: Record<string, string>;
|
|
460
458
|
pin_module_name_table: Record<string, string>;
|
|
@@ -465,7 +463,6 @@ declare function graph_ecr(ctx: Omit<ERC_INPUT, 'schematics'> & {
|
|
|
465
463
|
schematics: Record<string, IR_Graph>;
|
|
466
464
|
}): Promise<{
|
|
467
465
|
connection_graph: _modular_circuit_electronics_model.ConnectionGraph;
|
|
468
|
-
item_graphs: Record<string, _modular_circuit_electronics_model.ConnectionSubgraph>;
|
|
469
466
|
cg_schematics: Record<string, CG_SCHEMATIC>;
|
|
470
467
|
pin_name_table: Record<string, string>;
|
|
471
468
|
pin_module_name_table: Record<string, string>;
|
package/dist/index.js
CHANGED
|
@@ -1598,26 +1598,51 @@ var IR_GRAPH_CONVERTER = class {
|
|
|
1598
1598
|
for (const [sch_name, design] of Object.entries(designs)) {
|
|
1599
1599
|
this.schematics[sch_name] = { uuid: design.uuid ?? (0, import_utils.gen_uuid)(), sheets: [], powers: [] };
|
|
1600
1600
|
for (const block of design.blocks ?? []) {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
const
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
uuid
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1601
|
+
if (!(0, import_ir.block_is_abstract)(block)) {
|
|
1602
|
+
const circuit = this.circuits[(0, import_ir.block_is_associated_with_concrete_module)(block.type) ? block.type : (0, import_utils.fmt_module_name)(block.type)];
|
|
1603
|
+
this.schematics[sch_name].sheets.push({
|
|
1604
|
+
uuid: block.uuid,
|
|
1605
|
+
sheet_name: design.name ?? circuit.name,
|
|
1606
|
+
sheet_file_name: circuit.main,
|
|
1607
|
+
ports: block.ports.map((p) => p.uuid)
|
|
1608
|
+
});
|
|
1609
|
+
const port_map = (0, import_utils.get_circuit_ports)(circuit);
|
|
1610
|
+
for (const port of block.ports) {
|
|
1611
|
+
const param = (0, import_utils.deep_copy)(port_map[port.index]);
|
|
1612
|
+
const uuid = port.uuid;
|
|
1613
|
+
this.add_node(uuid);
|
|
1614
|
+
this.connection_node_map[uuid] = {
|
|
1615
|
+
uuid,
|
|
1616
|
+
type: import_electronics_model8.ConnectionNodeType.Port,
|
|
1617
|
+
param,
|
|
1618
|
+
label_shapes: (0, import_utils.get_port_labels)(param, circuit)
|
|
1619
|
+
};
|
|
1620
|
+
this.reporter_context.pin_module_name_table[port.uuid] = circuit.name;
|
|
1621
|
+
this.reporter_context.pin_name_table[port.uuid] = port.name;
|
|
1622
|
+
}
|
|
1623
|
+
} else {
|
|
1624
|
+
const sheet_name = design.name ?? block.name;
|
|
1625
|
+
this.schematics[sch_name].sheets.push({
|
|
1626
|
+
uuid: block.uuid,
|
|
1627
|
+
sheet_name,
|
|
1628
|
+
sheet_file_name: `${sheet_name}${import_utils.KICAD_SHC_FILE_EXT}`,
|
|
1629
|
+
ports: block.ports.map((p) => p.uuid)
|
|
1630
|
+
});
|
|
1631
|
+
for (const port of block.ports) {
|
|
1632
|
+
const param = port.port;
|
|
1633
|
+
const uuid = port.uuid;
|
|
1634
|
+
this.add_node(uuid);
|
|
1635
|
+
this.connection_node_map[uuid] = {
|
|
1636
|
+
uuid,
|
|
1637
|
+
type: import_electronics_model8.ConnectionNodeType.Port,
|
|
1638
|
+
param: typeof param === "string" ? {
|
|
1639
|
+
type: import_electronics_model8.PortType.Passive,
|
|
1640
|
+
name: port.port
|
|
1641
|
+
} : param
|
|
1642
|
+
};
|
|
1643
|
+
this.reporter_context.pin_module_name_table[port.uuid] = sheet_name;
|
|
1644
|
+
this.reporter_context.pin_name_table[port.uuid] = typeof port.port === "string" ? port.port : port.port.name;
|
|
1645
|
+
}
|
|
1621
1646
|
}
|
|
1622
1647
|
}
|
|
1623
1648
|
const lb_map = {};
|
|
@@ -1715,6 +1740,9 @@ async function get_dependent_modules_definition(ctx) {
|
|
|
1715
1740
|
const circuits = {};
|
|
1716
1741
|
for (const [, v] of Object.entries(ctx.schematics)) {
|
|
1717
1742
|
for (const block of v.blocks ?? []) {
|
|
1743
|
+
if ((0, import_ir2.block_is_abstract)(block)) {
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1718
1746
|
const module_name = (0, import_ir2.block_is_associated_with_concrete_module)(block.type) ? block.type : (0, import_utils2.fmt_module_name)(block.type);
|
|
1719
1747
|
let def;
|
|
1720
1748
|
if ((0, import_ir2.block_is_associated_with_concrete_module)(block.type)) {
|
|
@@ -1738,7 +1766,7 @@ var ConnectionGraphsBuilder = class {
|
|
|
1738
1766
|
constructor(connection_node_map) {
|
|
1739
1767
|
this.connection_node_map = connection_node_map;
|
|
1740
1768
|
this.net_count = 0;
|
|
1741
|
-
this.
|
|
1769
|
+
this.bundle_consumed_port_count = {};
|
|
1742
1770
|
this.connection_graph = {
|
|
1743
1771
|
subgraphs: []
|
|
1744
1772
|
};
|
|
@@ -1748,8 +1776,24 @@ var ConnectionGraphsBuilder = class {
|
|
|
1748
1776
|
sub_graph.is_global_pwr = false;
|
|
1749
1777
|
sub_graph.is_isolated = cc.length < 2;
|
|
1750
1778
|
const nodes = cc.map((id) => {
|
|
1751
|
-
this.
|
|
1752
|
-
|
|
1779
|
+
const node = this.connection_node_map[id];
|
|
1780
|
+
if (node.type === import_electronics_model10.ConnectionNodeType.Port) {
|
|
1781
|
+
const port = node.param;
|
|
1782
|
+
if (port.type === import_electronics_model10.PortType.DigitalBidirBundle) {
|
|
1783
|
+
const consumed_count = id in this.bundle_consumed_port_count ? this.bundle_consumed_port_count[id] : 0;
|
|
1784
|
+
this.bundle_consumed_port_count[id] = consumed_count + 1;
|
|
1785
|
+
const labels = port.labels_associated;
|
|
1786
|
+
return {
|
|
1787
|
+
...node,
|
|
1788
|
+
param: {
|
|
1789
|
+
...node.param,
|
|
1790
|
+
type: import_electronics_model10.PortType.DigitalBidir,
|
|
1791
|
+
label_associated: labels[consumed_count] ?? `${node.param.name}-${consumed_count}`
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return node;
|
|
1753
1797
|
});
|
|
1754
1798
|
sub_graph.nodes = nodes;
|
|
1755
1799
|
this.resolve_net_drive(nodes, sub_graph);
|
|
@@ -1809,9 +1853,6 @@ var ConnectionGraphsBuilder = class {
|
|
|
1809
1853
|
get_connection_graph() {
|
|
1810
1854
|
return this.connection_graph;
|
|
1811
1855
|
}
|
|
1812
|
-
get_item_graphs() {
|
|
1813
|
-
return this.item_graphs;
|
|
1814
|
-
}
|
|
1815
1856
|
};
|
|
1816
1857
|
async function build_connection_graph(ctx) {
|
|
1817
1858
|
const converter = new IR_GRAPH_CONVERTER(await get_dependent_modules_definition(ctx));
|
|
@@ -1822,7 +1863,6 @@ async function build_connection_graph(ctx) {
|
|
|
1822
1863
|
return {
|
|
1823
1864
|
...converter.get_report_context(),
|
|
1824
1865
|
connection_graph: cc_builder.get_connection_graph(),
|
|
1825
|
-
item_graphs: cc_builder.get_item_graphs(),
|
|
1826
1866
|
cg_schematics: converter.get_schematics()
|
|
1827
1867
|
};
|
|
1828
1868
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1535,8 +1535,18 @@ import {
|
|
|
1535
1535
|
import {
|
|
1536
1536
|
PowerShape
|
|
1537
1537
|
} from "@modular-circuit/electronics-model";
|
|
1538
|
-
import {
|
|
1539
|
-
|
|
1538
|
+
import {
|
|
1539
|
+
block_is_abstract,
|
|
1540
|
+
block_is_associated_with_concrete_module
|
|
1541
|
+
} from "@modular-circuit/ir";
|
|
1542
|
+
import {
|
|
1543
|
+
KICAD_SHC_FILE_EXT,
|
|
1544
|
+
deep_copy,
|
|
1545
|
+
fmt_module_name,
|
|
1546
|
+
gen_uuid,
|
|
1547
|
+
get_circuit_ports,
|
|
1548
|
+
get_port_labels
|
|
1549
|
+
} from "@modular-circuit/utils";
|
|
1540
1550
|
var IR_GRAPH_CONVERTER = class {
|
|
1541
1551
|
constructor(circuits) {
|
|
1542
1552
|
this.circuits = circuits;
|
|
@@ -1559,26 +1569,51 @@ var IR_GRAPH_CONVERTER = class {
|
|
|
1559
1569
|
for (const [sch_name, design] of Object.entries(designs)) {
|
|
1560
1570
|
this.schematics[sch_name] = { uuid: design.uuid ?? gen_uuid(), sheets: [], powers: [] };
|
|
1561
1571
|
for (const block of design.blocks ?? []) {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
uuid
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1572
|
+
if (!block_is_abstract(block)) {
|
|
1573
|
+
const circuit = this.circuits[block_is_associated_with_concrete_module(block.type) ? block.type : fmt_module_name(block.type)];
|
|
1574
|
+
this.schematics[sch_name].sheets.push({
|
|
1575
|
+
uuid: block.uuid,
|
|
1576
|
+
sheet_name: design.name ?? circuit.name,
|
|
1577
|
+
sheet_file_name: circuit.main,
|
|
1578
|
+
ports: block.ports.map((p) => p.uuid)
|
|
1579
|
+
});
|
|
1580
|
+
const port_map = get_circuit_ports(circuit);
|
|
1581
|
+
for (const port of block.ports) {
|
|
1582
|
+
const param = deep_copy(port_map[port.index]);
|
|
1583
|
+
const uuid = port.uuid;
|
|
1584
|
+
this.add_node(uuid);
|
|
1585
|
+
this.connection_node_map[uuid] = {
|
|
1586
|
+
uuid,
|
|
1587
|
+
type: ConnectionNodeType3.Port,
|
|
1588
|
+
param,
|
|
1589
|
+
label_shapes: get_port_labels(param, circuit)
|
|
1590
|
+
};
|
|
1591
|
+
this.reporter_context.pin_module_name_table[port.uuid] = circuit.name;
|
|
1592
|
+
this.reporter_context.pin_name_table[port.uuid] = port.name;
|
|
1593
|
+
}
|
|
1594
|
+
} else {
|
|
1595
|
+
const sheet_name = design.name ?? block.name;
|
|
1596
|
+
this.schematics[sch_name].sheets.push({
|
|
1597
|
+
uuid: block.uuid,
|
|
1598
|
+
sheet_name,
|
|
1599
|
+
sheet_file_name: `${sheet_name}${KICAD_SHC_FILE_EXT}`,
|
|
1600
|
+
ports: block.ports.map((p) => p.uuid)
|
|
1601
|
+
});
|
|
1602
|
+
for (const port of block.ports) {
|
|
1603
|
+
const param = port.port;
|
|
1604
|
+
const uuid = port.uuid;
|
|
1605
|
+
this.add_node(uuid);
|
|
1606
|
+
this.connection_node_map[uuid] = {
|
|
1607
|
+
uuid,
|
|
1608
|
+
type: ConnectionNodeType3.Port,
|
|
1609
|
+
param: typeof param === "string" ? {
|
|
1610
|
+
type: PortType3.Passive,
|
|
1611
|
+
name: port.port
|
|
1612
|
+
} : param
|
|
1613
|
+
};
|
|
1614
|
+
this.reporter_context.pin_module_name_table[port.uuid] = sheet_name;
|
|
1615
|
+
this.reporter_context.pin_name_table[port.uuid] = typeof port.port === "string" ? port.port : port.port.name;
|
|
1616
|
+
}
|
|
1582
1617
|
}
|
|
1583
1618
|
}
|
|
1584
1619
|
const lb_map = {};
|
|
@@ -1669,17 +1704,24 @@ var IR_GRAPH_CONVERTER = class {
|
|
|
1669
1704
|
import {
|
|
1670
1705
|
ConnectionNodeType as ConnectionNodeType4,
|
|
1671
1706
|
PRIORITY,
|
|
1707
|
+
PortType as PortType4,
|
|
1672
1708
|
get_connection_node_priority
|
|
1673
1709
|
} from "@modular-circuit/electronics-model";
|
|
1674
1710
|
import { test_connected_components } from "@modular-circuit/utils";
|
|
1675
1711
|
|
|
1676
1712
|
// src/utils/get_dependent_modules_definition.ts
|
|
1677
|
-
import {
|
|
1713
|
+
import {
|
|
1714
|
+
block_is_abstract as block_is_abstract2,
|
|
1715
|
+
block_is_associated_with_concrete_module as block_is_associated_with_concrete_module2
|
|
1716
|
+
} from "@modular-circuit/ir";
|
|
1678
1717
|
import { fmt_module_name as fmt_module_name2 } from "@modular-circuit/utils";
|
|
1679
1718
|
async function get_dependent_modules_definition(ctx) {
|
|
1680
1719
|
const circuits = {};
|
|
1681
1720
|
for (const [, v] of Object.entries(ctx.schematics)) {
|
|
1682
1721
|
for (const block of v.blocks ?? []) {
|
|
1722
|
+
if (block_is_abstract2(block)) {
|
|
1723
|
+
continue;
|
|
1724
|
+
}
|
|
1683
1725
|
const module_name = block_is_associated_with_concrete_module2(block.type) ? block.type : fmt_module_name2(block.type);
|
|
1684
1726
|
let def;
|
|
1685
1727
|
if (block_is_associated_with_concrete_module2(block.type)) {
|
|
@@ -1703,7 +1745,7 @@ var ConnectionGraphsBuilder = class {
|
|
|
1703
1745
|
constructor(connection_node_map) {
|
|
1704
1746
|
this.connection_node_map = connection_node_map;
|
|
1705
1747
|
this.net_count = 0;
|
|
1706
|
-
this.
|
|
1748
|
+
this.bundle_consumed_port_count = {};
|
|
1707
1749
|
this.connection_graph = {
|
|
1708
1750
|
subgraphs: []
|
|
1709
1751
|
};
|
|
@@ -1713,8 +1755,24 @@ var ConnectionGraphsBuilder = class {
|
|
|
1713
1755
|
sub_graph.is_global_pwr = false;
|
|
1714
1756
|
sub_graph.is_isolated = cc.length < 2;
|
|
1715
1757
|
const nodes = cc.map((id) => {
|
|
1716
|
-
this.
|
|
1717
|
-
|
|
1758
|
+
const node = this.connection_node_map[id];
|
|
1759
|
+
if (node.type === ConnectionNodeType4.Port) {
|
|
1760
|
+
const port = node.param;
|
|
1761
|
+
if (port.type === PortType4.DigitalBidirBundle) {
|
|
1762
|
+
const consumed_count = id in this.bundle_consumed_port_count ? this.bundle_consumed_port_count[id] : 0;
|
|
1763
|
+
this.bundle_consumed_port_count[id] = consumed_count + 1;
|
|
1764
|
+
const labels = port.labels_associated;
|
|
1765
|
+
return {
|
|
1766
|
+
...node,
|
|
1767
|
+
param: {
|
|
1768
|
+
...node.param,
|
|
1769
|
+
type: PortType4.DigitalBidir,
|
|
1770
|
+
label_associated: labels[consumed_count] ?? `${node.param.name}-${consumed_count}`
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return node;
|
|
1718
1776
|
});
|
|
1719
1777
|
sub_graph.nodes = nodes;
|
|
1720
1778
|
this.resolve_net_drive(nodes, sub_graph);
|
|
@@ -1774,9 +1832,6 @@ var ConnectionGraphsBuilder = class {
|
|
|
1774
1832
|
get_connection_graph() {
|
|
1775
1833
|
return this.connection_graph;
|
|
1776
1834
|
}
|
|
1777
|
-
get_item_graphs() {
|
|
1778
|
-
return this.item_graphs;
|
|
1779
|
-
}
|
|
1780
1835
|
};
|
|
1781
1836
|
async function build_connection_graph(ctx) {
|
|
1782
1837
|
const converter = new IR_GRAPH_CONVERTER(await get_dependent_modules_definition(ctx));
|
|
@@ -1787,7 +1842,6 @@ async function build_connection_graph(ctx) {
|
|
|
1787
1842
|
return {
|
|
1788
1843
|
...converter.get_report_context(),
|
|
1789
1844
|
connection_graph: cc_builder.get_connection_graph(),
|
|
1790
|
-
item_graphs: cc_builder.get_item_graphs(),
|
|
1791
1845
|
cg_schematics: converter.get_schematics()
|
|
1792
1846
|
};
|
|
1793
1847
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modular-circuit/perc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Programmable Electronic Circuit Check",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"import": "./dist/index.mjs",
|
|
17
|
-
"require": "./dist/index.js"
|
|
18
|
-
"types": "./dist/index.d.ts"
|
|
17
|
+
"require": "./dist/index.js"
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
@@ -27,9 +26,9 @@
|
|
|
27
26
|
"typescript": "^5.4.5"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"@modular-circuit/
|
|
31
|
-
"@modular-circuit/
|
|
32
|
-
"@modular-circuit/
|
|
29
|
+
"@modular-circuit/ir": "0.1.2",
|
|
30
|
+
"@modular-circuit/electronics-model": "0.1.1",
|
|
31
|
+
"@modular-circuit/utils": "0.1.2"
|
|
33
32
|
},
|
|
34
33
|
"scripts": {
|
|
35
34
|
"clean": "rimraf dist",
|