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

I don’t often convert VHDL to Verilog but when I do ...
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




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: 1324

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



Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 2000

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 470

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/fpgarela/public_html/new/Commax/include/commax.class.php on line 473

There are no comments yet!


Sorry, you need javascript enabled to post any comments.