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

Subversion Repositories spi_boot

[/] [spi_boot/] [trunk/] [rtl/] [vhdl/] [spi_counter.vhd] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 arniml
-------------------------------------------------------------------------------
2
--
3
-- SD/MMC Bootloader
4
-- Generic counter module
5
--
6
-- $Id: spi_counter.vhd,v 1.1 2005-02-08 20:41:33 arniml Exp $
7
--
8
-- Copyright (c) 2005, Arnim Laeuger (arniml@opencores.org)
9
--
10
-- All rights reserved, see COPYING.
11
--
12
-- Redistribution and use in source and synthezised forms, with or without
13
-- modification, are permitted provided that the following conditions are met:
14
--
15
-- Redistributions of source code must retain the above copyright notice,
16
-- this list of conditions and the following disclaimer.
17
--
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.
21
--
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.
25
--
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.
37
--
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.
41
--
42
-- The latest version of this file can be found at:
43
--      http://www.opencores.org/projects.cgi/web/spi_boot/overview
44
--
45
-------------------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
 
51
entity spi_counter is
52
 
53
  generic (
54
    cnt_width_g   : integer := 4;
55
    cnt_max_g     : integer := 15;
56
    reset_level_g : integer := 0
57
  );
58
 
59
  port (
60
    clk_i      : in  std_logic;
61
    reset_i    : in  std_logic;
62
    cnt_en_i   : in  boolean;
63
    cnt_o      : out std_logic_vector(cnt_width_g-1 downto 0);
64
    cnt_ovfl_o : out boolean
65
  );
66
 
67
end spi_counter;
68
 
69
 
70
library ieee;
71
use ieee.numeric_std.all;
72
use work.spi_boot_pack.all;
73
 
74
architecture rtl of spi_counter is
75
 
76
  signal cnt_q      : unsigned(cnt_width_g-1 downto 0);
77
  signal cnt_ovfl_s : boolean;
78
 
79
begin
80
 
81
  cnt: process (clk_i, reset_i)
82
  begin
83
    if reset_i = reset_level_g then
84
      cnt_q <= (others => '0');
85
 
86
    elsif clk_i'event and clk_i = '1' then
87
      if cnt_en_i then
88
        if not cnt_ovfl_s then
89
          cnt_q <= cnt_q + 1;
90
        else
91
          cnt_q <= (others => '0');
92
        end if;
93
      end if;
94
    end if;
95
  end process cnt;
96
 
97
  cnt_ovfl_s <= cnt_q = cnt_max_g;
98
 
99
 
100
  -----------------------------------------------------------------------------
101
  -- Output Mapping
102
  -----------------------------------------------------------------------------
103
  cnt_ovfl_o <= cnt_ovfl_s;
104
  cnt_o      <= std_logic_vector(cnt_q);
105
 
106
end rtl;
107
 
108
 
109
-------------------------------------------------------------------------------
110
-- File History:
111
--
112
-- $Log: not supported by cvs2svn $
113
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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