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

Subversion Repositories present

[/] [present/] [trunk/] [Decode/] [rtl/] [vhdl/] [counter.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 gajos
-----------------------------------------------------------------------
2
----                                                               ----
3
---- Present - a lightweight block cipher project                  ----
4
----                                                               ----
5
---- This file is part of the Present - a lightweight block        ----
6
---- cipher project                                                ----
7
---- http://www.http://opencores.org/project,present               ----
8
----                                                               ----
9
---- Description:                                                  ----
10
----     Typical construction of 5bit counter. It is counting up.  ----
11
---- Nothing special.                                              ----
12
---- To Do:                                                        ----
13
----                                                               ----
14
---- Author(s):                                                    ----
15
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
16
----                       k.gajewski@gmail.com                    ----
17
----                                                               ----
18
-----------------------------------------------------------------------
19
----                                                               ----
20
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
21
----                                                               ----
22
---- This source file may be used and distributed without          ----
23
---- restriction provided that this copyright statement is not     ----
24
---- removed from the file and that any derivative work contains   ----
25
---- the original copyright notice and the associated disclaimer.  ----
26
----                                                               ----
27
---- This source file is free software; you can redistribute it    ----
28
---- and-or modify it under the terms of the GNU Lesser General    ----
29
---- Public License as published by the Free Software Foundation;  ----
30
---- either version 2.1 of the License, or (at your option) any    ----
31
---- later version.                                                ----
32
----                                                               ----
33
---- This source is distributed in the hope that it will be        ----
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
36
---- PURPOSE. See the GNU Lesser General Public License for more   ----
37
---- details.                                                      ----
38
----                                                               ----
39
---- You should have received a copy of the GNU Lesser General     ----
40
---- Public License along with this source; if not, download it    ----
41
---- from http://www.opencores.org/lgpl.shtml                      ----
42
----                                                               ----
43
-----------------------------------------------------------------------
44 3 gajos
library IEEE;
45
use IEEE.STD_LOGIC_1164.ALL;
46
use IEEE.STD_LOGIC_UNSIGNED.ALL;
47
 
48
entity counter is
49
        generic (
50
                w_5 : integer := 5
51
        );
52
        port (
53
                clk, reset, cnt_res : in std_logic;
54
                num : out std_logic_vector (w_5-1 downto 0)
55
        );
56
end counter;
57
 
58
architecture Behavioral of counter is
59
        signal cnt : std_logic_vector(w_5-1 downto 0) := (others => '0');
60
        begin
61
                licznik : process (clk, reset, cnt)
62
                        begin
63
                                if (reset = '1') then
64
                                        cnt <= (others => '0');
65
                                elsif (clk'Event and clk = '1') then
66
                                        if (cnt_res = '1') then
67
                                                cnt <= cnt + 1;
68
                                        end if;
69
                                end if;
70
                        end process licznik;
71
                        num <= cnt;
72
        end Behavioral;
73
 

powered by: WebSVN 2.1.0

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