source: PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v1.00/IP_Timer.vhd @ 76

Last change on this file since 76 was 76, checked in by rolagamo, 10 years ago
File size: 1.6 KB
Line 
1---------------------------------------------------------------------------------
2-- Company:
3-- Engineer:
4--
5-- Create Date:    15:11:13 01/16/2014
6-- Design Name:
7-- Module Name:    IP_Timer - 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
21library ieee;
22use ieee.std_logic_1164.all;
23use ieee.std_logic_unsigned.all;
24-- Uncomment the following library declaration if using
25-- arithmetic functions with Signed or Unsigned values
26use IEEE.NUMERIC_STD.ALL;
27
28-- Uncomment the following library declaration if instantiating
29-- any Xilinx primitives in this code.
30--library UNISIM;
31--use UNISIM.VComponents.all;
32
33entity IP_Timer is
34
35port (clk,reset,upDn,load,start:in std_logic;
36loadval :in std_logic_vector(31 downto 0);
37outval : out std_logic_vector(31 downto 0);
38zero : out std_logic);
39
40end IP_Timer;
41
42architecture Behavioral of IP_Timer is
43signal count: std_logic_vector(31 downto 0);
44signal z:std_logic:='1';
45begin
46process (clk) 
47begin
48   if clk='1' and clk'event then
49      if reset='1' then 
50         count <= (others => '0');
51                        z<='1';
52      elsif start='1' then
53         if load='1' then
54            count <= loadval;
55         else 
56            if UpDn='1' then   
57               count <= count + 1;
58            else
59               count <= count - 1;
60            end if;
61         end if;
62                        if count=0 then
63                                z<='1';
64                        else
65                                z<='0';
66                        end if;
67      end if;
68   end if;
69end process; 
70OutVal<=count;
71zero<=z;
72end Behavioral;
73
Note: See TracBrowser for help on using the repository browser.