-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter.vhd
52 lines (39 loc) · 1.56 KB
/
counter.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
---------------------------------------------------------------------------
-- counter.vhd --
-- Raj Vinjamuri --
-- 3-13 --
-- --
-- Purpose/Description: --
-- custom counter modified from Wikipedia source code --
-- goal is to get input clock divided by 512 --
-- --
-- References: --
-- http://en.wikipedia.org/wiki/Vhdl_87#Example:_a_counter --
-- http://esd.cs.ucr.edu/labs/tutorial/counter.vhd --
-- --
-- Final Modifications by Raj Vinjamuri and Sai Koppula --
-- --
---------------------------------------------------------------------------
library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
----------------------------------------------------
entity counter is
generic(n: in natural := 16);
port( Clk: in std_logic;
mod_Clk: out std_logic);
end counter;
----------------------------------------------------
architecture behavioral of counter is
signal Pre_Q: std_logic_vector(n-1 downto 0);
begin
process(Clk)
begin
if (Clk='1' and Clk'event) then
Pre_Q <= Pre_Q + 1;
end if;
end process;
-- concurrent assignment statement
mod_Clk <= Pre_Q(9);
end behavioral;
-----------------------------------------------------