# Synthesising “constant” in VHDL

From point of view of a synthesiser, is there any difference between:

1. Signal offset: std_logic_vector ( 3 downto 0) := "0100";

2. Constant offset: std_logic_vector ( 3 downto 0) := "0100";

• Depends if you ever assign anything else to the signal. However, constant guarantees you won't, and communicates that intent to the reader. So use it where you can. – Brian Drummond Mar 17 '18 at 13:54

Nope. However "constant" cannot be assigned any value. Its value can never change during simulation. Otherwise its just like "signal" itself. It is just used to improve maintainability, readability and clarity in the code to the user. One use of constant is:

    constant const: integer := 7;
signal a: std_logic_vector(const downto 0);
signal b: std_logic_vector(const downto 0);
signal c: std_logic_vector(const+1 downto 0);


In future, if you want to change the bus width, you just need to change the initialising value of const.

Note that - As @damage pointed out, we usually do all initialisation by asserting reset signal in the beginning. However I have seen that most FPGA synthesisers synthesise the initialised value.

• Can you show specific examples where "most synthesisers synthesise the initial value" for FPGAs? It sounds like you're confining that view to RAM-based FPGAs. How will initial values work in a Flash-based FPGA or CPLD? – TonyM Apr 2 '18 at 18:17
• Have worked on Quartus II 13.1, which synthesises initial values on Altera cyclone series boards. – Mitu Raj Apr 2 '18 at 18:21

No, for almost all synthesis tools there will be no difference.

However, people with a background in ASIC design will discourage the use of initial values for signals and recommend the use of a resest signal to set the initial value. This is because for ASICs there is no configuration phase as for FPGAs and registers will usually be in an unknown state after power-on.

For FPGAs some vendors will recommend the use of initial values instead of resets whenever possible, since this can result in lower resource utilization. This is because during the configuration phase of SRAM-based FPGAs, when the bitstream is loaded to the FPGA, each register can be set to an initial value.

For simulation it will make no difference too.

• Can you show specific examples of "most vendors recommending initial values wherever possible" for FPGAs? It sounds like you're confining that view to RAM-based FPGAs. How will initial values work in a Flash-based FPGA or CPLD? – TonyM Mar 17 '18 at 22:04
• I'm not very familiar with flash-based FPGAs. I would assume that they also have a GSR (global-set-reset) net which is used to set all FFs to known values after configuration is complete (which happens comparably fast). – damage Mar 18 '18 at 1:07