-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenericTimeBase.vhd
56 lines (48 loc) · 1.21 KB
/
genericTimeBase.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity BaseDeTiempo is
Generic(
K: integer:=49999999; --Constante de la tarjeta.
N: integer:=27 --Número de bits del contador.
);
Port(
CLK : in std_logic; --Reloj maestro.
RST : in std_logic; --Reset maestro.
H : in std_logic; --Señal de habilitación.
BT : out std_logic --Base de tiempo.
);
end BaseDeTiempo;
Architecture Tiempo of BaseDeTiempo is
Signal Qp, Qn : std_logic_vector(N-1 downto 0):=(others => '0'); -- Estado presente y siguiente del contador.
Signal BdT : std_logic:='0';
Signal BdTconH: std_logic_vector(1 downto 0):=(others =>'0');
Begin
BT <= BdT;
BdTconH <= BdT & H;
Mux: Process(BdTconH, Qp) is
begin
case BdTconH is
when "01" => Qn <= Qp+1;
when "11" => Qn <= (others =>'0');
when others => Qn <= Qp;
end case;
end process Mux;
Comparador: Process(Qp) is
begin
if Qp = K then
BdT <= '1';
else
BdT <= '0';
end if;
end process Comparador;
Combinacional: Process(CLK, RST) is
begin
if RST = '0' then
Qp <= (others => '0');
elsif CLK'event and CLK = '1' then
Qp <= Qn;
end if;
end process Combinacional;
end Tiempo;