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

Subversion Repositories uart_plb

[/] [uart_plb/] [trunk/] [pcores/] [uart_plb_v1_00_a/] [hdl/] [vhdl/] [tmo.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 gavinux
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
use work.uart_components.UNSIGNED_NUM_BITS;
6
 
7
entity tmo is
8
    Port ( clk       : in  STD_LOGIC;
9
           clr       : in  STD_LOGIC;
10
           tick      : in  STD_LOGIC;
11
           timeout   : out STD_LOGIC); --pulse signal
12
end tmo;
13
 
14
architecture Behavioral of tmo is
15
 
16
-- one rcv_tick = 16 baud_tick
17
-- one bytte = 10 rcv_tick
18
-- delay 2 bytes
19
constant CNT_MAX    : integer := 16 * 10 * 2;
20
signal   cnt        : integer range 0 to 16 * 16 * 2;
21
signal   time_out_s : std_logic := '0';
22
signal   time_out_q : std_logic := '0';
23
 
24
begin
25
 
26
    process(clk)
27
    begin
28
        if rising_edge(clk) then
29
            if (clr = '1') then
30
                cnt <= 0;
31
            elsif (tick = '1') then
32
                cnt <= cnt + 1;
33
            end if;
34
        end if;
35
    end process;
36
 
37
    process(clk)
38
    begin
39
        if rising_edge(clk) then
40
            if clr = '1' then
41
                time_out_s <= '0';
42
            elsif (cnt = CNT_MAX) then
43
                time_out_s <= '1';
44
            end if;
45
        end if;
46
    end process;
47
 
48
    process(clk)
49
    begin
50
        if rising_edge(clk) then
51
            time_out_q <= time_out_s;
52
        end if;
53
    end process;
54
 
55
    process(clk)
56
    begin
57
        if rising_edge(clk) then
58
            if (time_out_s = '1' and time_out_q = '0') then
59
                timeout <= '1';
60
            else
61
                timeout <= '0';
62
            end if;
63
        end if;
64
    end process;
65
 
66
end Behavioral;
67
 

powered by: WebSVN 2.1.0

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