w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
sfs_gsim_core.vhd
Go to the documentation of this file.
1-- $Id: sfs_gsim_core.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2018- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: sfs_gsim_core - sim
7-- Description: simple frequency synthesis (SIM only!)
8-- simple vhdl model, without Xilinx UNISIM primitives
9--
10-- Dependencies: -
11-- Test bench: -
12-- Target Devices: generic
13-- Tool versions: xst 14.7; viv 2015.4-2018.2; ghdl 0.31-0.34
14--
15-- Revision History:
16-- Date Rev Version Comment
17-- 2018-11-03 1064 1.0 Initial version (derived from s7_cmt_sfs_gsim)
18------------------------------------------------------------------------------
19
20library ieee;
21use ieee.std_logic_1164.all;
22
23use work.slvtypes.all;
24
25entity sfs_gsim_core is -- frequency synthesis for simulation
26 generic (
27 VCO_DIVIDE : positive := 1; -- vco clock divide
28 VCO_MULTIPLY : positive := 1; -- vco clock multiply
29 OUT_DIVIDE : positive := 1); -- output divide
30 port (
31 CLKIN : in slbit; -- clock input
32 CLKFX : out slbit; -- clock output (synthesized freq.)
33 LOCKED : out slbit -- pll/mmcm locked
34 );
36
37
38architecture sim of sfs_gsim_core is
39 signal CLK_DIVPULSE : slbit := '0';
40 signal CLKOUT_PERIOD : Delay_length := 0 ns;
41 signal R_CLKOUT : slbit := '0';
42 signal R_LOCKED : slbit := '0';
43
44begin
45
46 proc_clkin : process (CLKIN)
47 variable t_lastclkin : time := 0 ns;
48 variable t_lastperiod : Delay_length := 0 ns;
49 variable t_period : Delay_length := 0 ns;
50 variable nclkin : integer := 1;
51 begin
52
53 if CLKIN'event then
54 if CLKIN = '1' then -- if CLKIN rising edge
55
56 if t_lastclkin > 0 ns then
57 t_lastperiod := t_period;
58 t_period := now - t_lastclkin;
60 if t_lastperiod > 0 ns and abs(t_period-t_lastperiod) > 1 ps then
61 report "sfs_gsim_core: CLKIN unstable" severity warning;
62 end if;
63 end if;
64 t_lastclkin := now;
65
66 if t_period > 0 ns then
67 nclkin := nclkin - 1;
68 if nclkin <= 0 then
69 nclkin := VCO_DIVIDE * OUT_DIVIDE;
70 CLK_DIVPULSE <= '1';
71 R_LOCKED <= '1';
72 end if;
73 end if;
74
75 else -- if CLKIN falling edge
76 CLK_DIVPULSE <= '0';
77 end if;
78 end if;
79
80 end process proc_clkin;
81
82 proc_clkout : process
83 begin
84
85 loop
86 wait until CLK_DIVPULSE = '1';
87
88 for i in 1 to VCO_MULTIPLY loop
89 R_CLKOUT <= '1';
90 wait for CLKOUT_PERIOD/2;
91 R_CLKOUT <= '0';
92 if i /= VCO_MULTIPLY then
93 wait for CLKOUT_PERIOD/2;
94 end if;
95 end loop; -- i
96
97 end loop;
98
99 end process proc_clkout;
100
101 CLKFX <= R_CLKOUT;
102 LOCKED <= R_LOCKED;
103
104end sim;
slbit := '0' R_CLKOUT
Delay_length := 0 ns CLKOUT_PERIOD
slbit := '0' R_LOCKED
slbit := '0' CLK_DIVPULSE
VCO_DIVIDE positive := 1
OUT_DIVIDE positive := 1
in CLKIN slbit
VCO_MULTIPLY positive := 1
out LOCKED slbit
out CLKFX slbit
std_logic slbit
Definition: slvtypes.vhd:30