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
10 changes: 10 additions & 0 deletions docs/decision-tables/dsn-net-assignment/pin-conflict.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prior_net,new_net,outcome,next,status,note
none,NET_A,assign the pin to the incoming net,,draft,"no prior assignment, so the incoming net is the pin's net"
none,NET_B,assign the pin to the incoming net,,draft,"no prior assignment, so the incoming net is the pin's net"
none,NC,assign the pin to the incoming net,,draft,"an unconnected pin is assigned to the NC net"
NET_A,NET_A,keep the existing assignment,,draft,"re-assigning the same net is idempotent; the pin stays a member of one net"
NET_A,NET_B,reject the conflicting assignment,,draft,"net-assembly.ts addPinToNet: a physical pin in two net memberships with only the last assignment recorded is the unreadable-JSON failure of #327"
NET_A,NC,reject the conflicting assignment,,draft,"a pin connected to a net and also recorded unconnected is the same conflict"
NC,NET_A,reject the conflicting assignment,,draft,"#327 repro case same-pin-unconnected-and-connected"
NC,NET_B,reject the conflicting assignment,,draft,"a pin recorded unconnected and also connected is the same conflict"
NC,NC,keep the existing assignment,,draft,"re-recording an unconnected pin is idempotent"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"default":{"next":"","outcome":"reject the conflicting assignment"},"name":"pin-conflict","rules":[{"cells":3,"next":"","outcome":"assign the pin to the incoming net","when":{"prior_net":["none"]}},{"cells":1,"next":"","outcome":"keep the existing assignment","when":{"new_net":["NET_A"],"prior_net":["NET_A"]}},{"cells":1,"next":"","outcome":"keep the existing assignment","when":{"new_net":["NC"],"prior_net":["NC"]}}]}
9 changes: 9 additions & 0 deletions docs/decision-tables/dsn-net-assignment/pin-conflict.rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
| # | When | Outcome | Next | Cells |
|---|---|---|---|---|
| 1 | prior_net = none | assign the pin to the incoming net | | 3 |
| 2 | prior_net = NET_A; new_net = NET_A | keep the existing assignment | | 1 |
| 3 | prior_net = NC; new_net = NC | keep the existing assignment | | 1 |
| else | everything else | reject the conflicting assignment | | |

9 cells became 3 rules plus a default
NET_A is the net of the pin's first assignment; NET_B is a different net; NC is the unconnected net.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"assumes":"One physical pin (refdes + pin number) assembled twice: NET_A is the net of its first assignment, NET_B a different net, NC the unconnected net. A net name here is the resolved name of the record's net id.","dimensions":{"prior_net":["none","NET_A","NC"],"new_net":["NET_A","NET_B","NC"]},"name":"pin-conflict"}
16 changes: 16 additions & 0 deletions src/parsers/cadence/dsn/net-assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,29 @@
import type { NetConnections } from "../../../types.js";
import type { PinInfo } from "./net-pins.js";

/**
* A physical pin (refdes + pin number) belongs to at most one net. A second
* assignment to a different net is a conflict, not a second membership: keeping
* both memberships while the component-side map records only the last
* assignment produces a graph the Universal Netlist reader rejects, so the
* conflict surfaces here instead of a successful export writing a file the
* same release cannot reload. Re-assigning the same net is idempotent.
*/
function addPinToNet(
nets: NetConnections,
componentPins: Map<string, Map<string, string>>,
netName: string,
refdes: string,
pinNumber: string
): void {
const assigned = componentPins.get(refdes)?.get(pinNumber);
if (assigned !== undefined && assigned !== netName) {
throw new Error(
`Pin ${refdes}.${pinNumber} is assigned to both '${assigned}' and '${netName}'; ` +
`a physical pin belongs to one net, so the netlist cannot be built until the ` +
`conflicting assignments are resolved.`
);
}
if (!nets[netName]) nets[netName] = {};
const existing = nets[netName][refdes];
if (!existing) {
Expand Down
43 changes: 42 additions & 1 deletion src/parsers/cadence/dsn/net-assignment.table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import path from "path";
import { describe, expect, it } from "vitest";
import { expandHierarchy } from "./hierarchy-expander.js";
import { assembleNets } from "./net-assembly.js";
import { buildNetConnectivity } from "./net-builder.js";
import { pinNetSource } from "./net-pins.js";
import { pinNetSource, type PinInfo } from "./net-pins.js";
import { findPinMap } from "./pin-resolver.js";
import type { BlockOccurrence, HierarchyScope, HierarchyStream } from "./hierarchy-parser.js";
import type { PageData } from "./page-parser.js";
Expand Down Expand Up @@ -201,6 +202,46 @@ describe("pin-net: where a pin's net comes from", () => {
}
});

describe("pin-conflict: one physical pin, one net", () => {
const dims = ["prior_net", "new_net"];
// A pin record assigning U1.OUT4 to a net: a distinct netId per record, with
// coordNet naming the net, so each record resolves to the net it names. An
// NC record is unconnected (netId 0, no coordNet), as classifyPins reads it.
const pin = (net: string, netId: number): PinInfo => ({
refdes: "U1",
pinNumber: "OUT4",
// An NC record carries netId 0; a nonzero netId with no coordNet would
// resolve to a fallback N{netId} name instead of the NC net.
netId: net === "NC" ? 0 : netId,
pageIdx: 0,
coord: "0,0",
...(net === "NC" ? {} : { coordNet: net }),
});

for (const row of readTable(TABLES, "pin-conflict").filter((r) => r.outcome !== "n/a")) {
it(cellName(row, dims), () => {
const pins: PinInfo[] = [];
if (row.prior_net !== "none") pins.push(pin(row.prior_net, 11));
pins.push(pin(row.new_net, 12));
if (row.outcome === "reject the conflicting assignment") {
// No-connect records are assembled before net-id groups, so NC is
// always the first assignment when it is one of the two.
const [first, second] =
row.new_net === "NC" ? ["NC", row.prior_net] : [row.prior_net, row.new_net];
expect(() => assembleNets(pins, new Set())).toThrowError(
`Pin U1.OUT4 is assigned to both '${first}' and '${second}'`
);
return;
}
const { nets, componentPins } = assembleNets(pins, new Set());
expect(componentPins.get("U1")?.get("OUT4")).toBe(row.new_net);
expect(nets[row.new_net]?.U1).toEqual(["OUT4"]);
// The pin is a member of exactly one net.
expect(Object.keys(nets)).toEqual([row.new_net]);
});
}
});

describe("pin-ignore: whether an ignored pin reaches a net", () => {
const dims = ["pin_ignored", "named_in_pack_short", "group_has_placed_pin"] as const;
const pin = (pinIndex: number, x: number, wireId: number): T0x10 => ({
Expand Down