0
votes

I am trying to write a verilog code for FPGA which will output sound from the embedded "line out" pin. I use Quartus II and Altera DE1.

I am new to hardware programming, therefore it just takes too much time for me to catch up with basics. Apparently I need to initialize the wolfson chip and need to write something to communicate with it, as discussed here: http://www.alteraforum.com/forum/showthread.php?t=6005

It uses wolfson WM8731 codec, manual is in here: http://www.rockbox.org/wiki/pub/Main/DataSheets/WM8731_8731L.pdf

and an example I found but couldnt figured out how to use it is in here: https://code.google.com/p/vector06cc/wiki/SoundCodec

I have found bunch of examples about how to generate sounds using GPIO pins, but barely anything about the usage of WM8731. I would really appreciate any guidance or experience you might share.

1
But I am looking for a verilog code for it, hardware is already there. Should I still move the question?ozgeneral
@OE1 - are you using a Nios II CPU (and SOPC/Qsys) or working only in hardware?wilcroft
Yes Altera DE1 uses Nios II CPU. I am programming an FPGA and trying to test my code using headphones to "line out" port of the FPGA.ozgeneral

1 Answers

3
votes

Assuming you're using Nios II and either SOPC Builder or Qsys, the Altera University Program offers an IP core to control the Audio CODEC on the DE-Series boards.

If you don't already have it, you can download it here (at the bottom of the page, listed as University Program Installer): https://www.altera.com/support/training/university/materials-ip-cores.html

Once you install it, check the <altera-directory>/University_Program\NiosII_Computer_Systems\DE1\DE1_Media_Computer directory. app_software and app_software_HAL both give example methods to write to the audio output (using C code running on the Nios II), and the verilog or vhdl folder show example systems on connecting the core to a NIOS II using your preferred HDL.

The core itself can be found in <altera-directory>\ip\University_Program\Audio_Video. See also ftp://ftp.altera.com/up/pub/Altera_Material/14.1/University_Program_IP_Cores/Audio_Video/Audio.pdf for some (potentially) helpful reading/reference.


Addendum: All of the FPGA inputs and outputs use the "Digital Audio Interface" of the WM8731 chip. The pins available on the FPGA are as follows:

  • PIN_A6 : AUD_ADCLRCK
  • PIN_B6 : AUD_ADCDAT
  • PIN_A5 : AUD_DACLRCK
  • PIN_B5 : AUD_DACDAT
  • PIN_A4 : AUD_BCLK
  • PIN_B4 : AUD_XCK (MCLK on WM8731)

Output is sent to the CODEC on the AUD_DACDAT pin. The chip is configured using the I2C_SDAT and I2C_SCLK pins on I2C address 0x34 for read, and 0x35 for write. No other pins are available to the FPGA - some are used for external connections (like the mike or line-in), or are not connected at all. For a full list of pin assignments for the DE1 (which can be directly imported to Quartus) see: ftp://ftp.altera.com/up/pub/Altera_Material/12.1/Boards/DE1/DE1.qsf