Skip to content

Instantly share code, notes, and snippets.

@davilamds
Created January 30, 2018 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davilamds/6aed812382262a9586b73545386253d5 to your computer and use it in GitHub Desktop.
Save davilamds/6aed812382262a9586b73545386253d5 to your computer and use it in GitHub Desktop.
Flip Flop tipo D con reset y eneable (2) VHDL
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity d_ff_en_2 is
port(
clk, reset: in std_logic;
en: in std_logic;
d: in std_logic;
q: out std_logic
);
end d_ff_en_2;
architecture arch_d_ff_en_2 of d_ff_en_2 is
signal r_reg, r_next: std_logic;-- se utiliza señales intermedias para guardar valores futuros
begin
process(clk, reset)
begin
if (reset='1') then --reset con prioridad
r_reg<='0';
elsif (clk'event and clk='1') then --cambio de clk=1 ejecuta
r_reg<=r_next; --registro=valor siguiente.
end if;
end process;
r_next<=d when en='1' else r_reg; --el valor siguiente=d si en=1, caso contrario es igual a r_reg
q<=r_reg;-- la salida es r_reg
end arch_d_ff_en_2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment