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

Subversion Repositories epc_rfid_transponder

[/] [epc_rfid_transponder/] [trunk/] [counterclear.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 erwing
-------------------------------------------------------------------------------
2
--     Politecnico di Torino                                              
3
--     Dipartimento di Automatica e Informatica             
4
-------------------------------------------------------------------------------
5
-------------------------------------------------------------------------------     
6
--
7
--     Title          : Simple Counter with clear    
8
--
9
--     File name      : counterclear.vhd 
10
--
11
--     Description    : Counter with clear.    
12
--
13 3 erwing
--     Authors        : Erwing R. Sanchez <erwing.sanchez@polito.it>
14 2 erwing
-------------------------------------------------------------------------------            
15
-------------------------------------------------------------------------------
16
 
17
library IEEE;
18
use IEEE.STD_LOGIC_1164.all;
19
use IEEE.STD_LOGIC_ARITH.all;
20
use IEEE.STD_LOGIC_UNSIGNED.all;
21
 
22
entity COUNTERCLR is
23
  generic (
24
    width : integer := 8);
25
 
26
  port (
27
    clk    : in  std_logic;
28
    rst_n  : in  std_logic;
29
    en     : in  std_logic;
30
    clear  : in  std_logic;
31
    outcnt : out std_logic_vector(width-1 downto 0));
32
end COUNTERCLR;
33
 
34
architecture COUNTERCLR1 of COUNTERCLR is
35
 
36
  signal cnt : std_logic_vector(width-1 downto 0);
37
 
38
begin  -- COUNTERCLR1
39
 
40
  process (clk, rst_n)
41
  begin  -- process
42
    if rst_n = '0' then                 -- asynchronous reset (active low)
43
      cnt <= (others => '0');
44
    elsif clk'event and clk = '1' then  -- rising clock edge
45
      if en = '1' then
46
        cnt <= conv_std_logic_vector(CONV_INTEGER(cnt) + 1, width);
47
      elsif clear = '1' then
48
        cnt <= (others => '0');
49
      end if;
50
 
51
    end if;
52
  end process;
53
 
54
  outcnt <= cnt;
55
 
56
end COUNTERCLR1;

powered by: WebSVN 2.1.0

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