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

Subversion Repositories distributed_intelligence

[/] [distributed_intelligence/] [trunk/] [SRC/] [binary_counter_x16.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 leoel
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:  Léo Germond
4
-- 
5
-- Create Date:    16:51:22 11/08/2009 
6
-- Design Name: 
7
-- Module Name:    binary_counter_x16 - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_UNSIGNED.ALL;
23
use IEEE.NUMERIC_STD.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity binary_counter_x16 is
31
        Port (  clk : in  STD_LOGIC;
32
                                reset: in STD_LOGIC;
33
                                set : in  STD_LOGIC;
34
                                inc : in  STD_LOGIC;
35
                                set_value : in  STD_LOGIC_VECTOR (15 downto 0);
36
                                count : out  STD_LOGIC_VECTOR (15 downto 0));
37
end binary_counter_x16;
38
 
39
architecture Behavioral of binary_counter_x16 is
40
        signal cnt: unsigned(15 downto 0);
41
begin
42
        doCountOrSet: process(clk, inc, set, set_value)
43
        begin
44
                if reset = '0' then
45
                        cnt <= to_unsigned(0,16);
46
                else
47
                        if clk'event and clk = '1' then
48
                                if set = '1' then
49
                                        cnt <= unsigned(set_value);
50
                                else
51
                                        if inc = '1' then
52
                                                cnt <= to_unsigned(to_integer(cnt) + 1, 16) ;
53
                                        end if;
54
                                end if;
55
                        end if;
56
                end if;
57
        end process;
58
 
59
        count <= std_logic_vector(cnt);
60
end Behavioral;
61
 

powered by: WebSVN 2.1.0

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