Hi
I come from « normal » programming world and I am very pertubated by INITIALISATION procedures in VHDL code.
I have difficulty with of course the most basics : 8 bit counter…
But if we generalise, the problem goes like this ….
[this is the « correct » VHDL code. Well « correct » according to your norms which still puzzle me …]
architecture
signal var1 : std_logic_vector ( n-1 )
signal var2 : std_logic_vector ( n-1 )
signal var3 : std_logic_vector ( n-1 )
process (clock, reset)
if reset = 0 then
var1 = 0
var2 = 0
var3 = 0
else if rising edge (clock) and clock event then
…
end process
exit1_Q = var1
exit2_Q = var2
exit3_Q = var3
end architecture
[this is what we would be tempted to do in « normal » programming world ». We would initialise in the declaration section. Don’t you think ? So the code would go like this …]
architecture
signal var1 : std_logic_vector ( n-1 ) = 0
signal var2 : std_logic_vector ( n-1 ) = 0
signal var3 : std_logic_vector ( n-1 ) = 0
process (clock, reset)
if reset = 0 then
var1 = 0
var2 = 0
var3 = 0
else if rising edge (clock) and clock event then
…
end process
exit1_Q = var1
exit2_Q = var2
exit3_Q = var3
end architecture
I would like to have the point of view of a PROFICIENT VHDL programmer to give me his view. I’ve never seen this thing :
architecture
signal var1 : std_logic_vector ( n-1 ) = 0
so I guess it is wrong. Wrong or inutile/useless ?
I don’t have a simulator at home (…). Could SO simulate the code and let me know what happens ?
architecture
signal count : std_logic_vector ( n-1 ) = 0
process (clock, reset)
if reset = 0 then
count = 0
else if rising edge (clock) and clock event then
count = count + 1
end process
exit_Q = count
end architecture
what does the simulator tell ? Does it accept Initialisation at the Signal Declaration level ? ? ? ? It is true that the body of the architecture is concurrent world. So I can imagine the initialisation should not be in the Declaration Section and just stay in the reset section (I don’t have any problem with initialisation after the reset. All the components are initialised after RESET). This gives a static and « FLAT » vision of the code.
If I initiliase with zeros , am I committing a breach ? Is it Erroneous VHDL code ? That’s why I would like the opinion of a PROFICIENT VHDL. I feel very uncomfortable with this issue so I hope someone will take the time to reply to me .