Posts Tagged ‘extract pld ic content’

PostHeaderIcon Extract PLD Source Code: Acceptance Is Recompilation, Not Identity

Every reconstruction project needs a definition of done, and in programmable logic that definition cannot be identity. The original source file is gone, and even if a copy existed there would be no way to prove the reconstruction matches it rather than merely producing the same configuration.

This is not a counsel of despair. It is a clarification that makes acceptance possible, because it replaces an unattainable test with two attainable ones. The first is recompilation: compile the reconstruction and compare the resulting configuration against the device. The second is simulation: evaluate both against every input combination. Either can be made rigorous, and the choice between them depends on what the customer needs to do next.

Three candidate acceptance tests

Test What it establishes Practical limit
Byte identity with the original source Nothing attainable The original is unavailable
Identity of the reconstructed configuration Exact structural match Depends on tool version and settings
Functional equivalence over all inputs Complete behavioural match Input count must be enumerable
Behavioural match on a test set Match for realistic use Coverage is a judgement

The second row is stronger than it looks and is often achievable, because the same equations fitted to the same device by the same tool tend to produce the same mapping. It is also brittle, since a tool version change can alter the mapping without changing behaviour.

The third row is the rigorous one, and on these devices it is genuinely available: a twenty-input device has just over a million input combinations, and exhaustive simulation of both the original array and the reconstructed equations settles the question completely.

Why equivalence is provable here and not on a microcontroller

The difference is state. A microcontroller has memory whose contents evolve, so equivalence requires reasoning about all reachable states. A combinational PLD has no state at all, and equivalence is a truth table comparison.

Device class Equivalence question Feasibility
Combinational PLD Same output for every input vector Trivial
Registered PLD Same output sequence for every input sequence Tractable with formal tools
Small CPLD Same state machine behaviour Tractable; state space is small
Microcontroller Same behaviour for all programs and data Not feasible in general

The second row is where most real devices sit, and the practical approach is to enumerate the reachable state space, which for a device with eight state bits and a handful of inputs is thousands of combinations rather than millions.

The reconstruction itself

What is produced is an equation set per output, with feedback nets named and configuration choices documented.

Component Why it is in the deliverable
Per-output equations The logic
Feedback net declarations Whether behaviour is sequential
Polarity information Whether outputs are inverted
Registered or combinational flag per cell The cell’s mode
Simplification level used Affects the form, not the function
Equivalence evidence Proof that the test passes

The fourth row is easy to omit and essential to include, because a reader who does not know whether a macrocell is registered will misinterpret every equation that references it.

When the tool refuses to reproduce the array

A reconstruction can be functionally correct and fail the identity test, and the reasons are worth knowing so the failure is not misread as an error.

Cause Evidence
Different tool version Same equations, different fitting
Different optimisation setting Different product term allocation
Different device revision Different internal mapping
Don’t-care exploitation Fewer terms than the original
Manual placement in the original The tool cannot reproduce a hand-placed fit

The fifth row is the interesting one. Some designs were fitted by hand, with specific signals assigned to specific macrocells to meet timing. A tool re-fitting the same equations will choose differently, and the result is functionally identical and structurally different.

What a customer usually wants

The acceptance test should match the purpose, and the purposes fall into a few categories.

Purpose Adequate test
Manufacture replacements Configuration identity, or equivalence
Modify the design Equivalence plus readable equations
Document the product Equivalence plus behavioural notes
Prove infringement or origin Structural similarity, which is a different analysis

The fourth row is not a technical acceptance test at all and should not be sold as one. Establishing that two designs are related requires comparing structure, placement and style, and it produces an opinion rather than a proof.

Delivering the evidence

The deliverable should include the test, not just its result.

Item Form
Equation set Text, human readable
Recompiled configuration In the device’s container
Comparison result Identical, or a diff
Simulation log Vectors, expected, actual
Known differences Explicitly listed

The fifth item is what makes a deliverable trustworthy. A reconstruction that claims perfect equivalence invites suspicion; one that lists the three places where the fit differs and explains why is credible.

Where this connects

The equation recovery that this acceptance test validates is described in reading PLD binary into equations, and the array that everything starts from is in reading PLD binary source code. Where the device contains a state machine, the equivalence argument has to cover sequences rather than vectors, and attacking CPLD source code covers the transition table that makes that possible.

Equivalence is also the tool used when several devices have to be told apart, since two arrays that are equivalent are the same build and two that are not are different builds by definition. Extracting PLD firmware applies that idea to the problem of identifying which revision a device holds.

Services at this boundary

Work covers equation reconstruction, configuration re-fitting, exhaustive or formal equivalence checking, documented diffs where identity is not achieved, and behavioural notes. It does not cover producing the original source file, and it does not cover claiming identity when only equivalence was demonstrated.

