Analog HW Testbench Gen
Generates FPGA Verilog for exercising an external analog circuit on a breadboard or test PCB. The FPGA controls enable/trim/bias, generates stimulus, reads the MAX10 internal ADC, and triggers the oscilloscope.
When to use
- After
analog-sizing-loop converges in SPICE (hardware verification phase)
- When the user says "test the LDO on hardware", "generate FPGA analog test"
- Step A9 of the analog track (hardware verification sub-step)
Inputs
analog/<block>/spec.json — performance specs + pin interface
analog/<block>/sizing_final.json — converged device sizes (for BOM reference)
- PDK / target FPGA board (default: DE10-Lite MAX10)
Workflow
- Parse spec.json for interface signals (enable, trim bits, analog in/out)
- Map interface to FPGA GPIO pins (DE10-Lite Arduino header or GPIO)
- Generate stimulus controller:
- Enable sequencer: timed enable/disable for POR testing
- Trim sweep: iterate all trim codes for calibration
- Load step: toggle a MOSFET load via GPIO for transient testing
- Generate ADC readback module:
- MAX10 internal ADC (12-bit, up to 17 channels on DE10-Lite)
- Continuous sampling with averaging (configurable window)
- Threshold comparator for pass/fail LED indication
- Generate scope trigger output:
- Pulse on GPIO before each stimulus event
- Configurable pre-trigger delay
- Generate top-level wrapper with pin assignments (.qsf)
- Generate Quartus project file (.qpf / .qsf)
Output format
analog/<block>/hw_test/<block>_hw_tb.v — stimulus + readback RTL
analog/<block>/hw_test/<block>_hw_tb_top.v — top-level with pin assignments
analog/<block>/hw_test/<block>_hw_tb.qpf — Quartus project
analog/<block>/hw_test/pin_assignments.qsf — FPGA pin mapping
analog/<block>/hw_test/README.md — breadboard wiring guide with component BOM
DE10-Lite MAX10 ADC usage
// MAX10 internal ADC — directly instantiable
altera_adc_control u_adc (
.clk (clk_50mhz),
.rst (rst),
.channel (5'd0), // ADC channel 0-16
.start (adc_start),
.done (adc_done),
.data (adc_data) // 12-bit result
);
Do not
- Do not generate testbenches that require commercial FPGA IP (use only free Quartus Lite primitives)
- Do not assume specific breadboard wiring — always generate a wiring guide
- Read Quartus pin-assignment and fitter reports for the emitted testbench. Resolve any duplicate signal assignment, unavailable pin, voltage-bank conflict or missing required connection before programming the board.
Read Quartus pin-assignment and fitter reports for the emitted testbench. Resolve any duplicate signal assignment, unavailable pin, voltage-bank conflict or missing required connection before programming the board.
Exit 0 = PASS, 1 = FAIL (a pin shorted to two signals, or no
set_location_assignment anywhere in the target), 2 = QSF missing or not a
DE10-Lite (MAX10 10M50DAF484C7G) board (out of scope — cannot judge). The
check only fires on DE10-Lite QSFs.
The external-I/O budget is now YOUR judgment again, and here is why. The
program used to FAIL a QSF assigning more than 46 pins ("36 GPIO + 10
Arduino") to the two user headers. That ceiling contradicts the board: the
DE10-Lite offers 36 GPIO_0 + 16 Arduino digital I/O + ARDUINO_RESET_N =
53 external-I/O pins, all enumerated in the program's own manual-sourced
tables. Measured, a physically valid map using 36 GPIO + 11 Arduino pins
(47 real pins, none doubled) came back FAIL external-io-budget. And the
rule could never catch the defect it was named for: it counted only pins
inside that 53-pin catalogue, so a design that genuinely needs more external
I/O than the board has would put the surplus on pins the rule does not
count. It only had false positives available to it, so it was withdrawn. The
program still MEASURES and REPORTS the header-pin count
(external_io_pins_used / external_io_pins_available); it just does not
judge it. Keep the design inside 36 GPIO_0 + 16 Arduino I/O yourself.
(Full-board physical-pin-map validation — HEX/VGA/SDRAM/G-sensor pins — is
also still your judgment: the program intentionally does not flag "unknown"
pins to avoid false-firing on legitimate peripheral assignments.)
Handoff
.v + .qpf → eda_fpga_compile → eda_fpga_program
- After programming →
analog-hw-measure for scope + ADC data collection
- Wiring guide → user builds/adjusts breadboard circuit
1---2name: analog-hw-testbench-gen3description: Generate FPGA RTL for hardware-in-the-loop analog testing — digital stimulus controller + ADC readback + scope trigger. Use when verifying analog blocks on real hardware, "generate hw testbench", "FPGA analog test", or at the hardware verification phase.4metadata:5 source: https://skillmd.com/skills/vibeic/analog-hw-testbench-gen6---78# Analog HW Testbench Gen910Generates FPGA Verilog for exercising an external analog circuit on a breadboard or test PCB. The FPGA controls enable/trim/bias, generates stimulus, reads the MAX10 internal ADC, and triggers the oscilloscope.1112## When to use1314- After `analog-sizing-loop` converges in SPICE (hardware verification phase)15- When the user says "test the LDO on hardware", "generate FPGA analog test"16- Step A9 of the analog track (hardware verification sub-step)1718## Inputs19201. `analog/<block>/spec.json` — performance specs + pin interface212. `analog/<block>/sizing_final.json` — converged device sizes (for BOM reference)223. PDK / target FPGA board (default: DE10-Lite MAX10)2324## Workflow25261. Parse spec.json for interface signals (enable, trim bits, analog in/out)272. Map interface to FPGA GPIO pins (DE10-Lite Arduino header or GPIO)283. Generate stimulus controller:29 - Enable sequencer: timed enable/disable for POR testing30 - Trim sweep: iterate all trim codes for calibration31 - Load step: toggle a MOSFET load via GPIO for transient testing324. Generate ADC readback module:33 - MAX10 internal ADC (12-bit, up to 17 channels on DE10-Lite)34 - Continuous sampling with averaging (configurable window)35 - Threshold comparator for pass/fail LED indication365. Generate scope trigger output:37 - Pulse on GPIO before each stimulus event38 - Configurable pre-trigger delay396. Generate top-level wrapper with pin assignments (.qsf)407. Generate Quartus project file (.qpf / .qsf)4142## Output format4344- `analog/<block>/hw_test/<block>_hw_tb.v` — stimulus + readback RTL45- `analog/<block>/hw_test/<block>_hw_tb_top.v` — top-level with pin assignments46- `analog/<block>/hw_test/<block>_hw_tb.qpf` — Quartus project47- `analog/<block>/hw_test/pin_assignments.qsf` — FPGA pin mapping48- `analog/<block>/hw_test/README.md` — breadboard wiring guide with component BOM4950## DE10-Lite MAX10 ADC usage5152```verilog53// MAX10 internal ADC — directly instantiable54altera_adc_control u_adc (55 .clk (clk_50mhz),56 .rst (rst),57 .channel (5'd0), // ADC channel 0-1658 .start (adc_start),59 .done (adc_done),60 .data (adc_data) // 12-bit result61);62```6364## Do not6566- Do not generate testbenches that require commercial FPGA IP (use only free Quartus Lite primitives)67- Do not assume specific breadboard wiring — always generate a wiring guide68- Read Quartus pin-assignment and fitter reports for the emitted testbench. Resolve any duplicate signal assignment, unavailable pin, voltage-bank conflict or missing required connection before programming the board.6970Read Quartus pin-assignment and fitter reports for the emitted testbench. Resolve any duplicate signal assignment, unavailable pin, voltage-bank conflict or missing required connection before programming the board.71 Exit 0 = PASS, 1 = FAIL (a pin shorted to two signals, or no72 `set_location_assignment` anywhere in the target), 2 = QSF missing or not a73 DE10-Lite (MAX10 10M50DAF484C7G) board (out of scope — cannot judge). The74 check only fires on DE10-Lite QSFs.7576- **The external-I/O budget is now YOUR judgment again, and here is why.** The77 program used to FAIL a QSF assigning more than 46 pins ("36 GPIO + 1078 Arduino") to the two user headers. That ceiling contradicts the board: the79 DE10-Lite offers **36 GPIO_0 + 16 Arduino digital I/O + ARDUINO_RESET_N =80 53** external-I/O pins, all enumerated in the program's own manual-sourced81 tables. Measured, a physically valid map using 36 GPIO + 11 Arduino pins82 (47 real pins, none doubled) came back `FAIL external-io-budget`. And the83 rule could never catch the defect it was named for: it counted only pins84 inside that 53-pin catalogue, so a design that genuinely needs more external85 I/O than the board has would put the surplus on pins the rule does not86 count. It only had false positives available to it, so it was withdrawn. The87 program still MEASURES and REPORTS the header-pin count88 (`external_io_pins_used` / `external_io_pins_available`); it just does not89 judge it. Keep the design inside 36 GPIO_0 + 16 Arduino I/O yourself.9091 (Full-board physical-pin-map validation — HEX/VGA/SDRAM/G-sensor pins — is92 also still your judgment: the program intentionally does not flag "unknown"93 pins to avoid false-firing on legitimate peripheral assignments.)9495## Handoff9697- `.v` + `.qpf` → `eda_fpga_compile` → `eda_fpga_program`98- After programming → `analog-hw-measure` for scope + ADC data collection99- Wiring guide → user builds/adjusts breadboard circuit