1
\$\begingroup\$

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";

\$\endgroup\$
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – Brian Drummond Mar 17 '18 at 13:54
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – TonyM Apr 2 '18 at 18:17
  • \$\begingroup\$ Have worked on Quartus II 13.1, which synthesises initial values on Altera cyclone series boards. \$\endgroup\$ – Mitu Raj Apr 2 '18 at 18:21
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – TonyM Mar 17 '18 at 22:04
  • \$\begingroup\$ 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). \$\endgroup\$ – damage Mar 18 '18 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.