OpenCores
URL https://opencores.org/ocsvn/am9080_cpu_based_on_microcoded_am29xx_bit-slices/am9080_cpu_based_on_microcoded_am29xx_bit-slices/trunk

Subversion Repositories am9080_cpu_based_on_microcoded_am29xx_bit-slices

[/] [am9080_cpu_based_on_microcoded_am29xx_bit-slices/] [trunk/] [counter16bit.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date: 08/26/2017 09:54:45 AM
6
-- Design Name: 
7
-- Module Name: counter16bit - 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
 
21
 
22
library IEEE;
23
use IEEE.STD_LOGIC_1164.ALL;
24
 
25
-- Uncomment the following library declaration if using
26
-- arithmetic functions with Signed or Unsigned values
27
use IEEE.NUMERIC_STD.ALL;
28
 
29
-- Uncomment the following library declaration if instantiating
30
-- any Xilinx leaf cells in this code.
31
--library UNISIM;
32
--use UNISIM.VComponents.all;
33
 
34
entity counter16bit is
35
    Port ( reset : in STD_LOGIC;
36
           clk : in STD_LOGIC;
37
           mode : in STD_LOGIC_VECTOR (1 downto 0);
38
           d : in STD_LOGIC_VECTOR (31 downto 0);
39
           q : out STD_LOGIC_VECTOR (31 downto 0));
40
end counter16bit;
41
 
42
architecture Behavioral of counter16bit is
43
 
44
signal count: std_logic_vector(31 downto 0);
45
 
46
begin
47
 
48
q <= count;
49
 
50
update: process (reset, clk, mode, d)
51
begin
52
 if (reset = '1') then -- async reset
53
        count <= X"00000000";
54
 else
55
        if (rising_edge(clk)) then
56
                case (mode) is
57
                        when "00" => -- no change
58
                                count <= count;
59
                        when "01" => -- increment
60
                                count <= std_logic_vector(unsigned(count) + 1);
61
                        when "10" => -- decrement
62
                            count <= std_logic_vector(unsigned(count) - 1);
63
                        when "11" => -- synchronous set
64
                                count <= d;
65
                        when others =>
66
                                null;
67
                end case;
68
        end if;
69
 end if;
70
 
71
end process;
72
 
73
end Behavioral;

powered by: WebSVN 2.1.0

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