Hi,
I have taken a look at this issue now. I think my testbench may not be configured identically to yours, because I can’t trigger the problem. I have two BFMs in my testbench. Both are configured to CPHA = ‘0’ and CPOL = ‘0’. One is a master and the other is a slave.
The following code is used to trigger the VVCs using the BFMs:
-- Chip select shall not be deasserted between operations, and there shall be no pause on SCLK between operations.
spi_master_transmit(data => 8x"55", action_when_transfer_is_done => HOLD_LINE_AFTER_TRANSFER);
spi_slave_check(data_exp => 8x"55", when_to_start_transfer => START_TRANSFER_ON_NEXT_SS);
spi_slave_transmit(data => 8x"AA", when_to_start_transfer => START_TRANSFER_IMMEDIATE);
spi_master_check(data_exp => 8x"AA", action_when_transfer_is_done => RELEASE_LINE_AFTER_TRANSFER);
await_completion(SPI_VVCT, 0, 1 us);
await_completion(SPI_VVCT, 1, 1 us);
As you can see from the code, I issue two commands to each of the two VVCs. First I command the master to transmit and slave to receive. Then, without any pause, I trigger the slave to transmit and master to receive.
In this example the BFM config is set so that bit time is 40 ns and the ss_n_to_sclk setting is 6 ns.
The following picture shows the moment where the master transmit/slave receive ends and the slave transmit/master receive begins.
The spi_slave_receive() procedure is finished at the final falling edge of SCLK + t_spi_bfm_config.ss_n_to_sclk . In my TB that is the time of the last falling edge of SCLK + 6 ns.
The spi_slave_transmit() procedure then sets the value of MISO, also at the last falling edge of SCLK + 6 ns. Because the BFM is set to SPI mode 0 the data shall be transmitted at the falling edge of SCLK and sampled at the rising edge of SCLK. Depending on the setting of spi_bit_time and ss_n_to_sclk the start of spi_slave_transmit() begins well within the required time before the rising edge of SCLK. The MISO updates 6 ns after the last falling edge of SCLK of the previous transaction, and 14 ns before the first rising edge of the spi_slave_transmit() procedure.
Have I configured anything differently with respect to your testbench?
Best regards,
Daniel Blomkvist
EmLogic
Edit:
Here’s the BFM config I am using:
constant C_SPI_BFM_CONFIG_DEFAULT : t_spi_bfm_config := (CPOL => '0',
CPHA => '0',
spi_bit_time => 40 ns,
ss_n_to_sclk => 6 ns,
sclk_to_ss_n => 5 ns,
inter_word_delay => 0 ns,
match_strictness => MATCH_EXACT,
id_for_bfm => ID_BFM);