How zipcpu/dblclockfft works
1. This repository is a configurable FFT IP generator, not a single fixed design. The central flow is: a C++ command-line generator builds an FFT configuration, emits Verilog RTL for that configuration, and the generated core is then exercised by C++ tests, RTL testbenches, and formal proofs.
2. The sw/ directory is the code-generation layer. fftgen.cpp is the main entry point, supported by reusable builders and helpers such as bldstage.cpp, butterfly.cpp, bitreverse.cpp, rounding.cpp, and softmpy.cpp. These components assemble the FFT architecture from parameters like transform direction, precision, twiddle width, and output bit ordering.
3. The generator is designed to produce different pipeline behaviors. The README describes two major operating styles: a two-samples-per-clock mode and a one-sample-per-clock mode with configurable input spacing. That choice affects the butterfly implementation and how many multiplies are used per FFT stage.
4. The rtl/ directory contains the Verilog implementation of the core building blocks. fftmain.v and ifftmain.v are the top-level forward/inverse FFT wrappers, while fftstage.v, qtrstage.v, and laststage.v represent the staged pipeline structure. This is the datapath that the generator instantiates.
5. The low-level RTL blocks map directly to arithmetic and permutation functions in the FFT. butterfly.v, hwbfly.v, bimpy.v, and longbimpy.v cover multiply-accumulate and butterfly math; bitreverse.v handles output ordering; convround.v handles rounding/conversion; and windowfn.v suggests optional preprocessing or windowing support.
6. The bench/cpp/ subtree is the software verification and benchmarking environment. It contains C++ testbenches for individual blocks and full designs such as fft_tb.cpp, ifft_tb.cpp, butterfly_tb.cpp, fftstage_tb.cpp, laststage_tb.cpp, mpy_tb.cpp, and bitreverse_tb.cpp. These act as the golden-model side of the verification flow.
7. The C++ bench code also includes small support utilities and plotting hooks. twoc.cpp/.h appear to provide numeric/two’s-complement helpers, and the .m files indicate MATLAB/Octave scripts used to inspect or plot simulation output. This makes the software bench a numerical reference layer, not just a compile test.
8. The bench/rtl/ directory holds a hardware testbench for the Verilog side. The presence of ifft_tb.v indicates direct RTL simulation of the inverse FFT path, likely used to confirm the generated core behaves correctly in a hardware-like environment.
9. The bench/formal/ directory is the formal-verification layer. The .sby files show the design is checked with SymbiYosys, and the abs_*.v files provide abstract models/specifications for blocks like multipliers. This layer focuses on proving local correctness of modules such as bimpy, butterfly, fftstage, hwbfly, laststage, qtrstage, and windowfn.
10. The doc/ tree contains the published specification and licensing material. spec.pdf and its source under doc/src/ document the architecture and expected behavior, which is important because this project is intended as generated IP with a defined external contract.
11. The repo is organized around a clear boundary between generation and implementation. The software generator defines the FFT instance, the RTL directory defines reusable hardware blocks, and the bench/formal trees validate those blocks against numerical expectations and formal properties.
12. A key architectural constraint is that the core does not include overflow protection. That means the caller or integrator must choose precision conservatively, and this assumption affects how the generated core is parameterized and validated.
13. Overall, this repository is best diagrammed as a configurable FFT toolchain: parameterized C++ generation on one side, a composable Verilog pipeline in the middle, and three validation paths around it—C++ reference simulation, RTL simulation, and formal proof.
Main entry points: fftstage.v FFT Stage · bldstage.cpp Stage Builder · fftgen.cpp FFT Gen · butterfly.v Butterfly
Components 22
Generator
C++ FFT IP generation layer
- FFT Gen · Main entry point that builds a parameterized FFT instance and emits Verilog.
sw/fftgen.cpp - Stage Builder · Assembles pipeline stages from FFT parameters and operating mode.
sw/bldstage.cpp - Butterfly Build · Build-time logic for butterfly structure and pipeline behavior.
sw/butterfly.cpp - Order Build · Build-time configuration for bit-reversal and output ordering.
sw/bitreverse.cpp - Rounding Build · Build-time control for rounding and numeric conversion behavior.
sw/rounding.cpp - Soft Multiply · Software-side multiply helper used by the generator and numerical modeling.
sw/softmpy.cpp
RTL Core
Reusable Verilog datapath and wrappers
- FFT Top · Forward FFT top-level wrapper around the staged core.
rtl/fftmain.v - IFFT Top · Inverse FFT top-level wrapper around the staged core.
rtl/ifftmain.v - FFT Stage · Main staged pipeline element used by the generated core.
rtl/fftstage.v - Quarter Stage · Specialized stage used in the FFT pipeline structure.
rtl/qtrstage.v - Last Stage · Terminal pipeline stage for the generated transform.
rtl/laststage.v - Butterfly · Butterfly datapath with multiply-accumulate behavior.
rtl/butterfly.v - HW Butterfly · Hardware butterfly variant used in the core datapath.
rtl/hwbfly.v - Bimpy · Multiplier block used by butterfly and FFT arithmetic.
rtl/bimpy.v - Long Bimpy · Wider multiplier variant for higher precision arithmetic.
rtl/longbimpy.v - Bit Reverse · Output ordering/permutation block used by the generated core.
rtl/bitreverse.v - Conv Round · Rounding and conversion logic for fixed-point results.
rtl/convround.v - Window Fn · Optional preprocessing or windowing function block.
rtl/windowfn.v
Verification
C++ simulation, RTL simulation, and formal checks
- C++ Bench · Reference-model and benchmark environment for generated FFT designs.
bench/cpp - RTL Bench · Verilog simulation environment for exercising the inverse FFT path.
bench/rtl/ifft_tb.v - Formal Suite · SymbiYosys proofs and abstract models for core RTL blocks.
bench/formal
Docs
Specification and licensing material
- Spec · Published specification and source documentation for the generated IP contract.
doc/spec.pdf
Connections 28
- FFT Gen → Stage Builder: builds · Generator delegates stage assembly to reusable builders.
- Stage Builder → Butterfly Build: configures · Stage builder selects butterfly structure and operating mode.
- Stage Builder → Order Build: orders · Build logic determines output ordering behavior.
- Stage Builder → Rounding Build: quantizes · Build logic sets rounding and conversion policy.
- Stage Builder → Soft Multiply: uses · Generator relies on arithmetic helpers for modeling and emission.
- FFT Gen → FFT Top: emits · The generator produces the forward FFT wrapper and core configuration.
- FFT Gen → IFFT Top: emits · The generator produces the inverse FFT wrapper and core configuration.
- FFT Top → FFT Stage: instantiates · Top-level forward design is built from staged pipeline blocks.
- IFFT Top → FFT Stage: instantiates · Top-level inverse design is built from staged pipeline blocks.
- FFT Stage → Quarter Stage: includes · Pipeline structure includes specialized quarter-stage logic.
- FFT Stage → Last Stage: terminates · Pipeline structure ends with the last-stage block.
- FFT Stage → Butterfly: computes · Stage datapath is centered on butterfly arithmetic.
- Butterfly → HW Butterfly: specializes · Hardware butterfly variant supports the core math path.
- Butterfly → Bimpy: multiplies · Butterfly arithmetic depends on multiplier blocks.
- Bimpy → Long Bimpy: widens · Long multiplier variant covers higher-width arithmetic cases.
- FFT Stage → Bit Reverse: permutes · Stage/output flow uses bit-reversal ordering when required.
- FFT Stage → Conv Round: rounds · Stage output passes through fixed-point rounding/conversion.
- FFT Top → Window Fn: optionally preprocesses · Forward path can include windowing or preprocessing.
- C++ Bench → FFT Gen: verifies · Software benches exercise generated configurations against numerical references.
- C++ Bench → Butterfly: models · C++ testbenches cover individual arithmetic blocks and full FFTs.
- C++ Bench → Bit Reverse: models · C++ tests check permutation and ordering behavior.
- RTL Bench → IFFT Top: simulates · RTL testbench runs direct hardware simulation of the inverse FFT path.
- Formal Suite → Bimpy: proves · Formal proofs cover multiplier correctness using abstractions.
- Formal Suite → Butterfly: proves · Formal suite checks butterfly-level arithmetic properties.
- Formal Suite → FFT Stage: proves · Formal suite checks staged pipeline behavior.
- Formal Suite → Window Fn: proves · Formal suite includes optional preprocessing/windowing properties.
- Spec → FFT Gen: defines · Documentation specifies the configurable generator contract and assumptions.
- Spec → FFT Top: describes · Spec documents the expected externally visible FFT/IP behavior.