-
Notifications
You must be signed in to change notification settings - Fork 0
/
registrador.vhd
37 lines (35 loc) · 1.21 KB
/
registrador.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity registrador is
generic (
larguraDados : natural := 8
);
port (DIN : in std_logic_vector(larguraDados-1 downto 0);
DOUT : out std_logic_vector(larguraDados-1 downto 0);
ENABLE : in std_logic;
CLK,RST : in std_logic
);
end entity;
architecture comportamento of registrador is
begin
-- In Altera devices, register signals have a set priority.
-- The HDL design should reflect this priority.
process(RST, CLK)
begin
-- The asynchronous reset signal has the highest priority
if (RST = '1') then
DOUT <= (others => '0'); -- Código reconfigurável.
else
-- At a clock edge, if asynchronous signals have not taken priority,
-- respond to the appropriate synchronous signal.
-- Check for synchronous reset, then synchronous load.
-- If none of these takes precedence, update the register output
-- to be the register input.
if (rising_edge(CLK)) then
if (ENABLE = '1') then
DOUT <= DIN;
end if;
end if;
end if;
end process;
end architecture;