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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "test/fixtures/cadence/LAUNCHXL-CC1310"]
path = test/fixtures/cadence/LAUNCHXL-CC1310
url = https://github.com/valentinozegna/kHome
[submodule "test/fixtures/altium/aberrant-sound-module"]
path = test/fixtures/altium/aberrant-sound-module
url = https://github.com/valentinozegna/aberrant-sound-module
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.1] - 2026-03-10

### Fixed

- Preserve leading/trailing whitespace in DSN net names instead of silently trimming ([#49](https://github.com/IntelligentElectron/universal-netlist/issues/49))
- Coverage report matches nets by connectivity (component set) instead of exact name, eliminating false missing/extra net pairs caused by whitespace differences

## [0.1.0] - 2026-03-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@intelligentelectron/universal-netlist",
"version": "0.1.0",
"version": "0.1.1",
"description": "MCP server for netlist parsing and circuit analysis",
"type": "module",
"main": "dist/index.js",
Expand Down
67 changes: 65 additions & 2 deletions src/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface CoverageResult {
compCoverage: number;
missingNets: { name: string; category: string; connections: Record<string, unknown> }[];
extraNets: { name: string; category: string }[];
renamedNets: number;
mpn: FieldStats;
value: FieldStats;
description: FieldStats;
Expand Down Expand Up @@ -86,14 +87,54 @@ export const analyzeCoverage = (
const dsnComps = new Set(Object.keys(dsn.components));
const commonCompKeys = [...dsnComps].filter((c) => refComps.has(c));

const missingNets = [...refNets]
let missingNets = [...refNets]
.filter((n) => !dsnNets.has(n))
.map((name) => ({ name, category: categorizeNet(name), connections: reference.nets[name] }));

const extraNets = [...dsnNets]
let extraNets = [...dsnNets]
.filter((n) => !refNets.has(n))
.map((name) => ({ name, category: categorizeNet(name) }));

// Second pass: match unmatched nets by connectivity (pin-set signature).
// Handles whitespace-renamed nets: DSN preserves " SIGNAL_A" while DAT
// strips to "SIGNAL_A" or appends "_1" on collision.
const pinSetSignature = (connections: Record<string, string | string[]>): string => {
const pairs: string[] = [];
for (const [refdes, pins] of Object.entries(connections)) {
const pinList = Array.isArray(pins) ? pins : [pins];
for (const pin of pinList) pairs.push(`${refdes}.${pin}`);
}
return pairs.sort().join(",");
};

let renamedNets = 0;
if (missingNets.length > 0 && extraNets.length > 0) {
const extraBySignature = new Map<string, string>();
for (const extra of extraNets) {
const connections = dsn.nets[extra.name];
if (connections) {
const sig = pinSetSignature(connections);
if (sig) extraBySignature.set(sig, extra.name);
}
}

const matchedMissing = new Set<string>();
const matchedExtra = new Set<string>();
for (const missing of missingNets) {
const sig = pinSetSignature(missing.connections as Record<string, string | string[]>);
if (sig && extraBySignature.has(sig)) {
matchedMissing.add(missing.name);
matchedExtra.add(extraBySignature.get(sig)!);
renamedNets++;
}
}

if (renamedNets > 0) {
missingNets = missingNets.filter((n) => !matchedMissing.has(n.name));
extraNets = extraNets.filter((n) => !matchedExtra.has(n.name));
}
}

const mpn = emptyFieldStats();
const value = emptyFieldStats();
const description = emptyFieldStats();
Expand Down Expand Up @@ -198,6 +239,7 @@ export const analyzeCoverage = (
compCoverage: refComps.size > 0 ? commonCompKeys.length / refComps.size : 1,
missingNets,
extraNets,
renamedNets,
mpn,
value,
description,
Expand Down Expand Up @@ -300,6 +342,11 @@ const formatVerboseDesignTerminal = (
}
};

if (r.renamedNets > 0) {
lines.push("");
lines.push(` Renamed nets (matched by connectivity): ${r.renamedNets}`);
}

formatNets("Missing nets", r.missingNets, true);
formatNets("Extra nets", r.extraNets, false);

Expand Down Expand Up @@ -389,6 +436,11 @@ const formatVerboseDesignMarkdown = (
}
};

if (r.renamedNets > 0) {
lines.push("");
lines.push(`Renamed nets (matched by connectivity): ${r.renamedNets}`);
}

formatNets("Missing nets", r.missingNets, true);
formatNets("Extra nets", r.extraNets, false);

Expand Down Expand Up @@ -473,6 +525,11 @@ const formatAggregateTerminal = (results: CoverageResult[], lines: string[]): vo
);
}

const totalRenamed = sum((r) => r.renamedNets);
if (totalRenamed > 0) {
lines.push(`Renamed: ${totalRenamed} (matched by connectivity)`);
}

const totalMissing = sum((r) => r.missingNets.length);
const totalExtra = sum((r) => r.extraNets.length);
if (totalMissing > 0 || totalExtra > 0) {
Expand Down Expand Up @@ -532,6 +589,12 @@ const formatAggregateMarkdown = (results: CoverageResult[], lines: string[]): vo
lines.push(`| ${field} | ${match} | ${total} | ${pct(match, total)} | ${notes} |`);
}

const totalRenamed = sum((r) => r.renamedNets);
if (totalRenamed > 0) {
lines.push("");
lines.push(`Renamed nets (matched by connectivity): ${totalRenamed}`);
}

const totalMissing = sum((r) => r.missingNets.length);
const totalExtra = sum((r) => r.extraNets.length);
if (totalMissing > 0 || totalExtra > 0) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/altium/aberrant-sound-module
Submodule aberrant-sound-module added at ff0c9f
Loading