SURF  1.0
AxiAd9467Mon.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : AxiAd9467Mon.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-09-23
5 -- Last update: 2014-09-24
6 -------------------------------------------------------------------------------
7 -- Description: AD9467 Monitor Module
8 -------------------------------------------------------------------------------
9 -- This file is part of 'SLAC Firmware Standard Library'.
10 -- It is subject to the license terms in the LICENSE.txt file found in the
11 -- top-level directory of this distribution and at:
12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
13 -- No part of 'SLAC Firmware Standard Library', including this file,
14 -- may be copied, modified, propagated, or distributed except according to
15 -- the terms contained in the LICENSE.txt file.
16 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.std_logic_unsigned.all;
21 use ieee.std_logic_arith.all;
22 
23 use work.StdRtlPkg.all;
24 
25 --! @see entity
26  --! @ingroup devices_AnalogDevices_ad9467
27 entity AxiAd9467Mon is
28  generic (
29  TPD_G : time := 1 ns;
30  ADC_CLK_FREQ_G : real := 250.0E+6); -- units of Hz
31  port (
32  adcClk : in sl;
33  adcRst : in sl;
34  adcData : in slv(15 downto 0);
35  adcDataMon : out Slv16Array(0 to 15));
36 end AxiAd9467Mon;
37 
38 architecture rtl of AxiAd9467Mon is
39 
40  constant MAX_CNT_C : natural := getTimeRatio(ADC_CLK_FREQ_G, 1.0); -- 1 second refresh rate
41 
42  type StateType is (
43  IDLE_S,
44  SMPL_S);
45 
46  type RegType is record
47  cnt : natural range 0 to MAX_CNT_C;
48  smplCnt : natural range 0 to 15;
49  adcDataMon : Slv16Array(0 to 15);
50  state : StateType;
51  end record RegType;
52 
53  constant REG_INIT_C : RegType := (
54  0,
55  0,
56  (others => x"0000"),
57  IDLE_S);
58 
59  signal r : RegType := REG_INIT_C;
60  signal rin : RegType;
61 
62 begin
63 
64  comb : process (adcData, adcRst, r) is
65  variable v : RegType;
66  begin
67  -- Latch the current value
68  v := r;
69 
70  -- Increment the counter
71  v.cnt := r.cnt + 1;
72 
73  -- State Machine
74  case (r.state) is
75  ----------------------------------------------------------------------
76  when IDLE_S =>
77  -- Check the counter
78  if r.cnt = MAX_CNT_C then
79  -- Reset the counter
80  v.cnt := 0;
81  -- Next State
82  v.state := SMPL_S;
83  end if;
84  ----------------------------------------------------------------------
85  when SMPL_S =>
86  -- Sample the ADC value
87  v.adcDataMon(r.smplCnt) := adcData;
88  -- Increment the counter
89  v.smplCnt := r.smplCnt + 1;
90  -- Check the counter
91  if r.smplCnt = 15 then
92  -- Reset the counter
93  v.smplCnt := 0;
94  -- Next State
95  v.state := IDLE_S;
96  end if;
97  ----------------------------------------------------------------------
98  end case;
99 
100  -- Reset
101  if (adcRst = '1') then
102  v := REG_INIT_C;
103  end if;
104 
105  -- Register the variable for next clock cycle
106  rin <= v;
107 
108  -- Outputs
109  adcDataMon <= r.adcDataMon;
110 
111  end process comb;
112 
113  seq : process (adcClk) is
114  begin
115  if rising_edge(adcClk) then
116  r <= rin after TPD_G;
117  end if;
118  end process seq;
119 
120 end rtl;
std_logic sl
Definition: StdRtlPkg.vhd:28
in adcDataslv( 15 downto 0)
TPD_Gtime := 1 ns
out adcDataMonSlv16Array( 0 to 15)
ADC_CLK_FREQ_Greal := 250.0E+6
array(natural range <> ) of slv( 15 downto 0) Slv16Array
Definition: StdRtlPkg.vhd:395
std_logic_vector slv
Definition: StdRtlPkg.vhd:29