The sentence worth putting in every report is the one that names the test: equivalent over all input vectors, or equivalent over the reachable state space, or matching on a specified set.

PostHeaderIcon Extract PLD Firmware: There Is No Version Number in a Fuse Map

Every other kind of firmware carries some mark of its identity. A microcontroller hex file has a checksum, a compiler version string in a comment, sometimes a firmware revision constant in a table. An FPGA bitstream has a header with a device and a date in the tool’s metadata. A PLD fuse map has none of this. It is a set of bits, and the bits do not know when they were created.

This becomes a practical problem the moment more than one build exists. A production run spans years, a design was revised twice, and the question is which devices on the shelf hold which revision. The fuse map cannot answer that directly. It can only be fingerprinted.

What the array does contain

Content Metadata? Useful for identification
Logic configuration No Only by comparison
Macrocell modes No Structural signature
Signature row, if used Sometimes Directly, if the designer filled it
Unused term patterns No Tool version fingerprint
Pin assignment No Board revision fingerprint

The signature row is the only intended channel, and it is empty on most devices. Its absence is the reason fingerprinting exists.

Unused terms as a tool fingerprint

This is the most underused identification technique in this field. Tools differ in how they disable unused product terms, and the difference is visible in the array.

Tool behaviour Pattern in unused terms
Term set to a contradiction Signal ANDed with its complement
Term left with no connections All fuses erased
Term connected to a constant A fixed input combination
Terms grouped per output Distinct blocks of disabled terms

Two devices produced by different tool versions frequently differ in the second row, and two devices from the same version agree. That gives a coarse but real classification: builds from era A versus builds from era B.

Structural signatures

Beyond unused terms, the structure of the logic itself is a signature, and it is more discriminating than the tool pattern.

Structural feature Stability across builds
Number of product terms used per output Changes when logic changes
Which macrocells are used at all Stable unless the design grows
Register usage pattern Stable for a given architecture
Feedback topology Stable unless the state machine changes
Pin assignment Stable unless the board changed

The fifth row deserves emphasis: pin assignment is chosen by the board, not by the tool, so it is one of the most stable features and one of the most useful for distinguishing board revisions.

Building a fingerprint that can be compared

A fingerprint is a vector of features, each of which is stable within a class and different between classes.

Feature Computation Discriminating power
Fuse count set Count of programmed locations Low; many designs land nearby
Per-output term counts Vector of term usage Medium
Macrocell mode bitmap Which cells are registered Medium
Pin usage bitmap Which pins are driven High for board revisions
Signature row bytes Direct read Definitive when present
Hash of the full array Cryptographic digest Definitive when comparing two files

The last row is worth having even though it identifies nothing on its own: a hash answers the question “are these two devices identical” instantly, and that question comes up constantly during a production audit.

The workflow for a shelf of devices

Step Purpose
Read every device Arrays in hand
Group by hash Exact duplicates identified
Group by structural signature Near-duplicates and revisions
Extract signature rows Any intentional labels
Compare groups against known builds Assignment
Report with confidence per group Honest output

The sixth step matters. Some devices will not be assignable, and a report that says so is more useful than one that forces every device into a category.

When the ambiguity cannot be resolved

Sometimes two builds differ in a way that does not show up in the array — a change to a constant that was optimised away, or a change that only affects timing through placement. In that case identification has to come from outside.

Additional evidence Source
Date code on the package Marking
Board revision the device sits on Silkscreen
Behavioural difference under test Bench measurement
Production records Customer’s own archive
Firmware revision in a companion MCU Its image

The fifth row is often decisive on mixed boards: the microcontroller’s image carries a version string, and the PLD revision is correlated with it.

What the extraction actually produces

The deliverable for this kind of work is not just arrays. It is arrays plus a comparison structure.

Item Purpose
Each device’s array The raw evidence
Hash per device Grouping
Feature vector per device Classification
Group assignment with confidence The answer
Unassigned devices with reasons Honest gaps

Where the surrounding work is covered

Reading the arrays is in reading PLD binary source code and extracting PLD EEPROM for the physical side. Establishing whether two arrays are equivalent is in extracting PLD source code, and the container that carries the arrays is in reading the JED format.

Services at this boundary

Work covers array readout across a batch, hashing and grouping, structural feature extraction, signature row interpretation, correlation with companion devices, and a per-device assignment with confidence. It does not cover inventing a version number that the device does not carry, and it does not cover distinguishing builds that are identical in the array.

The reframing is that identity in this field is constructed rather than read, and a constructed identity is only as good as the features behind it — which is why the feature list should be in the report.