Electronic – Using the AC97 Codec on an Atlys Spartan 6 Board

audiofpgaspartanverilog

I'm a beginner to FPGA programming. I just started programming an Atlys Spartan 6 board and so far have written one program to blink LEDs in a counter pattern.

Now I'm trying to send the clock signal down-sampled to audio frequencies to the AC97 codec. Here is the Verilog program I've written:

module music(
    input clk,
    output ac97_sdo
    );
reg [25:0] count_aud;
reg clk_aud;

assign ac97_sdo = clk_aud;

/* down-sample the 100MHz system clock to 1kHz */
always @(posedge clk)
begin
    count_aud <= count_aud + 1;
    if (50000 == count_aud)
    begin
        clk_aud <= !clk_aud;
        count_aud <= 0;
    end
end

endmodule

The bit-file generation is fine, but the code doesn't seem to work – I don't hear anything either on Line Out or on HP Out (I don't know how to control the output, either), and I don't have enough experience with the AC97 specification to figure this out. The audio part of the UCF is:

NET ac97_bitclk LOC = L13;
NET ac97_sdi LOC = T18;
NET ac97_sdo LOC = N16;
NET ac97_sync LOC = U17;
NET ac97_reset LOC = T17;

Do I need to use the bit clock, sync, reset, etc. to make this work? If yes, how can I go about it?

I couldn't find any detailed information on the Atlys Reference Manual.

Please help!

Thank you.

Best Answer

The interface to an AC97 codec is a bit more complicated than straight digital audio. The serial data consists of 256-bit data frames; each frame contains several channels of 20-bit samples. The overall data rate is 12.288 MHz; dividing by 256 gives the sample rate of 48 kHz. Part of the 256-bit frame is dedicated to control messages, e.g. to set mixer registers. You may need to do this once after power up/reset to set the volume.

The AC97 spec is available from Intel. Writing your own master is not unreasonable but it will take some time. You may also be able to find one you can reuse. OpenCores has one. There's a very barebones AC97 controller and some general information about the protocol here.

I can't remember how many of the AC97 registers are standardized. The manual I found online for your board says it has an LM4550 codec. Assuming that's right, you may want to refer to the LM4550 datasheet for a complete list of configuration registers.