Adds tools/neural_sim/, a NumPy-based reference implementation of the FPGA-Neural V2 numeric model (INT8 in/weight, 32-bit wraparound accumulation, ReLU+saturate out), derived directly from hardware/v2/rtl/neural_processor.v (not assumed) and reusing tools/validation/mac_oracle.py's own pre-existing, hand-verified two's-complement primitives rather than duplicating them. Provides: neuron/layer/network models, a logical memory model of the real V2 SDRAM map (weights/activations/results), deterministic test-vector generators (simple/signed/extremes/zero/random/D-Stress 256x128) with JSON golden-vector export, an FPGA-vs-Python bit-exact comparison utility, four example networks, a CLI (`python -m tools.neural_sim ...`), and a 96-test pytest suite (all passing) covering signed-arithmetic edge cases (including a direct 32-bit wraparound proof), scalar-vs-vectorized neuron cross-checks, layer/memory/vector/comparison tests. This is a golden functional reference (bit-exact numeric result), explicitly NOT a cycle-accurate FPGA simulator -- see tools/neural_sim/README.md for the full scope statement. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013xXuuRUWZScuo1DeYJxs3v
20 lines
740 B
Python
20 lines
740 B
Python
"""
|
|
neural_sim -- the Python GOLDEN FUNCTIONAL REFERENCE for FPGA-Neural V2.
|
|
|
|
Given weights, activations, and a network topology, this package
|
|
computes the mathematically correct result that the real V2 hardware
|
|
(hardware/v2/rtl/neural_processor.v, unmodified since before the
|
|
single-SDRAM freeze) must reproduce bit-for-bit.
|
|
|
|
This is NOT a cycle-accurate FPGA simulator: it models the numeric
|
|
result only, not clock cycles, memory-controller timing, or SPI
|
|
transaction timing. See README.md for the full scope statement and
|
|
tools/neural_sim/network.py / tools/neural_sim/memory.py for what IS
|
|
and is NOT modeled.
|
|
|
|
Python simulator = golden functional reference
|
|
RTL / P&R = hardware implementation
|
|
"""
|
|
|
|
__version__ = "0.1.0"
|