OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [vlib/] [xlib/] [dcm_sfs_gsim.vhd] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 wfjm
-- $Id: dcm_sp_sfs_gsim.vhd 338 2010-11-13 22:19:25Z mueller $
2
--
3
-- Copyright 2010- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    dcm_sp_sfs - sim
16
-- Description:    DCM_SP as 'simple freq. synthesis'
17
--                 simple vhdl model, without Xilinx UNISIM primitives
18
--
19
-- Dependencies:   -
20
-- Test bench:     -
21
-- Target Devices: generic Spartan-3A,-3E
22
-- Tool versions:  xst 12.1; ghdl 0.29
23
--
24
-- Revision History: 
25
-- Date         Rev Version  Comment
26
-- 2010-11-12   338   1.0    Initial version 
27
------------------------------------------------------------------------------
28
 
29
library ieee;
30
use ieee.std_logic_1164.all;
31
 
32
use work.slvtypes.all;
33
 
34
entity dcm_sp_sfs is                    -- DCM_SP as 'simple freq. synthesis'
35
  generic (
36
    CLKFX_DIVIDE : positive := 1;       -- FX clock divide   (1-32)
37
    CLKFX_MULTIPLY : positive := 1;     -- FX clock multiply (2-32) (1->no DCM)
38
    CLKIN_PERIOD : real := 20.0);       -- CLKIN period (def is 20.0 ns)
39
  port (
40
    CLKIN : in slbit;                   -- clock input
41
    CLKFX : out slbit;                  -- clock output (synthesized freq.) 
42
    LOCKED : out slbit                  -- dcm locked
43
  );
44
end dcm_sp_sfs;
45
 
46
 
47
architecture sim of dcm_sp_sfs is
48
 
49
  signal CLK_DIVPULSE : slbit := '0';
50
  signal CLKOUT_PERIOD : time := 0 ns;
51
  signal R_CLKOUT : slbit := '0';
52
  signal R_LOCKED : slbit := '0';
53
 
54
begin
55
 
56
  proc_clkin : process (CLKIN)
57
    variable t_lastclkin : time := 0 ns;
58
    variable t_lastperiod : time := 0 ns;
59
    variable t_period : time := 0 ns;
60
    variable nclkin : integer := 1;
61
  begin
62
 
63
    if CLKIN'event then
64
      if CLKIN = '1' then               -- if CLKIN rising edge
65
 
66
        if t_lastclkin > 0 ns then
67
          t_lastperiod := t_period;
68
          t_period := now - t_lastclkin;
69
          CLKOUT_PERIOD <= (t_period * CLKFX_DIVIDE) / CLKFX_MULTIPLY;
70
          if t_lastperiod > 0 ns and abs(t_period-t_lastperiod) > 1 ps then
71
            report "dcm_sp_sfs: CLKIN unstable" severity warning;
72
          end if;
73
        end if;
74
        t_lastclkin := now;
75
 
76
        if t_period > 0 ns then
77
          nclkin := nclkin - 1;
78
          if nclkin <= 0 then
79
            nclkin := CLKFX_DIVIDE;
80
            CLK_DIVPULSE <= '1';
81
            R_LOCKED     <= '1';
82
          end if;
83
        end if;
84
 
85
      else                              -- if CLKIN falling edge
86
        CLK_DIVPULSE <= '0';
87
      end if;
88
    end if;
89
 
90
  end process proc_clkin;
91
 
92
  proc_clkout : process
93
    variable t_lastclkin : time := 0 ns;
94
    variable t_lastperiod : time := 0 ns;
95
    variable t_period : time := 0 ns;
96
    variable nclkin : integer := 1;
97
  begin
98
 
99
    loop
100
      wait until CLK_DIVPULSE = '1';
101
 
102
      for i in 1 to CLKFX_MULTIPLY loop
103
        R_CLKOUT <= '1';
104
        wait for CLKOUT_PERIOD/2;
105
        R_CLKOUT <= '0';
106
        if i /= CLKFX_MULTIPLY then
107
          wait for CLKOUT_PERIOD/2;
108
        end if;
109
      end loop;  -- i
110
 
111
    end loop;
112
 
113
  end process proc_clkout;
114
 
115
  CLKFX  <= R_CLKOUT;
116
  LOCKED <= R_LOCKED;
117
 
118
end sim;

powered by: WebSVN 2.1.0

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