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

Subversion Repositories mod_mult_exp

[/] [mod_mult_exp/] [trunk/] [rtl/] [vhdl/] [commons/] [counter.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 gajos
-----------------------------------------------------------------------
2
----                                                               ----
3
---- Montgomery modular multiplier and exponentiator               ----
4
----                                                               ----
5
---- This file is part of the Montgomery modular multiplier        ----
6
---- and exponentiator project                                     ----
7
---- http://opencores.org/project,mod_mult_exp                     ----
8
----                                                               ----
9
---- Description:                                                  ----
10
----     Counter - nothing special.                                ----
11
---- To Do:                                                        ----
12
----                                                               ----
13
---- Author(s):                                                    ----
14
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
15
----                       k.gajewski@gmail.com                    ----
16
----                                                               ----
17
-----------------------------------------------------------------------
18
----                                                               ----
19
---- Copyright (C) 2019 Authors and OPENCORES.ORG                  ----
20
----                                                               ----
21
---- This source file may be used and distributed without          ----
22
---- restriction provided that this copyright statement is not     ----
23
---- removed from the file and that any derivative work contains   ----
24
---- the original copyright notice and the associated disclaimer.  ----
25
----                                                               ----
26
---- This source file is free software; you can redistribute it    ----
27
---- and-or modify it under the terms of the GNU Lesser General    ----
28
---- Public License as published by the Free Software Foundation;  ----
29
---- either version 2.1 of the License, or (at your option) any    ----
30
---- later version.                                                ----
31
----                                                               ----
32
---- This source is distributed in the hope that it will be        ----
33
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
34
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
35
---- PURPOSE. See the GNU Lesser General Public License for more   ----
36
---- details.                                                      ----
37
----                                                               ----
38
---- You should have received a copy of the GNU Lesser General     ----
39
---- Public License along with this source; if not, download it    ----
40
---- from http://www.opencores.org/lgpl.shtml                      ----
41
----                                                               ----
42
-----------------------------------------------------------------------
43
library IEEE;
44
use IEEE.STD_LOGIC_1164.ALL;
45
use IEEE.STD_LOGIC_ARITH.ALL;
46
use IEEE.STD_LOGIC_UNSIGNED.ALL;
47
use work.properties.ALL;
48
 
49
-- Uncomment the following library declaration if using
50
-- arithmetic functions with Signed or Unsigned values
51
--use IEEE.NUMERIC_STD.ALL;
52
 
53
-- Uncomment the following library declaration if instantiating
54
-- any Xilinx primitives in this code.
55
--library UNISIM;
56
--use UNISIM.VComponents.all;
57
 
58
entity counter is
59
    generic(
60
             size : integer := 4
61
         );
62
    port (
63
             count  : in STD_LOGIC;
64
                  zero   : in STD_LOGIC;
65
             output : out STD_LOGIC_VECTOR(size - 1 downto 0);
66
        clk    : in STD_LOGIC;
67
        reset  : in STD_LOGIC
68
         );
69
end counter;
70
 
71
architecture Behavioral of Counter is
72
    signal c : STD_LOGIC_VECTOR(size - 1 downto 0);
73
    begin
74
        licznik: process (reset,clk)
75
        begin
76
            if (clk = '1' and clk'Event) then
77
                                    if (reset = '1') then
78
                    c <= (others => '0');
79
                elsif count = '1' then
80
                    c <= c + 1;
81
                elsif zero = '1' then
82
                    c <= (others => '0');
83
                else
84
                                             c <= c;
85
                                         end if;
86
            end if;
87
        end process licznik;
88
    OUTPUT <= c;
89
end Behavioral;

powered by: WebSVN 2.1.0

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