{
  "episode": 12,
  "slug": "openhw-cve2-ep12-scope-fft",
  "title_zh": "CVE2 做数字示波器：1 kHz 测试音、32 抽头 FIR、1024 点 FFT 频谱仪",
  "verified_on_hardware": true,
  "verified_at": "2026-11-23T18:26:00+08:00",
  "board": {
    "vendor": "ALINX",
    "model": "PI-AR035-F1-1",
    "fpga": "XC7A35T-2FGG484",
    "clock_mhz": 50
  },
  "bitstream": {
    "bytes": 1626731,
    "sha256": "5728ca9de6e2af59d55cbafe889d3b0e1be6a1f7e6e91c13cc412d1cd713e78e"
  },
  "timing": {
    "wns_ns": 2.308,
    "whs_ns": 0.003,
    "tns_ns": 0.0,
    "ths_ns": 0.0,
    "failing_endpoints": 0,
    "total_endpoints": 44572,
    "hold_fix": "phys_opt_design -aggressive_hold_fix (was -0.032 ns)"
  },
  "utilization": {
    "lut": 14263,
    "lut_pct": 68.57,
    "ff": 20334,
    "ff_pct": 48.88,
    "bram_tiles": 12,
    "bram_pct": 24.0,
    "dsp": 29,
    "dsp_pct": 32.22
  },
  "dsp_chain": {
    "dds_hz": 1000,
    "sample_rate_hz": 100000,
    "fs_divider": 499,
    "capture_points": 1024,
    "waveform_peak": 16376,
    "waveform_max_deviation_lsb": 98,
    "fir_taps": 32,
    "fir_design": "low-pass, fc=0.15, Hamming window, Q14 coefficients, symmetric, sum 16382",
    "fir_latency_clk": 5,
    "fir_max_abs_diff_hw_vs_sw": 0,
    "fft_points": 1024,
    "fft_scaling": "block_floating_point",
    "fft_hw_cycles": 7342,
    "fft_measured_cycles": 7353,
    "fft_block_exponent": 8,
    "fft_peak_bin": 10,
    "fft_peak_mag_hw": 7619072,
    "fft_peak_mag_theory": 8388096,
    "fft_peak_mag_sw": 14933012,
    "spectrum_bins_printed": 64,
    "spectrum_cosine_similarity": 0.9999,
    "spectrum_hw_sw_ratio_range": [0.461, 0.524]
  },
  "firmware": {
    "uart": "115200 8N1",
    "hex_bytes": 36864,
    "hex_sha256": "d855457919d8666783a8cd3069be9c518902d87dc983ed8f02fb1cfb5fb63438",
    "packed_via": "$readmemh into both imem and dmem"
  },
  "criteria": {
    "csr_id": {"expected": "4609", "measured": "4609", "pass": true},
    "dds_test_tone": {"expected": "1 kHz at fs 100 kHz", "measured": "fs=100000 Hz f0=1000 Hz, sine period 100 samples", "pass": true},
    "capture_points": {"expected": 1024, "measured": 1024, "pass": true},
    "fir_vs_software": {"expected": "comparable point-by-point", "measured": "max|diff| = 0 over 32 points", "pass": true},
    "fft_peak_bin": {"expected": 10, "measured": 10, "pass": true},
    "no_trap": {"expected": "TRAP=0", "measured": "TRAP=0", "pass": true}
  },
  "defects_fixed": [
    "cap_arm level-sensitive -> rising-edge cap_arm_pulse",
    "dmem initialised with 0x13 -> $readmemh for dmem too",
    "fir_mem write port fed by fir_sum[35:4] -> fir_out",
    "fir_sum >> 14 logical -> $signed(fir_sum) >>> 14",
    "NCO constant 0x051EB852 (2 kHz) -> 0x028F5C29 (1 kHz)",
    "software DFT scale >> 10 -> >> 14",
    "FFT block exponent uncompensated -> new CSR 0x4006_0034 + <<bexp",
    "xr history not cleared on arm -> cleared",
    "fir_we = fir_v && (fir_wr < N) always true -> fir_busy gate (real root cause of the constant FIR readback)",
    "software FIR index i-j -> i-1-j (one-sample pipeline delay)",
    "software FIR per-tap >>14 truncation -> full-precision accumulate, single shift (maxdiff 16 -> 0)",
    "hold -0.032 ns -> phys_opt_design -aggressive_hold_fix"
  ],
  "known_limits": [
    "absolute spectrum magnitude not cross-calibrated (shape/peak only; hw/sw 0.46-0.52)",
    "WHS only +0.003 ns",
    "led_n[2:0] driven-by-constant warning kept",
    "no long-run / temperature / voltage-corner test"
  ]
}
