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

Subversion Repositories wdsp

[/] [wdsp/] [trunk/] [rtl/] [vhdl/] [WISHBONE_FFT/] [counterhle.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 parrado
--Counter with resetn and load enable 
2
--When load enable is high, it counts. 
3
--When load enable is low, it stops counting. 
4
--When a reset is triggered, it resets to zero. 
5
 
6
LIBRARY ieee;
7
USE ieee.std_logic_1164.ALL;
8
USE ieee.std_logic_arith.ALL;
9
 
10
entity counterhle is
11
  generic (
12
        width: integer :=3
13
        );
14
  port (
15
        clock : in std_logic;
16
        resetn : in std_logic;
17
        enable : in std_logic;
18
        clear : in std_logic;
19
        countout : out std_logic_vector(width-1 downto 0)
20
 
21
    );
22
end counterhle;
23
 
24
architecture behavior of counterhle is
25
signal count : std_logic_vector(width-1 downto 0);
26
 
27
begin
28
process(clock,resetn,enable)
29
begin
30
 if (resetn='0')then
31
     count <= (others => '0');
32
 
33
  elsif (clock'event and clock='1') then
34
      if (enable = '1' ) then
35
                        if (clear = '1') then
36
                                count <= (others => '0');
37
                        else
38
           count <= unsigned(count) + '1';
39
                          end if;
40
   end if;
41
 
42
 end if ;
43
end process;
44
countout <= count;
45
 
46
end;

powered by: WebSVN 2.1.0

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