In all examples:
en is the enable signal,d is the input,q is the output,srst is an active high synchronous reset,srstn is an active low synchronous reset,arst is an active high asynchronous reset,arstn is an active low asynchronous reset,sset is an active high synchronous set,ssetn is an active low synchronous set,aset is an active high asynchronous set,asetn is an active low asynchronous setAll signals are of type ieee.std_logic_1164.std_ulogic. The syntax used is the one that leads to correct synthesis results with all logic synthesizers. Please see the Clock edge detection example for a discussion about alternate syntax.
process(en, d)
begin
if en = '1' then
q <= d;
end if;
end process;
process(en, d)
begin
if en = '0' then
q <= d;
end if;
end process;
process(en, d)
begin
if en = '1' then
if srst = '1' then
q <= '0';
else
q <= d;
end if;
end if;
end process;
process(en, d, arst)
begin
if arst = '1' then
q <= '0';
elsif en = '1' then
q <= d;
end if;
end process;
process(en, d, arstn)
begin
if arstn = '0' then
q <= '0';
elsif en = '0' then
if sset = '1' then
q <= '1';
else
q <= d;
end if;
end if;
end process;
Note: set has higher priority than reset
process(en, d, arst, asetn)
begin
if asetn = '0' then
q <= '1';
elsif arst = '1' then
q <= '0';
elsif en = '1' then
q <= d;
end if;
end process;