diff --git a/src/system/pin_role.cpp b/src/system/pin_role.cpp index 445be05..050cdb2 100644 --- a/src/system/pin_role.cpp +++ b/src/system/pin_role.cpp @@ -40,13 +40,15 @@ bool parse_pin(const std::string &s, char &col, int &row) { } // namespace -SignalType pin_role(const std::string &kind, const std::string &pin_name) +PinSpec pin_role(const std::string &kind, const std::string &pin_name) { - if (kind.empty()) return SignalType::Other; + PinSpec spec; + if (kind.empty()) return spec; char col; int row; - if (!parse_pin(pin_name, col, row)) return SignalType::Other; + 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 @@ -55,9 +57,11 @@ SignalType pin_role(const std::string &kind, const std::string &pin_name) const std::string suffix = kind.substr(kind.size() - 1); try { idx = std::stoi(suffix); } catch (const std::exception &) {} } - if (is_vpx_3u && idx >= 0) return vpx_3u_role(col, row, idx); + if (is_vpx_3u && idx >= 0) st = vpx_3u_role(col, row, idx); - return SignalType::Other; + spec.function = function_from_signal_type(st); + spec.source = SpecSource::ConnectorModel; + return spec; } std::vector pin_layout(const std::string &kind) diff --git a/src/system/pin_role.hpp b/src/system/pin_role.hpp index fb20073..2a9f0fe 100644 --- a/src/system/pin_role.hpp +++ b/src/system/pin_role.hpp @@ -1,22 +1,22 @@ #ifndef _PIN_ROLE_HPP_ #define _PIN_ROLE_HPP_ -#include "signal_type.hpp" +#include "pin_spec.hpp" #include #include class Part; -// For a given connector type and pin position, return the expected SignalType -// (Power / GndShield / Other). Used at `set-connector-type` to populate each pin's -// `expected_signal_type`, then later by `verify` to flag mismatches between -// the connector's expectation and the actual signal's inferred/declared type. +// For a given connector type and pin position, return the expected PinSpec +// (function/direction/pad + source). Used at `set-connector-type` to populate +// each pin's `spec`, then later by `verify` to flag mismatches between the +// connector's expectation and the actual signal's inferred/declared type. // -// Returns SignalType::Other for unknown connector types or unmatched pins — -// caller can treat that as "no expectation, no constraint". -SignalType pin_role(const std::string &connector_type, - const std::string &pin_name); +// Returns a default PinSpec (function Unknown, source None) for unknown +// connector types or unmatched pins — i.e. "no expectation, no constraint". +PinSpec pin_role(const std::string &connector_type, + const std::string &pin_name); // Canonical full pin-name list for the connector type (e.g. for VPX 3U, // every (col, row) position the connector physically has). Returns an empty diff --git a/src/system/pin_spec.hpp b/src/system/pin_spec.hpp new file mode 100644 index 0000000..2d7189d --- /dev/null +++ b/src/system/pin_spec.hpp @@ -0,0 +1,54 @@ +#ifndef _PIN_SPEC_HPP_ +#define _PIN_SPEC_HPP_ + +#include "signal_type.hpp" + +#include + +#pragma once + +// Direction of a pin as seen from the component (port/BSDL semantics). +enum class PinDirection { Unknown, In, Out, Bidir, Passive, Power }; + +// Functional role of a pin. Richer than SignalType (which classifies *nets*): +// this classifies the *pin* itself and carries the TAP roles JTAG checks need. +enum class PinFunction { + Unknown, Power, Ground, Signal, Clock, NoConnect, + JtagTdi, JtagTdo, JtagTms, JtagTck, JtagTrst +}; + +// Where a pin's expected attributes came from. Lets verify report conflicts and +// lets a user override win over a model-derived value. +enum class SpecSource { None, Imported, ConnectorModel, Bsdl, Inferred, UserOverride }; + +// Expected, model-derived attributes of a pin (from a connector layout, a BSDL +// model, …). The "expected" half of the expected-vs-observed verify duality; +// the "observed" half stays Pin::signal() + the net + inference. +struct PinSpec { + PinFunction function = PinFunction::Unknown; + PinDirection direction = PinDirection::Unknown; + std::string pad; ///< Physical terminal (package ball/pin); "" if unknown. + SpecSource source = SpecSource::None; +}; + +// PinFunction -> the net SignalType a pin of that function expects to sit on. +inline SignalType to_signal_type(PinFunction f) +{ + switch (f) { + case PinFunction::Power: return SignalType::Power; + case PinFunction::Ground: return SignalType::GndShield; + default: return SignalType::Other; + } +} + +// Coarse SignalType -> PinFunction, used when a model only yields a SignalType. +inline PinFunction function_from_signal_type(SignalType t) +{ + switch (t) { + case SignalType::Power: return PinFunction::Power; + case SignalType::GndShield: return PinFunction::Ground; + default: return PinFunction::Unknown; + } +} + +#endif // _PIN_SPEC_HPP_ diff --git a/src/system/pins.cpp b/src/system/pins.cpp index 0173e2a..61c2fa4 100644 --- a/src/system/pins.cpp +++ b/src/system/pins.cpp @@ -3,8 +3,12 @@ #include "signals.hpp" Pin::Pin(std::string name) - : SystemElement(name), sig(nullptr), prnt(nullptr), - expected_signal_type(SignalType::Other) {}; + : SystemElement(name), sig(nullptr), prnt(nullptr) {}; + +SignalType Pin::expected_signal_type() const +{ + return to_signal_type(spec.function); +} const char *nc_origin_tag(NcOrigin o) { switch (o) { diff --git a/src/system/pins.hpp b/src/system/pins.hpp index 58f8913..c4ded90 100644 --- a/src/system/pins.hpp +++ b/src/system/pins.hpp @@ -2,6 +2,7 @@ #define _PINS_HPP_ #include "signal_type.hpp" +#include "pin_spec.hpp" #include "syselmts.hpp" #pragma once @@ -29,11 +30,13 @@ class Pin : public SystemElement public: Pin(std::string name); Part *prnt; ///< Pointer to the parent part. - SignalType expected_signal_type; ///< Set from connector_type at set-connector-type. + PinSpec spec; ///< Expected, model-derived attributes (connector layout / BSDL). Not persisted; re-applied from the model. NcOrigin nc_origin = NcOrigin::None; bool connected(); Signal *signal() const { return sig; } void connect(Signal *signal); + // Net type this pin expects, derived from spec.function (Power/GndShield/Other). + SignalType expected_signal_type() const; }; class Pins : public SystemElementContainer diff --git a/src/tui/commands.cpp b/src/tui/commands.cpp index f112823..7aef14c 100644 --- a/src/tui/commands.cpp +++ b/src/tui/commands.cpp @@ -235,7 +235,7 @@ void Tui::RegisterCommands() { for (auto &nkv : *prt) { Pin *pin = nkv.second; ++checked; - SignalType expected = pin->expected_signal_type; + SignalType expected = pin->expected_signal_type(); if (expected == SignalType::Other) continue; Signal *s = pin->signal(); SignalType actual = s ? s->type : SignalType::Other; @@ -440,7 +440,7 @@ void Tui::RegisterCommands() { prt->connector_type = args[2]; int filled = FillPartFromLayout(prt, args[2]); for (auto &kv : *prt) - kv.second->expected_signal_type = pin_role(args[2], kv.first); + kv.second->spec = pin_role(args[2], kv.first); Print(mod->name + "/" + prt->name + ": connector_type = " + (args[2].empty() ? "(none)" : args[2])); if (filled > 0) @@ -648,7 +648,7 @@ void Tui::RegisterCommands() { for (auto &nkv : *sp) { Pin *sn = nkv.second; Pin *dn = new Pin(sn->name); - dn->expected_signal_type = sn->expected_signal_type; + dn->spec = sn->spec; dn->nc_origin = sn->nc_origin; dp->add(dn); if (sn->signal()) { diff --git a/src/tui/screen_analyze.cpp b/src/tui/screen_analyze.cpp index baf0b86..d3020dd 100644 --- a/src/tui/screen_analyze.cpp +++ b/src/tui/screen_analyze.cpp @@ -64,7 +64,7 @@ Component Tui::BuildAnalyzeScreen() { for (auto &nkv : *prt) { Pin *pin = nkv.second; ++n_typed_pins; - SignalType expected = pin->expected_signal_type; + SignalType expected = pin->expected_signal_type(); if (expected == SignalType::Other) continue; Signal *s = pin->signal(); SignalType actual = s ? s->type : SignalType::Other; diff --git a/src/tui/screen_dashboard.cpp b/src/tui/screen_dashboard.cpp index a7eb69f..69223bf 100644 --- a/src/tui/screen_dashboard.cpp +++ b/src/tui/screen_dashboard.cpp @@ -83,7 +83,7 @@ Component Tui::BuildDashboardScreen() { for (auto &nkv : *prt) { Pin *pin = nkv.second; ++n_typed_pins; - SignalType expected = pin->expected_signal_type; + SignalType expected = pin->expected_signal_type(); if (expected == SignalType::Other) continue; Signal *s = pin->signal(); SignalType actual = s ? s->type : SignalType::Other; diff --git a/src/tui/screen_settype.cpp b/src/tui/screen_settype.cpp index e2ee30d..168f5ba 100644 --- a/src/tui/screen_settype.cpp +++ b/src/tui/screen_settype.cpp @@ -69,7 +69,7 @@ Component Tui::BuildSettypeScreen() { } prt->connector_type = settype_type; for (auto &kv : *prt) - kv.second->expected_signal_type = pin_role(settype_type, kv.first); + kv.second->spec = pin_role(settype_type, kv.first); std::string msg = mod->name + "/" + prt->name + " = " + (settype_type.empty() ? "(none)" : settype_type); settype_status = "applied: " + msg;