Sign in

Not a member? | Forgot your Password?

Search blogs

Search tips

Free PDF Downloads

Adam Taylor's MicroZed Chronicles

Performance driven FPGA design with an ASIC perspective

FPGAs!? Now What?

Architecture of FPGAs and CPLDs: A Tutorial

FPGA Implementation of Digital Filters

Recent Blogs on FPGARelated

Point of View
posted by Christopher Felton


Spline interpolation
posted by Markus Nentwig


BGA and QFP at Home 1 - A Practical Guide.
posted by Victor Yurkovsky


Introducing the VPCIe framework
posted by Fabien Le Mentec


How FPGAs work, and why you'll buy one
posted by Yossi Kreinin


Learning VHDL - Basics
posted by Enrico Garante


Yet another PWM
posted by Anton Babushkin




Articles by category

See Also

DSPEmbedded Systems

FPGA Blogs > Christopher Felton > MyHDL FPGA Tutorial II cont. (Echo, Audio Interface)

Christopher Felton (contact)
Christopher Felton's current favorite projects are implementing DSP digital circuits with MyHDL for FPGAs. More information @ show full bio

Would you like to be notified by email when Christopher Felton publishes a new blog?

  




Pageviews: 1260

MyHDL FPGA Tutorial II cont. (Echo, Audio Interface)

Posted by Christopher Felton on Sep 12 2012 under HDLs | HowTos | DSP | Tutorials   

Introduction

To demonstrate the echo on an FPGA board an interface to an audio ADC/DAC chip will be used. The following will explain the connection to the audio codec and the HDL module used to interface.

Audio Codec Interface

I have two boards with TI AIC23b audio codecs. The AIC23 has a configuration interface (ability to program the registers) and a streaming audio interface. The SPI mode will be used to configure the codec and the I2S interface is used to send and receive audio samples.

aic_intf

SPI Configuration Interface

The AIC23 has a collection of registers that are used to configure / program different settings, including the sample rate, number of bits in a sample, and other settings related to the codec. The SPI has a basic method for programming the registers. The register address and data are sent via the SPI bus.

The following timing diagram illustrates the SPI transfer.

aic_intf_spi

The MyHDL simulation of the SPI configuration.

spi_xfr

 

I2S Audio Interface

The audio sample interface is a I2S serial connection. The I2S is a full-duplex communication path and supports left and right (stereo) samples. The I2S interface has source synchronous clock, data in, data out, and a sync signal (edges indicate beginning of sample and high / low that indicates left or right channels).

aic_intf_i2s
 
 
 The MyHDL simulation.
 

i2s_xfr

 

The sample bit widths can be configured to be 32, 24, and 16 bits. The audio codec only supports max 24 bits so the 32 bit setting simply sign extends the samples.

AIC Module

The HDL module used to interface to the AIC23 will drive the SPI configuration bus at start-up. It will take a static configuration, provided by the Aic23Config object, and create the register settings required. The following is an example of setting the AIC23 configuration values for the module. The module will take the settings and create the register settings.

cfgopt = Aic23Config()
cfgopt.input_len = 16
cfgopt.sample_rate = 48

# Instantiate the AIC23 interface module
g_aic23 = aic23(clock=clk96MHz,
                reset=reset,
                au_bus=au_bus,
                aic23_bus=aic23_bus,
                tst_pts=tst_pts,
                ConfigOpt=ConfigOpt)

The above code snip demonstrates how to set the configuration of the audio codec. Printing the string of the object (print(cfgopt)) will have the following output

input_len .......................... 16
right :
   hp_lock ......................... False
   mute ............................ False
   lock ............................ False
   hp_volume ....................... 121
   volume .......................... 23
   hp_zero_cross ................... True
sample_rate ........................ 48
left :
   hp_lock ......................... False
   mute ............................ False
   lock ............................ False
   hp_volume ....................... 121
   volume .......................... 23
   hp_zero_cross ................... True

The AIC module will decode the samples from the I2S bus and provide the samples via a parallel bus and a sample valid strobe (Ts). The sample valid strobe is named Ts because it will match the sample rate period. The AIC module will accept a similar input. It will take a parallel bus input, it will take the samples in at the generated Ts. The sample rate and synchronization is driven by the AIC23 codec.

au_bus

 

To wire up a loopback is simple:

@always(clk96MHz.posedge)
def hdl_loopback():
    au_out_r.next = au_in_r
    au_out_l.next = au_in_l

The testbench will simply increment the right channel and decrement the left channel. And the aic23_top module will loopback the audio samples. The testbench will drive the DIN port with the serial samples. The au_in_r and au_in_l will be the received samples. The samples will be looped back to the au_out_r and au_out_l. The AIC23 module will drive the DOUT port with the serial samples.

Using the AIC23 module, it will be extremely easy to use the audio interface and modify the settings, if required.



Rate this article:
4.335
Rating: 4.34 | Votes: 3
 
   
 
posted by Christopher Felton
Christopher Felton's current favorite projects are implementing DSP digital circuits with MyHDL for FPGAs. More information @ LinkedIn.


Previous post by Christopher Felton: MyHDL FPGA Tutorial II (Audio Echo)
Next post by Christopher Felton: MyHDL Resources
all articles by Christopher Felton

Comments / Replies


stephaneb
Said:
Chris, I took the liberty to submit your tutorial to Reddit: http://www.reddit.com/r/ECE/comments/104stt/myhdl_fpga_tutorial_echo_audio_interface/
2 years ago
+1
Reply
Sorry, you need javascript enabled to post any comments.
muneebziaa
Said:
hi can you help in Xilinx Virtex4 ML403 board???
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
cfelton
Replied:
That is a fairly generic request and not related to this post? Is there something specific @muneebziaa is looking for? Does the ML403 have an audio codec?
2 years ago
0
muneebziaa
Said:
yes i know but i am tired of finding detail about this on the internet. yes it have an AC97 codec. please if you can help me I'll be thank full to you.
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
cfelton
Replied:
I plan on posting a similar information for an AC97 compatible audio codecs in the next post. That might be of use.
2 years ago
0
cfelton
Replied:
The idea is the simple audio effect that is being created can be used on a plethora of hardware development systems.
2 years ago
0
muneebziaa
Said:
k can you tell me where I can find detail about this board????
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
muneebziaa
Said:
"The idea is the simple audio effect that is being created can be used on a plethora of hardware development systems." CAN YOU BE MORE SPECIFIC?

actually i want to use this broad for my final year project, and i am tired of finding about the procedure used for audio processing.
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
cfelton
Said:
I think I know what you are talking about. If you search/google AC97 you usually find information about PC software drivers etc. I don't know what a refined search might find, e.g. "FPGA AC97". In either way the post with the AC97 information will be a couple days/weeks away. But you can get information about the specific chip from Analog devices.
2 years ago
0
Reply
Sorry, you need javascript enabled to post any comments.
muneebziaa
Replied:
i dont have that much time, well thank you bro for your help
2 years ago
0
Sorry, you need javascript enabled to post any comments.