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_integer_down.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 aborga
-----------------------------------------------------------------------------
2
--      Filename:       gh_counter_integer_down.vhd
3
--
4
--      Description:
5
--              an integer down counter
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             10/15/05        G Huber         Initial revision
15
--
16
-----------------------------------------------------------------------------
17
LIBRARY ieee;
18
USE ieee.std_logic_1164.all;
19
 
20
ENTITY gh_counter_integer_down IS
21
        generic(max_count : integer := 8);
22
        PORT(
23
                clk      : IN STD_LOGIC;
24
                rst      : IN STD_LOGIC;
25
                LOAD     : in STD_LOGIC; -- load D
26
                CE       : IN STD_LOGIC; -- count enable
27
                D        : in integer RANGE 0 TO max_count;
28
                Q        : out integer RANGE 0 TO max_count
29
                );
30
END gh_counter_integer_down;
31
 
32
ARCHITECTURE a OF gh_counter_integer_down IS
33
 
34
        signal iQ : integer RANGE 0 TO max_count;
35
 
36
BEGIN
37
 
38
        Q <= iQ;
39
 
40
process (clk,rst)
41
begin
42
        if (rst = '1') then
43
                iQ <= 0;
44
        elsif (rising_edge(clk))  then
45
                if (LOAD = '1') then
46
                        iQ <= D;
47
                elsif (CE = '1') then
48
                        if (iQ = 0) then
49
                                iQ <= max_count;
50
                        else
51
                                iQ <= iQ - 1;
52
                        end if;
53
                end if;
54
        end if;
55
end process;
56
 
57
END a;
58
 

powered by: WebSVN 2.1.0

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