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

Subversion Repositories potato

[/] [potato/] [trunk/] [src/] [pp_counter.vhd] - Blame information for rev 11

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

Line No. Rev Author Line
1 2 skordal
-- The Potato Processor - A simple processor for FPGAs
2
-- (c) Kristian Klomsten Skordal 2014 -2015 <kristian.skordal@wafflemail.net>
3 3 skordal
-- Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
4 2 skordal
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use ieee.numeric_std.all;
8
 
9
entity pp_counter is
10
        generic(
11
                COUNTER_WIDTH : natural := 64;
12
                COUNTER_STEP  : natural :=  1
13
        );
14
        port(
15
                clk   : in std_logic;
16
                reset : in std_logic;
17
 
18
                count     : out std_logic_vector(COUNTER_WIDTH - 1 downto 0);
19
                increment : in std_logic
20
        );
21
end entity pp_counter;
22
 
23
architecture behaviour of pp_counter is
24
        signal current_count : std_logic_vector(COUNTER_WIDTH - 1 downto 0);
25
begin
26
 
27
        count <= current_count;
28
 
29
        counter: process(clk)
30
        begin
31
                if rising_edge(clk) then
32
                        if reset = '1' then
33
                                current_count <= (others => '0');
34
                        elsif increment = '1' then
35
                                current_count <= std_logic_vector(unsigned(current_count) + COUNTER_STEP);
36
                        end if;
37
                end if;
38
        end process counter;
39
 
40
end architecture behaviour;

powered by: WebSVN 2.1.0

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