feat(v2): scaffold hardware/v1 frozen baseline + M1 Neural Processor
Begins the V2 Neural Multiprocessor / Dataflow architecture per docs/v2-description.md, per explicit user request to freeze V1 and start V2 development, copying from V1 what's needed. Scaffold: - hardware/v1/: byte-exact, read-only copy of the current V1 codebase (rtl, testbenches, tools, constraints, a representative subset of synthesis results, and reference docs) -- verified identical via diff/cmp against the live top-level tree before being made filesystem-read-only. The live top-level tree is untouched and remains the project's "production" V1 (see hardware/v1/README.md and hardware/v2/logs/decisions.log DEC-0001 for why copy-not-move). - hardware/v2/: mandatory structure (rtl/sim/constraints/synthesis/ reports/scripts/logs/docs) plus the full logging system required by the spec (development/architecture/simulation/synthesis/timing/ benchmark/decisions/experiments/errors.log). M1 -- Neural Processor (hardware/v2/rtl/neural_processor.v): - 8-stage pipelined perceptron unit (P_IN=8): input align, 8 multipliers, 3-level adder tree, accumulator, bias+activation, INT8 saturation. Genuine 1-tile/cycle throughput, not just a wider combinational datapath. - 7-state FSM (NP_IDLE..NP_ERROR per docs/v2-description.md §6, with 4 baseline states merged into NP_WAIT_OPERANDS -- see decisions.log DEC-0002); valid/ready/data/last stream interfaces per §7. - Bit-exact vs the frozen hardware/v1/rtl/neuron_parallel.v + mac8.v + mac_unit.v: 7/7 tests pass (hardware/v2/sim/tb_neural_processor.v), covering regular/mixed-sign/extreme-INT8 vectors, both activations, a zero-idle-gap back-to-back-tiles throughput check, and an 8-tile job -- verified with Verilator (see below for why). - Real synthesis + place&route (Yosys + nextpnr-ecp5): 0 CHECK problems, Fmax 183.12 MHz at ACC_WIDTH=32 (PASS at 80MHz, ~3x V1's isolated PARALLEL=8 Fmax of 61.71 MHz) and 176.21 MHz at ACC_WIDTH=24 (a user-requested comparison experiment, also bit-exact-verified; see experiments.log EXP-0001/EXP-0002 and benchmark.log). Three real bugs found and resolved during M1 development (full diagnostic record in errors.log): - Two independent, reproducible Icarus Verilog v13.0 scheduling defects (ERR-0001, ERR-0002) that silently produced wrong simulation results for standard sequential Verilog -- confirmed via Verilator 5.050 giving correct results on the same minimal repros. Verilator is now the trusted simulator for hardware/v2/ (decisions.log DEC-0004); Icarus's affected protocol-violation check was removed from the RTL and deferred architecturally to the Neural Director (DEC-0003) rather than chased further. - One real RTL bug (ERR-0003): last0 wasn't gated like valid0, letting a "last tile" tag leak into the pipeline ahead of its actual valid tile on back-to-back jobs. Fixed and verified. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013xXuuRUWZScuo1DeYJxs3v
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
# C.6 — Motore grafo (`graph_engine.v`, `act_buffer.v`)
|
||||
|
||||
Data: 2026-09-04.
|
||||
|
||||
---
|
||||
|
||||
## 6.1 Gather, padding, guard `src_id<out_id` — CERTIFICATO (test pre-esistenti, riverificati)
|
||||
|
||||
`sim/graph_engine_tb.v` (grafo calcolato a mano, §3 dell'esempio del manuale, con verifica
|
||||
diretta del contenuto di `act_buffer` via riferimento gerarchico, non solo dell'output
|
||||
finale) e `sim/graph_engine_guard_tb.v` (4 test: `src_id>=out_id` auto-riferimento,
|
||||
`out_id>=N_TOTAL`, `n_conn_padded==0`, percorso di recovery dopo un `err`) — entrambi
|
||||
pre-esistenti, riverificati PASS in Fase 0. Copertura solida su happy-path e sui casi
|
||||
avversari già identificati dal progetto.
|
||||
|
||||
**Verdetto: CERTIFICATO** per questi aspetti (copertura pre-esistente adeguata).
|
||||
|
||||
---
|
||||
|
||||
## 6.2 `num_neurons_graph=0` — stessa causa radice di BUG-005, ma protezione incidentale diversa
|
||||
|
||||
**Analisi strutturale**: `neuron_idx` (`rtl/graph_engine.v:159`) è un registro a 16 bit
|
||||
PIENI, e la condizione di terminazione (righe 527/561)
|
||||
`neuron_idx==num_neurons_graph-16'd1` per `num_neurons_graph=0` avvolge a `65535` — un
|
||||
valore che il contatore RAGGIUNGE naturalmente, stessa struttura esatta di BUG-005
|
||||
(`layer_idx`). Stessa causa radice: nessun guard su `num_neurons_graph`, né a compile-time
|
||||
né a runtime.
|
||||
|
||||
**Verificato empiricamente, con una riserva esplicita**: `sim/graph_engine_bug006_zero_neurons_probe_tb.v`,
|
||||
finestra di osservazione limitata a 5000 cicli (**non fatto girare fino a completamento
|
||||
reale** — fino a 65536 iterazioni con la logica di gather di questo modulo, più costosa per
|
||||
iterazione del semplice dispatch di `layer_sequencer`, sarebbe stato impraticabile per il
|
||||
budget di tempo di questa campagna; dichiarato come limite esplicito, non nascosto).
|
||||
|
||||
```
|
||||
RESULT: err fired at cycle 58 (neuron_idx=0) -- the src_id<out_id/N_TOTAL guard caught
|
||||
the garbage descriptor data before completion.
|
||||
```
|
||||
|
||||
**Differenza da BUG-005**: `graph_engine` possiede già un guard **a runtime, per-edge**
|
||||
(`src_id>=out_id` o `out_id>=N_TOTAL` → `err`, §6.1) che **non è stato progettato per
|
||||
proteggere da `num_neurons_graph=0`** ma **lo cattura come effetto collaterale**: con un
|
||||
pattern di dati "spazzatura" non banale (non tutto a zero, un pattern a rampa), il guard
|
||||
esistente ha fermato l'esecuzione dopo sole 58 cicli, al primissimo neurone fasullo letto,
|
||||
molto prima di avvicinarsi alle 65536 iterazioni possibili. `layer_sequencer.v` **non ha
|
||||
alcun guard equivalente** — da qui la severità molto più alta di BUG-005.
|
||||
|
||||
**Non è una garanzia**: questo test usa UN pattern di dati specifico. Non è stato
|
||||
dimostrato che OGNI possibile contenuto PSRAM causi un arresto altrettanto rapido — esiste
|
||||
in linea di principio un pattern di dati "sfortunato" che rispetti `src_id<out_id` e
|
||||
`out_id<N_TOTAL` per molte iterazioni consecutive prima di violarli (o non violarli mai, se
|
||||
i byte casuali formano per caso una sequenza monotona valida) facendo procedere
|
||||
l'esecuzione molto più a lungo. Il buco strutturale (nessun guard esplicito su
|
||||
`num_neurons_graph`) resta reale.
|
||||
|
||||
**Verdetto: NON CERTIFICATO per `num_neurons_graph=0` in senso assoluto** (stesso buco
|
||||
strutturale di BUG-005), **ma il rischio pratico osservato è marcatamente più basso**
|
||||
grazie al guard esistente per altri scopi. Non registrato come nuovo bug allo stesso
|
||||
livello di severità di BUG-005 — vedi `docs/validation/bugs.md` per la voce dedicata a
|
||||
severità ridotta (INFO/BASSA, non CRITICA), con la riserva sulla mancata verifica
|
||||
esaustiva su ogni pattern di dati.
|
||||
|
||||
---
|
||||
|
||||
## 6.3 Verdetto complessivo C.6
|
||||
|
||||
| Sotto-aspetto | Verdetto |
|
||||
|---|---|
|
||||
| Gather, padding, guard `src_id<out_id`/`out_id<N_TOTAL`/`n_conn_padded==0` | **CERTIFICATO** |
|
||||
| `num_neurons_graph=0` | **NON CERTIFICATO in senso assoluto**, rischio pratico basso osservato (guard esistente incidentale), non equiparato a BUG-005 |
|
||||
Reference in New Issue
Block a user