Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type SourceComponentId = NonNullable<SourcePort["source_component_id"]>

type ResolvedPointToPointConnection = {
sourcePorts: SourcePort[]
sourceNetName?: string
sourceTraceName?: string
}

const resolvePointToPointConnection = (
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -184,7 +157,7 @@ export const DifferentialPair_doInitialSourceDesignRuleChecks = (
differentialPairName: differentialPair.name,
connectionPolarity,
connectionSelector,
sourceNetName: resolvedConnection.sourceNetName,
sourceTraceName: resolvedConnection.sourceTraceName,
terminalPinSelectors,
}),
subcircuit_id:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
)
})
Loading