On Nov 5, 12:13*pm, Analog_Guy <analog_...@hotmail.com> wrote:
> If a variable is read before being assigned in a clocked process, I
> understand that a register will be generated during synthesis.
>
But your understanding is not firm enough...leading to the question
> So, with the code below:
>
> PROCESS (RESET, CLOCK)
> BEGIN
> * IF (RESET = 1) THEN
> * * a := '0';
> * ELSIF (CLOCK = '1' AND CLOCK'EVENT) THEN
> * * CASE a IS
> * * * WHEN IDLE => a := '1';
> ...
> * END IF;
> END PROCESS;
>
> 1. Does the assignment in the reset condition cover "assigned before
> being read", or is this separate from the clocked portion of the
> process?
>
Sounds like you're getting hung up on terminology, maybe a different
description of the behaviour will help.
Every time you re-enter a process, variables will have whatever value
was last assigned to them. So when your process is entered with reset
active, 'a' will be set to '0' and since there is nothing else to do,
the process will then suspend. The next time the process is entered
due to a change in reset or clock, 'a' will still have the value of
'0' since that what you last assigned it to.
Note that it is quite permissable for the process to wake up and not
assign to anything. In your case this would occur at the rising edge
of reset or the falling edge of clock. Since no new assignments will
be made to 'a' on those process wake ups, 'a' will remain at whatever
it was last assigned to.
> 2. Does the case statement case expression (i.e. CASE a IS) count as
> the variable being read? *In this instance the CASE expression is read
> first, then there is an action to assign the variable based on the
> present state.
>
The case statement will evaluate 'a' based on the last value that was
assigned to it which by looking at your code would have to been from
an earlier execution of the process. Any code after this...
> WHEN IDLE => a := '1';
> ...
that looks at 'a' (say perhaps another 'case' statement or an 'if'
statement) would use a value of '1' for 'a' since the assignment in
the 'when idle' branch would've been the last thing that updated 'a'.
If you think in terms of hardware, each and every assignment to a
variable in a process creates a line in the sand. Prior to the
assignment, the variable has one meaning (in your example, 'a' would
be the 'Q' output of a flip flop). After the assignment, the variable
has a different meaning (in your example, 'a' would be the 'D' input
of a flip flop).
Thinking of it in this way, will likely give you headaches. Like it
or not, the easier way to view variables in a process is by thinking
of it in terms of how software typically works...i.e. when something
updates 'a', everything that happens 'downstream' will use the updated
variable.
Kevin Jennings