#include "pin_role.hpp" #include "parts.hpp" #include "pin_name.hpp" #include "pins.hpp" #include #include #include #include #include // VPX 3U built-in pin role tables. // // NOTE: real VITA 46 pin roles are connector-/profile-specific (data lanes, // power planes, GND chassis, etc.). The placeholders below are intentionally // minimal — fill in the actual per-(col,row) roles for your design when the // reference is available; the rest of the chain (set-connector-type → verify) is // already wired through this single function. namespace { // Quick char column dispatch — returns Other when the column isn't recognised. SignalType vpx_3u_role(char /*col*/, int /*row*/, int /*connector_idx*/) { // TODO: encode the real layout. Right now everything is "other"; verify() // therefore reports nothing for VPX until this table is filled in. return SignalType::Other; } bool parse_pin(const std::string &s, char &col, int &row) { if (s.size() < 2) return false; if (!std::isalpha((unsigned char)s[0])) return false; for (size_t i = 1; i < s.size(); ++i) if (!std::isdigit((unsigned char)s[i])) return false; col = (char)std::toupper((unsigned char)s[0]); try { row = std::stoi(s.substr(1)); } catch (const std::exception &) { return false; } return true; } } // namespace PinSpec pin_role(const std::string &kind, const std::string &pin_name) { PinSpec spec; if (kind.empty()) return spec; char col; int row; if (!parse_pin(pin_name, col, row)) return spec; SignalType st = SignalType::Other; int idx = -1; bool is_vpx_3u = false; if (kind.rfind("vpx-3u-bkp-p", 0) == 0 || kind.rfind("vpx-3u-payload-p", 0) == 0) { is_vpx_3u = true; const std::string suffix = kind.substr(kind.size() - 1); try { idx = std::stoi(suffix); } catch (const std::exception &) {} } if (is_vpx_3u && idx >= 0) st = vpx_3u_role(col, row, idx); spec.function = function_from_signal_type(st); spec.source = SpecSource::ConnectorModel; return spec; } std::vector pin_layout(const std::string &kind) { // TODO: enumerate the canonical pin set for known connector types, // alongside `vpx_3u_role`. Empty for now — `FillPartFromLayout` becomes // a no-op and the rest of the pipeline (verify, explore, identity wiring) // works on whatever pins were imported. (void)kind; return {}; } int FillPartFromLayout(Part *p, const std::string &kind) { if (!p) return 0; auto layout = pin_layout(kind); if (layout.empty()) return 0; std::unordered_set existing; for (auto &kv : *p) existing.insert(canonical_pin_name(kv.first)); int added = 0; for (const auto &name : layout) { if (existing.count(canonical_pin_name(name))) continue; if (p->exists(name)) continue; p->add(new Pin(name)); ++added; } return added; }