Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

variable question in VHDL

Status
Not open for further replies.

Digit0001

Member level 1
Joined
Jun 12, 2010
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,547
Hi
Can someone tell me if this is true, Variables declared inside a clocked process are treated as signals for the purpose of synthesis.

P.S
 

Variable this is definition your task like combinatorial logic. For correct synthesis of it you need connect this combinatorial logic to triger.
 

The answer is that you're kind of correct.
Variables are converted to logic just like any signal, but the position of the variable in the code has an effect whereas a changing the position of a signal would have no effect. Because variables are updated immediatly they can be used to create combinatorial logic inside a clocked process.

an example. The first two processes are identical.
Code:
process
begin
  if rising_edge(clk) then
    a <= input;
    b <= a;
    c <= b;
    output <= c;
  end if;
end process;

process
begin
  if rising_edge(clk) then
    output <= c;
    c <= b;
    b <= a;
    a <= input;
  end if;
end process;

Both of these processes produce exactly the same logic - a shift register that has a delay of 4 clock cycles.

now the same codes using variables:

Code:
process
begin
  if rising_edge(clk) then
    a := input;
    b := a;
    c := b;
    output <= c;
  end if;
end process;

In this case, because variables are updated immediatly, then the output only has a single register between the input and output.

Code:
process
begin
  if rising_edge(clk) then
    output <= c;
    c := b;
    b := a;
    a := input;
  end if;
end process;

In this process, the synthis will produce the same logic as if a,b and c were signals, because you are using the variable before it is updated with new value - hence it places a register (so output is a 4 clock cycle delayed version of input).
 
ok i understand now

---------- Post added at 10:35 ---------- Previous post was at 10:31 ----------

however in general cases would this happen regularly? I assume most people when designing would not want a code to wait four clock cycles to update a signal.
 

This is a simple example, showing the behaviours of signals and variables. You may want a shift register of N delay to keep control signals aligned with a data pipeline. So your question doesnt make a lot of sense, because it all depends on your design.

As a general rule - unless you understand what you're doing, use signals. Variables used wrongly can cause problems. You probably wont go wrong with signals.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top