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

Subversion Repositories uart_fpga_slow_control_migrated

[/] [uart_fpga_slow_control/] [trunk/] [code/] [library/] [gh_counter_down_ce_ld_tc.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 aborga
-----------------------------------------------------------------------------
2
--      Filename:       gh_Counter_down_ce_ld_tc.vhd
3
--
4
--      Description:
5
--              Binary up/down counter with load, count enable and TC
6
--
7
--      Copyright (c) 2005 by George Huber 
8
--              an OpenCores.org Project
9
--              free to use, but see documentation for conditions 
10
--
11
--      Revision        History:
12
--      Revision        Date            Author          Comment
13
--      --------        ----------      ---------       -----------
14
--      1.0             09/03/05        S A Dodd        Initial revision
15
--      2.0             09/17/05        h lefevre       name change to avoid conflict
16
--                                                        with other libraries
17
--      2.1             09/24/05        S A Dodd        fix description 
18
--      2.2             05/21/06        S A Dodd        fix typo's
19
-----------------------------------------------------------------------------
20
LIBRARY ieee;
21
USE ieee.std_logic_1164.all;
22
USE ieee.std_logic_unsigned.all;
23
USE ieee.std_logic_arith.all;
24
 
25
ENTITY gh_counter_down_ce_ld_tc IS
26
        GENERIC (size: INTEGER :=8);
27
        PORT(
28
                CLK   : IN      STD_LOGIC;
29
                rst   : IN      STD_LOGIC;
30
                LOAD  : IN      STD_LOGIC;
31
                CE    : IN      STD_LOGIC;
32
                D     : IN  STD_LOGIC_VECTOR(size-1 DOWNTO 0);
33
                Q     : OUT STD_LOGIC_VECTOR(size-1 DOWNTO 0);
34
                TC    : OUT STD_LOGIC
35
                );
36
END gh_counter_down_ce_ld_tc;
37
 
38
ARCHITECTURE a OF gh_counter_down_ce_ld_tc IS
39
 
40
        signal iQ  : STD_LOGIC_VECTOR (size-1 DOWNTO 0);
41
        signal iTC : STD_LOGIC;
42
 
43
BEGIN
44
 
45
--
46
-- outputs
47
 
48
        TC <= (iTC and CE);
49
 
50
        Q <= iQ;
51
 
52
----------------------------------
53
----------------------------------
54
 
55
PROCESS (CLK,rst)
56
BEGIN
57
        if (rst = '1') then
58
                iTC <= '0';
59
        elsif (rising_edge(CLK)) then
60
                if (LOAD = '1') then
61
                        if (D = x"0") then
62
                                iTC <= '1';
63
                        else
64
                                iTC <= '0';
65
                        end if;
66
                elsif (CE = '0') then  -- LOAD = '0'
67
                                if (iQ = x"0") then
68
                                        iTC <= '1';
69
                                else
70
                                        iTC <= '0';
71
                                end if;
72
                else -- (CE = '1')      
73
                        if (iQ = x"1") then
74
                                iTC <= '1';
75
                        else
76
                                iTC <= '0';
77
                        end if;
78
                end if;
79
        end if;
80
END PROCESS;
81
 
82
 
83
PROCESS (CLK,rst)
84
BEGIN
85
        if (rst = '1') then
86
                iQ <= (others => '0');
87
        elsif (rising_edge(CLK)) then
88
                if (LOAD = '1') then
89
                        iQ <= D;
90
                elsif (CE = '1') then
91
                        iQ <= (iQ - "01");
92
                end if;
93
        end if;
94
END PROCESS;
95
 
96
END a;

powered by: WebSVN 2.1.0

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