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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [vhdl/] [ocidec2/] [ud_cnt.vhd] - Blame information for rev 31

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 rherveille
---------------------------------------------------------------------
2
----                                                             ----
3
----  Generic Up/Down counter (ripple carry architecture)        ----
4
----                                                             ----
5
----  Author: Richard Herveille                                  ----
6
----          richard@asics.ws                                   ----
7
----          www.asics.ws                                       ----
8
----                                                             ----
9
---------------------------------------------------------------------
10
----                                                             ----
11
---- Copyright (C) 2001, 2002 Richard Herveille                  ----
12
----                          richard@asics.ws                   ----
13
----                                                             ----
14
---- This source file may be used and distributed without        ----
15
---- restriction provided that this copyright statement is not   ----
16
---- removed from the file and that any derivative work contains ----
17
---- the original copyright notice and the associated disclaimer.----
18
----                                                             ----
19
----     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ----
20
---- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ----
21
---- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ----
22
---- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ----
23
---- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ----
24
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ----
25
---- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ----
26
---- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ----
27
---- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ----
28
---- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ----
29
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ----
30
---- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ----
31
---- POSSIBILITY OF SUCH DAMAGE.                                 ----
32
----                                                             ----
33
---------------------------------------------------------------------
34
 
35
--
36
--  CVS Log
37
--
38
--  $Id: ud_cnt.vhd,v 1.1 2002-03-01 03:49:03 rherveille Exp $
39
--
40
--  $Date: 2002-03-01 03:49:03 $
41
--  $Revision: 1.1 $
42
--  $Author: rherveille $
43
--  $Locker:  $
44
--  $State: Exp $
45
--
46
-- Change History:
47
--               $Log: not supported by cvs2svn $
48
 
49
 
50
library ieee;
51
use ieee.std_logic_1164.all;
52
use ieee.std_logic_arith.all;
53
 
54
entity ud_cnt is
55
        generic(
56
                SIZE : natural := 8;
57
                RESD : natural := 0
58
        );
59
        port(
60
                clk    : in  std_logic;                  -- master clock
61
                nReset : in  std_logic := '1';           -- asynchronous active low reset
62
                rst    : in  std_logic := '0';           -- synchronous active high reset
63
 
64
                cnt_en : in  std_logic := '1';           -- count enable
65
                ud     : in  std_logic := '0';           -- up / not down
66
                nld    : in  std_logic := '1';           -- synchronous active low load
67
                d      : in  unsigned(SIZE -1 downto 0); -- load counter value
68
                q      : out unsigned(SIZE -1 downto 0); -- current counter value
69
 
70
                rci    : in  std_logic := '1';           -- carry input
71
                rco    : out std_logic                   -- carry output
72
        );
73
end entity ud_cnt;
74
 
75
architecture structural of ud_cnt is
76
        signal Qi : unsigned(SIZE -1 downto 0);
77
        signal val : unsigned(SIZE downto 0);
78
begin
79
        val <= ( ('0' & Qi) + rci) when (ud = '1') else ( ('0' & Qi) - rci);
80
 
81
        regs: process(clk, nReset)
82
        begin
83
                if (nReset = '0') then
84
                        Qi <= conv_unsigned(RESD, SIZE);
85
                elsif (clk'event and clk = '1') then
86
                        if (rst = '1') then
87
                                Qi <= conv_unsigned(RESD, SIZE);
88
                        else
89
                                if (nld = '0') then
90
                                        Qi <= D;
91
                                elsif (cnt_en = '1') then
92
                                        Qi <= val(SIZE -1 downto 0);
93
                                end if;
94
                        end if;
95
                end if;
96
        end process regs;
97
 
98
        -- assign outputs
99
        Q <= Qi;
100
        rco <= val(SIZE);
101
end architecture structural;
102
 

powered by: WebSVN 2.1.0

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