Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16650 Discussions

In VHDL, does assigning initial value for variable can be synthesized?

Altera_Forum
Honored Contributor II
1,446 Views

In VHDL, we can assign a value to a variable in a process like: 

 

variable cnt : STD_LOGIC_VECTOR(3 DOWNTO 0) := -1; 

 

Can this be synthesized or just for simulation? 

 

Thanks very much.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
366 Views

yes, no problems with synthesis. But it will only have an effect if cnt becomes a register. 

 

NOTE: you cannot assign -1 to a std_logic_vector. a std_logic_Vector is not a number.
0 Kudos
Altera_Forum
Honored Contributor II
366 Views

A variable in vhdl process ends up as either register or not depending on how its value is located: 

if you assign its value after it is updated then no register is synthesized. 

 

e.g. var1 := var1+1; 

data <= var1; 

 

if you assign its value before it is updated then it implies memory. 

e.g. data <= var1; 

var1 := var1 + 1; 

 

in both cases its own value is updated immediately.
0 Kudos
Altera_Forum
Honored Contributor II
366 Views

Thanks very much, both of you.

0 Kudos
Reply