diff

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package diff computes a semantic diff between two netlist IR Designs. It operates purely on the IR (CONSTRAINTS C1), with no I/O and no platform calls, so the same diff runs over any format that reads into the IR. Design and rationale are in docsite/content/architecture/semantic-diff.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentChange

type ComponentChange struct {
	RefDes string
	Field  string
	Old    string
	New    string
}

ComponentChange records one changed field on a component present in both designs.

type NetChange

type NetChange struct {
	Kind    NetChangeKind
	Name    string
	OldName string
	Added   []string
	Removed []string
	OldProv *ir.Provenance
	NewProv *ir.Provenance
	// Approx is the near-match pass's evidence, non-nil only for NetRenamedApprox.
	Approx *RenameEvidence
}

NetChange is one classified net-level change. Name is the net's name in the design where it exists, so a rename gives the new name. OldName is set only for renames. Added/Removed hold the "refdes.pin" connection deltas for a Hard change. OldProv/NewProv locate the net in each revision's source. Each is nil on the side where the net does not exist.

type NetChangeKind

type NetChangeKind string

NetChangeKind classifies a net change. It follows the taxonomy that engineers use as ground truth (New / Deleted / rename / connectivity vs attribute-only). Equal nets are not changes, so they are kept apart in Report.Equal and reported only when a caller asks (agni issue 818).

const (
	NetNew     NetChangeKind = "new"     // present only in the new design
	NetDeleted NetChangeKind = "deleted" // present only in the old design
	NetRenamed NetChangeKind = "renamed" // same connectivity, different name
	// NetRenamedApprox marks a net that the near-match pass believes was renamed and ALSO changed.
	// The exact pass cannot recover such a net, because its signature no longer matches. The pairing
	// is the engine's best assignment among candidates, not a fact, so it gets a distinct kind. A
	// consumer that must not act on a guess can filter on it. Approx holds the evidence.
	NetRenamedApprox NetChangeKind = "renamed-approx"
	NetHard          NetChangeKind = "hard" // connectivity (pin membership) changed
	NetSoft          NetChangeKind = "soft" // attribute-only change; connectivity identical
	// NetEqual is a net present in both designs under one name with identical connectivity and
	// attributes. It is never in Report.Nets, only in Report.Equal.
	NetEqual NetChangeKind = "equal"
)

type RenameEvidence added in v0.2.0

type RenameEvidence struct {
	OldCoverage            float64 // fraction of the old net's endpoints that survived
	OldCoverageSignificant float64 // the same, ignoring insignificant endpoint classes
	NewCoverageSignificant float64 // fraction of the new net's significant endpoints that are old
	Overlap                int     // endpoints in both
	OverlapSignificant     int     // significant endpoints in both
	OldEndpoints           int     // size of the old net
	NewEndpoints           int     // size of the new net
	OldSignificant         int     // significant endpoints on the old net
	NewSignificant         int     // significant endpoints on the new net
}

RenameEvidence records why the near-match pass paired one deleted net with one added net, so a reader can DISAGREE with the pairing. It is set only on NetRenamedApprox. The significant figures ignore probe churn. See docsite/content/architecture/semantic-diff.md#near-matches-off-by-default.

type RenameOptions added in v0.2.0

type RenameOptions struct {
	// Enabled gates the whole pass. False reproduces the exact-signature output exactly.
	Enabled bool
	// MinOldCoverage is the fraction of the OLD net's endpoints that must survive into the
	// candidate. Lower catches heavier rewires and starts pairing nets that merely overlap.
	MinOldCoverage float64
	// MinOldCoverageSignificant is the same fraction over significant endpoints only. It does most
	// of the work, because probe churn cannot move it.
	MinOldCoverageSignificant float64
	// MinNewCoverage is the fraction of the NEW net made up of old endpoints. It guards the
	// asymmetric case, where a large net containing all of a small one is not its rename.
	MinNewCoverage float64
	// MinNewCoverageSignificant is that guard over significant endpoints.
	MinNewCoverageSignificant float64
	// MaxAddedSignificantFloor is how many significant endpoints a net may GAIN and still read as
	// itself, when half its old significant count is smaller. The floor lets a two-endpoint net
	// become four.
	MaxAddedSignificantFloor int
	// MinSignificantEndpoints is the floor below which no near-match is attempted. A net with one
	// significant endpoint has no shape to match on.
	MinSignificantEndpoints int
	// InsignificantClasses are the device classes excluded from the overlap arithmetic, by
	// ir.Component.DeviceClasses rather than by ref-des spelling. A house that treats mounting holes
	// or fiducials as probe-like churn adds them here.
	InsignificantClasses []string
}

RenameOptions tunes the NEAR-match rename pass. It sets how much a net may change and still read as itself. The zero value is disabled, so a caller that passes nothing gets the exact-signature behaviour and nothing else.

These are a value rather than ambient state (C22), because a dense board with heavy test point coverage wants different numbers from a small module.

The thresholds come in significant/all pairs. A significant count skips every endpoint whose component is in InsignificantClasses. That makes the pass insensitive to probe churn. The knob table is in docsite/content/architecture/semantic-diff.md#near-matches-off-by-default.

func DefaultRenameOptions added in v0.2.0

func DefaultRenameOptions() RenameOptions

DefaultRenameOptions returns the calibrated thresholds, with Enabled false.

They are the settled values of a netlist comparison tool run against real revision pairs for years. Looser values mis-paired unrelated power rails and tighter ones missed renames where one decoupling capacitor was added or removed. Produce a precision number before trusting them on a corpus that matters.

type Report

type Report struct {
	ComponentsAdded   []string
	ComponentsRemoved []string
	ComponentsChanged []ComponentChange
	Nets              []NetChange
	// Equal holds the nets that did not change, as NetEqual entries sorted by name. A revision report
	// lists every net under its outcome, and with Equal it need not rebuild the unchanged nets by
	// subtracting the changes (agni issue 818). Render and the wire leave them out unless asked.
	Equal []NetChange
}

Report is the result of diffing two designs.

func Designs

func Designs(a, b *ir.Design, opts ...RenameOptions) *Report

Designs diffs a (old) against b (new).

Passing no opts, or a RenameOptions with Enabled false, runs the exact passes alone. The near-match pass is opt-in because it guesses, and a gate reading the output should say whether it wants that. Later options win, so a caller may layer a default and an override.

func (*Report) Render

func (r *Report) Render(limit int) string

Render returns a human-readable report. limit caps how many items are listed per section; a non-positive limit lists everything. The caller (e.g. the CLI) chooses the limit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL