source: firmware/FTU/old_design/counter/upcnt16.vhd@ 18292

Last change on this file since 18292 was 156, checked in by qweitzel, 15 years ago
First check-in of VHDL code for FTU: counters, dcm, spi
File size: 952 bytes
Line 
1-- File: upcnt16.vhd
2--
3-- Purpose: Up 16-bit counter
4--
5-- Created: 7-25-00 ALS
6--
7
8library IEEE;
9use IEEE.std_logic_1164.all;
10use IEEE.std_logic_arith.all;
11
12entity upcnt16 is
13 port(
14 full : out STD_LOGIC;
15 clr : in STD_LOGIC;
16 reset : in STD_Logic;
17 clk : in STD_LOGIC
18 );
19
20end upcnt16;
21
22architecture DEFINITION of upcnt16 is
23
24 constant RESET_ACTIVE : std_logic := '0';
25 constant Cnt_full : Unsigned (15 DOWNTO 0) :="1111111111111111";
26
27 signal q : Unsigned (15 DOWNTO 0);
28
29begin
30
31 process(clk, reset, clr)
32 begin
33
34 if ((reset OR clr)='1') then
35 q <= (others => '0');-- Clear output register
36 elsif (clk'event) and clk = '1' and (not(q = Cnt_full)) then-- On rising edge of clock count
37 q <= q + 1;
38 end if;
39
40 end process;
41
42 process(q)
43 begin
44
45 if (q = Cnt_full) then
46 full <= '1';
47 else
48 full <= '0';
49 end if;
50
51 end process;
52
53end DEFINITION;
Note: See TracBrowser for help on using the repository browser.