AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
All Classes Variables
DaqLSCXG10G.vhd
1 
2 library IEEE;
3 use IEEE.STD_LOGIC_1164.ALL;
4 use ieee.std_logic_unsigned.all;
5 use work.amc13_pack.all;
6 use work.mydefs.all;
7 
8 
9 library UNISIM;
10 use UNISIM.VComponents.all;
11 
12 entity DaqLSCXG10G is
13  Port ( sys_reset : in STD_LOGIC; -- active high reset of all logic but GTX
14  sys_clk : in STD_LOGIC;
15  sfp_pd : in array3x2;
16  DRP_clk : in STD_LOGIC;
17  LinkWe : in STD_LOGIC_VECTOR (2 downto 0);
18  LinkCtrl : in STD_LOGIC_VECTOR (2 downto 0);
19  LinkData : in array3x64;
20  srcID : in array3x16;
21  LinkDown : out STD_LOGIC_VECTOR (2 downto 0);
22  LinkFull : out STD_LOGIC_VECTOR (2 downto 0);
23  --
24 -- ack_cnt : out STD_LOGIC_VECTOR (2 downto 0); -- 1 ck pulse (txusrclk) indicating a received acknowledge
25 -- pckt_cnt : out STD_LOGIC_VECTOR (2 downto 0); -- 1 ck pulse (txusrclk) indicating a transmit packet
26 -- retransmit_cnt : out STD_LOGIC_VECTOR (2 downto 0); -- 1 ck pulse (txusrclk) indicating a retransmit packet
27 -- event_cnt : out STD_LOGIC_VECTOR (2 downto 0); -- 1 ck pulse (sys_clk) indicating a sent event
28  sync_loss : out STD_LOGIC_VECTOR (2 downto 0); -- goes to '1' (rxusrclk) when SERDES is out of synch
29  status_ce : in std_logic_VECTOR (2 downto 0); -- not implemented yet
30  status_addr : in STD_LOGIC_VECTOR (15 downto 0); -- not implemented yet
31  status_port : out array3x64; -- first 32 bits are hard-wired
32  --
33  txusrclk_o : out STD_LOGIC; -- reconstructed tx clock, to be used to clock sending circuitry
34  rxusrclk_o : out STD_LOGIC; -- reconstructed rx clock, to be used to clock receiving circuitry
35  --
36  gtx_reset : in std_logic; -- full reset of GTX only
37  gtx_refclk_p : in std_logic; -- iob for refclk neg
38  gtx_refclk_n : in std_logic; -- iob for refclk neg
39  sfp_rxn : in std_logic_VECTOR (2 downto 0); -- sfp iobs
40  sfp_rxp : in std_logic_VECTOR (2 downto 0);
41  sfp_txn : out std_logic_VECTOR (2 downto 0);
42  sfp_txp : out std_logic_VECTOR (2 downto 0)
43  );
44 end DaqLSCXG10G;
45 
46 architecture Behavioral of DaqLSCXG10G is
47 COMPONENT SLINK_opt_XGMII
48 port (
49  reset : in std_logic;
50  -- FED interface
51  SYS_CLK : in std_logic;
52  LINKWe : in std_logic;
53  LINKCtrl : in std_logic;
54  LINKData : in std_logic_vector(63 downto 0);
55  src_ID : in std_logic_vector(15 downto 0);
56  inject_err : in std_logic_vector(17 downto 0);
57  read_CE : in std_logic;
58  Addr : in std_logic_vector(15 downto 0);
59  status_data : out std_logic_vector(63 downto 0);
60  LINKDown : out std_logic;
61  LINK_LFF : out std_logic;
62 
63  -- interface SERDES
64  clock : in std_logic;
65  serdes_init : in std_logic;
66  SD_Data_o : out std_logic_vector(63 downto 0);
67  SD_Kb_o : out std_logic_vector(7 downto 0);
68  clock_r : in std_logic;
69  SD_Data_i : in std_logic_vector(63 downto 0);
70  SD_Kb_i : in std_logic_vector(7 downto 0);
71 
72  Serdes_status : in std_logic_vector(31 downto 0)
73 
74  );
75 END COMPONENT;
76 COMPONENT XGMII_serdes_wapper
77  generic(N_SFP : integer := 3);
78  PORT(
79  DRPclk : IN std_logic;
80  reset : IN std_logic;
81  gtx_reset : IN std_logic;
82  sfp_pd : in array3x2;
83  SFP0_RXN : IN std_logic;
84  SFP0_RXP : IN std_logic;
85  SFP1_RXN : IN std_logic;
86  SFP1_RXP : IN std_logic;
87  SFP2_RXN : IN std_logic;
88  SFP2_RXP : IN std_logic;
89  SFP_REFCLK_P : IN std_logic;
90  SFP_REFCLK_N : IN std_logic;
91  xgmii_txd : IN array3x64;
92  xgmii_txc : IN array3x8;
93  SFP0_TXN : OUT std_logic;
94  SFP0_TXP : OUT std_logic;
95  SFP1_TXN : OUT std_logic;
96  SFP1_TXP : OUT std_logic;
97  SFP2_TXN : OUT std_logic;
98  SFP2_TXP : OUT std_logic;
99  clk156 : OUT std_logic;
100  PCS_lock : OUT std_logic_vector(2 downto 0);
101  gtx_rxresetdone : OUT std_logic_vector(2 downto 0);
102  xgmii_rxd : OUT array3x64;
103  xgmii_rxc : OUT array3x8
104  );
105 END COMPONENT;
106 
107 -- Local signals
108 
109 signal sys_reset_bar : std_logic;
110 signal serdes_core_clk156_out : std_logic;
111 signal txdata, rxdata : array3x64;
112 signal rxcharisk, txcharisk, rxchariscomma, gtx_rxnotintable : array3x8;
113 signal gtx_rxresetdone : std_logic_vector(2 downto 0);
114 signal PCS_lock : std_logic_vector(2 downto 0);
115 signal serdes_status : array3x32 := (others => (others => '0'));
116 begin
117 txusrclk_o <= serdes_core_clk156_out;
118 rxusrclk_o <= serdes_core_clk156_out;
119 sync_loss <= not PCS_lock;
120 g_SLINK_opt : for i in 0 to 2 generate
121  Inst_SLINK_opt: SLINK_opt_XGMII
122 PORT MAP(
123 -- FROM FED logic
124  reset => sys_reset_bar, -- needs an active low reset
125  SYS_CLK => sys_clk,
126 -- DATA interface from FED
127  LINKWe => not LinkWe (i),
128  LINKCtrl => LinkCtrl(i),
129  LINKData => LinkData(i),
130  src_ID => srcID(i),
131  inject_err => (others =>'0'),
132  read_CE => '0',
133  Addr => status_addr,
134  status_data => status_port(i),
135  serdes_status => serdes_status(i),
136  LINKDown => LinkDown(i),
137  LINK_LFF => LinkFull(i),
138 -- SERDES interface
139  clock => serdes_core_clk156_out, --clk_156_service, -- clk tx from SERDES
140  serdes_init => serdes_status(i)(0), -- status that comes back from GTX
141  SD_Data_o => TXDATA(i), -- data sent to serdes (64 bit)
142  SD_Kb_o => TXCHARISK(i), -- control K associated to SD_Data_o (8 bits)
143  clock_r => serdes_core_clk156_out, -- reconstructed clock from SERDES
144  SD_Data_i => RXDATA(i), -- return data from SERDES 64 bit
145  SD_Kb_i => RXCHARISK(i) -- return control K associated to SD_Data_i (8 bits)
146  );
147  serdes_status(i)(0) <= PCS_lock(i);
148  serdes_status(i)(1) <= gtx_rxresetdone(i);
149 end generate;
150 sys_reset_bar <= not(sys_reset);
151 i_XGMII_serdes_wapper: XGMII_serdes_wapper PORT MAP(
152  DRPclk => DRP_clk,
153  reset => sys_reset,
154  gtx_reset => gtx_reset,
155  sfp_pd => sfp_pd,
156  SFP0_RXN => sfp_rxn(0),
157  SFP0_RXP => sfp_rxp(0),
158  SFP1_RXN => sfp_rxn(1),
159  SFP1_RXP => sfp_rxp(1),
160  SFP2_RXN => sfp_rxn(2),
161  SFP2_RXP => sfp_rxp(2),
162  SFP0_TXN => sfp_txn(0),
163  SFP0_TXP => sfp_txp(0),
164  SFP1_TXN => sfp_txn(1),
165  SFP1_TXP => sfp_txp(1),
166  SFP2_TXN => sfp_txn(2),
167  SFP2_TXP => sfp_txp(2),
168  SFP_REFCLK_P => gtx_refclk_p,
169  SFP_REFCLK_N => gtx_refclk_n,
170  clk156 => serdes_core_clk156_out,
171  PCS_lock => PCS_lock,
172  gtx_rxresetdone => gtx_rxresetdone,
173  xgmii_txd => TXDATA,
174  xgmii_txc => TXCHARISK,
175  xgmii_rxd => RXDATA,
176  xgmii_rxc => RXCHARISK
177  );
178 end Behavioral;
179