kpex 0.12.0__py3-none-any.whl
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.
- kpex/__init__.py +23 -0
- kpex/__main__.py +36 -0
- kpex/calibration/__init__.py +25 -0
- kpex/calibration/artifacts.py +135 -0
- kpex/calibration/cli.py +90 -0
- kpex/calibration/collect.py +266 -0
- kpex/calibration/patterns.py +194 -0
- kpex/calibration/prepare.py +241 -0
- kpex/calibration/prepared_input.py +144 -0
- kpex/calibration/solve.py +354 -0
- kpex/calibration/solve_cli.py +126 -0
- kpex/calibration/targets.py +185 -0
- kpex/calibration/validation.py +36 -0
- kpex/common/__init__.py +23 -0
- kpex/common/capacitance_matrix.py +111 -0
- kpex/common/path_validation.py +74 -0
- kpex/device_models.py +280 -0
- kpex/device_totals.py +135 -0
- kpex/env.py +113 -0
- kpex/extraction_engine.py +33 -0
- kpex/fastcap/__init__.py +23 -0
- kpex/fastcap/fastcap_runner.py +144 -0
- kpex/fastcap/output_interpreter.py +30 -0
- kpex/fastercap/__init__.py +23 -0
- kpex/fastercap/fastercap_error.py +52 -0
- kpex/fastercap/fastercap_input_builder.py +111 -0
- kpex/fastercap/fastercap_model_generator.py +1090 -0
- kpex/fastercap/fastercap_runner.py +321 -0
- kpex/fastercap/numerical_report.py +135 -0
- kpex/fastercap/output_interpreter.py +30 -0
- kpex/fastercap/pex25d_exporter.py +165 -0
- kpex/fastercap/pex25d_model_builder.py +322 -0
- kpex/fastercap/result_collection.py +67 -0
- kpex/klayout/__init__.py +38 -0
- kpex/klayout/capacitance_matrix_interpreter.py +37 -0
- kpex/klayout/lvs_cache.py +218 -0
- kpex/klayout/lvs_runner.py +178 -0
- kpex/klayout/lvsdb_extractor.py +1171 -0
- kpex/klayout/native_coordinates.py +38 -0
- kpex/klayout/netlist_csv.py +59 -0
- kpex/klayout/netlist_expander.py +214 -0
- kpex/klayout/netlist_printer.py +158 -0
- kpex/klayout/netlist_reducer.py +66 -0
- kpex/klayout/output_files.py +49 -0
- kpex/klayout/parasitic_device_classes.py +34 -0
- kpex/klayout/pex25d_accounting.py +230 -0
- kpex/klayout/pex25d_builder.py +633 -0
- kpex/klayout/pex25d_exclusions.py +154 -0
- kpex/klayout/pex25d_ground.py +119 -0
- kpex/klayout/pex25d_stack.py +698 -0
- kpex/klayout/physical_geometry.py +219 -0
- kpex/klayout/repair_rdb.py +137 -0
- kpex/klayout/rex_core.py +56 -0
- kpex/klayout/shapes_pb2_converter.py +121 -0
- kpex/kpex_cli.py +2417 -0
- kpex/log/__init__.py +45 -0
- kpex/log/logger.py +187 -0
- kpex/magic/__init__.py +23 -0
- kpex/magic/magic_ext_data_structures.py +128 -0
- kpex/magic/magic_ext_file_parser.py +155 -0
- kpex/magic/magic_log_analyzer.py +221 -0
- kpex/magic/magic_runner.py +212 -0
- kpex/netlist/__init__.py +23 -0
- kpex/netlist/__main__.py +36 -0
- kpex/netlist/admittance_check.py +387 -0
- kpex/netlist/coupling.py +152 -0
- kpex/netlist/expression/__init__.py +23 -0
- kpex/netlist/expression/ngspice.py +107 -0
- kpex/netlist/expression/nodes.py +234 -0
- kpex/netlist/expression/parser.py +201 -0
- kpex/netlist/expression/scope.py +86 -0
- kpex/netlist/expression/syntax.py +81 -0
- kpex/netlist/ground_subcommand.py +124 -0
- kpex/netlist/netlist_cli.py +307 -0
- kpex/netlist/netlist_convert.py +145 -0
- kpex/netlist/netlist_format.py +42 -0
- kpex/netlist/netlist_grounding.py +254 -0
- kpex/netlist/netlist_reduction.py +204 -0
- kpex/netlist/rc_network.py +229 -0
- kpex/netlist/rc_reduction.py +343 -0
- kpex/netlist/reduce_subcommand.py +259 -0
- kpex/netlist/spice_hierarchy.py +219 -0
- kpex/netlist/spice_netlist.py +122 -0
- kpex/netlist/spice_rc_netlist.py +358 -0
- kpex/netlist/spice_reader.py +484 -0
- kpex/netlist/spice_syntax.py +219 -0
- kpex/netlist/vacask_writer.py +585 -0
- kpex/netlistsvg/analog_skin.svg +332 -0
- kpex/netlistsvg/analog_skin.svg.license +23 -0
- kpex/netlistsvg/netlist_json.py +178 -0
- kpex/netlistsvg/netlistsvg_runner.py +101 -0
- kpex/openrcx/__init__.py +25 -0
- kpex/openrcx/pex25d_importer.py +545 -0
- kpex/pdk/__init__.py +23 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/gf180mcu.lvs +547 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/gf180mcu.lyp +2008 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/gf180mcu.lyt +233 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/auto_name_layers.rb +29 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/bjt_connections.lvs +80 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/bjt_derivations.lvs +104 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/bjt_extraction.lvs +145 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/custom_classes.lvs +151 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/custom_schottky_extractor.lvs +60 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/devices_connections.lvs +65 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/diode_extraction.lvs +237 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/efuse_connections.lvs +26 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/efuse_derivations.lvs +28 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/efuse_extraction.lvs +27 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/general_connections.lvs +95 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/general_derivations.lvs +126 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/layers_definitions.lvs +642 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mimcap_connections.lvs +40 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mimcap_derivations.lvs +37 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mimcap_extraction.lvs +42 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mos_connections.lvs +28 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mos_derivations.lvs +125 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mos_extraction.lvs +160 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mos_sab_derivations.lvs +87 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/mos_sab_extraction.lvs +141 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/moscap_derivations.lvs +66 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/moscap_extraction.lvs +106 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/res_connections.lvs +27 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/res_derivations.lvs +197 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/res_extraction.lvs +375 -0
- kpex/pdk/gf180mcuD/libs.tech/kpex/rule_decks/substrate_connections.lvs +32 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/auto_name_layers.rb +29 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/bjt_connections.lvs +69 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/bjt_derivations.lvs +124 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/bjt_extraction.lvs +87 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_cmomf_connections.lvs +40 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_cmomf_derivations.lvs +64 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_cmomi_connections.lvs +37 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_cmomi_derivations.lvs +57 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_connections.lvs +58 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_derivations.lvs +117 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_extraction.lvs +128 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cap_svaricap_cmos5l.lvs +48 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/cmos5l_forbidden_check.lvs +95 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_bjt_extractor.lvs +221 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_classes.lvs +58 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_combiner.lvs +230 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_devices.lvs +264 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_extractor.lvs +457 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_isolbox_extractor.lvs +99 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_mim_extractor.lvs +285 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_mom_extractor.lvs +244 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_moscap_extractor.lvs +139 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_reader.lvs +676 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/custom_writer.lvs +131 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/devices_connections.lvs +86 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/diode_connections.lvs +46 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/diode_derivations.lvs +86 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/diode_extraction.lvs +48 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/esd_connections.lvs +108 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/esd_derivations.lvs +149 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/esd_extraction.lvs +116 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/general_connections.lvs +66 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/general_derivations.lvs +122 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/globals.lvs +115 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/ind_connections.lvs +39 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/ind_derivations.lvs +81 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/ind_extraction.lvs +44 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/layers_definitions.lvs +1570 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/mos_connections.lvs +24 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/mos_derivations.lvs +94 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/mos_extraction.lvs +77 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/res_connections.lvs +45 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/res_derivations.lvs +81 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/res_extraction.lvs +99 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/rfmos_connections.lvs +24 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/rfmos_derivations.lvs +47 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/rfmos_extraction.lvs +80 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/sram_integration.lvs +53 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/tap_connections.lvs +41 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/tap_derivations.lvs +51 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/rule_decks/tap_extraction.lvs +54 -0
- kpex/pdk/ihp-sg13cmos5l/libs.tech/kpex/sg13cmos5l.lvs +735 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/auto_name_layers.rb +29 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/bjt_connections.lvs +69 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/bjt_derivations.lvs +123 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/bjt_extraction.lvs +87 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_cmomf_connections.lvs +40 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_cmomf_derivations.lvs +64 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_cmomi_connections.lvs +37 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_cmomi_derivations.lvs +57 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_connections.lvs +58 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_derivations.lvs +117 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/cap_extraction.lvs +128 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_bjt_extractor.lvs +221 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_classes.lvs +58 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_combiner.lvs +230 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_devices.lvs +264 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_extractor.lvs +457 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_isolbox_extractor.lvs +99 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_mim_extractor.lvs +285 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_mom_extractor.lvs +244 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_moscap_extractor.lvs +139 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_reader.lvs +676 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/custom_writer.lvs +131 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/devices_connections.lvs +86 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/diode_connections.lvs +46 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/diode_derivations.lvs +86 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/diode_extraction.lvs +48 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/esd_connections.lvs +108 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/esd_derivations.lvs +147 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/esd_extraction.lvs +116 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/general_connections.lvs +65 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/general_derivations.lvs +122 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/globals.lvs +115 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/ind_connections.lvs +39 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/ind_derivations.lvs +81 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/ind_extraction.lvs +44 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/layers_definitions.lvs +1570 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/mos_connections.lvs +24 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/mos_derivations.lvs +94 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/mos_extraction.lvs +77 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/res_connections.lvs +45 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/res_derivations.lvs +81 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/res_extraction.lvs +99 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/rfmos_connections.lvs +24 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/rfmos_derivations.lvs +47 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/rfmos_extraction.lvs +80 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/sram_integration.lvs +53 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/tap_connections.lvs +41 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/tap_derivations.lvs +51 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/rule_decks/tap_extraction.lvs +54 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/sg13g2.lvs +670 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/sg13g2.lyp +7282 -0
- kpex/pdk/ihp-sg13g2/libs.tech/kpex/sg13g2.lyt +198 -0
- kpex/pdk/sky130A/libs.tech/kpex/debug_sky130.lvs.lylvs +35 -0
- kpex/pdk/sky130A/libs.tech/kpex/rule_decks/auto_name_layers.rb +29 -0
- kpex/pdk/sky130A/libs.tech/kpex/sky130.lvs +2998 -0
- kpex/pdk/sky130A/libs.tech/kpex/sky130A.lyp +8563 -0
- kpex/pdk/sky130A/libs.tech/kpex/sky130A.lyt +169 -0
- kpex/pdk_config.py +103 -0
- kpex/pex25d/__init__.py +259 -0
- kpex/pex25d/__main__.py +38 -0
- kpex/pex25d/accounting.py +156 -0
- kpex/pex25d/accounting_validation.py +156 -0
- kpex/pex25d/artifact.py +270 -0
- kpex/pex25d/capability_validation.py +55 -0
- kpex/pex25d/codec.py +188 -0
- kpex/pex25d/diagnostics.py +300 -0
- kpex/pex25d/electrical.py +98 -0
- kpex/pex25d/exporters.py +184 -0
- kpex/pex25d/format_version.py +36 -0
- kpex/pex25d/importers.py +99 -0
- kpex/pex25d/pex25d_cli.py +752 -0
- kpex/pex25d/protobuf.py +174 -0
- kpex/pex25d/reader.py +1039 -0
- kpex/pex25d/resolver.py +893 -0
- kpex/pex25d/show.py +170 -0
- kpex/pex25d/validator.py +1057 -0
- kpex/pex25d/writer.py +544 -0
- kpex/plugin/__init__.py +25 -0
- kpex/plugin/exporter_registry.py +56 -0
- kpex/plugin/importer_registry.py +56 -0
- kpex/plugin/registry.py +185 -0
- kpex/plugin_api/__init__.py +25 -0
- kpex/plugin_api/v1/__init__.py +78 -0
- kpex/plugin_api/v1/pex25d_importer.py +75 -0
- kpex/plugin_api/v1/pex25d_scene_exporter.py +142 -0
- kpex/plugin_api/v1/pex25d_scene_tools.py +70 -0
- kpex/rcx25/__init__.py +23 -0
- kpex/rcx25/c/__init__.py +23 -0
- kpex/rcx25/c/capacitance_integrals.py +138 -0
- kpex/rcx25/c/device_capacitance_checks.py +266 -0
- kpex/rcx25/c/device_capacitance_references.py +184 -0
- kpex/rcx25/c/device_capacitor_plates.py +99 -0
- kpex/rcx25/c/geometry_restorer.py +46 -0
- kpex/rcx25/c/overlap_extractor.py +191 -0
- kpex/rcx25/c/polygon_utils.py +100 -0
- kpex/rcx25/c/sidewall_and_fringe_extractor.py +615 -0
- kpex/rcx25/capacitance_distributor.py +418 -0
- kpex/rcx25/coupling.py +51 -0
- kpex/rcx25/exclusion.py +1170 -0
- kpex/rcx25/extraction_reporter.py +468 -0
- kpex/rcx25/extraction_results.py +741 -0
- kpex/rcx25/extractor.py +622 -0
- kpex/rcx25/netlist_checks.py +570 -0
- kpex/rcx25/netlist_expander.py +238 -0
- kpex/rcx25/pex_mode.py +51 -0
- kpex/rcx25/r/__init__.py +23 -0
- kpex/rcx25/r/r_extractor.py +1623 -0
- kpex/rcx25/schematic_device_names.py +359 -0
- kpex/rcx25/types.py +39 -0
- kpex/run_result.py +261 -0
- kpex/schematic_devices.py +117 -0
- kpex/stl/__init__.py +25 -0
- kpex/stl/pex25d_exporter.py +89 -0
- kpex/tech_catalog.py +544 -0
- kpex/tech_identity.py +44 -0
- kpex/tech_info.py +717 -0
- kpex/tool_version_constraints.py +366 -0
- kpex/types.py +49 -0
- kpex/util/__init__.py +23 -0
- kpex/util/argparse_helpers.py +340 -0
- kpex/util/disjoint_sets.py +46 -0
- kpex/util/multiple_choice.py +86 -0
- kpex/util/number_range.py +71 -0
- kpex/util/peak_memory.py +130 -0
- kpex/util/protobuf_json.py +86 -0
- kpex/util/stdio.py +44 -0
- kpex/util/unit_formatter.py +150 -0
- kpex/version.py +24 -0
- kpex-0.12.0.dist-info/METADATA +334 -0
- kpex-0.12.0.dist-info/RECORD +416 -0
- kpex-0.12.0.dist-info/WHEEL +4 -0
- kpex-0.12.0.dist-info/entry_points.txt +5 -0
- kpex-0.12.0.dist-info/licenses/LICENSE +674 -0
- kpex_protobuf/NOTE_-_AUTOMATICALLY_GENERATED_PROTOBUF_FILES.txt +0 -0
- kpex_protobuf/__init__.py +25 -0
- kpex_protobuf/gf180mcuD_tech.pb.json +3680 -0
- kpex_protobuf/ihp-sg13cmos5l_tech.pb.json +3208 -0
- kpex_protobuf/ihp-sg13g2_tech.pb.json +4529 -0
- kpex_protobuf/kpex/c/capacitance_pb2.py +49 -0
- kpex_protobuf/kpex/calibration/patterns_pb2.py +51 -0
- kpex_protobuf/kpex/calibration/preparation_pb2.py +63 -0
- kpex_protobuf/kpex/calibration/solving_pb2.py +55 -0
- kpex_protobuf/kpex/calibration/targets_pb2.py +52 -0
- kpex_protobuf/kpex/geometry/shapes_pb2.py +46 -0
- kpex_protobuf/kpex/klayout/lvs_input_fingerprint_pb2.py +48 -0
- kpex_protobuf/kpex/klayout/r_extractor_tech_pb2.py +43 -0
- kpex_protobuf/kpex/layout/device_pb2.py +42 -0
- kpex_protobuf/kpex/layout/layer_ref_pb2.py +36 -0
- kpex_protobuf/kpex/layout/layer_region_pb2.py +38 -0
- kpex_protobuf/kpex/layout/location_pb2.py +39 -0
- kpex_protobuf/kpex/layout/pin_pb2.py +38 -0
- kpex_protobuf/kpex/pex25d/pex25d_capabilities_pb2.py +36 -0
- kpex_protobuf/kpex/pex25d/pex25d_capacitance_accounting_pb2.py +46 -0
- kpex_protobuf/kpex/pex25d/pex25d_diagnostics_pb2.py +43 -0
- kpex_protobuf/kpex/pex25d/pex25d_dielectric_pb2.py +45 -0
- kpex_protobuf/kpex/pex25d/pex25d_domain_pb2.py +40 -0
- kpex_protobuf/kpex/pex25d/pex25d_file_pb2.py +59 -0
- kpex_protobuf/kpex/pex25d/pex25d_geometry_pb2.py +46 -0
- kpex_protobuf/kpex/pex25d/pex25d_ground_pb2.py +38 -0
- kpex_protobuf/kpex/pex25d/pex25d_meta_pb2.py +37 -0
- kpex_protobuf/kpex/pex25d/pex25d_resistance_pb2.py +43 -0
- kpex_protobuf/kpex/pex25d/pex25d_scene_pb2.py +67 -0
- kpex_protobuf/kpex/pex25d/pex25d_source_ref_pb2.py +36 -0
- kpex_protobuf/kpex/pex25d/pex25d_terminal_pb2.py +40 -0
- kpex_protobuf/kpex/pex25d/pex25d_units_pb2.py +38 -0
- kpex_protobuf/kpex/r/r_network_pb2.py +53 -0
- kpex_protobuf/kpex/request/pex_request_pb2.py +44 -0
- kpex_protobuf/kpex/result/capacitance_matrix_pb2.py +44 -0
- kpex_protobuf/kpex/result/pex_result_pb2.py +44 -0
- kpex_protobuf/kpex/result/solver_execution_pb2.py +44 -0
- kpex_protobuf/kpex/tech/device_models_pb2.py +56 -0
- kpex_protobuf/kpex/tech/process_parasitics_pb2.py +54 -0
- kpex_protobuf/kpex/tech/process_stack_pb2.py +56 -0
- kpex_protobuf/kpex/tech/substrate_pb2.py +38 -0
- kpex_protobuf/kpex/tech/tech_catalog_pb2.py +67 -0
- kpex_protobuf/kpex/tech/tech_pb2.py +54 -0
- kpex_protobuf/kpex/tech/tech_selection_pb2.py +41 -0
- kpex_protobuf/sky130A_tech.pb.json +4764 -0
- kpex_protobuf/tech/gf180mcuD/capacitance/high.pb.json +816 -0
- kpex_protobuf/tech/gf180mcuD/capacitance/low.pb.json +816 -0
- kpex_protobuf/tech/gf180mcuD/capacitance/nominal.pb.json +780 -0
- kpex_protobuf/tech/gf180mcuD/catalog.pb.json +380 -0
- kpex_protobuf/tech/gf180mcuD/device_references/high.pb.json +72 -0
- kpex_protobuf/tech/gf180mcuD/device_references/low.pb.json +72 -0
- kpex_protobuf/tech/gf180mcuD/device_references/nominal.pb.json +49 -0
- kpex_protobuf/tech/gf180mcuD/process_stack/capiche-high.pb.json +443 -0
- kpex_protobuf/tech/gf180mcuD/process_stack/capiche-low.pb.json +443 -0
- kpex_protobuf/tech/gf180mcuD/process_stack/nominal.pb.json +406 -0
- kpex_protobuf/tech/gf180mcuD/resistance/fixed-layout-high-r.pb.json +226 -0
- kpex_protobuf/tech/gf180mcuD/resistance/fixed-layout-low-r-ideal-contacts.pb.json +242 -0
- kpex_protobuf/tech/gf180mcuD/resistance/fixed-layout-reference-r.pb.json +226 -0
- kpex_protobuf/tech/gf180mcuD/resistance/nominal.pb.json +128 -0
- kpex_protobuf/tech/gf180mcuD/shared.pb.json +2550 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/capacitance/high.pb.json +634 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/capacitance/low.pb.json +634 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/capacitance/nominal.pb.json +638 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/catalog.pb.json +396 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/device_references/nominal.pb.json +110 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/process_stack/capiche-high.pb.json +361 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/process_stack/capiche-low.pb.json +361 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/process_stack/nominal.pb.json +348 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/resistance/fixed-layout-high-r.pb.json +208 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/resistance/fixed-layout-low-r.pb.json +208 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/resistance/gatpoly-high-sheet.pb.json +211 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/resistance/gatpoly-low-sheet.pb.json +211 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/resistance/nominal.pb.json +114 -0
- kpex_protobuf/tech/ihp-sg13cmos5l/shared.pb.json +2273 -0
- kpex_protobuf/tech/ihp-sg13g2/capacitance/high.pb.json +1143 -0
- kpex_protobuf/tech/ihp-sg13g2/capacitance/low.pb.json +1143 -0
- kpex_protobuf/tech/ihp-sg13g2/capacitance/nominal.pb.json +1130 -0
- kpex_protobuf/tech/ihp-sg13g2/catalog.pb.json +349 -0
- kpex_protobuf/tech/ihp-sg13g2/device_references/high.pb.json +72 -0
- kpex_protobuf/tech/ihp-sg13g2/device_references/low.pb.json +72 -0
- kpex_protobuf/tech/ihp-sg13g2/device_references/nominal.pb.json +110 -0
- kpex_protobuf/tech/ihp-sg13g2/process_stack/capiche-high.pb.json +457 -0
- kpex_protobuf/tech/ihp-sg13g2/process_stack/capiche-low.pb.json +457 -0
- kpex_protobuf/tech/ihp-sg13g2/process_stack/nominal.pb.json +431 -0
- kpex_protobuf/tech/ihp-sg13g2/resistance/gatpoly-high-sheet.pb.json +239 -0
- kpex_protobuf/tech/ihp-sg13g2/resistance/gatpoly-low-sheet.pb.json +239 -0
- kpex_protobuf/tech/ihp-sg13g2/resistance/nominal.pb.json +142 -0
- kpex_protobuf/tech/ihp-sg13g2/shared.pb.json +3007 -0
- kpex_protobuf/tech/sky130A/capacitance/high.pb.json +1139 -0
- kpex_protobuf/tech/sky130A/capacitance/low.pb.json +1139 -0
- kpex_protobuf/tech/sky130A/capacitance/nominal.pb.json +1117 -0
- kpex_protobuf/tech/sky130A/catalog.pb.json +421 -0
- kpex_protobuf/tech/sky130A/device_references/hrhc.pb.json +117 -0
- kpex_protobuf/tech/sky130A/device_references/hrlc.pb.json +117 -0
- kpex_protobuf/tech/sky130A/device_references/lrhc.pb.json +117 -0
- kpex_protobuf/tech/sky130A/device_references/lrlc.pb.json +117 -0
- kpex_protobuf/tech/sky130A/device_references/nominal.pb.json +49 -0
- kpex_protobuf/tech/sky130A/process_stack/capiche-high.pb.json +502 -0
- kpex_protobuf/tech/sky130A/process_stack/capiche-low.pb.json +521 -0
- kpex_protobuf/tech/sky130A/process_stack/nominal.pb.json +465 -0
- kpex_protobuf/tech/sky130A/resistance/hrhc-mim-bound.pb.json +194 -0
- kpex_protobuf/tech/sky130A/resistance/hrlc-mim-bound.pb.json +194 -0
- kpex_protobuf/tech/sky130A/resistance/lrhc-mim-bound.pb.json +194 -0
- kpex_protobuf/tech/sky130A/resistance/lrlc-mim-bound.pb.json +194 -0
- kpex_protobuf/tech/sky130A/resistance/nominal.pb.json +140 -0
- kpex_protobuf/tech/sky130A/shared.pb.json +3217 -0
kpex/__init__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#
|
|
2
|
+
# --------------------------------------------------------------------------------
|
|
3
|
+
# SPDX-FileCopyrightText: 2024-2025 Martin Jan Köhler and Harald Pretl
|
|
4
|
+
# Johannes Kepler University, Institute for Integrated Circuits.
|
|
5
|
+
#
|
|
6
|
+
# This file is part of KPEX
|
|
7
|
+
# (see https://github.com/iic-jku/kpex).
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
#
|
kpex/__main__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#
|
|
2
|
+
# --------------------------------------------------------------------------------
|
|
3
|
+
# SPDX-FileCopyrightText: 2024-2025 Martin Jan Köhler and Harald Pretl
|
|
4
|
+
# Johannes Kepler University, Institute for Integrated Circuits.
|
|
5
|
+
#
|
|
6
|
+
# This file is part of KPEX
|
|
7
|
+
# (see https://github.com/iic-jku/kpex).
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
#
|
|
24
|
+
from .kpex_cli import KpexCLI
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
from .util.stdio import use_utf8_stdio
|
|
28
|
+
|
|
29
|
+
def main():
|
|
30
|
+
use_utf8_stdio()
|
|
31
|
+
cli = KpexCLI()
|
|
32
|
+
cli.main(sys.argv)
|
|
33
|
+
|
|
34
|
+
if __name__ == '__main__':
|
|
35
|
+
main()
|
|
36
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#
|
|
2
|
+
# --------------------------------------------------------------------------------
|
|
3
|
+
# SPDX-FileCopyrightText: 2024-2026 Martin Jan Köhler and Harald Pretl
|
|
4
|
+
# Johannes Kepler University, Institute for Integrated Circuits.
|
|
5
|
+
#
|
|
6
|
+
# This file is part of KPEX
|
|
7
|
+
# (see https://github.com/iic-jku/kpex).
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
"""Finite geometry and provenance preparation for built-in calibration."""
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#
|
|
2
|
+
# --------------------------------------------------------------------------------
|
|
3
|
+
# SPDX-FileCopyrightText: 2024-2026 Martin Jan Köhler and Harald Pretl
|
|
4
|
+
# Johannes Kepler University, Institute for Integrated Circuits.
|
|
5
|
+
#
|
|
6
|
+
# This file is part of KPEX
|
|
7
|
+
# (see https://github.com/iic-jku/kpex).
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
"""Portable, hashed protobuf artifacts for calibration execution and collection."""
|
|
26
|
+
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
import hashlib
|
|
30
|
+
import os
|
|
31
|
+
from pathlib import Path, PurePosixPath
|
|
32
|
+
import re
|
|
33
|
+
from typing import Iterable, List, TypeVar
|
|
34
|
+
from uuid import uuid4
|
|
35
|
+
|
|
36
|
+
from google.protobuf.json_format import MessageToJson, ParseError
|
|
37
|
+
from google.protobuf.message import Message
|
|
38
|
+
|
|
39
|
+
from .validation import CalibrationError
|
|
40
|
+
from ..util.protobuf_json import parse_protobuf_json
|
|
41
|
+
|
|
42
|
+
MessageType = TypeVar('MessageType', bound=Message)
|
|
43
|
+
MAX_JSON_BYTES = 16 * 1024 * 1024
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def read_message(path: Path, message: MessageType) -> MessageType:
|
|
47
|
+
try:
|
|
48
|
+
if path.is_symlink():
|
|
49
|
+
raise CalibrationError(f"Artifact '{path}' must not be a symlink")
|
|
50
|
+
with path.open('rb') as stream:
|
|
51
|
+
data = stream.read(MAX_JSON_BYTES + 1)
|
|
52
|
+
if len(data) > MAX_JSON_BYTES:
|
|
53
|
+
raise CalibrationError(f"Artifact '{path}' exceeds {MAX_JSON_BYTES} bytes")
|
|
54
|
+
return parse_protobuf_json(data.decode('utf-8'), message)
|
|
55
|
+
except (OSError, UnicodeError, ValueError, ParseError, RecursionError) as exc:
|
|
56
|
+
raise CalibrationError(f"Cannot read protobuf artifact '{path}': {exc}") from exc
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def write_message(path: Path, message: Message, *, replace: bool = False) -> Path:
|
|
60
|
+
data = (MessageToJson(message, preserving_proto_field_name=True, sort_keys=True,
|
|
61
|
+
ensure_ascii=False, always_print_fields_with_no_presence=True) + '\n').encode('utf-8')
|
|
62
|
+
temporary = path.with_name(path.name + '.' + uuid4().hex + '.tmp')
|
|
63
|
+
try:
|
|
64
|
+
with temporary.open('xb') as stream:
|
|
65
|
+
stream.write(data)
|
|
66
|
+
stream.flush()
|
|
67
|
+
os.fsync(stream.fileno())
|
|
68
|
+
if replace:
|
|
69
|
+
if path.is_symlink():
|
|
70
|
+
raise CalibrationError(f"Checkpoint '{path}' must not be a symlink")
|
|
71
|
+
os.replace(temporary, path)
|
|
72
|
+
else:
|
|
73
|
+
# A hard link creates the name exclusively; never overwrite existing evidence.
|
|
74
|
+
os.link(temporary, path)
|
|
75
|
+
return path
|
|
76
|
+
except OSError as exc:
|
|
77
|
+
raise CalibrationError(f"Cannot write protobuf artifact '{path}': {exc}") from exc
|
|
78
|
+
finally:
|
|
79
|
+
temporary.unlink(missing_ok=True)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def sha256_file(path: Path) -> str:
|
|
83
|
+
try:
|
|
84
|
+
with path.open('rb') as stream:
|
|
85
|
+
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
|
86
|
+
except OSError as exc:
|
|
87
|
+
raise CalibrationError(f"Cannot hash artifact '{path}': {exc}") from exc
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def artifact_path(directory: Path, name: str, *, required: bool = True) -> Path:
|
|
91
|
+
if (not name or '\\' in name or ':' in name or '\x00' in name
|
|
92
|
+
or name != PurePosixPath(name).as_posix() or PurePosixPath(name).is_absolute()
|
|
93
|
+
or any(part in ('.', '..') for part in PurePosixPath(name).parts)):
|
|
94
|
+
raise CalibrationError(f"Invalid relative artifact path {name!r}")
|
|
95
|
+
path = directory
|
|
96
|
+
for part in PurePosixPath(name).parts:
|
|
97
|
+
path = path / part
|
|
98
|
+
if path.is_symlink():
|
|
99
|
+
raise CalibrationError(f"Artifact path '{name}' must not contain symlinks")
|
|
100
|
+
if required and not path.is_file():
|
|
101
|
+
raise CalibrationError(f"Artifact '{name}' is missing or is not a regular file")
|
|
102
|
+
return path
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def verify_artifacts(directory: Path, records: Iterable[Message]) -> List[Path]:
|
|
106
|
+
paths = []
|
|
107
|
+
seen = set()
|
|
108
|
+
for record in records:
|
|
109
|
+
path = artifact_path(directory, record.path)
|
|
110
|
+
if record.path.casefold() in seen:
|
|
111
|
+
raise CalibrationError(f"Artifact path '{record.path}' repeats ignoring case")
|
|
112
|
+
seen.add(record.path.casefold())
|
|
113
|
+
if re.fullmatch(r'[0-9a-f]{64}', record.sha256) is None:
|
|
114
|
+
raise CalibrationError(f"Artifact '{record.path}' needs a lowercase SHA256 digest")
|
|
115
|
+
if sha256_file(path) != record.sha256:
|
|
116
|
+
raise CalibrationError(f"Artifact '{record.path}' has changed (SHA256 mismatch)")
|
|
117
|
+
paths.append(path)
|
|
118
|
+
return paths
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def copy_artifact(source: Path, destination: Path, expected_hash: str) -> Path:
|
|
122
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
123
|
+
with source.open('rb') as src, destination.open('xb') as dst:
|
|
124
|
+
while chunk := src.read(1024 * 1024):
|
|
125
|
+
dst.write(chunk)
|
|
126
|
+
if sha256_file(destination) != expected_hash:
|
|
127
|
+
raise CalibrationError(f"Artifact '{source}' changed during copying")
|
|
128
|
+
return destination
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def validate_output_directory(path: Path):
|
|
132
|
+
if path.exists() or path.is_symlink():
|
|
133
|
+
raise CalibrationError(f"Output path '{path}' already exists; choose a new directory")
|
|
134
|
+
if not path.parent.is_dir():
|
|
135
|
+
raise CalibrationError(f"Output parent '{path.parent}' must be an existing directory")
|
kpex/calibration/cli.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#
|
|
2
|
+
# --------------------------------------------------------------------------------
|
|
3
|
+
# SPDX-FileCopyrightText: 2024-2026 Martin Jan Köhler and Harald Pretl
|
|
4
|
+
# Johannes Kepler University, Institute for Integrated Circuits.
|
|
5
|
+
#
|
|
6
|
+
# This file is part of KPEX
|
|
7
|
+
# (see https://github.com/iic-jku/kpex).
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
"""Command-line preparation, solving and collection of calibration patterns."""
|
|
26
|
+
|
|
27
|
+
import argparse
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
import sys
|
|
30
|
+
|
|
31
|
+
from google.protobuf.json_format import ParseError
|
|
32
|
+
from rich_argparse import RichHelpFormatter
|
|
33
|
+
|
|
34
|
+
from .patterns import CalibrationError, read_patterns
|
|
35
|
+
from .prepare import prepare_calibration, validate_output_directory
|
|
36
|
+
from ..klayout.pex25d_stack import BuildError
|
|
37
|
+
from ..log import error, info, set_log_level
|
|
38
|
+
from ..pdk_config import PDK
|
|
39
|
+
from ..pex25d.diagnostics import ExitCode
|
|
40
|
+
from ..pex25d.resolver import ResolveError
|
|
41
|
+
from ..tech_info import TechDefError, TechInfo
|
|
42
|
+
from ..util.argparse_helpers import add_log_level_argument
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def add_calibration_subparser(subparsers: argparse._SubParsersAction):
|
|
46
|
+
parser = subparsers.add_parser(
|
|
47
|
+
'calibrate', help='Prepare calibration patterns, run field solves and collect raw matrices',
|
|
48
|
+
description='Prepare patterns, run bounded field solves and collect raw matrices. '
|
|
49
|
+
'Numerical qualification and coefficient fitting are separate stages.', formatter_class=RichHelpFormatter)
|
|
50
|
+
commands = parser.add_subparsers(dest='calibration_command', required=True)
|
|
51
|
+
from .solve_cli import add_execution_subparsers
|
|
52
|
+
prepare = commands.add_parser(
|
|
53
|
+
'prepare', help='Write validated PEX25D patterns and a preparation manifest',
|
|
54
|
+
description='Create finite substrate, parallel-plate, parallel-wire and directional-fringe patterns '
|
|
55
|
+
'from exact dimensions and optional typed table targets in protobuf JSON. '
|
|
56
|
+
'The output is ready for inspection or export, not a qualified reference solution.',
|
|
57
|
+
formatter_class=RichHelpFormatter)
|
|
58
|
+
prepare.add_argument('--pdk', required=True, type=PDK.from_string, choices=list(PDK),
|
|
59
|
+
help='Technology whose complete physical stack supplies the patterns')
|
|
60
|
+
prepare.add_argument('--patterns', required=True, type=Path, metavar='SPEC.json',
|
|
61
|
+
help='Pattern specification with dimensions in µm, exact grid and domain margin')
|
|
62
|
+
prepare.add_argument('--out-dir', required=True, type=Path, metavar='PATH',
|
|
63
|
+
help='New output directory under an existing parent; existing paths are refused')
|
|
64
|
+
add_log_level_argument(prepare)
|
|
65
|
+
add_execution_subparsers(commands)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def run_calibration_command(args: argparse.Namespace):
|
|
69
|
+
set_log_level(args.log_level)
|
|
70
|
+
if args.calibration_command in ('solve', 'collect'):
|
|
71
|
+
from .solve_cli import run_execution_command
|
|
72
|
+
return run_execution_command(args)
|
|
73
|
+
if args.calibration_command != 'prepare':
|
|
74
|
+
raise NotImplementedError(f'Calibration command {args.calibration_command!r}')
|
|
75
|
+
try:
|
|
76
|
+
spec = read_patterns(args.patterns)
|
|
77
|
+
validate_output_directory(args.out_dir)
|
|
78
|
+
tech_info = TechInfo.from_catalog(args.pdk.config.tech_catalog_path, dielectric_filter=None,
|
|
79
|
+
scenario_id='nominal', expected_technology=str(args.pdk))
|
|
80
|
+
result = prepare_calibration(tech_info, spec, args.out_dir)
|
|
81
|
+
except (CalibrationError, OSError, ParseError) as exc:
|
|
82
|
+
error(str(exc))
|
|
83
|
+
sys.exit(ExitCode.USAGE)
|
|
84
|
+
except (TechDefError, BuildError, ResolveError) as exc:
|
|
85
|
+
error(str(exc))
|
|
86
|
+
for note in getattr(exc, '__notes__', ()):
|
|
87
|
+
error(note)
|
|
88
|
+
sys.exit(ExitCode.DIAGNOSTIC_ERRORS)
|
|
89
|
+
info(f'Prepared {len(spec.patterns)} finite 3D cases: {result.manifest_path}')
|
|
90
|
+
info('Reference solving and coefficient fitting have not run')
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#
|
|
2
|
+
# --------------------------------------------------------------------------------
|
|
3
|
+
# SPDX-FileCopyrightText: 2024-2026 Martin Jan Köhler and Harald Pretl
|
|
4
|
+
# Johannes Kepler University, Institute for Integrated Circuits.
|
|
5
|
+
#
|
|
6
|
+
# This file is part of KPEX
|
|
7
|
+
# (see https://github.com/iic-jku/kpex).
|
|
8
|
+
#
|
|
9
|
+
# This program is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
"""Recollect immutable raw evidence, including interrupted campaigns."""
|
|
26
|
+
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
from dataclasses import dataclass
|
|
30
|
+
import math
|
|
31
|
+
from pathlib import Path
|
|
32
|
+
import re
|
|
33
|
+
from typing import Dict, List, Optional, Tuple
|
|
34
|
+
|
|
35
|
+
from .artifacts import (artifact_path, copy_artifact, read_message, sha256_file,
|
|
36
|
+
validate_output_directory, verify_artifacts, write_message)
|
|
37
|
+
from .validation import CalibrationError
|
|
38
|
+
from kpex_protobuf.kpex.calibration.preparation_pb2 import CalibrationManifest, CapacitanceMeasurement
|
|
39
|
+
from kpex_protobuf.kpex.calibration.solving_pb2 import (
|
|
40
|
+
CalibrationRunManifest, CalibrationRunCheckpoint, CalibrationRunCompletion,
|
|
41
|
+
CalibrationCollection, CalibrationCaseResult,
|
|
42
|
+
)
|
|
43
|
+
from kpex_protobuf.kpex.result.solver_execution_pb2 import SolverExecution
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass(frozen=True)
|
|
47
|
+
class CalibrationCollectionResult:
|
|
48
|
+
manifest_path: Path
|
|
49
|
+
written_paths: Tuple[Path, ...]
|
|
50
|
+
successful_cases: int
|
|
51
|
+
failed_cases: int
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _native_statistics(log: Path) -> Dict[str, Optional[int]]:
|
|
55
|
+
"""Read only the final matrix's statistics block; missing or ambiguous counts stay unknown."""
|
|
56
|
+
fields = {
|
|
57
|
+
'input_panels': ('Number of input panels to solver engine:', r'Number of input panels to solver engine: (\d+)'),
|
|
58
|
+
'refined_panels': ('Number of panels after refinement:', r'Number of panels after refinement: (\d+)'),
|
|
59
|
+
'potential_estimates': ('Number of potential estimates:', r'Number of potential estimates: (\d+)'),
|
|
60
|
+
'links': ('Number of links:', r'Number of links: (\d+)(?: \(.*\))?'),
|
|
61
|
+
}
|
|
62
|
+
unknown = {name: None for name in fields}
|
|
63
|
+
lines = log.read_text(encoding='utf-8', errors='replace').splitlines()
|
|
64
|
+
matrices = [index for index, line in enumerate(lines) if line.strip() == 'Capacitance matrix is:']
|
|
65
|
+
if not matrices:
|
|
66
|
+
return unknown
|
|
67
|
+
tail = lines[matrices[-1] + 1:]
|
|
68
|
+
# A later unfinished adaptive iteration must not contribute statistics to an earlier matrix.
|
|
69
|
+
for index, line in enumerate(tail):
|
|
70
|
+
if line.startswith('Iteration number #'):
|
|
71
|
+
tail = tail[:index]
|
|
72
|
+
break
|
|
73
|
+
blocks = [index for index, line in enumerate(tail) if line.strip() == 'Solve statistics:']
|
|
74
|
+
if len(blocks) != 1:
|
|
75
|
+
return unknown
|
|
76
|
+
block = tail[blocks[0] + 1:]
|
|
77
|
+
for name, (prefix, pattern) in fields.items():
|
|
78
|
+
candidates = [line.strip() for line in block if line.strip().startswith(prefix)]
|
|
79
|
+
if len(candidates) == 1:
|
|
80
|
+
match = re.fullmatch(pattern, candidates[0])
|
|
81
|
+
if match:
|
|
82
|
+
try:
|
|
83
|
+
unknown[name] = int(match.group(1))
|
|
84
|
+
except ValueError:
|
|
85
|
+
pass # Oversized or malformed native counts are unknown, not fabricated
|
|
86
|
+
return unknown
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _validate_checkpoint(checkpoint: CalibrationRunCheckpoint, case_id: str):
|
|
90
|
+
if checkpoint.schema_version != 1 or checkpoint.case_id != case_id:
|
|
91
|
+
raise CalibrationError(f"Checkpoint for '{case_id}' has an incompatible identity or version")
|
|
92
|
+
execution = checkpoint.execution
|
|
93
|
+
if execution.status not in (SolverExecution.NOT_STARTED, SolverExecution.RUNNING,
|
|
94
|
+
SolverExecution.SUCCEEDED, SolverExecution.FAILED,
|
|
95
|
+
SolverExecution.TIMED_OUT, SolverExecution.CANCELLED):
|
|
96
|
+
raise CalibrationError(f"Checkpoint for '{case_id}' has an unknown execution status")
|
|
97
|
+
if not math.isfinite(execution.duration_seconds) or execution.duration_seconds < 0:
|
|
98
|
+
raise CalibrationError(f"Checkpoint for '{case_id}' has an invalid duration")
|
|
99
|
+
if execution.status == SolverExecution.SUCCEEDED and (
|
|
100
|
+
not execution.HasField('return_code') or execution.return_code != 0 or not checkpoint.HasField('log')):
|
|
101
|
+
raise CalibrationError(f"Successful checkpoint for '{case_id}' needs exit code zero and a hashed log")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def collect_calibration(run_manifest: Path, output_dir: Path) -> CalibrationCollectionResult:
|
|
105
|
+
# No geometry imports or executable discovery: saved evidence is portable.
|
|
106
|
+
from .solve import reference, validate_options_message
|
|
107
|
+
from .prepared_input import read_preparation
|
|
108
|
+
from ..fastercap.result_collection import collect_fastercap_matrix
|
|
109
|
+
from ..fastercap.fastercap_error import FasterCapError
|
|
110
|
+
|
|
111
|
+
validate_output_directory(output_dir)
|
|
112
|
+
root = run_manifest.parent
|
|
113
|
+
manifest_hash = sha256_file(run_manifest)
|
|
114
|
+
manifest = read_message(run_manifest, CalibrationRunManifest())
|
|
115
|
+
if manifest.schema_version != 1 or not manifest.kpex_version or manifest.solver.name != 'fastercap':
|
|
116
|
+
raise CalibrationError('Unsupported calibration run schema, version or solver')
|
|
117
|
+
validate_options_message(manifest.options)
|
|
118
|
+
if (not manifest.solver.version or not manifest.solver.operating_system or not manifest.solver.architecture
|
|
119
|
+
or re.fullmatch(r'[0-9a-f]{64}', manifest.solver.executable_sha256) is None):
|
|
120
|
+
raise CalibrationError('Solver identity is incomplete')
|
|
121
|
+
files: Dict[str, str] = {run_manifest.name: manifest_hash}
|
|
122
|
+
|
|
123
|
+
def remember(path: Path, digest: Optional[str] = None):
|
|
124
|
+
name = path.relative_to(root).as_posix()
|
|
125
|
+
value = sha256_file(path) if digest is None else digest
|
|
126
|
+
if name in files and files[name] != value:
|
|
127
|
+
raise CalibrationError(f"Artifact '{name}' changed during collection")
|
|
128
|
+
files[name] = value
|
|
129
|
+
|
|
130
|
+
verify_artifacts(root, [manifest.preparation])
|
|
131
|
+
preparation_path = artifact_path(root, manifest.preparation.path)
|
|
132
|
+
remember(preparation_path, manifest.preparation.sha256)
|
|
133
|
+
prepared = read_preparation(preparation_path).manifest
|
|
134
|
+
if (prepared.schema_version != 1 or prepared.stage != CalibrationManifest.PREPARED
|
|
135
|
+
or not prepared.cases or len(prepared.cases) != len(manifest.cases)):
|
|
136
|
+
raise CalibrationError('Run preparation has an unsupported stage or case set')
|
|
137
|
+
for item, path in zip(prepared.artifacts, verify_artifacts(preparation_path.parent, prepared.artifacts)):
|
|
138
|
+
remember(path, item.sha256)
|
|
139
|
+
completion_path = root / 'completed.pb.json'
|
|
140
|
+
complete = completion_path.exists() or completion_path.is_symlink()
|
|
141
|
+
if complete:
|
|
142
|
+
completion = read_message(completion_path, CalibrationRunCompletion())
|
|
143
|
+
if completion.schema_version != 1 or completion.manifest != reference(run_manifest, root):
|
|
144
|
+
raise CalibrationError('Completion record does not identify this run')
|
|
145
|
+
verify_artifacts(root, completion.checkpoints)
|
|
146
|
+
if [ref.path for ref in completion.checkpoints] != [case.checkpoint_path for case in manifest.cases]:
|
|
147
|
+
raise CalibrationError('Completion record does not identify every case checkpoint')
|
|
148
|
+
remember(completion_path)
|
|
149
|
+
checkpoints = []
|
|
150
|
+
identities = set()
|
|
151
|
+
declared_paths = set(files)
|
|
152
|
+
for case, preparation in zip(manifest.cases, prepared.cases):
|
|
153
|
+
if case.case_id != preparation.id or not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9_-]{0,63}', case.case_id):
|
|
154
|
+
raise CalibrationError('Run cases differ from the prepared cases')
|
|
155
|
+
if case.case_id.casefold() in identities:
|
|
156
|
+
raise CalibrationError('Run case IDs must be unique ignoring case')
|
|
157
|
+
identities.add(case.case_id.casefold())
|
|
158
|
+
if (case.checkpoint_path != f'cases/{case.case_id}/checkpoint.pb.json'
|
|
159
|
+
or case.log_path != f'cases/{case.case_id}/solver.log'
|
|
160
|
+
or case.numerical_report_path not in ('', f'cases/{case.case_id}/numerical-report.json')):
|
|
161
|
+
raise CalibrationError('Run case paths do not match their case identity')
|
|
162
|
+
signals = list(preparation.measurement.conductor_order)
|
|
163
|
+
measurement = preparation.measurement
|
|
164
|
+
if (measurement.kind != CapacitanceMeasurement.MAXWELL_CAPACITANCE_MATRIX
|
|
165
|
+
or measurement.convention != CapacitanceMeasurement.MAXWELL_GROUNDED_UNEXCITED
|
|
166
|
+
or measurement.capacitance_unit != CapacitanceMeasurement.FARAD
|
|
167
|
+
or measurement.floating_conductors or measurement.reference.potential_v != 0
|
|
168
|
+
or not signals or any(not name for name in signals) or len(set(signals)) != len(signals)
|
|
169
|
+
or not measurement.reference.profile or measurement.reference.profile in signals):
|
|
170
|
+
raise CalibrationError('Unsupported prepared measurement contract')
|
|
171
|
+
for item, path in zip(case.inputs, verify_artifacts(root, case.inputs)):
|
|
172
|
+
if not item.path.startswith(f'cases/{case.case_id}/inputs/') or item.path.casefold() in declared_paths:
|
|
173
|
+
raise CalibrationError('Solver input paths must be unique and owned by their case')
|
|
174
|
+
declared_paths.add(item.path.casefold())
|
|
175
|
+
remember(path, item.sha256)
|
|
176
|
+
if case.inputs and (case.primary_input_path not in [item.path for item in case.inputs]
|
|
177
|
+
or not case.primary_input_path.endswith('.lst')):
|
|
178
|
+
raise CalibrationError('Primary solver input is absent from the declared inputs')
|
|
179
|
+
checkpoint_path = artifact_path(root, case.checkpoint_path, required=False)
|
|
180
|
+
if checkpoint_path.exists():
|
|
181
|
+
checkpoint = read_message(checkpoint_path, CalibrationRunCheckpoint())
|
|
182
|
+
_validate_checkpoint(checkpoint, case.case_id)
|
|
183
|
+
remember(checkpoint_path)
|
|
184
|
+
else:
|
|
185
|
+
checkpoint = CalibrationRunCheckpoint(schema_version=1, case_id=case.case_id)
|
|
186
|
+
checkpoint.execution.status = SolverExecution.NOT_STARTED
|
|
187
|
+
if complete and checkpoint.execution.status in (SolverExecution.RUNNING, SolverExecution.NOT_STARTED):
|
|
188
|
+
raise CalibrationError('Completion record contains unfinished execution')
|
|
189
|
+
if checkpoint.execution.status == SolverExecution.SUCCEEDED and not case.inputs:
|
|
190
|
+
raise CalibrationError('Successful execution is missing solver inputs')
|
|
191
|
+
if checkpoint.HasField('log'):
|
|
192
|
+
if checkpoint.log.path != case.log_path:
|
|
193
|
+
raise CalibrationError('Checkpoint log does not belong to this case')
|
|
194
|
+
verify_artifacts(root, [checkpoint.log])
|
|
195
|
+
remember(root / case.log_path, checkpoint.log.sha256)
|
|
196
|
+
elif checkpoint.execution.status in (SolverExecution.RUNNING, SolverExecution.NOT_STARTED):
|
|
197
|
+
log = artifact_path(root, case.log_path, required=False)
|
|
198
|
+
if log.is_file():
|
|
199
|
+
remember(log) # Snapshot partial output, but never promote it to a successful result.
|
|
200
|
+
if checkpoint.HasField('numerical_report'):
|
|
201
|
+
if not case.numerical_report_path or checkpoint.numerical_report.path != case.numerical_report_path:
|
|
202
|
+
raise CalibrationError('Checkpoint numerical report does not belong to this case')
|
|
203
|
+
verify_artifacts(root, [checkpoint.numerical_report])
|
|
204
|
+
remember(root / case.numerical_report_path, checkpoint.numerical_report.sha256)
|
|
205
|
+
elif case.numerical_report_path and checkpoint.execution.status in (
|
|
206
|
+
SolverExecution.RUNNING, SolverExecution.NOT_STARTED):
|
|
207
|
+
report = artifact_path(root, case.numerical_report_path, required=False)
|
|
208
|
+
if report.is_file():
|
|
209
|
+
remember(report) # Preserve partial evidence without accepting a result.
|
|
210
|
+
checkpoints.append(checkpoint)
|
|
211
|
+
if sha256_file(run_manifest) != manifest_hash:
|
|
212
|
+
raise CalibrationError('Run manifest changed during collection')
|
|
213
|
+
output = output_dir.absolute()
|
|
214
|
+
try:
|
|
215
|
+
output.mkdir()
|
|
216
|
+
written = [copy_artifact(artifact_path(root, name), output / 'runs' / name, digest)
|
|
217
|
+
for name, digest in files.items()]
|
|
218
|
+
collection = CalibrationCollection(schema_version=1, execution_complete=complete,
|
|
219
|
+
run_manifest=reference(output / 'runs' / run_manifest.name, output))
|
|
220
|
+
for case, preparation, checkpoint in zip(manifest.cases, prepared.cases, checkpoints):
|
|
221
|
+
record = collection.cases.add(case_id=case.case_id, execution=checkpoint.execution)
|
|
222
|
+
status = checkpoint.execution.status
|
|
223
|
+
if status in (SolverExecution.NOT_STARTED, SolverExecution.RUNNING):
|
|
224
|
+
record.status = CalibrationCaseResult.INCOMPLETE
|
|
225
|
+
elif status in (SolverExecution.FAILED, SolverExecution.TIMED_OUT, SolverExecution.CANCELLED):
|
|
226
|
+
record.status = CalibrationCaseResult.EXECUTION_FAILED
|
|
227
|
+
record.diagnostics.append(checkpoint.execution.diagnostic)
|
|
228
|
+
elif status == SolverExecution.SUCCEEDED:
|
|
229
|
+
log = output / 'runs' / case.log_path
|
|
230
|
+
try:
|
|
231
|
+
numerical_report = None
|
|
232
|
+
expected_input = None
|
|
233
|
+
if case.numerical_report_path:
|
|
234
|
+
if not checkpoint.HasField('numerical_report') or not checkpoint.execution.arguments:
|
|
235
|
+
raise FasterCapError('Requested numerical report or recorded solver arguments are missing')
|
|
236
|
+
numerical_report = output / 'runs' / case.numerical_report_path
|
|
237
|
+
expected_input = checkpoint.execution.arguments[-1]
|
|
238
|
+
# The recorded argv retains quotes for FasterCap's second
|
|
239
|
+
# tokenizer; its report identifies the unquoted input path.
|
|
240
|
+
if expected_input.startswith('"') and expected_input.endswith('"'):
|
|
241
|
+
expected_input = expected_input[1:-1]
|
|
242
|
+
native, measured = collect_fastercap_matrix(
|
|
243
|
+
log, list(preparation.measurement.conductor_order), preparation.measurement.reference.profile,
|
|
244
|
+
numerical_report=numerical_report, expected_input=expected_input,
|
|
245
|
+
expected_version=manifest.solver.version)
|
|
246
|
+
record.native_matrix.CopyFrom(native)
|
|
247
|
+
record.measured_matrix.CopyFrom(measured)
|
|
248
|
+
record.status = CalibrationCaseResult.COLLECTED
|
|
249
|
+
except FasterCapError as exc:
|
|
250
|
+
record.status = CalibrationCaseResult.INVALID_RESULT
|
|
251
|
+
record.diagnostics.append(str(exc))
|
|
252
|
+
for name, value in _native_statistics(log).items():
|
|
253
|
+
if value is not None and value <= 2**64 - 1:
|
|
254
|
+
setattr(record, name, value)
|
|
255
|
+
for line in log.read_text(encoding='utf-8', errors='replace').splitlines():
|
|
256
|
+
if re.match(r'^\s*(Warning|Error):', line, flags=re.IGNORECASE):
|
|
257
|
+
record.diagnostics.append(line)
|
|
258
|
+
else:
|
|
259
|
+
raise NotImplementedError(f'Collect execution status {status}')
|
|
260
|
+
collection.artifacts.extend(reference(path, output) for path in written)
|
|
261
|
+
path = write_message(output / 'collection.pb.json', collection)
|
|
262
|
+
written.append(path)
|
|
263
|
+
success = sum(case.status == CalibrationCaseResult.COLLECTED for case in collection.cases)
|
|
264
|
+
return CalibrationCollectionResult(path, tuple(written), success, len(collection.cases) - success)
|
|
265
|
+
except OSError as exc:
|
|
266
|
+
raise CalibrationError(f"Cannot collect into '{output}'; evidence was retained: {exc}") from exc
|