OpenCores
URL https://opencores.org/ocsvn/loadbalancer/loadbalancer/trunk

Subversion Repositories loadbalancer

[/] [loadbalancer/] [trunk/] [TABLE/] [Aging_Timer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 atalla
-- UART BAUD RATE GENERATOR
2
 
3
library ieee;
4
use ieee.std_logic_1164.all;
5
use ieee.numeric_std.all;
6
 
7
-- N is the size of the register that holds the counter in bits.
8
-- M represents the modulo value, i.e., if 10, counter counts to 9 and wraps
9
entity Aging_Timer is
10
   generic(
11
      N: integer := 32;  -- 32 bits couter
12
      M: integer := 10  -- 125000  = 1 miliscond
13
   );
14
   port(
15
      clk, reset: in std_logic;
16
      timeout: out std_logic;
17
          timer_aging_bit: out std_logic;
18
      count_out: out std_logic_vector(31 downto 0)--N-1
19
   );
20
end Aging_Timer;
21
 
22
architecture beh of Aging_Timer is
23
   SIGNAL timeout_i : STD_LOGIC;
24
   SIGNAL timer_aging_bit_i : STD_LOGIC;
25
   signal r_reg: unsigned(N-1 downto 0);
26
   signal r_next: unsigned(N-1 downto 0);
27
   begin
28
 
29
-- sequential logic that creates the FF
30
   process(clk, reset)
31
      begin
32
         if (reset = '1') then
33
            r_reg <= (others => '0');
34
         elsif (clk'event and clk='1') then
35
            r_reg <= r_next;
36
         end if;
37
   end process;
38
 
39
-- next state logic for the FF, count from 0 to M-1 and wrap
40
   r_next <= (others => '0') when r_reg=(M-1) else r_reg + 1;
41
 
42
-- output logic, output the actually count in the register, in case it's needed
43
   count_out <= std_logic_vector(r_reg);
44
 
45
-- generate a 1 clock cycle wide 'tick' when counter reaches max value
46
   timeout_i <= '1' when r_reg=(M-1) else '0';
47
 
48
          process(clk, reset)
49
      begin
50
         if (reset = '1') then
51
                                timer_aging_bit_i <= '0';
52
         elsif (clk'event and clk='1') then
53
                                IF(timeout_i = '1' ) THEN
54
                                timer_aging_bit_i <= NOT  timer_aging_bit_i;
55
                                END IF ;
56
         end if;
57
   end process;
58
timeout <= timeout_i;
59
timer_aging_bit <=timer_aging_bit_i;
60
end beh;
61
 
62
 
63
 
64
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.