diff --git a/lib/components/primitive-components/DifferentialPair_doInitialSourceDesignRuleChecks.ts b/lib/components/primitive-components/DifferentialPair_doInitialSourceDesignRuleChecks.ts index fbb896234..060576740 100644 --- a/lib/components/primitive-components/DifferentialPair_doInitialSourceDesignRuleChecks.ts +++ b/lib/components/primitive-components/DifferentialPair_doInitialSourceDesignRuleChecks.ts @@ -7,7 +7,7 @@ type SourceComponentId = NonNullable type ResolvedPointToPointConnection = { sourcePorts: SourcePort[] - sourceNetName?: string + sourceTraceName?: string } const resolvePointToPointConnection = ( @@ -54,16 +54,10 @@ const resolvePointToPointConnection = ( (sourcePort) => sourcePort.subcircuit_connectivity_map_key === connectivityMapKey, ) - const sourceNet = db.source_net - .list() - .find( - (sourceNet) => - sourceNet.subcircuit_connectivity_map_key === connectivityMapKey, - ) - return { sourcePorts, - sourceNetName: sourceNet?.name, + sourceTraceName: + matchingSourceTraces.length > 0 ? connectionSelector : undefined, } } @@ -94,44 +88,23 @@ const getPointToPointWarningMessage = ({ differentialPairName, connectionPolarity, connectionSelector, - sourceNetName, + sourceTraceName, terminalPinSelectors, }: { differentialPairName: string connectionPolarity: ConnectionPolarity connectionSelector: string - sourceNetName?: string + sourceTraceName?: string terminalPinSelectors: string[] }): string => { - let resolvedConnectionName = `"${connectionSelector}"` - if (sourceNetName) { - resolvedConnectionName = `net.${sourceNetName}` - } - const terminalCount = terminalPinSelectors.length - let pinOrPins = "pins" - if (terminalCount === 1) { - pinOrPins = "pin" - } const terminalList = formatTerminalPinList(terminalPinSelectors) - const suggestedSelector = terminalPinSelectors[0] - let correction = "Connect exactly two terminal pins" - if (terminalCount > 2) { - correction = "Remove the extra connection" - } - let selectorRecommendation = "" - if (suggestedSelector) { - selectorRecommendation = ` and prefer a pin selector such as ${connectionPolarity}Connection="${suggestedSelector}"` - } - let terminalListDescription = "" - if (terminalList) { - terminalListDescription = `: ${terminalList}` + const terminalListDescription = terminalList ? `: ${terminalList}` : "" + + if (sourceTraceName && terminalPinSelectors.length > 2) { + return `Differential pair "${differentialPairName}" ${connectionPolarity}Connection uses the ambiguous trace name "${sourceTraceName}": its connection has more than 2 terminal pins${terminalListDescription}.` } - return ( - `Differential pair "${differentialPairName}" ${connectionPolarity}Connection resolves to ${resolvedConnectionName}, which is not point-to-point. ` + - `It connects to ${terminalCount} ${pinOrPins}${terminalListDescription}. ` + - `${correction}${selectorRecommendation}.` - ) + return `Differential pair "${differentialPairName}" ${connectionPolarity}Connection="${connectionSelector}" is not point-to-point: expected exactly 2 terminal pins, found ${terminalPinSelectors.length}${terminalListDescription}.` } export const DifferentialPair_doInitialSourceDesignRuleChecks = ( @@ -184,7 +157,7 @@ export const DifferentialPair_doInitialSourceDesignRuleChecks = ( differentialPairName: differentialPair.name, connectionPolarity, connectionSelector, - sourceNetName: resolvedConnection.sourceNetName, + sourceTraceName: resolvedConnection.sourceTraceName, terminalPinSelectors, }), subcircuit_id: diff --git a/tests/components/primitive-components/differential-pair/failure-tests/port-selector-multiple-traces-warning.test.tsx b/tests/components/primitive-components/differential-pair/failure-tests/port-selector-multiple-traces-warning.test.tsx index 6bdc92b3b..bea6de7f8 100644 --- a/tests/components/primitive-components/differential-pair/failure-tests/port-selector-multiple-traces-warning.test.tsx +++ b/tests/components/primitive-components/differential-pair/failure-tests/port-selector-multiple-traces-warning.test.tsx @@ -40,6 +40,10 @@ test("stores a warning when a differential pair port selector matches multiple t property_name: "positiveConnection", }) expect(pointToPointWarning?.message).toContain( - 'positiveConnection resolves to ".R1 > .pin1", which is not point-to-point', + 'positiveConnection=".R1 > .pin1" is not point-to-point: expected exactly 2 terminal pins, found 3', ) + expect(pointToPointWarning?.message).not.toContain( + "Remove the extra connection", + ) + expect(pointToPointWarning?.message).not.toContain("prefer a pin selector") }) diff --git a/tests/components/primitive-components/differential-pair/point-to-point-warning-circuit-json.test.tsx b/tests/components/primitive-components/differential-pair/point-to-point-warning-circuit-json.test.tsx index e556a8113..ead649515 100644 --- a/tests/components/primitive-components/differential-pair/point-to-point-warning-circuit-json.test.tsx +++ b/tests/components/primitive-components/differential-pair/point-to-point-warning-circuit-json.test.tsx @@ -32,6 +32,6 @@ test("stores a property warning for a branched differential pair", (): void => { }) expect(pointToPointWarnings[0]?.source_component_id).toBeDefined() expect(pointToPointWarnings[0]?.message).toBe( - 'Differential pair "USB_DATA" positiveConnection resolves to net.DP, which is not point-to-point. It connects to 3 pins: .J1 > .pin1, .TP1 > .pin1, and .U1 > .pin1. Remove the extra connection and prefer a pin selector such as positiveConnection=".J1 > .pin1".', + 'Differential pair "USB_DATA" positiveConnection uses the ambiguous trace name "DP_FROM_J1": its connection has more than 2 terminal pins: .J1 > .pin1, .TP1 > .pin1, and .U1 > .pin1.', ) }) diff --git a/tests/components/primitive-components/differential-pair/zero-terminal-point-to-point-warning.test.tsx b/tests/components/primitive-components/differential-pair/zero-terminal-point-to-point-warning.test.tsx index b2e260018..9ff717230 100644 --- a/tests/components/primitive-components/differential-pair/zero-terminal-point-to-point-warning.test.tsx +++ b/tests/components/primitive-components/differential-pair/zero-terminal-point-to-point-warning.test.tsx @@ -30,6 +30,6 @@ test("stores a warning for a differential-pair connection with no terminal pins" property_name: "positiveConnection", }) expect(warning?.message).toBe( - 'Differential pair "USB_DATA" positiveConnection resolves to net.DP, which is not point-to-point. It connects to 0 pins. Connect exactly two terminal pins.', + 'Differential pair "USB_DATA" positiveConnection="DP_EMPTY" is not point-to-point: expected exactly 2 terminal pins, found 0.', ) })