feat: add DRC check to prevent I2C SDA and SCL from connecting#98
Open
techmannih wants to merge 9 commits intotscircuit:mainfrom
Open
feat: add DRC check to prevent I2C SDA and SCL from connecting#98techmannih wants to merge 9 commits intotscircuit:mainfrom
techmannih wants to merge 9 commits intotscircuit:mainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
seveibar
reviewed
Feb 21, 2026
seveibar
reviewed
Feb 22, 2026
seveibar
reviewed
Feb 22, 2026
seveibar
reviewed
Feb 22, 2026
seveibar
reviewed
Feb 22, 2026
| } from "circuit-json" | ||
| import { getSourcePortConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map" | ||
|
|
||
| type SourceComponent = Extract< |
seveibar
reviewed
Feb 22, 2026
|
|
||
| errors.push({ | ||
| type: "source_i2c_misconfigured_error", | ||
| source_i2c_misconfigured_error_id: `source_i2c_misconfigured_error_${conflictIdStr}`, |
Contributor
There was a problem hiding this comment.
these are normally generated or something- you should never create ids like this
seveibar
reviewed
Feb 22, 2026
| 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.`, |
Contributor
There was a problem hiding this comment.
bad. Give the user exact instructions for how to fix and use toMatchInlineSnapshot for the error in the test
Contributor
There was a problem hiding this comment.
It's just not a good error but i can't even see it until you have toMatchInlineSnapshot
seveibar
reviewed
Feb 22, 2026
|
|
||
| const connMap = getSourcePortConnectivityMapFromCircuitJson(circuitJson) | ||
|
|
||
| for (const [netId, connectedPortIds] of Object.entries(connMap.netMap)) { |
Contributor
There was a problem hiding this comment.
inefficient mechanism. Find the ports first
seveibar
reviewed
Feb 22, 2026
|
|
||
| // Get all source ports to easily look up their attributes | ||
| const sourcePorts = circuitJson.filter( | ||
| (el): el is Extract<AnyCircuitElement, { type: "source_port" }> => |
seveibar
reviewed
Feb 24, 2026
| > | ||
|
|
||
| export function checkI2cSdaConnectedToSclMisconfigured( | ||
| circuitJson: AnyCircuitElement[], |
Contributor
There was a problem hiding this comment.
Suggested change
| circuitJson: AnyCircuitElement[], | |
| circuitJson: AnyCircuitElement[], | |
| ctx?: DrcContext |
ctx ??= getDrcContext(circuitJson) type DrcContext = {
connMap: ConnectivityMap,
db: CircuitJsonUtil
}
Contributor
There was a problem hiding this comment.
ctx.db.source_port.list({ is_i2c_sda: true })
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.