1 -- $Id: s7_cmt_sfs_tb.vhd 984 2018-01-02 20:56:27Z mueller $ 3 -- Copyright 2016- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de> 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 3, or (at your option) any later version. 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. 14 ------------------------------------------------------------------------------ 15 -- Module Name: s7_cmt_sfs_tb - sim 16 -- Description: Series-7 CMT for simple frequency synthesis (SIM only!) 17 -- simple vhdl model, without Xilinx UNISIM primitives 21 -- Target Devices: generic Series-7 22 -- Tool versions: xst 14.7; viv 2015.4-2016.2; ghdl 0.31-0.33 25 -- Date Rev Version Comment 26 -- 2016-08-18 799 1.1.1 remove 'assert false' from report statements 27 -- 2016-04-09 760 1.1 BUGFIX: correct mmcm range check boundaries 28 -- 2016-02-20 734 1.0 Initial version (copied from s7_cmt_sfs_gsim) 29 ------------------------------------------------------------------------------ 32 use ieee.std_logic_1164.
all;
48 LOCKED :
out slbit -- pll/mmcm locked
64 -- currently frequency limits taken from Artix-7 speed grade -1 65 constant f_vcomin_pll
: := 800;
66 constant f_vcomax_pll
: := 1600;
67 constant f_pdmin_pll
: := 19;
68 constant f_pdmax_pll
: := 450;
70 constant f_vcomin_mmcm
: := 600;
71 constant f_vcomax_mmcm
: := 1200;
72 constant f_pdmin_mmcm
: := 10;
73 constant f_pdmax_mmcm
: := 450;
75 variable t_vco : Delay_length := 0 ns;
76 variable t_vcomin : Delay_length := 0 ns;
77 variable t_vcomax : Delay_length := 0 ns;
78 variable t_pd : Delay_length := 0 ns;
79 variable t_pdmin : Delay_length := 0 ns;
80 variable t_pdmax : Delay_length := 0 ns;
87 report "assert(GEN_TYPE='PLL' or GEN_TYPE='MMCM')" 94 -- check DIV/MULT parameter range 100 "assert(VCO_DIVIDE in 1:56 VCO_MULTIPLY in 2:64 OUT_DIVIDE in 1:128)" 103 -- setup VCO and PD range check boundaries 104 t_vcomin := (1000 ns / f_vcomax_pll) - 1 ps;
105 t_vcomax := (1000 ns / f_vcomin_pll) + 1 ps;
106 t_pdmin := (1000 ns / f_pdmax_pll) - 1 ps;
107 t_pdmax := (1000 ns / f_pdmin_pll) + 1 ps;
109 end if;
-- GEN_TYPE = "PLL" 112 -- check DIV/MULT parameter range 118 "assert(VCO_DIVIDE in 1:106 VCO_MULTIPLY in 2:64 OUT_DIVIDE in 1:128)" 121 -- setup VCO and PD range check boundaries 122 t_vcomin := (1000 ns / f_vcomax_mmcm) - 1 ps;
123 t_vcomax := (1000 ns / f_vcomin_mmcm) + 1 ps;
124 t_pdmin := (1000 ns / f_pdmax_mmcm) - 1 ps;
125 t_pdmax := (1000 ns / f_pdmin_mmcm) + 1 ps;
127 end if;
-- GEN_TYPE = "MMCM" 129 -- now common check whether VCO and PD frequency is in range 133 if t_vco<t_vcomin or t_vco>t_vcomax then 134 report "assert(VCO frequency out of range); t_cvo: " 139 if t_pd<t_pdmin or t_pd>t_pdmax then 140 report "assert(PD frequency out of range)" 144 end if;
-- one factor /= 1 147 end process proc_init;
150 variable t_lastclkin : := 0 ns;
151 variable t_lastperiod : Delay_length := 0 ns;
152 variable t_period : Delay_length := 0 ns;
153 variable nclkin : := 1;
157 if CLKIN = '1' then -- if CLKIN rising edge 159 if t_lastclkin > 0 ns then 160 t_lastperiod := t_period;
161 t_period := now - t_lastclkin;
163 if t_lastperiod > 0 ns and abs(t_period-t_lastperiod) > 1 ps then 164 report "s7_cmt_sp_sfs: CLKIN unstable" severity warning;
169 if t_period > 0 ns then 170 nclkin := nclkin - 1;
178 else -- if CLKIN falling edge 183 end process proc_clkin;
185 proc_clkout :
process 186 variable t_lastclkin : := 0 ns;
187 variable t_lastperiod : Delay_length := 0 ns;
188 variable t_period : Delay_length := 0 ns;
189 variable nclkin : := 1;
206 end process proc_clkout;
Delay_length := 0 ns CLKOUT_PERIOD
slbit := '0' CLK_DIVPULSE
STARTUP_WAITboolean := false
VCO_MULTIPLYpositive := 1