EmbDev.net

Forum: FPGA, VHDL & Verilog Help creating a SPI state machine in VHDL


von Michael N. (minaknim)


Rate this post
useful
not useful
Hi all, I'm new to FPGA but am really motivated to become well-adept in 
VHDL and FPGA. I am trying to program figure 31 (page 18) shown here: 
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7352.pdf 
with the help of the timing specifications on page 5. I think there 
should be two states: SCLK = High and low and I was thinking about using 
a shift register to take the input of a vector of bits. But I am having 
difficulty 1) making the state machine 2) programming it into VHDL. I 
would appreciate any help!

: Moved by Moderator
von Gustl B. (-gb-)


Rate this post
useful
not useful
Not that hard. Make a simple counter counting for the full cycle. For 
some time in the cycle toggle SCLK for enough clocks. Maybe 30 clocks 
will be enough?
Also use SCLK to shift in the value from SDATA.
At the end of the cycle, when counter is at it's maximum, store the two 
sample values in the shift register to some other register and set the 
counter to zero.

von Gustl B. (-gb-)



Rate this post
useful
not useful
So here is the solution:
AD7352_sim.vhd simulates the very basic functionality of the ADC.
AD7352_read.vhd contains what you intend to do, read data from the ADC.
AD7352_bench.vhd connects them both together.

Have fun (-:

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.