jakubcabal / spi-fpga

SPI master and SPI slave for FPGA written in VHDL
MIT License
163 stars 38 forks source link

Question: spi slave sim with just master => slave mosi data transfer #8

Closed imuguruza closed 2 years ago

imuguruza commented 2 years ago

Hi!

I am trying to simulate just a master to slave data transfer through MOSI where the slave transfer nothing to the master. I was wondering if that's OK, I am trying to usethe SPI_MASTER procedure to generate the SPI waveforms, but I see nothing.

I was wondering if I misundertood some part of the code. Thanks!

jakubcabal commented 2 years ago

Hi, that configuration should work. But without your source code, I can't tell where the error is.

imuguruza commented 2 years ago

Hi, I have finally managed it, for the record, I have commented out the next processes:

And I have used the procedude SPI_MASTER to generate data transmission, this line.

I want to add two things:

The SPI slave is wrapped around a top.vhd where some additional stuff is done with the received data from SPI.

Running the TB, I see the following waveforms:

image

Any idea why miso is driving a signal, when I am not using it in the TB?

jakubcabal commented 2 years ago

Hi, to your questions:

imuguruza commented 2 years ago

SMM_MDI signal of the procedure SPI_MASTER is used to receive (therefore DI) user data into the SPI_MASTER model (procedure). The SPI_MASTER then sends this data via the MOSI signal. But it probably deserves a clearer name.

I see

SPI_SLAVE has a common shift register for both received and sent data. Therefore, if the user does not write data to SPI_SLAVE to send to SPI_MASTER, SPI_SLAVE will start sending (via MISO) the last received data. This should be eliminated by constant setting of some port SPI_SLAVE: DIN_VLD => '1', DIN => (others => '0').

Ok, I have tried it out and now I see nothing in MISO. Thanks!