Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ debug-outputs
cosmos-export
.vercel
.aider*
demo-decoupling.ts
demo-decoupling.js
package-lock.json
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./solvers/LayoutPipelineSolver/LayoutPipelineSolver"
export * from "./types/InputProblem"
export * from "./types/OutputLayout"
export { DecouplingCapLayoutSolver } from "./solvers/DecouplingCapLayoutSolver"
36 changes: 36 additions & 0 deletions lib/solvers/DecouplingCapLayoutSolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export class DecouplingCapLayoutSolver {
inputProblem: any

constructor(inputProblem: any) {
this.inputProblem = inputProblem
}

solve() {
const components = this.inputProblem.components || []

const capacitors = components.filter((c: any) =>
c.type?.toLowerCase()?.includes("cap"),
)

const chips = components.filter((c: any) =>
c.type?.toLowerCase()?.includes("chip"),
)

chips.forEach((chip: any) => {
const relatedCaps = capacitors.filter((cap: any) =>
cap.pins?.some((p: any) => p.net === "GND"),
)

const spacing = 5
const startX = (chip.x || 0) + 10
const startY = chip.y || 0

relatedCaps.forEach((cap: any, i: number) => {
cap.x = startX
cap.y = startY + i * spacing
})
})

return this.inputProblem
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
"graphics-debug": "^0.0.64",
"react-cosmos": "^7.0.0",
"react-cosmos-plugin-vite": "^7.0.0",
"ts-node": "^10.9.2",
"tscircuit": "^0.0.593",
"tsup": "^8.5.0"
"tsup": "^8.5.0",
"typescript": "^5.9.3"
},
"peerDependencies": {
"typescript": "^5"
Expand Down
Loading