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 | |
---|
21 | library ieee; |
---|
22 | use ieee.std_logic_1164.all; |
---|
23 | use ieee.std_logic_unsigned.all; |
---|
24 | -- Uncomment the following library declaration if using |
---|
25 | -- arithmetic functions with Signed or Unsigned values |
---|
26 | use 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 | |
---|
33 | entity IP_Timer is |
---|
34 | |
---|
35 | port (clk,reset,upDn,load,start:in std_logic; |
---|
36 | loadval :in std_logic_vector(31 downto 0); |
---|
37 | outval : out std_logic_vector(31 downto 0); |
---|
38 | zero : out std_logic); |
---|
39 | |
---|
40 | end IP_Timer; |
---|
41 | |
---|
42 | architecture Behavioral of IP_Timer is |
---|
43 | signal count: std_logic_vector(31 downto 0); |
---|
44 | signal z:std_logic:='1'; |
---|
45 | begin |
---|
46 | process (clk) |
---|
47 | begin |
---|
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; |
---|
69 | end process; |
---|
70 | OutVal<=count; |
---|
71 | zero<=z; |
---|
72 | end Behavioral; |
---|
73 | |
---|
Note: See
TracBrowser
for help on using the repository browser.