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)beginif Enable = '1' thenQ <= 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)beginif S = '1' thenQ <= '1';elsif R = '1' thenQ <= '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)beginif R = '1' thenQ <= '0';elsif S = '1' thenQ <= '1';end if;end process;
No comments:
Post a Comment