# Twin generation and checks

How CircuitTwin builds twins from vendor documents on its own engine, cross-checks sources and validates cores and peripherals. Every number links to its evidence JSON.

Every record below carries the `provisional` label (nothing is labelled `verified` yet). 9 of 10 records come from a clean tree on 21 November 2026 at `287d49a4a` after freezing release binaries; the remaining 1 is an older clean-tree record. Hardware checks use one unit per board.

## Inputs

Every extracted fact stores its exact source so later sources can challenge it.

| Input                                | Extracted data                                                                                |
| ------------------------------------ | --------------------------------------------------------------------------------------------- |
| Datasheets & reference manuals (PDF) | Register maps, reset values, memory maps, bus addresses, protocol timing and sensor behavior. |
| CMSIS-SVD                            | Peripherals, registers, bit fields, reset values, interrupts and CPU core.                    |
| CMSIS packs                          | Resolved via Open-CMSIS-Pack index for register maps, memories, processor and startup region. |
| Vendor C headers (CMSIS / HAL)       | Base addresses, offsets, bit positions and interrupt numbers (no reset values).               |
| Microchip ATDF                       | Classic/modern AVR core selection and offsets; SAM pin signals.                               |
| Zephyr device trees (Apache-2.0)     | Memories, boot address, interrupts, core description and STM32 pin muxing.                    |
| Errata sheets                        | Per-revision silicon errata and workarounds (opt-in only; off by default).                    |

