OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [port_clkcntl/] [clockcntl.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
 
5
entity clockcntl is
6
        port(   reset                           : in    std_logic;
7
                        userResetInternal       : in    std_logic;
8
                        baseClock                       : in    std_logic;
9
                        terminationCountRegister        : in std_logic_vector(31 downto 0);
10
                        configurationRegister           : in std_logic_vector(7 downto 0);
11
                        gatedClock                      : out   std_logic
12
                        );
13
end clockcntl;
14
 
15
architecture behavioral of clockcntl is
16
 
17
        signal edgeCounter      : std_logic_vector(31 downto 0);
18
        signal clockEnable      : std_logic;
19
        signal gatedClockInt    : std_logic;
20
        signal startBit         : std_logic;
21
        signal freeRun                  : std_logic;
22
 
23
begin
24
 
25
startBit <= configurationRegister(0);
26
freeRun <= configurationRegister(1);
27
 
28
-------------------------------------------------------------------------------
29
-- Asynchronously enables, synchronously disables the gated clock.
30
-------------------------------------------------------------------------------
31
clockEnableP: process(reset, edgeCounter, baseClock, userResetInternal, freeRun)
32
 begin
33
   if (reset = '1') or
34
      ((edgeCounter = terminationCountRegister) and (baseClock = '0') and (freeRun = '0')) or
35
      (userResetInternal = '1') then
36
     clockEnable <= '0';
37
   elsif baseClock'event and baseClock = '1' then
38
          if (edgeCounter /= terminationCountRegister) then
39
            clockEnable <= startBit or freeRun;
40
          elsif freeRun = '1' then
41
            clockEnable <= '1';
42
          else
43
            clockEnable <= '0';
44
          end if;
45
   end if;
46
 end process clockEnableP;
47
 
48
 gatedClockInt <= baseClock and clockEnable;
49
 
50
 --gatedDUTClock <= baseClock and DUTClockEnable and clockEnable;
51
 
52
-------------------------------------------------------------------------------
53
-- The edge counter used by the control state machine.
54
-------------------------------------------------------------------------------
55
edgeCounterP: process(gatedClockInt, reset, startBit, userResetInternal)
56
begin
57
 if reset = '1' or startBit = '0' or userResetInternal = '1' then
58
   edgeCounter <= (others => '0');
59
 elsif gatedClockInt'event and gatedClockInt = '1' then
60
   edgeCounter <= edgeCounter + '1';
61
 end if;
62
end process edgeCounterP;
63
 
64
gatedClock <= gatedClockInt;
65
 
66
 
67
end behavioral;
68
 
69
-------------------------------------------------------------------------------
70
-- A debugging counter that increments on the DUTClock.
71
-------------------------------------------------------------------------------
72
--DUTClockCounterP: process(DUTClockInternal, reset, counterReset)
73
--begin
74
-- if reset = '1' or counterReset = ENABLED then
75
--   DUTClockCounter <= (others => '0');
76
-- elsif DUTClockInternal'event and DUTClockInternal = '1' then
77
--   DUTClockCounter <= DUTClockCounter + '1';
78
-- end if;
79
--end process DUTClockCounterP;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.