10
\$\begingroup\$

I know two ways in which a VHDL variable is synthesized by synthesis tool:

  • Variable synthesized as Combinational logic
  • Variable synthesized as a Latch unintentionally (when an uninitialized variable is assigned to a signal or another variable)

What are the other ways in which a VHDL variable can be synthesized ? (Example: can it be interpreted as a FF ? )

Martin Thompson
8,6491 gold badge26 silver badges45 bronze badges
asked Jun 19, 2013 at 21:58
\$\endgroup\$

2 Answers 2

10
\$\begingroup\$

I would distinguish three possibilities:

  1. A VHDL variable has no hardware representation at all. Assume the following example

    signal a,b,c : integer; 
    ... 
    process ( clk ) is 
    variable var : integer := 0; 
    begin 
    if ( rising_edge(clk) ) then 
    var := a + b; 
    c <= var; 
    end if; 
    end process;
    

    The variable var is not really synthesized as combinatorial logic at all (assuming this is what was meant in the question). It's rather the right hand side of the assignment a + b that is synthesized into hardware. Strictly speaking a variable never is synthesized into combinatorial logic.

  2. A variable merely holds an intermediate result, which is either evaluated in the same clock cycle -> no hardware synthesized ( this is 1) again ), or is evaluated in the following clock cycle -> a flipflop is synthezised.

  3. One of those dreaded latches is inferred in such cases where conditional branches exist in which the variable is assigned neither a new value (depending on some signals) nor a default value. Usually this case happens unintended :-)

Dan D.
6727 silver badges11 bronze badges
answered Jun 21, 2013 at 1:20
\$\endgroup\$
1
  • \$\begingroup\$ The "dreaded latch" can only happen outside of a clocked process though and most people (in my experience) these days are not using non-clocked processes. So the latch dread is not an issue anymore (IMHO) - it stems from the olden days when you had to write your combinatorial logic in a separate process to your flip flops \$\endgroup\$ Commented Jul 13, 2016 at 12:56
6
\$\begingroup\$

If you use the value in a variable before you store it, you get the value that was stored last time the process stored it (in a clocked process, the value from a previous clock cycle). That is synthesised as a register or FF.

Of course, in the first clock cycle you get garbage, unless you initialised the variable in a reset clause.

answered Jun 20, 2013 at 20:52
\$\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.