Friday, October 30, 2009

Latch Templates

Latch Templates

A transparent latch is basically one bit of memory which is updated when an enable signal is raised:

-- latch template 1:

Q <= D when Enable = '1' else Q;
-- latch template 2:

process(D,Enable)

begin

if Enable = '1' then

Q <= D;

end if;

end process;

A SR-latch uses a set and reset signal instead:

-- SR-latch template 1:

Q <= '1' when S = '1' else

'0' when R = '1' else Q;

-- SR-latch template 2:

process(S,R)

begin

if S = '1' then

Q <= '1';

elsif R = '1' then

Q <= '0';

end if;

end process;

Template 2 has an implicit "else Q <= Q;" which may be explicitly added if desired.

-- This one is a RS-latch (i.e. reset dominates)

process(S,R)

begin

if R = '1' then

Q <= '0';

elsif S = '1' then

Q <= '1';

end if;

end process;

No comments:

Post a Comment

Popular Posts