-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalInc.vhd
63 lines (52 loc) · 1.71 KB
/
valInc.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:31:23 01/31/2018
-- Design Name:
-- Module Name: valInc - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;--so + is understoud
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity valInc is
Port ( clk50 : in STD_LOGIC;
reset : in STD_LOGIC;
zero : in STD_LOGIC;
val : inout STD_LOGIC_VECTOR (31 downto 0));
end valInc;
architecture Behavioral of valInc is
signal valNext : std_logic_vector(31 downto 0);
signal valNextNext : std_logic_vector(31 downto 0);
signal cpthsup50M : std_logic;
signal val_mux : std_logic_vector(31 downto 0);
begin
cpthsup50M <= '1' when unsigned(valNext)>=50000000 else '0';
valNextNext <= (others => '0') when cpthsup50M='1'
else std_logic_vector(unsigned(valNext)+1);
valNext <= (others => '0') when reset='1'
else valNextNext when rising_edge(clk50);
val <= (others => '0') when (reset='1' or zero='1')
else val_mux when rising_edge (clk50);
val_mux <= std_logic_vector(unsigned(val)+1) when cpthsup50M='1'
else val;
end Behavioral;