Missing fields fall back to cited family tables (always overridden by supplied documents). Unbound peripherals stay register files and trigger the [unmodelled policy](#unmodelled). Assisted proposals are accepted only when deterministic code parses a verbatim quote from the cited page; disabling them leaves output byte-identical.

## Fact ledger

Each extracted fact (register offset, bit width, IRQ number) lands in one of three states:

| State    | Meaning                                                    |
| -------- | ---------------------------------------------------------- |
| agree    | All values match across at least two independent lineages. |
| disagree | Sources report different values.                           |
| single   | One source, or multiple files sharing a single lineage.    |

SVD, CMSIS device headers and HAL headers share one vendor-database lineage and count as one witness. Community sources (Zephyr device trees, Linux drivers) are independent witnesses. Because the ledgers below compare SVD and CMSIS headers only, `agree` is 0; all listed disagreements are real.

| Part        | Disagree | Single source | Agree | Disagreements (per bit field) |
| ----------- | -------- | ------------- | ----- | ----------------------------- |
| STM32F407VG | 30       | 31,960        | 0     | 27                            |
| STM32F103C8 | 15       | 16,347        | 0     | 13                            |
| STM32F767ZI | 127      | 46,967        | 0     | 127                           |

**Record provenance (twin-generation/fact-ledger.json)**

[twin-generation/fact-ledger.json](https://circuittwin.ai/evidence/twin-generation/fact-ledger.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

## Promotion gate

Evaluates a ledger for a part or path prefix (whole-segment match: `peripherals.USART1` skips `USART10`). Prints `pass` with zero disagreements, `block` with the conflict list, or refuses uncovered parts. Report-only today; it does not auto-set capability labels.

Example: STM32F407VG returned `block` (30 disagreements, e.g. `peripherals.FLASH.registers.CR.fields.SNB.bitWidth`: SVD 4, CMSIS header 5). NOSUCHPART exited 2 (“the ledger does not cover NOSUCHPART”).

**Record provenance (twin-generation/fact-ledger.json)**

[twin-generation/fact-ledger.json](https://circuittwin.ai/evidence/twin-generation/fact-ledger.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

## Held-out reset values

Compares stable post-reset register reads from physical silicon against twins generated without that unit’s data. A hash-sealed variant commits expected values beforehand (proves non-tampering, not blind generation).

| Part (unit)                                                      | Checked | Documents alone | With family rules |
| ---------------------------------------------------------------- | ------- | --------------- | ----------------- |
| ESP32-S3 (Adafruit Qualia ESP32-S3 rev v0.2 (ROM download mode)) | 3,372   | 2,924           | 3,334             |
| STM32F767ZI (NUCLEO-F767ZI rev Z)                                | 2,082   | 1,914           | 1,979             |
| STM32U585AI (Arduino UNO Q (STM32U585))                          | 4,072   | 3,306           | 3,987             |
| **All three**                                                    | 9,526   | 8,144           |                   |

Small sample (three parts, two families, one unit each, mostly zeros) from generator `0.1.0+policy.6` (not re-run since). Same record across 16 MCUs (SVD vs vendor header): 625 disagreements, 231,634 single-source; 67,946 matches share one vendor lineage and are not counted as independent agreement.

**Record provenance (twin-generation/held-out-reset-values.json)**

[twin-generation/held-out-reset-values.json](https://circuittwin.ai/evidence/twin-generation/held-out-reset-values.json) (2026-11-05, `08bfb0b91`, clean tree). Label: provisional.

## Peripheral oracles

Small firmware binaries checking single reference-manual rules (e.g. ADC trigger, DMA completion). Checks the model against the manual, not silicon.

23 of 23 pass on one frozen build:

| Oracle                    | Board             | Result |
| ------------------------- | ----------------- | ------ |
| avr-adc-trigger-oracle    | arduino-uno       | PASS   |
| nrf52-saadc-oracle        | nrf52840-dk       | PASS   |
| stm32f0-hal-adc-oracle    | nucleo-f091rc     | PASS   |
| stm32f0-hal-dma-oracle    | nucleo-f091rc     | PASS   |
| stm32f0-hal-exti-oracle   | nucleo-f091rc     | PASS   |
| stm32f0-hal-i2c-oracle    | nucleo-f091rc     | PASS   |
| stm32f0-hal-spi-oracle    | nucleo-f091rc     | PASS   |
| stm32f0-hal-tim-oracle    | nucleo-f091rc     | PASS   |
| stm32f0-hal-uart-oracle   | nucleo-f091rc     | PASS   |
| stm32f103-hal-adc-oracle  | nucleo-f103rb     | PASS   |
| stm32f103-hal-dma-oracle  | nucleo-f103rb     | PASS   |
| stm32f103-hal-exti-oracle | nucleo-f103rb     | PASS   |
| stm32f103-hal-i2c-oracle  | nucleo-f103rb     | PASS   |
| stm32f103-hal-spi-oracle  | nucleo-f103rb     | PASS   |
| stm32f103-hal-tim-oracle  | nucleo-f103rb     | PASS   |
| stm32f103-hal-uart-oracle | nucleo-f103rb     | PASS   |
| stm32f407-hal-adc-oracle  | stm32f4-discovery | PASS   |
| stm32h743-hal-tim-oracle  | nucleo-h743zi2    | PASS   |
| stm32l476-hal-adc-oracle  | nucleo-l476rg     | PASS   |
| stm32l476-hal-i2c-oracle  | nucleo-l476rg     | PASS   |
| stm32l476-hal-spi-oracle  | nucleo-l476rg     | PASS   |
| stm32l476-hal-uart-oracle | nucleo-l476rg     | PASS   |
| teensy41-edma-gpt-oracle  | teensy-4-1        | PASS   |

**Record provenance (accuracy/peripheral-oracles-2026-11-21.json)**

[accuracy/peripheral-oracles-2026-11-21.json](https://circuittwin.ai/evidence/accuracy/peripheral-oracles-2026-11-21.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

## Vendor-driver checks

Unmodified open-source drivers (pinned commits, minimal bus/console glue) run against generated twins and verify round-trip readings within datasheet bounds. Every part includes a **negative control** (out-of-tolerance stimulus or wrong bus address) that must fail.

10 of 10 pass positive runs; 10 of 10 negative controls fail as intended. Host: nucleo-f767zi (generator `0.1.0+policy.12`).

| Part      | Driver (commit, licence)                                                     | Stages        | Round-trip error vs bound                                                                                                                     | Negative control                                            |
| --------- | ---------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| MCP9808   | [2f534d26b](https://github.com/libdriver/mcp9808), MIT                       | PASS (5 of 5) | TEMPERATURE\_mC error 0 of ±500 mC                                                                                                            | Fails as intended: stimulus outside the datasheet tolerance |
| HDC1080   | [265403c03](https://github.com/libdriver/hdc1080), MIT                       | PASS (6 of 6) | TEMPERATURE\_mC error -1 of ±400 mC; HUMIDITY\_m%RH error 0 of ±2,000 m%RH                                                                    | Fails as intended: stimulus outside the datasheet tolerance |
| INA219    | [266a1ee32](https://github.com/libdriver/ina219), MIT                        | PASS (7 of 7) | BUS\_mV error 0 of ±4 mV; SHUNT\_uV error 0 of ±310 uV; CURRENT\_mA error -1 of ±3 mA                                                         | Fails as intended: stimulus outside the datasheet tolerance |
| PCA9685   | [592c8ee64](https://github.com/libdriver/pca9685), MIT                       | PASS (7 of 7) | FREQUENCY\_Hz error 0 of ±1 Hz; DUTY\_m% error -25 of ±25 m%                                                                                  | Fails as intended: part at address 0x41 instead of 0x40     |
| AT24C256C | [aa2a2a393](https://github.com/libdriver/at24cxx), MIT                       | PASS (6 of 6) | NEIGHBOUR\_BYTES error 0 of ±0 sum                                                                                                            | Fails as intended: part at address 0x51 instead of 0x50     |
| ADXL345   | [b15a89852](https://github.com/libdriver/adxl345), MIT                       | PASS (7 of 7) | ACCEL\_X\_mg error -1 of ±40 mg; ACCEL\_Y\_mg error 0 of ±35 mg; ACCEL\_Z\_mg error -2 of ±50 mg                                              | Fails as intended: stimulus outside the datasheet tolerance |
| MPU-6050  | [4b46e1ec3](https://github.com/libdriver/mpu6050), MIT                       | PASS (8 of 8) | ACCEL\_X\_mg error 0 of ±65 mg; ACCEL\_Z\_mg error 0 of ±110 mg; GYRO\_X\_mdps error 0 of ±23,000 mdps; TEMPERATURE\_mC error 0 of ±1,000 mC  | Fails as intended: stimulus outside the datasheet tolerance |
| SHT31-DIS | [4026a907a](https://github.com/Sensirion/embedded-i2c-sht3x), BSD-3-Clause   | PASS (6 of 6) | TEMPERATURE\_mC error -2 of ±200 mC; HUMIDITY\_m%RH error 0 of ±2,000 m%RH                                                                    | Fails as intended: stimulus outside the datasheet tolerance |
| LSM6DSO   | [b45daae59](https://github.com/STMicroelectronics/lsm6dso-pid), BSD-3-Clause | PASS (8 of 8) | ACCEL\_X\_mg error 0 of ±21 mg; ACCEL\_Z\_mg error -1 of ±21 mg; GYRO\_X\_mdps error +3 of ±2,000 mdps; TEMPERATURE\_mC error 0 of ±15,000 mC | Fails as intended: stimulus outside the datasheet tolerance |
| MAX31855  | [5f145c394](https://github.com/libdriver/max31855), MIT                      | PASS (6 of 6) | THERMOCOUPLE\_mC error 0 of ±2,000 mC; JUNCTION\_mC error 0 of ±63 mC                                                                         | Fails as intended: stimulus outside the datasheet tolerance |

One datasheet per twin, except MPU-6050 (2 docs). Defaulted reads logged: HDC1080 (3), INA219 (1), LSM6DSO (8). Host board notes (2): energy.not-estimated (info) and mcu.fixed-word-upper-defaulted (warning).

**Record provenance (accuracy/driver-oracles-2026-11-21.json)**

[accuracy/driver-oracles-2026-11-21.json](https://circuittwin.ai/evidence/accuracy/driver-oracles-2026-11-21.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

## CPU differential testing

Seeded random valid programs execute identically on our core and an independent emulator, comparing all registers, flags, stores and faults. Planted bugs (negative controls) must be rejected.

| Profile                    | Reference                                                                 | Programs | Disagreements |
| -------------------------- | ------------------------------------------------------------------------- | -------- | ------------- |
| ARMv6-M                    | Unicorn 2.1.4 (QEMU 5.0.1), Cortex-M0 model                               | 20,000   | 0             |
| ARMv7-M                    | Unicorn 2.1.4 (QEMU 5.0.1), Cortex-M3 model                               | 20,000   | 0             |
| ARMv7E-M, FPv4-SP          | Unicorn 2.1.4 (QEMU 5.0.1), Cortex-M4 model                               | 20,000   | 0             |
| ARMv7E-M, FPv5-D16         | Unicorn 2.1.4 (QEMU 5.0.1), Cortex-M7 model                               | 20,000   | 0             |
| ARMv8-M Baseline           | Unicorn 2.1.4 (QEMU 5.0.1), Cortex-M33 model (no Cortex-M23 in reference) | 20,000   | 0             |
| ARMv8-M Mainline           | Unicorn 2.1.4 (QEMU 5.0.1), Cortex-M33 model                              | 20,000   | 0             |
| Xtensa LX6 (ESP32)         | qemu-xtensa (Espressif fork), esp\_develop\_9.2.2\_20260417               | 20,000   | 0             |
| Xtensa LX7 (ESP32-S3)      | qemu-xtensa (Espressif fork), esp\_develop\_9.2.2\_20260417               | 20,000   | 0             |
| Xtensa LX7 (ESP32-S3), FPU | qemu-xtensa (Espressif fork), esp\_develop\_9.2.2\_20260417               | 20,000   | 0             |
| RISC-V rv32imac            | Unicorn, SiFive E31                                                       | 20,000   | 0             |
| RISC-V rv32ec              | Unicorn, SiFive E31                                                       | 20,000   | 0             |
| RISC-V rv32 bitmanip       | QEMU user mode                                                            | 20,000   | 0             |
| RISC-V rv32imafc           | QEMU user mode                                                            | 20,000   | 0             |
| RISC-V rv32imafdc          | QEMU user mode                                                            | 20,000   | 0             |

Arm retired 1,973,189 instructions. Rejected controls: EOR is computed as ORR (Thumb 16-bit) (24/9,000); ADDX2 shifts the first operand by 2 instead of 1 (10/1,500); floating-point rounding ignores the rounding-mode register (16/1,500); XOR is computed as OR (12/4,500); the rounding modes round-down and round-up are swapped (8/8,000).

16-bit Arm sweep (excluding SVC, 59,136/profile): 0 undocumented differences; documented reference deviations across profiles: 1,288, 46, 46, 46, 296, 78\. Found and fixed 7 core bugs; logged 26 reference deviations. Cumulative across 13 runs: 12,200,000 programs, 0 disagreements (8 lack revision stamps, so only the stamped run is tabulated). Excludes exception entry/return, NVIC and MPU (absent in Unicorn).

**Record provenance (accuracy/cpu-differential.json)**

[accuracy/cpu-differential.json](https://circuittwin.ai/evidence/accuracy/cpu-differential.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

Additional cores run at both cited and default test counts:

| Core & profile     | Reference                                                                                                   | Cited count | Default count |                |      |
| ------------------ | ----------------------------------------------------------------------------------------------------------- | ----------- | ------------- | -------------- | ---- |
| Cases              | Disagreements                                                                                               | Cases       | Disagreements |                |      |
| AVR, atmega2560    | simavr 1.6                                                                                                  | 200         | 0             | 4,000          | 0    |
| AVR, atmega328p    | simavr 1.6                                                                                                  | 200         | 0             | 4,000          | 0    |
| Renesas RXv1, rxv1 | qemu-system-rx (RX62N, gdbsim-r5f562n8 machine) 10.2.4                                                      | 4,000       | 0             | same           | same |
| STM8, stm8         | ucsim sstm8 (from SDCC 4.2.0) 0.6.4                                                                         | 200         | 0             | 2,000          | 8    |
| PIC24F/H, pic24    | specification model written by the project (not an executing reference, not independent of the core author) | 400         | 0             | 2,704 of 6,000 | 8    |

Default-count disagreements: STM8 (2,000 programs) has 8 (reference bug on Z flag after division); PIC24F/H has 8 in the stack-limit path and uses a same-team specification model (no independent reference). Details in [Accuracy report](https://circuittwin.ai/docs/accuracy#cores).

**Record provenance (4 JSON files)**

[accuracy/avr-differential.json](https://circuittwin.ai/evidence/accuracy/avr-differential.json) (2026-11-21, `287d49a4a`, clean tree) ; [accuracy/rx-differential.json](https://circuittwin.ai/evidence/accuracy/rx-differential.json) (2026-11-21, `287d49a4a`, clean tree) ; [accuracy/stm8-differential.json](https://circuittwin.ai/evidence/accuracy/stm8-differential.json) (2026-11-21, `287d49a4a`, clean tree) ; [accuracy/pic24-differential.json](https://circuittwin.ai/evidence/accuracy/pic24-differential.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

## Unmodelled registers

Unmodelled accesses are logged with register, direction and count. When all assertions pass, policy sets the verdict:

| Policy                | Verdict                                                                                                                                                                                                        |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| behavioural (default) | Inconclusive on writes/polls to register-file peripherals, reserved/undocumented offsets, unmapped/unclocked addresses, RO-memory stores or log overflow. Plain reads of documented registers are logged only. |
| strict                | Any unmodelled access (including plain reads) exits inconclusive.                                                                                                                                              |
| allow                 | Stays pass; accesses remain logged. No built-in vendor allowlist exists.                                                                                                                                       |

- ESP32-S3 ESP-IDF hello: default exits 4 (inconclusive, 40 accesses across 8 registers: APB\_SARADC, UART0); `allow` exits 0\. Twister exits 5 default / 0 with `allow`.
- NUCLEO-F767ZI servo-sweep: passes with 0 unmodelled accesses.
- CH32V003 (unmodelled I2C1/ADC1 writes): default and strict exit 4; `allow` exits 0.

**Record provenance (accuracy/unmodelled-access-2026-11-21.json)**

[accuracy/unmodelled-access-2026-11-21.json](https://circuittwin.ai/evidence/accuracy/unmodelled-access-2026-11-21.json) (2026-11-21, `287d49a4a`, clean tree). Label: provisional.

## Evidence labels

| Label       | Meaning                                                                                                            |
| ----------- | ------------------------------------------------------------------------------------------------------------------ |
| provisional | Modelled or measured without clean-tree independent multi-unit confirmation.                                       |
| unsupported | Unmodelled, refused or reported as register-file only.                                                             |
| verified    | Independent reproducible reference on a clean tree (2+ physical units for boards). Nothing carries verified today. |

Labels stay scoped: a peripheral result never transfers to another part’s memory map, clocks, pin muxing, reset values or errata. Current checks use one physical unit per board, same-lineage SVD and CMSIS headers for fact ledgers, and user-mode Arm differential coverage (excluding exceptions, NVIC and MPU). See [Board dashboard](https://circuittwin.ai/docs/board-dashboard) and [Accuracy report](https://circuittwin.ai/docs/accuracy).

**Source records, commit revisions & SHA-256 hashes**

Summary records retain numbers, revision, tree state and source SHA-256 without local build paths.

| Record                                                                                                                     | Scope                                 | Revision & tree                   | Product repo source (SHA-256)                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| [twin-generation/fact-ledger.json](https://circuittwin.ai/evidence/twin-generation/fact-ledger.json)                       | Fact ledger and promotion gate        | 287d49a4a, clean tree, 2026-11-21 | eval-results/final-2026-11-21/final-13/results.json at d02ef5052 (f2787153ed090fa86efb19f9a673768ffb12c3cc1ffb312b50c505feee641d84)           |
| [twin-generation/held-out-reset-values.json](https://circuittwin.ai/evidence/twin-generation/held-out-reset-values.json)   | Held-out reset values                 | 08bfb0b91, clean tree, 2026-11-05 | eval-results/generator-confidence-2026-11-05.json (9348ffbc73f4f2d3af7b352ad1a36521b82cd202bbccfefa49771370ab9665a6)                          |
| [accuracy/peripheral-oracles-2026-11-21.json](https://circuittwin.ai/evidence/accuracy/peripheral-oracles-2026-11-21.json) | Peripheral oracles                    | 287d49a4a, clean tree, 2026-11-21 | eval-results/final-2026-11-21/oracles/results.json at d02ef5052 (1d0e8112288f85b94468b6a97ff06c1cb9c8cd3ce31dd07f93cf9f83d539c424)            |
| [accuracy/driver-oracles-2026-11-21.json](https://circuittwin.ai/evidence/accuracy/driver-oracles-2026-11-21.json)         | Vendor-driver checks                  | 287d49a4a, clean tree, 2026-11-21 | eval-results/final-2026-11-21/F-Drivers/evidence-drivers.json at d02ef5052 (dd20a19b84c9c621d08efd6e5a6e8f68c9bd18bc41e4a08ca809a8ffbad871c1) |
| [accuracy/cpu-differential.json](https://circuittwin.ai/evidence/accuracy/cpu-differential.json)                           | CPU differential: Arm, Xtensa, RISC-V | 287d49a4a, clean tree, 2026-11-21 | eval-results/cpu-differential.json at d02ef5052 (bc589b5e21f2204c88a7270eff622af7cb138d8615bbc0c955554f7663812395)                            |
| [accuracy/avr-differential.json](https://circuittwin.ai/evidence/accuracy/avr-differential.json)                           | CPU differential: AVR                 | 287d49a4a, clean tree, 2026-11-21 | eval-results/avr-differential.json at d02ef5052 (efd99be5e19fb7cc587c0814f1f9a53d3ba9249ad41d7bc6d70d531a1bdefc7c)                            |
| [accuracy/rx-differential.json](https://circuittwin.ai/evidence/accuracy/rx-differential.json)                             | CPU differential: RXv1                | 287d49a4a, clean tree, 2026-11-21 | eval-results/rx-differential.json at d02ef5052 (e9b5ef1d203e750b05414855a268c67a14d80d6f89d571d8b22e2c0cf18c19a5)                             |
| [accuracy/stm8-differential.json](https://circuittwin.ai/evidence/accuracy/stm8-differential.json)                         | CPU differential: STM8                | 287d49a4a, clean tree, 2026-11-21 | eval-results/stm8-differential.json at d02ef5052 (117983692b6b0dd61582b7bebb80fca1be93a70a41f78ee4470c97ff22d24b3a)                           |
| [accuracy/pic24-differential.json](https://circuittwin.ai/evidence/accuracy/pic24-differential.json)                       | CPU differential: PIC24               | 287d49a4a, clean tree, 2026-11-21 | eval-results/pic24-differential.json at d02ef5052 (d1342a12815ea2f1bbd3d013a0a76e19dced267da2c39854d0f0254434ece36e)                          |
| [accuracy/unmodelled-access-2026-11-21.json](https://circuittwin.ai/evidence/accuracy/unmodelled-access-2026-11-21.json)   | Unmodelled-register policy runs       | 287d49a4a, clean tree, 2026-11-21 | eval-results/final-2026-11-21/F-Honesty/results.json at d02ef5052 (2081c44c531afeca7bdaf94e19fa1ff6591b1413ad2015aad133b3449a2c7ae8)          |
