K
kristoff
Guest
Hi all,
I have a question on a very simple piece of code:
I have been looking in the different VHDL documentation I have here, but
have not found it.
This is part of a process:
My question is related to the fact there are two signals that are
assignments, but these two signals are inter-dependent.
Here there are two actions:
- store data from the spi_mosi input-pin to the correct position of the
buffer
- move down the buffer-position pointer
The order in which these two actions are executed does matter.
If I understand this correctly, as this is part of a process, the
general rule is that the assignment is actually done at the END of the
process!!!
So, I tested this and ... in this case, this works nice. ... But ... why?
How does the VHDL compiler know what actions comes first?
At first, I thought that this was related to the order in which the two
actions are written in the process (commands inside a process do are
processed in sequence, no?), but when I move the "move down
buffer-position pointer" part to the start of this process, the code
still works. (so this part was executed LAST, not first!)
What exactly is going on here?
Is this just a random behaviour or how quartus is processing this
paricular example, or is this senario exactually described in the VHDL
specification?
(as said, I have been looking in the documentation I have, and not found
any information about this).
Now, I know there are other ways to code this that are more explicit
about the order these two actions are executed:
- make the statemachine more complex
- use a temporary variable.
What would be "best practice" to code this "the proper way"?
Cheerio!
Kristoff
I have a question on a very simple piece of code:
I have been looking in the different VHDL documentation I have here, but
have not found it.
This is part of a process:
if (s_sclk_edgeup = '1') then
-- on rising edge of spi-clock, read data, and determine
-- next bit position
buffer(bitcounter) <= spi_mosi;
-- determine new bitposition
if (bitcounter > 0) then
bitcounter <= bitcounter - 1;
else
bitcounter <= 7;
-- last bit -> go process received data
state <= PROCESS_DATA;
end if;
end if;
My question is related to the fact there are two signals that are
assignments, but these two signals are inter-dependent.
Here there are two actions:
- store data from the spi_mosi input-pin to the correct position of the
buffer
- move down the buffer-position pointer
The order in which these two actions are executed does matter.
If I understand this correctly, as this is part of a process, the
general rule is that the assignment is actually done at the END of the
process!!!
So, I tested this and ... in this case, this works nice. ... But ... why?
How does the VHDL compiler know what actions comes first?
At first, I thought that this was related to the order in which the two
actions are written in the process (commands inside a process do are
processed in sequence, no?), but when I move the "move down
buffer-position pointer" part to the start of this process, the code
still works. (so this part was executed LAST, not first!)
What exactly is going on here?
Is this just a random behaviour or how quartus is processing this
paricular example, or is this senario exactually described in the VHDL
specification?
(as said, I have been looking in the documentation I have, and not found
any information about this).
Now, I know there are other ways to code this that are more explicit
about the order these two actions are executed:
- make the statemachine more complex
- use a temporary variable.
What would be "best practice" to code this "the proper way"?
Cheerio!
Kristoff