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

Subversion Repositories present

[/] [present/] [trunk/] [32BitIO/] [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
----     A little modified counter construction - it additionally  ----
11
---- control another one signal. It contains "built-in" reset if   ----
12
---- it is not counting.                                           ----
13
---- To Do:                                                        ----
14
----                                                               ----
15
---- Author(s):                                                    ----
16
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
17
----                       k.gajewski@gmail.com                    ----
18
----                                                               ----
19
-----------------------------------------------------------------------
20
----                                                               ----
21
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
22
----                                                               ----
23
---- This source file may be used and distributed without          ----
24
---- restriction provided that this copyright statement is not     ----
25
---- removed from the file and that any derivative work contains   ----
26
---- the original copyright notice and the associated disclaimer.  ----
27
----                                                               ----
28
---- This source file is free software; you can redistribute it    ----
29
---- and-or modify it under the terms of the GNU Lesser General    ----
30
---- Public License as published by the Free Software Foundation;  ----
31
---- either version 2.1 of the License, or (at your option) any    ----
32
---- later version.                                                ----
33
----                                                               ----
34
---- This source is distributed in the hope that it will be        ----
35
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
36
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
37
---- PURPOSE. See the GNU Lesser General Public License for more   ----
38
---- details.                                                      ----
39
----                                                               ----
40
---- You should have received a copy of the GNU Lesser General     ----
41
---- Public License along with this source; if not, download it    ----
42
---- from http://www.opencores.org/lgpl.shtml                      ----
43
----                                                               ----
44
-----------------------------------------------------------------------
45 2 gajos
library IEEE;
46
use IEEE.STD_LOGIC_1164.ALL;
47
use IEEE.STD_LOGIC_ARITH.ALL;
48
use IEEE.STD_LOGIC_UNSIGNED.ALL;
49
 
50
entity counter is
51
        generic (
52
                w_2 : integer := 2;
53
                w_5 : integer := 5
54
        );
55
        port (
56
                clk, reset, cnt_res : in std_logic;
57
                info : out std_logic_vector (w_2-1 downto 0);
58
                num : out std_logic_vector (w_5-1 downto 0)
59
        );
60
end counter;
61
 
62
architecture Behavioral of counter is
63
        begin
64
                licznik : process (clk, reset)
65
                        variable cnt : unsigned(w_5-1 downto 0);
66
                        begin
67
                                if (reset = '1') then
68
                                        cnt := (others => '0');
69
                                elsif (clk'Event and clk = '1') then
70
                                        if (cnt_res = '1') then
71
                                                cnt := cnt + 1;
72
                                                if (std_logic_vector(cnt) = "00001") then
73
                                                        info <= "01";
74
                                                elsif (std_logic_vector(cnt) = "00000") then
75
                                                        info <= "00";
76
                                                else
77
                                                        info <= "11";
78
                                                end if;
79
                                        else
80
                                                cnt := (others => '0');
81
                                        end if;
82
                                end if;
83
                                num <= std_logic_vector(cnt);
84
                        end process licznik;
85
        end Behavioral;
86
 

powered by: WebSVN 2.1.0

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