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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ export interface AutoroutingPhaseProps extends RoutingTolerances {
connection?: string;
connections?: string[];
reroute?: boolean;
/**
* Fanout direction for each named bus in this phase. `center` leaves the
* direction unconstrained.
*/
busFanoutDirections?: Record<BusName, BusFanoutDirection>;
}
```

Expand Down
15 changes: 15 additions & 0 deletions generated/COMPONENT_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,11 @@ export const analogTransientSimulationProps = z
### autoroutingphase

```typescript
export type BusFanoutDirection =
| NinePointAnchor
| {
direction: NinePointAnchor
}
export interface AutoroutingPhaseProps extends RoutingTolerances {
key?: any
name?: string
Expand All @@ -1142,7 +1147,12 @@ export interface AutoroutingPhaseProps extends RoutingTolerances {
connection?: string
connections?: string[]
reroute?: boolean
busFanoutDirections?: Record<BusName, BusFanoutDirection>
}
/**
* Fanout direction for each named bus in this phase. `center` leaves the
* direction unconstrained.
*/
export const autoroutingPhaseProps = z
.object({
key: z.any().optional(),
Expand All @@ -1162,6 +1172,7 @@ export const autoroutingPhaseProps = z
connection: z.string().optional(),
connections: z.array(z.string()).optional(),
reroute: z.boolean().optional(),
busFanoutDirections: z.record(busFanoutDirection).optional(),
})
```

Expand Down Expand Up @@ -2347,6 +2358,8 @@ export interface AutorouterConfig {
| "krt"
| "freerouting"
| "laser_prefab" // Prefabricated PCB with laser copper ablation
| "single_layer_fanout"
| "fanout"
| /** @deprecated Use "auto_jumper" */ "auto-jumper"
| /** @deprecated Use "sequential_trace" */ "sequential-trace"
| /** @deprecated Use "auto_local" */ "auto-local"
Expand Down Expand Up @@ -2392,6 +2405,8 @@ export const autorouterConfig = z.object({
"krt",
"freerouting",
"laser_prefab",
"single_layer_fanout",
"fanout",
"auto-jumper",
"sequential-trace",
"auto-local",
Expand Down
7 changes: 7 additions & 0 deletions generated/PROPS_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export interface AutorouterConfig {
| "krt"
| "freerouting"
| "laser_prefab" // Prefabricated PCB with laser copper ablation
| "single_layer_fanout"
| "fanout"
| /** @deprecated Use "auto_jumper" */ "auto-jumper"
| /** @deprecated Use "sequential_trace" */ "sequential-trace"
| /** @deprecated Use "auto_local" */ "auto-local"
Expand Down Expand Up @@ -202,6 +204,11 @@ export interface AutoroutingPhaseProps extends RoutingTolerances {
connection?: string
connections?: string[]
reroute?: boolean
/**
* Fanout direction for each named bus in this phase. `center` leaves the
* direction unconstrained.
*/
busFanoutDirections?: Record<BusName, BusFanoutDirection>
}


Expand Down
2 changes: 2 additions & 0 deletions lib/common/ninePointAnchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export const ninePointAnchor = z.enum([
"bottom_center",
"bottom_right",
])

export type NinePointAnchor = z.infer<typeof ninePointAnchor>
22 changes: 22 additions & 0 deletions lib/components/autoroutingphase.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { expectTypesMatch } from "lib/typecheck"
import { z } from "zod"
import {
type NinePointAnchor,
ninePointAnchor,
} from "../common/ninePointAnchor"
import type { BusName } from "./bus"
import {
type AutorouterProp,
type RoutingTolerances,
autorouterProp,
routingTolerances,
} from "./group"

export type BusFanoutDirection =
| NinePointAnchor
| {
direction: NinePointAnchor
}

export interface AutoroutingPhaseProps extends RoutingTolerances {
key?: any
name?: string
Expand All @@ -22,8 +33,18 @@ export interface AutoroutingPhaseProps extends RoutingTolerances {
connection?: string
connections?: string[]
reroute?: boolean
/**
* Fanout direction for each named bus in this phase. `center` leaves the
* direction unconstrained.
*/
busFanoutDirections?: Record<BusName, BusFanoutDirection>
}

const busFanoutDirection = z.union([
ninePointAnchor,
z.object({ direction: ninePointAnchor }),
])

export const autoroutingPhaseProps = z
.object({
key: z.any().optional(),
Expand All @@ -43,6 +64,7 @@ export const autoroutingPhaseProps = z
connection: z.string().optional(),
connections: z.array(z.string()).optional(),
reroute: z.boolean().optional(),
busFanoutDirections: z.record(busFanoutDirection).optional(),
})
.superRefine((value, ctx) => {
if (
Expand Down
2 changes: 2 additions & 0 deletions lib/components/bus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expectTypesMatch } from "lib/typecheck"
import { z } from "zod"

export type BusName = string

/**
* Declares a group of connections that an autorouter should keep together.
* Each connection may be a trace name or a port selector.
Expand Down
8 changes: 8 additions & 0 deletions lib/components/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ export interface AutorouterConfig {
| "krt"
| "freerouting"
| "laser_prefab" // Prefabricated PCB with laser copper ablation
| "single_layer_fanout"
| "fanout"
| /** @deprecated Use "auto_jumper" */ "auto-jumper"
| /** @deprecated Use "sequential_trace" */ "sequential-trace"
| /** @deprecated Use "auto_local" */ "auto-local"
Expand All @@ -371,6 +373,8 @@ export type AutorouterPreset =
| "krt"
| "freerouting"
| "laser_prefab"
| "single_layer_fanout"
| "fanout"
| "auto-jumper"
| "sequential-trace"
| "auto-local"
Expand Down Expand Up @@ -425,6 +429,8 @@ export const autorouterConfig = z.object({
"krt",
"freerouting",
"laser_prefab",
"single_layer_fanout",
"fanout",
"auto-jumper",
"sequential-trace",
"auto-local",
Expand All @@ -446,6 +452,8 @@ export const autorouterPreset = z.union([
z.literal("krt"),
z.literal("freerouting"),
z.literal("laser_prefab"), // Prefabricated PCB with laser copper ablation
z.literal("single_layer_fanout"),
z.literal("fanout"),
z.literal("auto-jumper"),
z.literal("sequential-trace"),
z.literal("auto-local"),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/node": "^20.12.11",
"@types/react": "^18.3.2",
"ava": "^6.1.3",
"circuit-json": "^0.0.450",
"circuit-json": "^0.0.455",
"expect-type": "^1.3.0",
"glob": "^11.0.0",
"madge": "^8.0.0",
Expand Down
10 changes: 10 additions & 0 deletions tests/autorouter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ test("supports krt preset", () => {
expect(result).toBe("krt")
})

test("supports fanout presets", () => {
expect(autorouterProp.parse("single_layer_fanout")).toBe(
"single_layer_fanout",
)
expect(autorouterProp.parse("fanout")).toBe("fanout")
expect(autorouterProp.parse({ preset: "fanout" })).toMatchObject({
preset: "fanout",
})
})
Comment on lines +47 to +55

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A *.test.ts file may have AT MOST one test(...) call. This file already contained at least one test(...) before this PR, and the new test("supports fanout presets", ...) block adds another. The file should be split into multiple numbered files, e.g. autorouter1.test.ts, autorouter2.test.ts, etc., each containing exactly one test(...) call.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.


test("still supports deprecated kebab-case presets", () => {
const result = autorouterProp.parse("auto-cloud")
expect(result).toBe("auto-cloud")
Expand Down
12 changes: 12 additions & 0 deletions tests/autoroutingphase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ test("autorouting phase accepts autorouter and phase index", () => {
expect(parsed.phaseIndex).toBe(1)
})

test("autorouting phase accepts per-bus fanout directions", () => {
const raw = {
autorouter: "fanout",
busFanoutDirections: {
DATA: "top_right",
CONTROL: { direction: "center_left" },
},
} satisfies AutoroutingPhaseProps

expect(autoroutingPhaseProps.parse(raw)).toEqual(raw)
})
Comment on lines +33 to +43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A *.test.ts file may have AT MOST one test(...) call. This file already contained multiple test(...) calls before this PR, and the new test("autorouting phase accepts per-bus fanout directions", ...) block adds yet another. The file should be split into multiple numbered files, e.g. autoroutingphase1.test.ts, autoroutingphase2.test.ts, etc., each containing exactly one test(...) call.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.


test("autorouting phase accepts a single connection", () => {
const raw: AutoroutingPhaseProps = {
phaseIndex: 2,
Expand Down
Loading