R
RCIngham
Guest
There is an utterly horrible VHDL howler on page of 45 of the latest Xcel
Journal. Two example codes for a register with reset are given:
signal Q: std_logic:=â1â;
....
async: process (CLK,RST)
begin
if (RST= â1â) then
Q <= â0â;
elsif (rising_edge CLK) then
Q <= D;
end if;
end
This would be OK if the clock edge function call had bee
'rising_edge(CLK)' instead, and there was a semi-colon after the las
'end'.
signal Q: std_logic:=â1â;
....
async: process (CLK)
begin
if (RST= â1â) then
Q <= â0â;
elsif (rising_edge CLK) then
Q <= D;
end if;
end
This has the same errors as the first, but (despite the unchanged proces
name) is meant to infer a synchronously reset register. BUT ALAS AND ALACK
As written - at least in simulation - the reset will be applied on eithe
edge of CLK. What XST would make of it can only guess. It should be:
signal Q: std_logic:='1';
....
sync: process (CLK)
begin
if rising_edge(CLK) then
if (RST= '1') then
Q <= '0';
else
Q <= D;
end if;
end if;
end process sync;
Such slip-shop work rather reduces one's confidence in the rest of th
contents.
---------------------------------------
Posted through http://www.FPGARelated.com
Journal. Two example codes for a register with reset are given:
signal Q: std_logic:=â1â;
....
async: process (CLK,RST)
begin
if (RST= â1â) then
Q <= â0â;
elsif (rising_edge CLK) then
Q <= D;
end if;
end
This would be OK if the clock edge function call had bee
'rising_edge(CLK)' instead, and there was a semi-colon after the las
'end'.
signal Q: std_logic:=â1â;
....
async: process (CLK)
begin
if (RST= â1â) then
Q <= â0â;
elsif (rising_edge CLK) then
Q <= D;
end if;
end
This has the same errors as the first, but (despite the unchanged proces
name) is meant to infer a synchronously reset register. BUT ALAS AND ALACK
As written - at least in simulation - the reset will be applied on eithe
edge of CLK. What XST would make of it can only guess. It should be:
signal Q: std_logic:='1';
....
sync: process (CLK)
begin
if rising_edge(CLK) then
if (RST= '1') then
Q <= '0';
else
Q <= D;
end if;
end if;
end process sync;
Such slip-shop work rather reduces one's confidence in the rest of th
contents.
---------------------------------------
Posted through http://www.FPGARelated.com