How ahmadgon/wm8731-audio-codec works
Project type and purpose
• This is an FPGA‐based hardware project (DE2-115 board) implementing a WM8731 audio CODEC interface in Verilog.
• It configures the WM8731 via an I2C driver and streams 13 seconds of 16-bit, 8 kHz PCM data stored in on-chip M9K ROM blocks to the codec.
• A MATLAB script converts a HEX audio dump (from Audacity + HEX Editor) into a Quartus-readable MIF file.
File structure
• Top-level files:
– Audio_CODEC.rar: likely contains the Verilog source, constraints, Quartus project files and I2C/I2S modules
– PCM_16bit_Audio.m: MATLAB script that turns a HEX audio file into a MIF memory initialization file
– README.md: project overview and workflow
• No separate “src” or “lib” folders visible; everything packs into the RAR archive.
• Key configuration artifacts: .mif (memory init), Quartus project files inside the RAR, pin constraints, Verilog modules.
README for additional insights
• Workflow:
1. Use Audacity → export 16-bit PCM @8 kHz → save as HEX via HEX Editor Neo
2. Run MATLAB script to convert HEX → .mif
3. .mif in Quartus, synthesize onto DE2-115
4. FPGA I2C config + I2S audio streaming to WM8731
Components and relationships
a. Main components
• Audio Preprocessing (Audacity + HEX Editor)
• MATLAB conversion script (PCM_16bit_Audio.m) → produces .mif
• Quartus Project (Verilog modules, .mif, pin constraints)
• FPGA Design:
– I2C Configuration Controller (initializes WM8731 registers)
– ROM (M9K block) storing audio samples
– I2S Audio Transmitter (serial audio data to codec)
• External Hardware:
– DE2-115 FPGA board
– WM8731 Audio CODEC chip
– Speakers or headphone output
b. Interactions & data flow
1. Audio file → HEX → MATLAB script → .mif
2. Quartus imports .mif → synthesizes FPGA bitstream
3. FPGA loads bitstream on DE2-115 at power-on
4. FPGA I2C controller programs WM8731 over two‐wire bus
5. FPGA reads sample words from M9K ROM → feeds I2S transmitter
6. I2S bus carries clocked audio data to WM8731 → analog output to speakers
c. Architectural patterns
• Simple streaming pipeline: ROM → I2S → CODEC
• Control plane vs. data plane separation: I2C (configuration) vs. I2S (audio streaming)
• Memory-mapped ROM using Quartus M9K block primitives
d. Key technologies
• Verilog HDL (I2C + I2S finite‐state machines)
• Quartus II synthesizer, .mif for block RAM initialization
• MATLAB for data conversion
• Audacity + HEX Editor Neo for audio export