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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [vhdl/] [ocidec3/] [ro_cnt.vhd] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 rherveille
---------------------------------------------------------------------
2
----                                                             ----
3
----  Run-Once Counter                                           ----
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: ro_cnt.vhd,v 1.1 2002-03-01 03:49:25 rherveille Exp $
39
--
40
--  $Date: 2002-03-01 03:49:25 $
41
--  $Revision: 1.1 $
42
--  $Author: rherveille $
43
--  $Locker:  $
44
--  $State: Exp $
45
--
46
-- Change History:
47
--               $Log: not supported by cvs2svn $
48
 
49
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.std_logic_arith.all;
52
 
53
entity ro_cnt is
54
        generic(
55
                SIZE : natural := 8;
56
                UD   : std_logic := '0'; -- default count down
57
                ID   : natural := 0      -- initial data after reset
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
                go     : in  std_logic;                  -- load counter and start sequence
66
                done   : out std_logic;                  -- done counting
67
                d      : in  unsigned(SIZE -1 downto 0); -- load counter value
68
                q      : out unsigned(SIZE -1 downto 0)  -- current counter value
69
        );
70
end entity ro_cnt;
71
 
72
architecture structural of ro_cnt is
73
        component ud_cnt is
74
        generic(
75
                SIZE : natural := 8;
76
                RESD : natural := 0      -- initial data after reset
77
        );
78
        port(
79
                clk    : in  std_logic;                  -- master clock
80
                nReset : in  std_logic := '1';           -- asynchronous active low reset
81
                rst    : in  std_logic := '0';           -- synchronous active high reset
82
 
83
                cnt_en : in  std_logic := '1';           -- count enable
84
                ud     : in  std_logic := '0';           -- up / not down
85
                nld    : in  std_logic := '1';           -- synchronous active low load
86
                d      : in  unsigned(SIZE -1 downto 0); -- load counter value
87
                q      : out unsigned(SIZE -1 downto 0); -- current counter value
88
 
89
                rci    : in  std_logic := '1';           -- carry input
90
                rco    : out std_logic                   -- carry output
91
        );
92
        end component ud_cnt;
93
 
94
        signal rci, rco, nld : std_logic;
95
begin
96
        gen_ctrl: process(clk, nReset)
97
        begin
98
                if (nReset = '0') then
99
                        rci <= '0';
100
                elsif (clk'event and clk = '1') then
101
                        if (rst = '1') then
102
                                rci <= '0';
103
                        else
104
                                rci <= go or (rci and not rco);
105
                        end if;
106
                end if;
107
        end process;
108
 
109
        nld <= not go;
110
 
111
        -- hookup counter
112
        cnt : ud_cnt
113
                generic map (
114
                        SIZE => SIZE,
115
                        RESD => ID
116
                )
117
                port map (
118
                        clk => clk,
119
                        nReset => nReset,
120
                        rst => rst,
121
                        cnt_en => cnt_en,
122
                        ud => UD,
123
                        nld => nld,
124
                        D => D,
125
                        Q => Q,
126
                        rci => rci,
127
                        rco => rco
128
                );
129
 
130
        done <= rco;
131
end architecture structural;

powered by: WebSVN 2.1.0

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