0
\$\begingroup\$

I get an error message "Error (10398): VHDL Process Statement error: Process Statement must contain only one Wait Statement" for this code
FOR i IN 0 TO N LOOP WAIT UNTIL tx_busy = '0'; tx_data <= data(i); END LOOP;
I understand what it means and why it's there, but I still feel there's a way to do what I intended, but haven't found a way

asked Aug 17, 2018 at 4:46
\$\endgroup\$
6
  • 4
    \$\begingroup\$ FPGAs can't wait for things. \$\endgroup\$ Commented Aug 17, 2018 at 4:50
  • \$\begingroup\$ I think they do, if it is a signal that has to get a significant value they are waiting for. For example link \$\endgroup\$ Commented Aug 17, 2018 at 4:59
  • 4
    \$\begingroup\$ You can write wait, but if the compiler can figure out a way to make it not actually wait, it will do that. If it can't figure that out, you get an error. With an FPGA, all of your code is running, all of the time. You can't make code not run until something happens. \$\endgroup\$ Commented Aug 17, 2018 at 5:32
  • 5
    \$\begingroup\$ In synthesis for loops are unrolled. Thus although you have written one WAIT, in fact you have N waits. Re-write using a clock and a counter for 'i'. \$\endgroup\$ Commented Aug 17, 2018 at 5:51
  • 1
    \$\begingroup\$ Just because its legal VHDL (and does what you want in sim, which this probably won't) doesn't mean a synthesis tool has to obey it. Either find a way the tool understands, or find a better tool. \$\endgroup\$ Commented Aug 17, 2018 at 7:57

1 Answer 1

-1
\$\begingroup\$

You loop doesn't work because loops are executed in one clock-cycle and therefore multiple WAIT-Statements exist at the same time.

This is how you could do it:

process
 variable i : natural := 0;
 constant N : natural := 42;
begin
 wait until tx_busy = '0'; -- step 1
 if i < N then -- step 2
 i := i + 1; -- |
 else -- |
 i := 0; -- |
 end if; -- |
 tx_data <= data(i); -- step 3
end process;

The code has three steps:

  1. wait until tx_busy is '0'
  2. increase i as long as it's smaller than N, otherwise reset it to 0
  3. write out data(i) to the target signal
answered Aug 22, 2018 at 12:59
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.