W
Weng Tianxiang
Guest
Hi,
I am very confused with latch generation in VHDL.
1. I have been using VHDL for 7 years and I have never met a situation
I need a latch.
2. I want to know why VHDL let VHDL programmers guess what is to be
generated in the following situation that I know is only case a latch
may be generated:
process(a, ...)
begin
-- signalA <= '0';
case state is
when A_S =>
if(a = "000001") then
signalA <= '1'; <--- a latch is generated, why not
generating an error ?
state_ns <= B_S;
else
state_ns <= A_S;
end if;
....
end process;
Because the first line " Latch_A <= '0'; " is easily missed when the
process content is big, signalA is generated by VHDL definition as a
latch.
Here are my questions:
1. Latch is rarily used throughout all VHDL, why doesn't VHDL
introduce a latch() statement to specially be used for this purpose
while generating an error in the above process().
2. Here is a latch function definition true table:
Enable = 1:
CLK = H, D = H, OUT = H
CLK = H, D = L, OUT = L
CLK = L, D = X, OUT = Q0 (latched data).
It means when clock is high, data is transparent. Input is directed
into output.
When clock is low, the data is latched on falling edge of clock.
In the above process(), there is no clock specified. Which clock will
be used if there are multiple clocks in the design ?
3. In the above example, condition: K = (state = A_S and a = "000001")
should be true to set signalA. What is K role? If K is used as the
latch enable signal, half clock the latch is transparent and its
stored data would be destroyed if there is a glitch with K and could
not keep signalA true value unchanged.
4. I don't know how to design the latch for signalA with K input?
If you know the answers, please help.
Thank you.
Weng
I am very confused with latch generation in VHDL.
1. I have been using VHDL for 7 years and I have never met a situation
I need a latch.
2. I want to know why VHDL let VHDL programmers guess what is to be
generated in the following situation that I know is only case a latch
may be generated:
process(a, ...)
begin
-- signalA <= '0';
case state is
when A_S =>
if(a = "000001") then
signalA <= '1'; <--- a latch is generated, why not
generating an error ?
state_ns <= B_S;
else
state_ns <= A_S;
end if;
....
end process;
Because the first line " Latch_A <= '0'; " is easily missed when the
process content is big, signalA is generated by VHDL definition as a
latch.
Here are my questions:
1. Latch is rarily used throughout all VHDL, why doesn't VHDL
introduce a latch() statement to specially be used for this purpose
while generating an error in the above process().
2. Here is a latch function definition true table:
Enable = 1:
CLK = H, D = H, OUT = H
CLK = H, D = L, OUT = L
CLK = L, D = X, OUT = Q0 (latched data).
It means when clock is high, data is transparent. Input is directed
into output.
When clock is low, the data is latched on falling edge of clock.
In the above process(), there is no clock specified. Which clock will
be used if there are multiple clocks in the design ?
3. In the above example, condition: K = (state = A_S and a = "000001")
should be true to set signalA. What is K role? If K is used as the
latch enable signal, half clock the latch is transparent and its
stored data would be destroyed if there is a glitch with K and could
not keep signalA true value unchanged.
4. I don't know how to design the latch for signalA with K input?
If you know the answers, please help.
Thank you.
Weng