B
Brian Drummond
Guest
On Sun, 17 Aug 2008 01:07:51 -0700 (PDT), rickman <gnuarm@gmail.com>
wrote:
but on a casual read, obscures the meaning; this to my mind
overcomes any advantage of using variables over signals.
(It works because the variable assignments take place immediately; the
signal assignments follow them, and therefore happen in the SAME delta
cycle, not the next time the process wakes)
Confusing the reader is bad. However I think I also managed to confuse
Xilinx ISE 7.1 through 9.2 where this style is combined with expressions
involving both signals and variables. I need to simplify the case in
question until the evidence is clear (and see what ISE 10.1 does with
it) before I say more.
(On a vaguely related topic, namely confusing the reader; I managed to
pin down my unease with the conditional operator, a?b:c which we
discussed recently. I didn't learn it in Verilog, but in a weird
language that doesn't even have a boolean type, and requires 'a' to be
some species of integer. This makes me want the cases 0 and 1 to appear
in ascending order for some reason; I have to force myself to read them
in descending order. YMMV and probably does.)
In favour of variables is their local status, and their semantics
resembling conventional programming language assignment to variables.
Against them is (a) some uses can be confusing as above and (b) if you
use them for registers in a pipeline, you have to describe the pipeline
backwards.
So I normally use them for intermediate results, and (with apologies to
Mike T) use signals for my pipeline registers.
- Brian
wrote:
Mike's defense of it makes sense, but I still agree with you. It worksOn Aug 17, 1:23 am, Mike Treseler <mtrese...@gmail.com> wrote:
The version below is still silly, but is readable.
process (Clk)
variable q1_v : std_ulogic;
variable q2_v : std_ulogic;
begin
if rising_edge(Clk) then
q1_v := A and B; -- right before left
q2_v := q1_v and C; -- means no regs here
end if;
Q1 <= q1_v; -- output register
Q2 <= q2_v; -- output register
end process;
This still is not clear to me. Why are the signal assignments outside
of the clocked if condition? But they are inside the clocked
process! To me, this is un-synthesizable as it is describing a
register clocked on both edges.
but on a casual read, obscures the meaning; this to my mind
overcomes any advantage of using variables over signals.
(It works because the variable assignments take place immediately; the
signal assignments follow them, and therefore happen in the SAME delta
cycle, not the next time the process wakes)
Confusing the reader is bad. However I think I also managed to confuse
Xilinx ISE 7.1 through 9.2 where this style is combined with expressions
involving both signals and variables. I need to simplify the case in
question until the evidence is clear (and see what ISE 10.1 does with
it) before I say more.
(On a vaguely related topic, namely confusing the reader; I managed to
pin down my unease with the conditional operator, a?b:c which we
discussed recently. I didn't learn it in Verilog, but in a weird
language that doesn't even have a boolean type, and requires 'a' to be
some species of integer. This makes me want the cases 0 and 1 to appear
in ascending order for some reason; I have to force myself to read them
in descending order. YMMV and probably does.)
In favour of variables is their local status, and their semantics
resembling conventional programming language assignment to variables.
Against them is (a) some uses can be confusing as above and (b) if you
use them for registers in a pipeline, you have to describe the pipeline
backwards.
So I normally use them for intermediate results, and (with apologies to
Mike T) use signals for my pipeline registers.
- Brian