(E-Mail Removed) writes:

> temp <= X"1A";

>

> if ((X"1A" <= temp) and (X"1E" >= temp)) then

> k <= X"002";

> elsif ((X"1F" <= temp) and (X"23" >= temp)) then

> k <= X"003";

> elsif ((X"24" <= temp) and (X"28" >= temp)) then

> k <= X"004";

> else

> k <= X"005";

> end if;

>

> then k is X"005", not like X"002" as I want. Is there anyone here can

> explain why the result is like that? Do we have to notice anything with
Possibly you misunderstand the way signals work. When you assign a

new value to a signal (e.g., temp <= X"1A"), that doesn't change the

value of the signal "now". It schedules a change for some future time.

If no explicit time is given, the change occurs on the next delta time.

So if your assignment to temp and your conditionals are in a process and

being simulated on the same delta, the value the conditionals will see

for temp will be the old value.

If you advance to the next simuluation delta time, temp will have the

value you expect, and the conditional will work as you expect.

Remember, signals aren't variables. Signals represent a physical signal,

and can't change instantaneously. They take at least one delta time

to change. If you aren't using temp to model an electrical signal, then

you probably want it to be a variable rather than a signal.

Note that a simulation delta time is arbitrarily smaller than any time

unit you can designate, so in terms of measurable time it is

conceptually instantaneous, but in terms of simulation the next delta

time is always later, not "now".