@modular-circuit/perc 0.1.3 → 0.1.5

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _modular_circuit_electronics_model from '@modular-circuit/electronics-model';
2
- import { VECTOR2, BOX2, ELECTRICAL_NODE, ELECTRICAL_PINTYPE, ConnectionSubgraph, ConnectionNodeMap, GS_SCH_SHEET_PATH, ConnectionGraph, CG_SHEET, NL_PowerSymbol, PowerShape, PowerSymbolPort, Connection, ConnectionNode, DigitalBidirBundle } from '@modular-circuit/electronics-model';
2
+ import { VECTOR2, BOX2, ELECTRICAL_NODE, ELECTRICAL_PINTYPE, ConnectionSubgraph, ConnectionNodeMap, GS_SCH_SHEET_PATH, ConnectionGraph, CG_SHEET, NL_PowerSymbol, DigitalBidirBundle, PowerShape, PowerSymbolPort, Connection, ConnectionNode } from '@modular-circuit/electronics-model';
3
3
  import { SCH_ITEM, ModuleResolver, ModuleCircuit, IR_Graph } from '@modular-circuit/ir';
4
4
  import { PowerBase } from '@modular-circuit/ir/build/graph/pwr_base';
5
5
  import { CC_Visitor } from '@modular-circuit/utils';
@@ -431,12 +431,23 @@ interface CG_SCHEMATIC {
431
431
  sheets: CG_SHEET[];
432
432
  powers: NL_PowerSymbol[];
433
433
  }
