Javier Valcarce's Personal Website

Main | Private | Templates | MediaWiki | Categories | Special pages | Upload |||| XHTML 1.0 Strict? | CSS?

Interface AD7303

From JavierValcarce.Es

You are at: Home > Hardware > Interface AD7303
Jump to: navigation, search
Summary
This VHDL macro is intended for interface (say) PicoBlaze with the 8-bit DAC AD7303 from Analog Devices or compatible ones. Such device is included in Digilent AIO1 peripheral board sold by Digilent.

VHDL Macro

xc3s400-4ft256 utilization
Element Used
Slices 30
Flip-Flops 45
LUTs 42
Bonded IOBs 26
Global CLKs 1
Max Freq. 233.91MHz
component ad7303
  port (
    reset   : in  std_logic;
    clk     : in  std_logic;  
    wr      : in  std_logic;
    XL_wr   : in  std_logic;
    XR_wr   : in  std_logic;
    XL      : in  std_logic_vector(7 downto 0);
    XR      : in  std_logic_vector(7 downto 0);
    rdy     : out std_logic;
    int_rdy : out std_logic;
    sclk    : out std_logic;
    din     : out std_logic;
    sync    : out std_logic);
end component;
AD7303 pinout
AD7303 pinout

The AD7303 is an 2-channel 8-bit DAC with a SPI interface. Rather than use a complete, general SPI master transceiver, I developed an specific (ad hoc) interface logic which is extremely simple and easy to use from PicoBlaze or some system else.

The interface moves two 8-bit samples in 68 system clock cycles so the maximum DAC data rate @50MHz is 50 \times 10^6 / 68 = 735.29kHz for each channel. The predefined configuration for AD7303[1] is

  • the two DAC channels enabled
  • collect data from the shift register instead from input register
  • set the internal reference (Vdd / 2)

Ports and Usage

The macro has the following ports:

Port DIR Type Description
reset Input signal Asynchronous reset
clk Input signal Clock signal. Must be lower than 60MHz because sclk freq. is a half of the clk freq. and the AD7303 admit a sclk of 30MHz at maximum
wr Input signal Chip enable (write signal). Start the tx operation, rdy goes low until the macro has finished the tx of two samples (L and R).
XL_wr Input signal Chip enable signal for the XL register
XR_wr Input signal Chip enable signal for the XR register
XL Input 8-bit bus Register that stores the "left" sample (AD7303 is a 2-channel DAC)
XR Input 8-bit bus Register that stores the "right" sample (AD7303 is a 2-channel DAC)
rdy Output signal Ready signal, while the macro is busy, this signal is 0
int_rdy Output signal Rise one clock cycle pulse when rdy goes 1 (use it to interrupt PicoBlaze for example)
sclk Output signal SPI serial clock signal
din Output signal SPI serial data signal
sync Output signal SPI chip select signal

Put data samples on XL and XR ports and assert XL_wr and XR_wr until the next clk rising edge, then assert wr signal until the clk rising edge. At this moment rdy goes 0, the sample will be transferred to DAC in 68 clock (clk) cycles. Wait rdy signal to be 1 again, this notifies you that the transmission has finished. See the cronogram below.

Block Diagram And Control State Machine

The figure depicted below shows the RTL block diagram of the circuit. All sequential blocks share the same asyncronous reset and clock signals. The control finite state machine (FSM) has 9 states, there are 6 control signals for datapath. The 4-bits up counter serves to greatly simply the FSM's graph.

Datapath

Control

The FSM has the following graph, state after reset is e0, the control signals in each state are shown in the table. The value '-' means "no matter", this is very convenient because it relieves the constraints over the job that has to be done by the synthesizer, the synthesized circuits are simpler.

Control signals for datapath
State rs sel sync osr_ce osr_ld ctr_ce sclk
e0 0 - 1 0 0 0 0
e1 0 0 1 1 1 0 0
e2 0 0 0 0 0 1 0
e3 0 0 0 1 0 0 1
ee 0 - 1 - - 0 0
e4 0 1 1 1 1 0 0
e5 0 1 0 0 0 1 0
e6 0 1 0 1 0 0 1
e7 0 - 0 0 0 1 0


Simulation

Cronogram in ModelSim. Transmission of 2 8-bit samples in 68 clk cycles:

(todo)

Download

  • ad7303.vhd AD7303 interface macro. Thanks to Faisal Abu-Nimeh, who fixed an error in SPI transmision.
  • ad7303_test.vhd Test Bench for AD7303 interface macro.
  • utils.vhd Utils package.

References