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.

How variables differ from signals ?

Status
Not open for further replies.

kalaiyarasan

Member level 1
Joined
Jun 30, 2010
Messages
33
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Location
hyderabad
Activity points
1,454
variables are used only inside the process statement

signal are used both inside and outside process statements.

so how variable differs from signal or in what aspect it differs ... in memory or processing speed.

instead of creating variable if i m creating a signal what will happen
 

sigal and variable

variables are updated immediatly
Signals are updated on the next delta cycle.

so, if you look at the following process:

Code:
signal a,b : std_logic;


process(clk)
  variable c,d : std_logic;
begin
  if rising_edge(clk) then
    
    a <= ip;
    b <= a;
    op1 <= b;
    
    c := ip;
    d := c;
    op2 <= d;
    
  end if;
end process;

In this process, op1 is connected to the input via 3 pipeline registers.

For op2, the pipeline length is only 1 register, because c and d only represent a wire as they are updated immediatly.

Now, to confuse you:

Code:
signal a,b : std_logic;


process(clk)
  variable c,d : std_logic;
begin
  if rising_edge(clk) then
    
    a <= ip;
    b <= a;
    op1 <= b;
    

    op2 <= d;
    d := c;
    c := ip;

  end if;
end process;

Here, both op1 and op2 show an input to output connection of 3 registers.


In a simulator, variables use a lot less memory as signals have to store current value, future value and when to apply the value. Here is an example

a <= '1', '0' after 10ns;

This needs to store '1' now and the fact that at time = 10ns it changes to '0'.

A variable only stores current value.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top