1 -------------------------------------------------------------------------------
4 -- Generic counter module
6 -- $Id: spi_counter.vhd,v 1.2 2007/02/25 18:24:12 arniml Exp $
8 -- Copyright (c) 2005, Arnim Laeuger (arniml@opencores.org)
10 -- All rights reserved, see COPYING.
12 -- Redistribution and use in source and synthezised forms, with or without
13 -- modification, are permitted provided that the following conditions are met:
15 -- Redistributions of source code must retain the above copyright notice,
16 -- this list of conditions and the following disclaimer.
18 -- Redistributions in synthesized form must reproduce the above copyright
19 -- notice, this list of conditions and the following disclaimer in the
20 -- documentation and/or other materials provided with the distribution.
22 -- Neither the name of the author nor the names of other contributors may
23 -- be used to endorse or promote products derived from this software without
24 -- specific prior written permission.
26 -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 -- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 -- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
30 -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 -- POSSIBILITY OF SUCH DAMAGE.
38 -- Please report bugs to the author, but before you do so, please
39 -- make sure that this is not a derivative work and that
40 -- you have the latest version of this file.
42 -- The latest version of this file can be found at:
43 -- http://www.opencores.org/projects.cgi/web/spi_boot/overview
45 -------------------------------------------------------------------------------
48 use ieee.std_logic_1164.all;
54 cnt_width_g : integer := 4;
55 cnt_max_g : integer := 15
61 cnt_en_i : in boolean;
62 cnt_o : out std_logic_vector(cnt_width_g-1 downto 0);
63 cnt_ovfl_o : out boolean
70 use ieee.numeric_std.all;
71 use work.spi_boot_pack.all;
73 architecture rtl of spi_counter is
75 signal cnt_q : unsigned(cnt_width_g-1 downto 0);
76 signal cnt_ovfl_s : boolean;
80 cnt: process (clk_i, reset_i)
83 cnt_q <= (others => '0');
85 elsif clk_i'event and clk_i = '1' then
87 if not cnt_ovfl_s then
90 cnt_q <= (others => '0');
96 cnt_ovfl_s <= cnt_q = cnt_max_g;
99 -----------------------------------------------------------------------------
101 -----------------------------------------------------------------------------
102 cnt_ovfl_o <= cnt_ovfl_s;
103 cnt_o <= std_logic_vector(cnt_q);
108 -------------------------------------------------------------------------------
111 -- $Log: spi_counter.vhd,v $
112 -- Revision 1.2 2007/02/25 18:24:12 arniml
113 -- fix type handling of resets
115 -- Revision 1.1 2005/02/08 20:41:33 arniml
118 -------------------------------------------------------------------------------