PS, PL comunication, SPI block

Hello
I am using PYNQ-Z2. I created a block in Vivado 2022.1 using vhdl for SPI communication. From the Jupyter notebook I am passing there Register’s addresses which I want to read from sensor. Received data is displayed also in the Jupyter notebook. For now I am reading only registers with constant values so Device ID, brand ID etc.

I checked the vhdl code multiple times and everything seemed to be okay however the values displayed in Jupyter Notebooks were wrong. I used a logic analyzer and there everything also seems to be working. Then I came up with idea that problem might be between PS and PL communication so I added this piece of code to my vhdl:

           if (data_read = x"AD") then
                led (0) <= '1';
                led (1) <= '0';
                led (2) <= '0';
            end if;
            if (data_read = x"1D") then
                led (0) <= '0';
                led (1) <= '1';
                led (2) <= '0';
            end if;
            if (data_read = x"ED") then
                led (0) <= '0';
                led (1) <= '0';
                led (2) <= '1';
            end if;

It lights up the diode if received data is correct (as expected, eg device ID). If the diode would light up and displayed data would be wrong then I would know that the problem is between PS and PL. But for surprise, this piece of code made that data displayed in the Jupyter notebook is correct. Changing this construction for if… elsif… elsif… end if; makes that data displayed in Jupyter notebook is again incorrect. If I delete the “if” construction the data in Jupyter Notebook is wrong. Also other changes which should not affect the data make that data in jupyter notebook is incorrect eg. adding additional state to the state machine (even state which will never run).

I already tried to restart the board and computer but it did not help.

The problem seems to be weird for me, I feel like the code presented above should not affect data in jupyter notebook. I will be very thankful for any suggestions on what could be wrong.

Summary:

  • Data flow between board and sensor according to logic analyzer is correct.
  • Data received and displayed by Jupyter notebook is correct only if I check it with LEDs.
  • If I delete part with LEDs then data received and displayed by Jupyter notebook is incorrect
  • If I change if… construction data received and displayed by Jupyter notebook is incorrect

Below is my block design and code from jupyter notebook (full code also in attachment).
Vivado project is here

Untitled.ipynb (2.7 KB)

1 Like