SURF  1.0
JesdTestSigGen.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : JesdTestSigGen.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-15
5 -- Last update: 2015-04-15
6 -------------------------------------------------------------------------------
7 -- Description: Outputs a digital signal depending on thresholds
8 -- This is a test module so only F_G = 2
9 -- and is GT_WORD_SIZE_C = 4 is supported.
10 -------------------------------------------------------------------------------
11 -- This file is part of 'SLAC Firmware Standard Library'.
12 -- It is subject to the license terms in the LICENSE.txt file found in the
13 -- top-level directory of this distribution and at:
14 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
15 -- No part of 'SLAC Firmware Standard Library', including this file,
16 -- may be copied, modified, propagated, or distributed except according to
17 -- the terms contained in the LICENSE.txt file.
18 -------------------------------------------------------------------------------
19 
20 library ieee;
21 use ieee.std_logic_1164.all;
22 use ieee.std_logic_unsigned.all;
23 use ieee.std_logic_arith.all;
24 
25 use work.StdRtlPkg.all;
26 use work.Jesd204bPkg.all;
27 
28 --! @see entity
29  --! @ingroup protocols_jesd204b
30 entity JesdTestSigGen is
31  generic (
32  TPD_G : time := 1 ns;
33 
34  -- Number of bytes in a frame
35  F_G : positive := 2);
36  port (
37  clk : in sl;
38  rst : in sl;
39 
40  -- Enable pulser
41  enable_i : in sl;
42 
43  -- Threshold for Rising edge detection
44  thresoldLow_i : in slv((F_G*8)-1 downto 0);
45  thresoldHigh_i : in slv((F_G*8)-1 downto 0);
46 
47  -- Sample data input
48  sampleData_i : in slv((GT_WORD_SIZE_C*8)-1 downto 0);
49 
50  -- Test signal
51  testSig_o : out sl
52  );
53 end entity JesdTestSigGen;
54 
55 architecture rtl of JesdTestSigGen is
56 
57  type RegType is record
58  sig : sl;
59  end record RegType;
60 
61  constant REG_INIT_C : RegType := (
62  sig => '0'
63  );
64 
65  signal r : RegType := REG_INIT_C;
66  signal rin : RegType;
67  signal s_sampleDataBr : slv(sampleData_i'range);
68 
69 begin
70 
71  s_sampleDataBr <= sampleData_i;
72 
73  -- Buffer two GT words. And compare previous and current samples to threshold.
74  -- If the difference between the previous and current sample is higher than threshold
75  -- output a pulse.
76  ---------------------------------------------------------------------
77  ---------------------------------------------------------------------
78  comb : process (r, rst,s_sampleDataBr, thresoldLow_i, thresoldHigh_i, enable_i) is
79  variable v : RegType;
80  begin
81  v := r;
82 
83 -- if ( signed(s_sampleDataBr((F_G*8)-1 downto 0) ) > signed(thresoldHigh_i)) then
84  if ( s_sampleDataBr((F_G*8)-1 downto 0) > thresoldHigh_i) then
85  v.sig := '1';
86 -- elsif ( signed(s_sampleDataBr((F_G*8)-1 downto 0) ) < signed(thresoldLow_i)) then
87  elsif ( s_sampleDataBr((F_G*8)-1 downto 0) < thresoldLow_i) then
88  v.sig := '0';
89  end if;
90 
91  if (rst = '1' or enable_i='0') then
92  v := REG_INIT_C;
93  end if;
94 
95  -- Output assignment
96  rin <= v;
97  testSig_o <= r.sig;
98  -----------------------------------------------------------
99  end process comb;
100 
101  seq : process (clk) is
102  begin
103  if (rising_edge(clk)) then
104  r <= rin after TPD_G;
105  end if;
106  end process seq;
107  ---------------------------------------------------------------------
108  ---------------------------------------------------------------------
109 end architecture rtl;
std_logic sl
Definition: StdRtlPkg.vhd:28
in sampleData_islv(( GT_WORD_SIZE_C* 8)- 1 downto 0)
TPD_Gtime := 1 ns
F_Gpositive := 2
in thresoldHigh_islv(( F_G* 8)- 1 downto 0)
positive := 4 GT_WORD_SIZE_C
Definition: Jesd204bPkg.vhd:31
in thresoldLow_islv(( F_G* 8)- 1 downto 0)
_library_ ieeeieee
std_logic_vector slv
Definition: StdRtlPkg.vhd:29