434
+ interface BundleInfo {
435
+ bundle: DigitalBidirBundle;
436
+ block_name: string;
437
+ circuit?: ModuleCircuit;
438
+ }
434
439
  declare class IR_GRAPH_CONVERTER implements GRAPH_CONVERTER {
435
440
  private readonly circuits;
436
441
  private graph;
437
442
  private connection_node_map;
438
443
  private schematics;
444
+ private bundle_consumed_port_count;
445
+ private bundles;
439
446
  private reporter_context;
447
+ get_bundle_consumed_port_count(): {
448
+ bundle_consumed_port_count: Record<string, number>;
449
+ bundles: Record<string, BundleInfo>;
450
+ };
440
451
  get_report_context(): ERC_REPORTER_CONTEXT;
441
452
  constructor(circuits: Record<string, ModuleCircuit>);
442
453
  convert_to_graph(designs: Record<string, IR_Graph>): true | Error[];
@@ -453,23 +464,17 @@ declare class ConnectionGraphsBuilder implements CC_Visitor {
453
464
  private readonly connection_node_map;
454
465
  private net_count;
455
466
  private connection_graph;
456
- private bundle_consumed_port_count;
457
- private bundles;
458
467
  constructor(connection_node_map: ConnectionNodeMap);
459
468
  end_visit_component(cc: string[]): void;
460
469
  resolve_net_drive(nodes: ConnectionNode[], sub_graph: ConnectionSubgraph): void;
461
470
  get_connection_graph(): ConnectionGraph;
462
- get_bundle_consumed_port_count(): {
463
- bundle_consumed_port_count: Record<string, number>;
464
- bundles: Record<string, DigitalBidirBundle>;
465
- };
466
471
  }
467
472
  declare function build_connection_graph(ctx: CONNECTION_GRAPH_BUILDER_CTX): Promise<{
468
473
  connection_graph: ConnectionGraph;
469
474
  cg_schematics: Record<string, CG_SCHEMATIC>;
470
475
  bundle_consume_status: {
471
476
  bundle_consumed_port_count: Record<string, number>;
472
- bundles: Record<string, DigitalBidirBundle>;
477
+ bundles: Record<string, BundleInfo>;
473
478
  };
474
479
  pin_name_table: Record<string, string>;
475
480
  pin_module_name_table: Record<string, string>;
@@ -484,10 +489,10 @@ declare function graph_ecr(ctx: Omit<ERC_INPUT, 'schematics'> & {
484
489
  cg_schematics: Record<string, CG_SCHEMATIC>;
485
490
  bundle_consume_status: {
486
491
  bundle_consumed_port_count: Record<string, number>;
487
- bundles: Record<string, _modular_circuit_electronics_model.DigitalBidirBundle>;
492
+ bundles: Record<string, BundleInfo>;
488
493
  };
489
494
  pin_name_table: Record<string, string>;
490
495
  pin_module_name_table: Record<string, string>;
491
496
  }>;
492
497
 
493
- export { type ADT_AdjacencyList, type ADT_Graph, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
498
+ export { type ADT_AdjacencyList, type ADT_Graph, type BundleInfo, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _modular_circuit_electronics_model from '@modular-circuit/electronics-model';
2
- import { VECTOR2, BOX2, ELECTRICAL_NODE, ELECTRICAL_PINTYPE, ConnectionSubgraph, ConnectionNodeMap, GS_SCH_SHEET_PATH, ConnectionGraph, CG_SHEET, NL_PowerSymbol, PowerShape, PowerSymbolPort, Connection, ConnectionNode, DigitalBidirBundle } from '@modular-circuit/electronics-model';
2
+ import { VECTOR2, BOX2, ELECTRICAL_NODE, ELECTRICAL_PINTYPE, ConnectionSubgraph, ConnectionNodeMap, GS_SCH_SHEET_PATH, ConnectionGraph, CG_SHEET, NL_PowerSymbol, DigitalBidirBundle, PowerShape, PowerSymbolPort, Connection, ConnectionNode } from '@modular-circuit/electronics-model';
3
3
  import { SCH_ITEM, ModuleResolver, ModuleCircuit, IR_Graph } from '@modular-circuit/ir';
4
4
  import { PowerBase } from '@modular-circuit/ir/build/graph/pwr_base';
5
5
  import { CC_Visitor } from '@modular-circuit/utils';
@@ -431,12 +431,23 @@ interface CG_SCHEMATIC {
431
431
  sheets: CG_SHEET[];
432
432
  powers: NL_PowerSymbol[];
433
433
  }
434
+ interface BundleInfo {
435
+ bundle: DigitalBidirBundle;
436
+ block_name: string;
437
+ circuit?: ModuleCircuit;
438
+ }
434
439
  declare class IR_GRAPH_CONVERTER implements GRAPH_CONVERTER {
435
440
  private readonly circuits;
436
441
  private graph;
437
442
  private connection_node_map;
438
443
  private schematics;
444
+ private bundle_consumed_port_count;
445
+ private bundles;
439
446
  private reporter_context;
447
+ get_bundle_consumed_port_count(): {
448
+ bundle_consumed_port_count: Record<string, number>;
449
+ bundles: Record<string, BundleInfo>;
450
+ };
440
451
  get_report_context(): ERC_REPORTER_CONTEXT;
441
452
  constructor(circuits: Record<string, ModuleCircuit>);
442
453
  convert_to_graph(designs: Record<string, IR_Graph>): true | Error[];
@@ -453,23 +464,17 @@ declare class ConnectionGraphsBuilder implements CC_Visitor {
453
464
  private readonly connection_node_map;
454
465
  private net_count;
455
466
  private connection_graph;
456
- private bundle_consumed_port_count;
457
- private bundles;
458
467
  constructor(connection_node_map: ConnectionNodeMap);
459
468
  end_visit_component(cc: string[]): void;
460
469
  resolve_net_drive(nodes: ConnectionNode[], sub_graph: ConnectionSubgraph): void;
461
470
  get_connection_graph(): ConnectionGraph;
462
- get_bundle_consumed_port_count(): {
463
- bundle_consumed_port_count: Record<string, number>;
464
- bundles: Record<string, DigitalBidirBundle>;
465
- };
466
471
  }
467
472
  declare function build_connection_graph(ctx: CONNECTION_GRAPH_BUILDER_CTX): Promise<{
468
473
  connection_graph: ConnectionGraph;
469
474
  cg_schematics: Record<string, CG_SCHEMATIC>;
470
475
  bundle_consume_status: {
471
476
  bundle_consumed_port_count: Record<string, number>;
472
- bundles: Record<string, DigitalBidirBundle>;
477
+ bundles: Record<string, BundleInfo>;
473
478
  };
474
479
  pin_name_table: Record<string, string>;
475
480
  pin_module_name_table: Record<string, string>;
@@ -484,10 +489,10 @@ declare function graph_ecr(ctx: Omit<ERC_INPUT, 'schematics'> & {
484
489
  cg_schematics: Record<string, CG_SCHEMATIC>;
485
490
  bundle_consume_status: {
486
491
  bundle_consumed_port_count: Record<string, number>;
487
- bundles: Record<string, _modular_circuit_electronics_model.DigitalBidirBundle>;
492
+ bundles: Record<string, BundleInfo>;
488
493
  };
489
494
  pin_name_table: Record<string, string>;
490
495
  pin_module_name_table: Record<string, string>;
491
496
  }>;
492
497
 
493
- export { type ADT_AdjacencyList, type ADT_Graph, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
498
+ export { type ADT_AdjacencyList, type ADT_Graph, type BundleInfo, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
package/dist/index.js CHANGED
@@ -1589,11 +1589,19 @@ var IR_GRAPH_CONVERTER = class {
1589
1589
  this.graph = {};
1590
1590
  this.connection_node_map = {};
1591
1591
  this.schematics = {};
1592
+ this.bundle_consumed_port_count = {};
1593
+ this.bundles = {};
1592
1594
  this.reporter_context = {
1593
1595
  pin_name_table: {},
1594
1596
  pin_module_name_table: {}
1595
1597
  };
1596
1598
  }
1599
+ get_bundle_consumed_port_count() {
1600
+ return {
1601
+ bundle_consumed_port_count: this.bundle_consumed_port_count,
1602
+ bundles: this.bundles
1603
+ };
1604
+ }
1597
1605
  get_report_context() {
1598
1606
  return this.reporter_context;
1599
1607
  }
@@ -1602,6 +1610,12 @@ var IR_GRAPH_CONVERTER = class {
1602
1610
  if (Object.keys(designs).length > 1) {
1603
1611
  throw new Error("Multiple designs are not supported");
1604
1612
  }
1613
+ const handle_graph_node = (uuid, port_block_name, port_name, port) => {
1614
+ this.add_node(uuid);
1615
+ this.connection_node_map[uuid] = port;
1616
+ this.reporter_context.pin_module_name_table[port.uuid] = port_block_name;
1617
+ this.reporter_context.pin_name_table[port.uuid] = port_name;
1618
+ };
1605
1619
  for (const [sch_name, design] of Object.entries(designs)) {
1606
1620
  this.schematics[sch_name] = { uuid: design.uuid ?? (0, import_utils.gen_uuid)(), sheets: [], powers: [] };
1607
1621
  for (const block of design.blocks ?? []) {
@@ -1609,7 +1623,7 @@ var IR_GRAPH_CONVERTER = class {
1609
1623
  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)];
1610
1624
  this.schematics[sch_name].sheets.push({
1611
1625
  uuid: block.uuid,
1612
- sheet_name: design.name ?? circuit.name,
1626
+ sheet_name: circuit.name,
1613
1627
  sheet_file_name: circuit.main,
1614
1628
  ports: block.ports.map((p) => p.uuid)
1615
1629
  });
@@ -1624,38 +1638,47 @@ var IR_GRAPH_CONVERTER = class {
1624
1638
  };
1625
1639
  }
1626
1640
  const uuid = port.uuid;
1627
- this.add_node(uuid);
1628
- this.connection_node_map[uuid] = {
1641
+ if (param.type === import_electronics_model8.PortType.DigitalBidirBundle) {
1642
+ this.bundles[uuid] = {
1643
+ bundle: param,
1644
+ block_name: circuit.name,
1645
+ circuit
1646
+ };
1647
+ continue;
1648
+ }
1649
+ handle_graph_node(uuid, circuit.name, port.name, {
1629
1650
  uuid,
1630
1651
  type: import_electronics_model8.ConnectionNodeType.Port,
1631
1652
  param,
1632
1653
  label_shapes: (0, import_utils.get_port_labels)(param, circuit)
1633
- };
1634
- this.reporter_context.pin_module_name_table[port.uuid] = circuit.name;
1635
- this.reporter_context.pin_name_table[port.uuid] = port.name;
1654
+ });
1636
1655
  }
1637
1656
  } else {
1638
- const sheet_name = design.name ?? block.name;
1657
+ const sheet_name = block.name;
1639
1658
  this.schematics[sch_name].sheets.push({
1640
1659
  uuid: block.uuid,
1641
1660
  sheet_name,
1642
- sheet_file_name: `${sheet_name}${import_utils.KICAD_SHC_FILE_EXT}`,
1661
+ sheet_file_name: `${sheet_name}.${import_utils.KiCadSchematicFileExtension}`,
1643
1662
  ports: block.ports.map((p) => p.uuid)
1644
1663
  });
1645
1664
  for (const port of block.ports) {
1646
1665
  const param = port.port;
1647
1666
  const uuid = port.uuid;
1648
- this.add_node(uuid);
1649
- this.connection_node_map[uuid] = {
1667
+ if (typeof port.port !== "string" && port.port.type === import_electronics_model8.PortType.DigitalBidirBundle) {
1668
+ this.bundles[uuid] = {
1669
+ bundle: port.port,
1670
+ block_name: sheet_name
1671
+ };
1672
+ continue;
1673
+ }
1674
+ handle_graph_node(uuid, sheet_name, typeof port.port === "string" ? port.port : port.port.name, {
1650
1675
  uuid,
1651
1676
  type: import_electronics_model8.ConnectionNodeType.Port,
1652
1677
  param: typeof param === "string" ? {
1653
1678
  type: import_electronics_model8.PortType.Passive,
1654
1679
  name: port.port
1655
1680
  } : param
1656
- };
1657
- this.reporter_context.pin_module_name_table[port.uuid] = sheet_name;
1658
- this.reporter_context.pin_name_table[port.uuid] = typeof port.port === "string" ? port.port : port.port.name;
1681
+ });
1659
1682
  }
1660
1683
  }
1661
1684
  }
@@ -1701,10 +1724,47 @@ var IR_GRAPH_CONVERTER = class {
1701
1724
  this.add_node(uuid);
1702
1725
  this.connection_node_map[uuid] = { uuid, type: import_electronics_model8.ConnectionNodeType.Graphics };
1703
1726
  }
1704
- for (const connection of design.wires ?? []) {
1705
- const uuid = connection.uuid;
1706
- this.add_connection(connection.from, connection.to);
1707
- this.connection_node_map[uuid] = { uuid, type: import_electronics_model8.ConnectionNodeType.Graphics };
1727
+ const handel_wire_instance = (abstract_or_actual_wire, actual_wire_id) => {
1728
+ this.add_connection(abstract_or_actual_wire.from, abstract_or_actual_wire.to);
1729
+ this.connection_node_map[abstract_or_actual_wire.uuid] = {
1730
+ uuid: actual_wire_id,
1731
+ type: import_electronics_model8.ConnectionNodeType.Graphics
1732
+ };
1733
+ };
1734
+ const handel_bundle_connection = (bundle_id) => {
1735
+ const uuid = (0, import_utils.gen_uuid)();
1736
+ const bundle_info = this.bundles[bundle_id];
1737
+ const consumed_count = bundle_id in this.bundle_consumed_port_count ? this.bundle_consumed_port_count[bundle_id] : 0;
1738
+ this.bundle_consumed_port_count[bundle_id] = consumed_count + 1;
1739
+ let labels_shapes = void 0;
1740
+ if (bundle_info.circuit) labels_shapes = (0, import_utils.get_port_labels)(bundle_info.bundle, bundle_info.circuit);
1741
+ const label = bundle_info.bundle.labels_associated[consumed_count] ?? `${bundle_info.bundle.name}-${consumed_count}`;
1742
+ const label_shape = labels_shapes?.[label];
1743
+ handle_graph_node(uuid, bundle_info.block_name, bundle_info.bundle.name, {
1744
+ type: import_electronics_model8.ConnectionNodeType.Port,
1745
+ label_shapes: label_shape ? { [label]: label_shape } : void 0,
1746
+ param: {
1747
+ ...{
1748
+ ...bundle_info.bundle,
1749
+ labels_associated: void 0,
1750
+ type: import_electronics_model8.PortType.DigitalBidir,
1751
+ label_associated: label
1752
+ }
1753
+ },
1754
+ uuid
1755
+ });
1756
+ return uuid;
1757
+ };
1758
+ for (const actual_wire of design.wires ?? []) {
1759
+ const actual_wire_id = actual_wire.uuid;
1760
+ const connection = { ...actual_wire };
1761
+ if (connection.from in this.bundles) {
1762
+ connection.from = handel_bundle_connection(connection.from);
1763
+ }
1764
+ if (connection.to in this.bundles) {
1765
+ connection.to = handel_bundle_connection(connection.to);
1766
+ }
1767
+ handel_wire_instance(connection, actual_wire_id);
1708
1768
  }
1709
1769
  }
1710
1770
  return errors.length ? errors : true;
@@ -1780,8 +1840,6 @@ var ConnectionGraphsBuilder = class {
1780
1840
  constructor(connection_node_map) {
1781
1841
  this.connection_node_map = connection_node_map;
1782
1842
  this.net_count = 0;
1783
- this.bundle_consumed_port_count = {};
1784
- this.bundles = {};
1785
1843
  this.connection_graph = {
1786
1844
  subgraphs: []
1787
1845
  };
@@ -1790,27 +1848,7 @@ var ConnectionGraphsBuilder = class {
1790
1848
  const sub_graph = {};
1791
1849
  sub_graph.is_global_pwr = false;
1792
1850
  sub_graph.is_isolated = cc.length < 2;
1793
- const nodes = cc.map((id) => {
1794
- const node = this.connection_node_map[id];
1795
- if (node?.type === import_electronics_model10.ConnectionNodeType.Port) {
1796
- const port = node.param;
1797
- if (port.type === import_electronics_model10.PortType.DigitalBidirBundle) {
1798
- const consumed_count = id in this.bundle_consumed_port_count ? this.bundle_consumed_port_count[id] : 0;
1799
- this.bundle_consumed_port_count[id] = consumed_count + 1;
1800
- this.bundles[id] = port;
1801
- const labels = port.labels_associated;
1802
- return {
1803
- ...node,
1804
- param: {
1805
- ...node.param,
1806
- type: import_electronics_model10.PortType.DigitalBidir,
1807
- label_associated: labels[consumed_count] ?? `${node.param.name}-${consumed_count}`
1808
- }
1809
- };
1810
- }
1811
- }
1812
- return node;
1813
- });
1851
+ const nodes = cc.map((id) => this.connection_node_map[id]);
1814
1852
  sub_graph.nodes = nodes;
1815
1853
  this.resolve_net_drive(nodes, sub_graph);
1816
1854
  this.connection_graph.subgraphs.push(sub_graph);
@@ -1869,12 +1907,6 @@ var ConnectionGraphsBuilder = class {
1869
1907
  get_connection_graph() {
1870
1908
  return this.connection_graph;
1871
1909
  }
1872
- get_bundle_consumed_port_count() {
1873
- return {
1874
- bundle_consumed_port_count: this.bundle_consumed_port_count,
1875
- bundles: this.bundles
1876
- };
1877
- }
1878
1910
  };
1879
1911
  async function build_connection_graph(ctx) {
1880
1912
  const converter = new IR_GRAPH_CONVERTER(await get_dependent_modules_definition(ctx));
@@ -1886,7 +1918,7 @@ async function build_connection_graph(ctx) {
1886
1918
  ...converter.get_report_context(),
1887
1919
  connection_graph: cc_builder.get_connection_graph(),
1888
1920
  cg_schematics: converter.get_schematics(),
1889
- bundle_consume_status: cc_builder.get_bundle_consumed_port_count()
1921
+ bundle_consume_status: converter.get_bundle_consumed_port_count()
1890
1922
  };
1891
1923
  }
1892
1924
 
@@ -1898,7 +1930,8 @@ async function graph_ecr(ctx) {
1898
1930
  };
1899
1931
  const connection_graph = await build_connection_graph(ctx);
1900
1932
  for (const [port_id, count] of Object.entries(connection_graph.bundle_consume_status.bundle_consumed_port_count)) {
1901
- const bundle = connection_graph.bundle_consume_status.bundles[port_id];
1933
+ const bundle_info = connection_graph.bundle_consume_status.bundles[port_id];
1934
+ const bundle = bundle_info.bundle;
1902
1935
  if (Array.isArray(bundle.labels_associated) && count > bundle.labels_associated.length) {
1903
1936
  erc_report.erc_errors.push(CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT(port_id));
1904
1937
  } else {
package/dist/index.mjs CHANGED
@@ -1546,12 +1546,12 @@ import {
1546
1546
  block_is_associated_with_concrete_module
1547
1547
  } from "@modular-circuit/ir";
1548
1548
  import {
1549
- KICAD_SHC_FILE_EXT,
1550
1549
  deep_copy,
1551
1550
  fmt_module_name,
1552
1551
  gen_uuid,
1553
1552
  get_circuit_ports,
1554
- get_port_labels
1553
+ get_port_labels,
1554
+ KiCadSchematicFileExtension
1555
1555
  } from "@modular-circuit/utils";
1556
1556
  var IR_GRAPH_CONVERTER = class {
1557
1557
  constructor(circuits) {
@@ -1559,11 +1559,19 @@ var IR_GRAPH_CONVERTER = class {
1559
1559
  this.graph = {};
1560
1560
  this.connection_node_map = {};
1561
1561
  this.schematics = {};
1562
+ this.bundle_consumed_port_count = {};
1563
+ this.bundles = {};
1562
1564
  this.reporter_context = {
1563
1565
  pin_name_table: {},
1564
1566
  pin_module_name_table: {}
1565
1567
  };
1566
1568
  }
1569
+ get_bundle_consumed_port_count() {
1570
+ return {
1571
+ bundle_consumed_port_count: this.bundle_consumed_port_count,
1572
+ bundles: this.bundles
1573
+ };
1574
+ }
1567
1575
  get_report_context() {
1568
1576
  return this.reporter_context;
1569
1577
  }
@@ -1572,6 +1580,12 @@ var IR_GRAPH_CONVERTER = class {
1572
1580
  if (Object.keys(designs).length > 1) {
1573
1581
  throw new Error("Multiple designs are not supported");
1574
1582
  }
1583
+ const handle_graph_node = (uuid, port_block_name, port_name, port) => {
1584
+ this.add_node(uuid);
1585
+ this.connection_node_map[uuid] = port;
1586
+ this.reporter_context.pin_module_name_table[port.uuid] = port_block_name;
1587
+ this.reporter_context.pin_name_table[port.uuid] = port_name;
1588
+ };
1575
1589
  for (const [sch_name, design] of Object.entries(designs)) {
1576
1590
  this.schematics[sch_name] = { uuid: design.uuid ?? gen_uuid(), sheets: [], powers: [] };
1577
1591
  for (const block of design.blocks ?? []) {
@@ -1579,7 +1593,7 @@ var IR_GRAPH_CONVERTER = class {
1579
1593
  const circuit = this.circuits[block_is_associated_with_concrete_module(block.type) ? block.type : fmt_module_name(block.type)];
1580
1594
  this.schematics[sch_name].sheets.push({
1581
1595
  uuid: block.uuid,
1582
- sheet_name: design.name ?? circuit.name,
1596
+ sheet_name: circuit.name,
1583
1597
  sheet_file_name: circuit.main,
1584
1598
  ports: block.ports.map((p) => p.uuid)
1585
1599
  });
@@ -1594,38 +1608,47 @@ var IR_GRAPH_CONVERTER = class {
1594
1608
  };
1595
1609
  }
1596
1610
  const uuid = port.uuid;
1597
- this.add_node(uuid);
1598
- this.connection_node_map[uuid] = {
1611
+ if (param.type === PortType3.DigitalBidirBundle) {
1612
+ this.bundles[uuid] = {
1613
+ bundle: param,
1614
+ block_name: circuit.name,
1615
+ circuit
1616
+ };
1617
+ continue;
1618
+ }
1619
+ handle_graph_node(uuid, circuit.name, port.name, {
1599
1620
  uuid,
1600
1621
  type: ConnectionNodeType3.Port,
1601
1622
  param,
1602
1623
  label_shapes: get_port_labels(param, circuit)
1603
- };
1604
- this.reporter_context.pin_module_name_table[port.uuid] = circuit.name;
1605
- this.reporter_context.pin_name_table[port.uuid] = port.name;
1624
+ });
1606
1625
  }
1607
1626
  } else {
1608
- const sheet_name = design.name ?? block.name;
1627
+ const sheet_name = block.name;
1609
1628
  this.schematics[sch_name].sheets.push({
1610
1629
  uuid: block.uuid,
1611
1630
  sheet_name,
1612
- sheet_file_name: `${sheet_name}${KICAD_SHC_FILE_EXT}`,
1631
+ sheet_file_name: `${sheet_name}.${KiCadSchematicFileExtension}`,
1613
1632
  ports: block.ports.map((p) => p.uuid)
1614
1633
  });
1615
1634
  for (const port of block.ports) {
1616
1635
  const param = port.port;
1617
1636
  const uuid = port.uuid;
1618
- this.add_node(uuid);
1619
- this.connection_node_map[uuid] = {
1637
+ if (typeof port.port !== "string" && port.port.type === PortType3.DigitalBidirBundle) {
1638
+ this.bundles[uuid] = {
1639
+ bundle: port.port,
1640
+ block_name: sheet_name
1641
+ };
1642
+ continue;
1643
+ }
1644
+ handle_graph_node(uuid, sheet_name, typeof port.port === "string" ? port.port : port.port.name, {
1620
1645
  uuid,
1621
1646
  type: ConnectionNodeType3.Port,
1622
1647
  param: typeof param === "string" ? {
1623
1648
  type: PortType3.Passive,
1624
1649
  name: port.port
1625
1650
  } : param
1626
- };
1627
- this.reporter_context.pin_module_name_table[port.uuid] = sheet_name;
1628
- this.reporter_context.pin_name_table[port.uuid] = typeof port.port === "string" ? port.port : port.port.name;
1651
+ });
1629
1652
  }
1630
1653
  }
1631
1654
  }
@@ -1671,10 +1694,47 @@ var IR_GRAPH_CONVERTER = class {
1671
1694
  this.add_node(uuid);
1672
1695
  this.connection_node_map[uuid] = { uuid, type: ConnectionNodeType3.Graphics };
1673
1696
  }
1674
- for (const connection of design.wires ?? []) {
1675
- const uuid = connection.uuid;
1676
- this.add_connection(connection.from, connection.to);
1677
- this.connection_node_map[uuid] = { uuid, type: ConnectionNodeType3.Graphics };
1697
+ const handel_wire_instance = (abstract_or_actual_wire, actual_wire_id) => {
1698
+ this.add_connection(abstract_or_actual_wire.from, abstract_or_actual_wire.to);
1699
+ this.connection_node_map[abstract_or_actual_wire.uuid] = {
1700
+ uuid: actual_wire_id,
1701
+ type: ConnectionNodeType3.Graphics
1702
+ };
1703
+ };
1704
+ const handel_bundle_connection = (bundle_id) => {
1705
+ const uuid = gen_uuid();
1706
+ const bundle_info = this.bundles[bundle_id];
1707
+ const consumed_count = bundle_id in this.bundle_consumed_port_count ? this.bundle_consumed_port_count[bundle_id] : 0;
1708
+ this.bundle_consumed_port_count[bundle_id] = consumed_count + 1;
1709
+ let labels_shapes = void 0;
1710
+ if (bundle_info.circuit) labels_shapes = get_port_labels(bundle_info.bundle, bundle_info.circuit);
1711
+ const label = bundle_info.bundle.labels_associated[consumed_count] ?? `${bundle_info.bundle.name}-${consumed_count}`;
1712
+ const label_shape = labels_shapes?.[label];
1713
+ handle_graph_node(uuid, bundle_info.block_name, bundle_info.bundle.name, {
1714
+ type: ConnectionNodeType3.Port,
1715
+ label_shapes: label_shape ? { [label]: label_shape } : void 0,
1716
+ param: {
1717
+ ...{
1718
+ ...bundle_info.bundle,
1719
+ labels_associated: void 0,
1720
+ type: PortType3.DigitalBidir,
1721
+ label_associated: label
1722
+ }
1723
+ },
1724
+ uuid
1725
+ });
1726
+ return uuid;
1727
+ };
1728
+ for (const actual_wire of design.wires ?? []) {
1729
+ const actual_wire_id = actual_wire.uuid;
1730
+ const connection = { ...actual_wire };
1731
+ if (connection.from in this.bundles) {
1732
+ connection.from = handel_bundle_connection(connection.from);
1733
+ }
1734
+ if (connection.to in this.bundles) {
1735
+ connection.to = handel_bundle_connection(connection.to);
1736
+ }
1737
+ handel_wire_instance(connection, actual_wire_id);
1678
1738
  }
1679
1739
  }
1680
1740
  return errors.length ? errors : true;
@@ -1717,7 +1777,6 @@ var IR_GRAPH_CONVERTER = class {
1717
1777
  import {
1718
1778
  ConnectionNodeType as ConnectionNodeType4,
1719
1779
  PRIORITY,
1720
- PortType as PortType4,
1721
1780
  get_connection_node_priority
1722
1781
  } from "@modular-circuit/electronics-model";
1723
1782
  import { test_connected_components } from "@modular-circuit/utils";
@@ -1758,8 +1817,6 @@ var ConnectionGraphsBuilder = class {
1758
1817
  constructor(connection_node_map) {
1759
1818
  this.connection_node_map = connection_node_map;
1760
1819
  this.net_count = 0;
1761
- this.bundle_consumed_port_count = {};
1762
- this.bundles = {};
1763
1820
  this.connection_graph = {
1764
1821
  subgraphs: []
1765
1822
  };
@@ -1768,27 +1825,7 @@ var ConnectionGraphsBuilder = class {
1768
1825
  const sub_graph = {};
1769
1826
  sub_graph.is_global_pwr = false;
1770
1827
  sub_graph.is_isolated = cc.length < 2;
1771
- const nodes = cc.map((id) => {
1772
- const node = this.connection_node_map[id];
1773
- if (node?.type === ConnectionNodeType4.Port) {
1774
- const port = node.param;
1775
- if (port.type === PortType4.DigitalBidirBundle) {
1776
- const consumed_count = id in this.bundle_consumed_port_count ? this.bundle_consumed_port_count[id] : 0;
1777
- this.bundle_consumed_port_count[id] = consumed_count + 1;
1778
- this.bundles[id] = port;
1779
- const labels = port.labels_associated;
1780
- return {
1781
- ...node,
1782
- param: {
1783
- ...node.param,
1784
- type: PortType4.DigitalBidir,
1785
- label_associated: labels[consumed_count] ?? `${node.param.name}-${consumed_count}`
1786
- }
1787
- };
1788
- }
1789
- }
1790
- return node;
1791
- });
1828
+ const nodes = cc.map((id) => this.connection_node_map[id]);
1792
1829
  sub_graph.nodes = nodes;
1793
1830
  this.resolve_net_drive(nodes, sub_graph);
1794
1831
  this.connection_graph.subgraphs.push(sub_graph);
@@ -1847,12 +1884,6 @@ var ConnectionGraphsBuilder = class {
1847
1884
  get_connection_graph() {
1848
1885
  return this.connection_graph;
1849
1886
  }
1850
- get_bundle_consumed_port_count() {
1851
- return {
1852
- bundle_consumed_port_count: this.bundle_consumed_port_count,
1853
- bundles: this.bundles
1854
- };
1855
- }
1856
1887
  };
1857
1888
  async function build_connection_graph(ctx) {
1858
1889
  const converter = new IR_GRAPH_CONVERTER(await get_dependent_modules_definition(ctx));
@@ -1864,7 +1895,7 @@ async function build_connection_graph(ctx) {
1864
1895
  ...converter.get_report_context(),
1865
1896
  connection_graph: cc_builder.get_connection_graph(),
1866
1897
  cg_schematics: converter.get_schematics(),
1867
- bundle_consume_status: cc_builder.get_bundle_consumed_port_count()
1898
+ bundle_consume_status: converter.get_bundle_consumed_port_count()
1868
1899
  };
1869
1900
  }
1870
1901
 
@@ -1876,7 +1907,8 @@ async function graph_ecr(ctx) {
1876
1907
  };
1877
1908
  const connection_graph = await build_connection_graph(ctx);
1878
1909
  for (const [port_id, count] of Object.entries(connection_graph.bundle_consume_status.bundle_consumed_port_count)) {
1879
- const bundle = connection_graph.bundle_consume_status.bundles[port_id];
1910
+ const bundle_info = connection_graph.bundle_consume_status.bundles[port_id];
1911
+ const bundle = bundle_info.bundle;
1880
1912
  if (Array.isArray(bundle.labels_associated) && count > bundle.labels_associated.length) {
1881
1913
  erc_report.erc_errors.push(CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT(port_id));
1882
1914
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/perc",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Programmable Electronic Circuit Check",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@modular-circuit/electronics-model": "0.1.1",
30
- "@modular-circuit/ir": "0.1.2",
31
- "@modular-circuit/utils": "0.1.2"
30
+ "@modular-circuit/ir": "0.1.5",
31
+ "@modular-circuit/utils": "0.1.5"
32
32
  },
33
33
  "scripts": {
34
34
  "clean": "rimraf dist",