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.

assign initail value to signal

Status
Not open for further replies.

electronical

Advanced Member level 4
Joined
Nov 4, 2011
Messages
104
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
1,975
hello, how can i assign initail value to signal without using process?
 

thank you , but it is just for simulation not in real synth model,I need for real circuit

Shame on TrickyDicky's super power rangers powers of deduction for not deducing this from your detailed post. :(

- - - Updated - - -

*ahem*

Sorry for being mildly sarcastic. But please at least /try/ to give a bit of detail when you ask a question. Otherwise we have to resort to voodoo powers, or more likely ... bit depending on mood, your post gets ignored and people spend their time answering people who actually do provide some details.
 

signal a : std_logic := '1';
Hi,I write this code but when I synt ,I face with this error:
Code:
package my_package is
type matrix1x8 is array ( 1 to 8) of integer range -127 to 127;
end package;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_logic_unsigned.all;
use work.my_package.all;
entity as is
  port(clk,clr,reset:in bit;col_L:in matrix1x8
  ...);
end;
 architecture behave of new_min_value is
signal a:integer range -127 to 127 :=1;
signal  ii:integer range 1 to 8;
signal Mes_c_to_v:integer range -127 to 127:=1;
signal out_1:integer range -127 to 127:=1;
signal d:integer range -127 to 127:=1; 
signal Lnew:integer range -127 to 127:=1;
begin
  .
  .
  .
  a<=col_L(ii);
  d<=a-Mes_c_to_v;
  ...
 process(clk,reset,clr  )
    variable  i:integer range 0 to 8;
    begin 
      if reset ='1' then 
        i:=0;
      else
        if (clk 'event and clk='1' )then
         if clr='1' then 
          if i=8 then
           i:=1;
          else
           i:=i+1;ii<=i;
          end if;
         end if; 
        end if;
     end if;
    end process;
    --------------------------------------------------------------------------------------  
;
   
 end; 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
error :
Value -128 is out of range -127 to 127 .
this error occured at d<=a-Mes_c_to_v;
 

Code:
signal a:integer range -127 to 127 :=1;

signal Mes_c_to_v:integer range -127 to 127:=1;

So any result "d"

Code:
d<=a-Mes_c_to_v;

will be in the -254 to 254 range.

I think the error you got is the result of a simple range check by the synthesis tool. So either you mask the result, or you extend the range for "d".
 

Don't put initial values on signals your synthesizable vhdl.

Initial signal values can be supported by fpgas, taking effect straight after configuration. But they're usually regarded as bad news. Use a reset circuit to initialise signals (flip-flops) to a known state. Otherwise your design may behave differently on the board than on the simulator. This can confuse you and others during debugging.

(I only ever use an initial signal value in fpgas in internal reset generator circuits. The resultant reset then initialises all fpga circuitry.)
 

Don't put initial values on signals your synthesizable vhdl.

Initial signal values can be supported by fpgas, taking effect straight after configuration. But they're usually regarded as bad news.

Are you sure it's a bad idea? In the past I've read some conflicting opinions about it. Because I also used to use explicit reset circuitry in fpga's ... because the folk wisdom said so. But as usual with folk wisdom, these folks should update their wisdom more often!

While explicit reset code for everything in your HDL looks nice and clean, and makes you a better and happier person, there's a flip-side to it. All those nice reset lines (and of course there is going to be more than one :p ) will cost you precious routing resources. And this while you could be using the global reset for it.

If you for example use a flip-flop with initial value of 1 and then view the synthesis results, you'll get a FF with the SET connected to the global reset.

I don't know about Altera recommendations, but Xilinx seems to advocate using these initial value assignments (thus using the global reset).

So if your design is intended to always target an fpga (i.e no plans for ASICs or some such), then as far as I can tell there is no need to ALWAYS do an explicit reset for everything. Just wondering what other people experiences regarding this are...

- - - Updated - - -

Otherwise your design may behave differently on the board than on the simulator. This can confuse you and others during debugging.

In what way? You probably mean synthesis / simulation mismatches, right?

But in what way? If the simulator handles these initial values correctly AND in real hardware you start out with these same initial values as expected, then what further issues are there?

Mmmh, this just made me think of something ... Regarding the fgpa global reset, is there a difference in the way this is simulated in pre- vs post-synthesis simulation? Probably, but I must confess I never checked that. Anyone know the answer to that one?


PS: see for example http://www.xilinx.com/support/documentation/white_papers/wp272.pdf for what I mean in the above.
 

I understand that Tony's reservations are referring to the problem of releasing resets asynchronously when the system clock is already applied, which is often the case in FPGA systems. It can e.g. cause state machines to fall into illegal states, and at worst case never recover from it.

Explicite resets can be released synchronously by adding a standard reset synchronizer, but POR that is responsible for registers with initializer can't. In so far the doubts are validated.

The situation is however different for clocks sourced from an internal PLL. They are assured to start with valid timing after POR release.

In terms of FPGA resources, explicite resets are more or less free, respectively cost not more than one global signal - and of course text lines So it's a good idea to use explicite reset initializers for all design entities, resetting at least all signals that keep state and similar information. Applying the reset also to those signals that don't necessarily need it, e.g. pipeline registers may be the easiest way, because you don't need to think about the signal's nature.
 

Are you sure it's a bad idea? In the past I've read some conflicting opinions about it. Because I also used to use explicit reset circuitry in fpga's ... because the folk wisdom said so. But as usual with folk wisdom, these folks should update their wisdom more often!

While explicit reset code for everything in your HDL looks nice and clean, and makes you a better and happier person, there's a flip-side to it. All those nice reset lines (and of course there is going to be more than one :p ) will cost you precious routing resources. And this while you could be using the global reset for it.

I think you've got a bit mixed up between initial values and reset values :) Resets uses circuitry and routed wires, whereas initial values use nothing. They're completely different.

The VHDL language supports initial values. In simulation, when an initial value is placed on a signal, then that signal adopts that value at time 0, before any deltas. When you restart the simulation you'll find that signal will have that value and no time will have elapsed yet.

If you synthesize this into an ASIC, the initial value will be thrown away. The ASIC flip-flops will power up in a random state. The silicon has no equivalent for an initial value. So the simulated VHDL will behave differently to the real silicon.

If you synthesize this into an FPGA, the initial value will be inserted into the configuration file. In an FPGA, flip-flops will power-up in a random state. When the FPGA supply voltage is high enough, internal circuitry will clear the internal configuration RAM. Then after configuration, each flip-flop will have the value given to it by the configuration file, as will internal block RAM contents. Note that no 'user-available' flip-flop terminals are pulsed or used to get these initial values in. So...if you pulse your circuit's RESET-etc input pin, the FPGA won't load configuration again and your flip-flops will not contain initial values. (People may well be pushing a RESET button for a reset pin, rather than powering down and up - depends on the system). However, when you restart the simulator they will have initial values. So the simulated VHDL will behave differently to the real silicon.

I'd have to call designing-in differences between the simulated VHDL and real circuit behaviour a bad thing at any age :)

On the other hand, the reset circuit does actually drive FPGA flip-flop preset/set terminals (if you use asynchronous resets, uses gating for syn resets). The manufacturers make sure the device has a good reset distribution network as they expect you to use resets across lots of flip-flops. If you write good standard VHDL, pulsing reset will have the same effect on your actual circuit as id does on the simulation.

So using initial values means the VHDL will behave differently in an ASIC to an FPGA, but using resets leaves it portable.

All in all: don't use initial values, use resets throughout. Just makes for clean and simple design. I've previously read and made use of the app note but I think it's making a different point.

Thanks, hope this clears my point up a bit.
 
Last edited:
Although the result isn't possibly much different, I would make a small correction to your view of initial values.

Register initial values are using the same dedicated register reset function than an explicite reset. The only difference is, that they aren't wired to the FPGA fabric respective external pins but the internal POR generator. Some FPGA families (e.g. all recent Altera devices) have the option to wire the POR network aditional to a dedicated pin in an OR manner.

So, the default POR reset behaviour isn't different from a purely asynchronous reset, either if it's exposed to an external pin or not. It's limitations are in only this asynchronous nature.
 

I think I understand the point you're making, sorry if I may not be, and I can stand by my earlier post.

In any event, I have found that initial values are for testbenches and not for circuit designs.

I've worked for one major ASIC company in which initial values were banned. Avoiding them in logic designs, using a reset signal instead, will bring you naught but happiness :)

Hope all this helps the original questioner, pleasure to see and hear all as always...
 

This will work for a real circuit - at least with Xilinx and Altera.

I'm 99.9% sure of this as well as I've used it before.

Also, side note, I could be mistaken but I believe that there's a subtle difference between the initial (power-on) reset mechanism for:

signal a : std_logic := '0';

vs

if reset = '1' then
a <= '0';
else rising_edge(clock) then
end if;
 
Last edited:

Are you sure it's a bad idea? In the past I've read some conflicting opinions about it. Because I also used to use explicit reset circuitry in fpga's ... because the folk wisdom said so. But as usual with folk wisdom, these folks should update their wisdom more often!
There is a very good engineering reason and it has nothing to do with 'folk wisdom' or 'opinions'. It's also a very simple explanation best explained by considering the following:
- The initial value is only good up until the very first clock edge comes along.
- Ask yourself what happens when the FPGA first comes out of configuration and the device comes live?
- Ask yourself what relation there is between the time that the device comes live and that first clock edge used to clock the device?
- Ask yourself how will you guarantee that the inputs to the device and every flip flop inside the device will meet the setup and hold time requirements to that very first clock edge? (since that's the only clock edge that matters as it relates to overwriting those initial values).

If you can guarantee that all inputs will meet setup and hold time requirements then there is no issue with using initial values. If you cannot guarantee this, well...many times devices do work in spite of violation of the specified requirements, simply because nearly every specified requirement has some margin in it. If you want to ignore requirements on the hope that it will never fail then that's your call, it's not good engineering but it is your call. After all, those initial values get wiped out on that first edge and what are the odds that the really important flip flop(s) will be the ones that fail?

Lest I sound too pessimistic, there are ways to guarantee this. Design a way that the clock doesn't start until after configuration is complete and it can turn on in at a controlled time.

While explicit reset code for everything in your HDL looks nice and clean, and makes you a better and happier person, there's a flip-side to it. All those nice reset lines (and of course there is going to be more than one :p ) will cost you precious routing resources. And this while you could be using the global reset for it.
The flip side also is that reset code can (and should be) designed to meet timing requirements. Specifically, 'reset' needs to go inactive at a known time relative to the clock. If you have multiple clocks, then you need seperate resets signals for each clock domain. A dual clock fifo? You hope that the designer knows what they were doing.

So if your design is intended to always target an fpga (i.e no plans for ASICs or some such), then as far as I can tell there is no need to ALWAYS do an explicit reset for everything. Just wondering what other people experiences regarding this are...
- There is rarely a need to reset everything. Certain key things do need to be reset somehow, examples being the state of a state machine. Many flip flops do not need to be reset, examples being pretty much the entire data path. While reset can still have a lot of loads, the number of flops dedicated to data path that do not need to be reset will far outnumber the state machine, control and status bits that do need to be reset.
- At a system level, if the FPGA needs to be 'reset', is it acceptable that the reset be performed by re-configuring the device in order to reload those initial values?
- If FPGA configuration is only performed at power up, then the only way to reload those initial values to reset the device is to cycle power. Is that acceptable in your application?

Kevin Jennings
 
- At a system level, if the FPGA needs to be 'reset', is it acceptable that the reset be performed by re-configuring the device in order to reload those initial values?
- If FPGA configuration is only performed at power up, then the only way to reload those initial values to reset the device is to cycle power. Is that acceptable in your application?
Most FPGAs allow to trigger configuration by an external signal, many are exposing an optional input feeding the POR net.

But this doesn't change anything to the problem of timing violations during asynchronous POR release. As said, the problem ususally doesn't exist for internal PLL generated clocks, but I'm not sure for all FPGA families, you should check this yourself.

Also, side note, I could be mistaken but I believe that there's a subtle difference between the initial (power-on) reset mechanism for:

signal a : std_logic := '0';

vs

if reset = '1' then
a <= '0';
else rising_edge(clock) then
end if;
Which difference do you imagine? If reset is asynchronously released, there's no difference in timing behaviour I think. Of course reset can be applied on demand, and it can be originated from a reset synchronizer, which changes a lot.
 

I think initial values only exist in the VHDL language as a 'nicety', a hangover from the Ada programming lanuage VHDL is based on. In no way were they intended to put reset values onto flip-flops within circuits. The fact that initial values can get put into FPGA programming files doesn't mean that they are 'the way forward' instead of reset circuits.

Initial values are very useful in testbenches, setting up test signals before use and getting rid of 'U's all over the wave window and test circuit.

Incidentally, an FPGA configuration file will usually default to loading all device flip-flops with an initial value of 0 during configuration. This global initial value can sometimes be changed in a menu setting. I wouldn't start doing designs that rely on that though, it's the enemy of portability.

I find initial values in designs a bit of an academic discussion, really. Resets are around for good and continuing reasons and initial values in synthesized designs are asking for confusion.

I'm a little concerned a few might not be recognising the gulf between an initial value and a reset - they're worlds apart in digital circuitry, as some have described above. I hope no-one's fooled by what the simulator can show you, it's digital circuitry that matters.
 

Incidentally, an FPGA configuration file will usually default to loading all device flip-flops with an initial value of 0 during configuration.
I'm a little concerned a few might not be recognising the gulf between an initial value and a reset - they're worlds apart in digital circuitry, as some have described above.
I hear a lack of knowledge about actual FPGA hardware behind this statement. I'm not talking about ASICs.

There is no thing like loading flip-flops with a value from configuration file with the FPGA families I was talking about, e.g. all recent Altera FPGAs. Instead the power-on-reset (POR) signal is fed to the asynchronous reset input of registers through a global net (possibly ORed with other signals). This power on reset to an initial value (default is 0) is always present and can't be disabled at will. You can at best declare POR state as "don't care", in this case the synthesis tool is free to invert the state without a warning.

In so far, initial values are working the same way as asynchronous resets with these devices, believe it or not.

The asynchronous nature however brings up timing issues, as Kevin explained in detail in post #16.
 

I hear a lack of knowledge about actual FPGA hardware behind this statement. I'm not talking about ASICs.

There is no thing like loading flip-flops with a value from configuration file with the FPGA families I was talking about, e.g. all recent Altera FPGAs.

Sorry if my last post was a bit forceful. I just want to strongly discourage newcomers to VHDL from getting an idea that initial values are a good idea in synthesizable VHDL for FPGAs or ASICs or anything else. Experienced engineers will know their way around anyway. (I was referring particularly to FvM when remarking about good points we've made above so I am reading :) )

But yes, I do have a very clear picture of the internal architecture of FPGAs as I've had to exploit it on several occassions.

Have a look at the below text from the Altera Quartus II Handbook, Volume 1 (2008 was the one I had to hand!). I've blued a few statements supporting some of my last points, probably missed some others


Altera Corporation 6–41
May 2008
Recommended HDL Coding Styles

REGISTER POWER-UP VALUES IN ALTERA DEVICES
Registers in the device core always power up to a low (0) logic level on all
Altera devices. However, there are ways to implement logic such that
registers behave as if they were powering up to a high (1) logic level.
If you use a preset signal on a device that does not support presets in the
register architecture, then your synthesis tool may convert the preset
signal to a clear signal, which requires synthesis to perform an
optimization referred to as NOT gate push-back. NOT gate push-back adds
an inverter to the input and the output of the register so that the reset and
power-up conditions will appear to be high but the device operates as
expected. In this case, your synthesis tool may issue a message informing
you about the power-up condition. The register itself powers up low, but
the register output is inverted so the signal that arrives at all destinations
is high.
Due to these effects, if you specify a non-zero reset value, you may cause
your synthesis tool to use the asynchronous clear (aclr) signals available
on the registers to implement the high bits with NOT gate push-back. In
that case, the registers look as though they power up to the specified reset
value. You see this behavior, for example, if your design targets
FLEX 10KE or ACEX devices.
When a load signal is available in the device, your synthesis tools can
implement a reset of 1 or 0 value by using an asynchronous load of 1 or
0. When the synthesis tool uses an asynchronous load signal, it is not
performing NOT gate push-back, so the registers power up to a 0 logic
level.
Designers typically use an explicit reset signal for the design, which
forces all registers into their appropriate values after reset but not
necessarily at power-up. You can create your design such that the
asynchronous reset allows the board to operate in a safe condition and
then you can bring up the design with the reset active. This is a good
practice so you do not depend on the power-up conditions of the device.

You can make the your design more stable and avoid potential glitches by
synchronizing external or combinational logic of the device architecture
before you drive the asynchronous control ports of registers.
For additional information about good synchronous design practices,
refer to the Design Recommendations for Altera Devices and the Quartus II
Design Assistant chapter in volume 1 of the Quartus II Handbook.
If you want to force a particular power-up condition for your design, use
the synthesis options available in your synthesis tool. With Quartus II
integrated synthesis, you can apply the Power-Up Level logic option. You
can also apply the option with an altera_attribute assignment in
your source code. Using this option forces synthesis to perform NOT gate
push-back because synthesis tools cannot actually change the power-up
states of core registers.
You can apply the Quartus II integrated synthesis Power-Up Level
assignment to a specific register or to a design entity, module or
subdesign. If you do so, every register in that block receives the value.

Registers power up to 0 by default; therefore you can use this assignment
to force all registers to power up to 1 using NOT gate push-back.
1 Be aware that using NOT gate push-back as a global assignment
could slightly degrade the quality of results due to the number
of inverters that are needed. In some situations, issues are
caused by enable or secondary control logic inference. It may
also be more difficult to migrate such a design to an ASIC or a
HardCopy® device.
You can simulate the power-up behavior in
a functional simulation if you use initialization.
The Power-Up Level option and the altera_attribute assignment
are described in the Quartus II Integrated Synthesis chapter in volume 1 of
the Quartus II Handbook.

POWER-UP LEVEL OPTION
Some synthesis tools can also read the default or initial values for
registered signals and implement this behavior in the device.
For
example, Quartus II integrated synthesis converts default values for
registered signals into Power-Up Level settings. That way, the
synthesized behavior matches the power-up state of the HDL code
during a functional simulation.
For example, the code samples in Example 6–30 and Example 6–31 both
infer a register for q and set its power-up level to high (while the reset
value is 0).

EXAMPLE 6–31. VHDL REGISTER WITH RESET AND HIGH POWER-UP LEVEL
SIGNAL q : STD_LOGIC := '1'; -- q has a default value of '1'
PROCESS (clk, reset)
BEGIN
IF (reset = '1') THEN
q <= '0';
ELSIF (rising_edge(clk)) THEN
q <= d;
END IF;
END PROCESS;
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top