Skip to content

feat: add DRC check to prevent I2C SDA and SCL from connecting#98

Open
techmannih wants to merge 9 commits intotscircuit:mainfrom
techmannih:jk
Open

feat: add DRC check to prevent I2C SDA and SCL from connecting#98
techmannih wants to merge 9 commits intotscircuit:mainfrom
techmannih:jk

Conversation

@techmannih
Copy link
Member

No description provided.

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@techmannih techmannih changed the title feat: add DRC constraint to prevent I2C SDA and SCL from connecting feat: add DRC check to prevent I2C SDA and SCL from connecting Feb 21, 2026
@techmannih techmannih requested a review from seveibar February 22, 2026 05:23
} from "circuit-json"
import { getSourcePortConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map"

type SourceComponent = Extract<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


errors.push({
type: "source_i2c_misconfigured_error",
source_i2c_misconfigured_error_id: `source_i2c_misconfigured_error_${conflictIdStr}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are normally generated or something- you should never create ids like this

type: "source_i2c_misconfigured_error",
source_i2c_misconfigured_error_id: `source_i2c_misconfigured_error_${conflictIdStr}`,
error_type: "source_i2c_misconfigured_error",
message: `${portDetails.join(" is connected to ")} on the same net. To fix this, ensure SDA and SCL are routed to separate nets.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad. Give the user exact instructions for how to fix and use toMatchInlineSnapshot for the error in the test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just not a good error but i can't even see it until you have toMatchInlineSnapshot


const connMap = getSourcePortConnectivityMapFromCircuitJson(circuitJson)

for (const [netId, connectedPortIds] of Object.entries(connMap.netMap)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inefficient mechanism. Find the ports first


// Get all source ports to easily look up their attributes
const sourcePorts = circuitJson.filter(
(el): el is Extract<AnyCircuitElement, { type: "source_port" }> =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import SourcePort

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

>

export function checkI2cSdaConnectedToSclMisconfigured(
circuitJson: AnyCircuitElement[],
Copy link
Contributor

@seveibar seveibar Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
circuitJson: AnyCircuitElement[],
circuitJson: AnyCircuitElement[],
ctx?: DrcContext
ctx ??= getDrcContext(circuitJson)  
type DrcContext = {
  connMap: ConnectivityMap,
  db: CircuitJsonUtil
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.db.source_port.list({ is_i2c_sda: true })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants