SURF  1.0
JesdLmfcGen.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : JesdLmfcGen.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-15
5 -- Last update: 2017-05-02
6 -------------------------------------------------------------------------------
7 -- Description: LMFC Generator
8 -- Local Multi Frame Clock Generator
9 -- Periodically outputs one clock cycle pulse (LMFC).
10 -- Synchronizes with the rising edge of sysref_i if sync is requested
11 -- by any of the on-board JESD receivers.
12 -- Outputs first pulse 2 c-c after sysref_i='1'
13 -- Period determined by F_G*K_G/GT_WORD_SIZE_C.
14 -- (Example: 2*32/4 = 16)
15 -------------------------------------------------------------------------------
16 -- This file is part of 'SLAC Firmware Standard Library'.
17 -- It is subject to the license terms in the LICENSE.txt file found in the
18 -- top-level directory of this distribution and at:
19 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
20 -- No part of 'SLAC Firmware Standard Library', including this file,
21 -- may be copied, modified, propagated, or distributed except according to
22 -- the terms contained in the LICENSE.txt file.
23 -------------------------------------------------------------------------------
24 
25 library ieee;
26 use ieee.std_logic_1164.all;
27 use ieee.std_logic_unsigned.all;
28 use ieee.std_logic_arith.all;
29 
30 use work.StdRtlPkg.all;
31 use work.jesd204bpkg.all;
32 
33 --! @see entity
34  --! @ingroup protocols_jesd204b
35 entity JesdLmfcGen is
36  generic (
37  TPD_G : time := 1 ns;
38  K_G : positive := 32;
39  F_G : positive := 2);
40  port (
41  clk : in sl;
42  rst : in sl;
43 
44  -- Synchronization inputs
45  nSync_i : in sl;
46  sysref_i : in sl;
47 
48  -- Outs
49  sysrefRe_o : out sl;
50  lmfc_o : out sl
51  );
52 end entity JesdLmfcGen;
53 
54 architecture rtl of JesdLmfcGen is
55 
56  constant PERIOD_C : positive := ((K_G * F_G)/GT_WORD_SIZE_C)-1;
57  constant CNT_WIDTH_C : positive := bitSize(PERIOD_C);
58 
59  type RegType is record
60  sysrefD1 : sl;
61  cnt : slv(CNT_WIDTH_C-1 downto 0);
62  lmfc : sl;
63  sysrefRe : sl;
64  end record RegType;
65 
66  constant REG_INIT_C : RegType := (
67  sysrefD1 => '0',
68  cnt => (others => '0'),
69  lmfc => '0',
70  sysrefRe => '0'
71  );
72 
73  signal r : RegType := REG_INIT_C;
74  signal rin : RegType;
75 
76 begin
77 
78  comb : process (r, rst,sysref_i,nSync_i) is
79  variable v : RegType;
80  begin
81  v := r;
82 
83  -- Delay sysref for one clock cycle
84  v.sysrefD1 := sysref_i;
85 
86  -- Detect rising edge on sysref
87  v.sysrefRe := sysref_i and not r.sysrefD1;
88 
89 
90  -- Period counter
91 
92  -- LMFC is aligned to sysref on rising edge of sysref_i.
93  -- The alignment is only done when nSync_i='0'
94  if (r.sysrefRe = '1' and nSync_i = '0' ) then
95  v.cnt := (others => '0');
96  v.lmfc := '1';
97  elsif (r.cnt = PERIOD_C) then
98  v.cnt := (others => '0');
99  v.lmfc := '1';
100  else
101  v.cnt := r.cnt + 1;
102  v.lmfc := '0';
103  end if;
104 
105  if (rst = '1') then
106  v := REG_INIT_C;
107  end if;
108 
109  rin <= v;
110 
111  end process comb;
112 
113  seq : process (clk) is
114  begin
115  if (rising_edge(clk)) then
116  r <= rin after TPD_G;
117  end if;
118  end process seq;
119 
120  -- Output assignment
121  lmfc_o <= r.lmfc;
122  sysrefRe_o <= r.sysrefRe;
123 ---------------------------------------
124 end architecture rtl;
TPD_Gtime := 1 ns
Definition: JesdLmfcGen.vhd:37
std_logic sl
Definition: StdRtlPkg.vhd:28
K_Gpositive := 32
Definition: JesdLmfcGen.vhd:38
in sysref_isl
Definition: JesdLmfcGen.vhd:46
_library_ ieeeieee
Definition: JesdIlasGen.vhd:19
out lmfc_osl
Definition: JesdLmfcGen.vhd:51
out sysrefRe_osl
Definition: JesdLmfcGen.vhd:49
in nSync_isl
Definition: JesdLmfcGen.vhd:45
F_Gpositive := 2
Definition: JesdLmfcGen.vhd:39
std_logic_vector slv
Definition: StdRtlPkg.vhd:29