Author Topic: VHDL SPI core  (Read 526 times)

0 Members and 1 Guest are viewing this topic.

Offline ali_asadzadeh

  • Frequent Contributor
  • **
  • Posts: 873
  • Country: ir
    • ASiD Designer
VHDL SPI core
« on: February 04, 2019, 06:42:36 am »
Hi,
It seems an obvious code,but |O |O
I'm trying to interface the ADS131E08 to my Spartan6 FPGA, the problem is that when I implement my SPI bus, I can access some registers but when I try to verify the written registers some would fail, I want to know if you happen to know a good known source for a Master SPI code in VHDL that would support different modes of CPOL and CPHA modes.

I have tried the FPGA4fun core and my own implementation, but both of them are not working in here.
You can order parts from www.ASiDesigner.com
we are a wire-based company
 

Offline DC1MC

  • Frequent Contributor
  • **
  • Posts: 973
  • Country: de
Re: VHDL SPI core
« Reply #1 on: February 04, 2019, 06:49:03 am »
You can try this one:

https://opencores.org/projects/spi_master_slave

 Cheers,
 DC1MC
 

Offline ali_asadzadeh

  • Frequent Contributor
  • **
  • Posts: 873
  • Country: ir
    • ASiD Designer
Re: VHDL SPI core
« Reply #2 on: February 04, 2019, 07:00:38 am »
Quote
You can try this one:

https://opencores.org/projects/spi_master_slave

 Cheers,
 DC1MC

Thanks,I have already tried this one too, the problem is that the core would send and receive in both falling edge clocks, But I wanted to send in falling edge and receive in rising edge clock, also in the core it mentioned that it had a bug for CPHA =1
You can order parts from www.ASiDesigner.com
we are a wire-based company
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 1775
  • Country: ca
Re: VHDL SPI core
« Reply #3 on: February 04, 2019, 03:17:51 pm »
What is easier?

(1) write 20 lines of VHDL code

or

(2) figure out how somebody else's core works?


SPI is just a sift register. You simply create a counter. Say if your clock  is 100 MHz and you want 1.75 MHz SPI, you count from 0 to 56. When it is at 0 that's your rising edge, you set CLK high and shift out MOSI. When it is at 28, that's your falling edge - you set CLK low and shift in MISO. When it's 56, you reset the counter to 0. That's all there is to it.

If the line is long, you can delay shifting MISO from 28 to a later count, or even move it to the rising edge.

 
The following users thanked this post: Siwastaja

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3215
  • Country: fr
Re: VHDL SPI core
« Reply #4 on: February 04, 2019, 04:11:39 pm »
I second that. SPI is pretty easy, write that yourself. With a couple 'generic' statements, you'll make a decently generic SPI module for all modes in a couple of hours.

The only thing to worry about for a completely generic SPI module though would be the clock domains, but that would matter only if you want to implement slave SPI, which is not what you're talking about here. Master SPI is very simple.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf