Pixie16 Analysis Software Suite
Analysis code for processing of .ldf files
pixie16app_defs.h
1 #ifndef __PIXIE16APP_DEFS_H
2 #define __PIXIE16APP_DEFS_H
3 
4 /*----------------------------------------------------------------------
5  * Copyright (c) 2005 - 2009, XIA LLC
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms,
9  * with or without modification, are permitted provided
10  * that the following conditions are met:
11  *
12  * * Redistributions of source code must retain the above
13  * copyright notice, this list of conditions and the
14  * following disclaimer.
15  * * Redistributions in binary form must reproduce the
16  * above copyright notice, this list of conditions and the
17  * following disclaimer in the documentation and/or other
18  * materials provided with the distribution.
19  * * Neither the name of XIA LLC nor the names of its
20  * contributors may be used to endorse or promote products
21  * derived from this software without specific prior
22  * written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
33  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
35  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *----------------------------------------------------------------------*/
38 
39 /******************************************************************************
40  *
41  * File Name:
42  *
43  * pixie16app_defs.h
44  *
45  * Description:
46  *
47  * Constant definitions.
48  *
49  * $Rev: 13856 $
50  * $Id: pixie16app_defs.h 13856 2009-11-20 23:03:35Z htan $
51  ******************************************************************************/
52 
53 /* If this is compiled by a C++ compiler, make it */
54 /* clear that these are C routines. */
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 
60 /*-------------------------------------
61  Pixie16 hardware revisions
62  -------------------------------------*/
63 #define PIXIE16_REVA 0
64 #define PIXIE16_REVB 1
65 #define PIXIE16_REVC_MSU 2
66 #define PIXIE16_REVC_GENERAL 3
67 #define PIXIE16_REVD_ITHEMBA 4
68 #define PIXIE16_REVD_GENERAL 5
69 // Changing PIXIE16_REVISION here affects the code globally
70 #define PIXIE16_REVISION PIXIE16_REVD_GENERAL
71 
72 
73 /*-------------------------------------
74  Define special operation modes
75  (normally requires a special firmware)
76  -------------------------------------*/
77 #ifdef CAPTURE_SLOW_TRACE
78  #undef CAPTURE_SLOW_TRACE
79 #endif
80 #ifdef MSU_SEGA_MODE
81  #undef MSU_SEGA_MODE
82 #endif
83 #ifdef EXTENDED_FASTFILTER_LEN
84  #undef EXTENDED_FASTFILTER_LEN
85 #endif
86 #ifdef ORNL_PSD
87  #undef ORNL_PSD
88 #endif
89 
90 
91 /*-------------------------------------
92  At which platform to compile this code -
93  Windows or Linux?
94  -------------------------------------*/
95 #define PIXIE16_WINDOWS_APPAPI 0
96 #define PIXIE16_LINUX_APPAPI 1
97 // Changing PIXIE16_APPAPI_VER here affects the code globally
98 #define PIXIE16_APPAPI_VER PIXIE16_LINUX_APPAPI
99 
100 
101 /*-------------------------------------
102  Define EXPORT macro
103  -------------------------------------*/
104 #if PIXIE16_APPAPI_VER == PIXIE16_WINDOWS_APPAPI
105  #define PIXIE16APP_EXPORT __declspec(dllexport)
106  #define PIXIE16APP_API _stdcall
107 #elif PIXIE16_APPAPI_VER == PIXIE16_LINUX_APPAPI
108  #define PIXIE16APP_EXPORT
109  #define PIXIE16APP_API
110 #endif
111 
112 
113 /*-------------------------------------
114  Define math constants
115  -------------------------------------*/
116 
117 #ifndef PI
118  #define PI 3.14159265358979
119 #endif
120 
121 #ifndef PI2
122  #define PI2 6.28318530717959
123 #endif
124 
125 
126 /*-----------------------------------------------------------------
127  size of system FPGA, trigger FPGA, Fippi, DSP parameters files
128  -----------------------------------------------------------------*/
129 
130 #if PIXIE16_REVISION == PIXIE16_REVA
131 #define N_COM_FPGA_CONF 58614 // size of communications FPGA configuration (32-bit word)
132 #define N_TRIG_FPGA_CONF 58614 // size of trigger FPGA configuration (32-bit word)
133 #define N_SP_FPGA_CONF 127581 // size of signal processing FPGA configuration (32-bit word)
134 #elif PIXIE16_REVISION == PIXIE16_REVB || PIXIE16_REVISION == PIXIE16_REVC_MSU || PIXIE16_REVISION == PIXIE16_REVC_GENERAL
135 #define N_COM_FPGA_CONF 162962 // size of communications FPGA configuration (32-bit word)
136 #define N_SP_FPGA_CONF 162962 // size of signal processing FPGA configuration (32-bit word)
137 #endif
138 #define N_DSP_PAR 1280 // number of DSP parameters (32-bit word)
139 #define DSP_IO_BORDER 832 // number of DSP I/O variables
140 
141 
142 /*-----------------------------------------------------------------
143  module specifications
144  -----------------------------------------------------------------*/
145 
146 #define PRESET_MAX_MODULES 24 // Preset maximum number of Pixie modules
147 #define NUMBER_OF_CHANNELS 16
148 
149 #define SYSTEM_CLOCK_MHZ 100 // system (ADC and FPGA) clock frequency in MHz
150 
151 #if PIXIE16_REVISION == PIXIE16_REVA
152 #define DSP_CLOCK_MHZ 80 // DSP clock frequency in MHz
153 #elif PIXIE16_REVISION == PIXIE16_REVB || PIXIE16_REVISION == PIXIE16_REVC_MSU || PIXIE16_REVISION == PIXIE16_REVC_GENERAL || PIXIE16_REVISION == PIXIE16_REVD_ITHEMBA || PIXIE16_REVISION == PIXIE16_REVD_GENERAL
154 #define DSP_CLOCK_MHZ 100 // DSP clock frequency in MHz
155 #endif
156 
157 #define DAC_VOLTAGE_RANGE 3.0 // Pixie-16 DAC range is -1.5 V to +1.5 V
158 
159 #define MAX_ADC_TRACE_LEN 8192 // Maximum ADC trace length for a channel
160 
161 /*-----------------------------------------------------------------
162  run type
163  -----------------------------------------------------------------*/
164 
165 #define NEW_RUN 1 // New data run
166 #define RESUME_RUN 0 // Resume run
167 
168 #define LIST_MODE_RUN0 0x100 // List mode run (chl=9, with traces)
169 #define LIST_MODE_RUN1 0x101 // List mode run (chl=9, no traces)
170 #define LIST_MODE_RUN2 0x102 // List mode run (chl=4, no traces)
171 #define LIST_MODE_RUN3 0x103 // List mode run (chl=2, no traces)
172 #define HISTOGRAM_RUN 0x301 // Histogram run
173 
174 
175 /*-----------------------------------------------------------------
176  I/O mode
177  -----------------------------------------------------------------*/
178 
179 #define MOD_READ 1 // Host read from modules
180 #define MOD_WRITE 0 // Host write to modules
181 
182 
183 /*-----------------------------------------------------------------
184  Data memory, buffer, histogram, and list mode data structure
185  -----------------------------------------------------------------*/
186 
187 #define DSP_IMBUFFER_START_ADDR 0x40000 // 32-bit wide
188 #define DSP_IMBUFFER_END_ADDR 0x5FFFF // 32-bit wide
189 
190 #define DSP_EMBUFFER_START_ADDR 0x0 // 32-bit wide
191 #if PIXIE16_REVISION == PIXIE16_REVA
192 #define DSP_EMBUFFER_END_ADDR 0xFFFFF // 32-bit wide
193 #else
194 #define DSP_EMBUFFER_END_ADDR 0x7FFFF // 32-bit wide
195 #endif
196 
197 #if PIXIE16_REVISION == PIXIE16_REVA
198 #define EM_PINGPONGBUFA_ADDR 0x80000 // 32-bit wide
199 #define EM_PINGPONGBUFB_ADDR 0xC0000 // 32-bit wide
200 #endif
201 
202 #define DATA_MEMORY_ADDRESS 0x4A000 // DSP data memory address
203 #define HISTOGRAM_MEMORY_ADDRESS 0x0 // histogram memory buffer in external memory
204 #define MAX_HISTOGRAM_LENGTH 32768 // Maximum MCA histogram length
205 #define IO_BUFFER_ADDRESS 0x50000 // Address of I/O output buffer
206 #define IO_BUFFER_LENGTH 65536 // Length of I/O output buffer
207 #define EXTERNAL_FIFO_LENGTH 131072 // Length of external FIFO
208 
209 #define BUFFER_HEAD_LENGTH 6 // Output buffer header length
210 #define EVENT_HEAD_LENGTH 3 // Event header length
211 #define CHANNEL_HEAD_LENGTH 9 // Channel header length
212 
213 #define EVENT_INFO_LENGTH 68 // Information length for each event
214 #define CHANNEL_INFO_LENGTH 4 // Information length for each channel
215 #define EVENT_INFO_HEADER_LENGTH 4 // Information length for each event header
216 
217 
218 /*-------------------------------------
219  Length limits for certain DSP parameters
220  --------------------------------------*/
221 
222 #ifdef EXTENDED_FASTFILTER_LEN
223 #define FASTFILTER_MAX_LEN 128
224 #else
225 #if (PIXIE16_REVISION == PIXIE16_REVD_ITHEMBA) || (PIXIE16_REVISION == PIXIE16_REVD_GENERAL)
226 #define FASTFILTER_MAX_LEN 64
227 #else
228 #define FASTFILTER_MAX_LEN 32
229 #endif
230 #endif
231 #define MIN_FASTLENGTH_LEN 1
232 
233 #define SLOWFILTER_MAX_LEN 128
234 #define MIN_SLOWLENGTH_LEN 2
235 #define MIN_SLOWGAP_LEN 3
236 
237 #ifdef EXTENDED_FASTFILTER_LEN
238 #define FAST_THRESHOLD_MAX 65536
239 #else
240 #define FAST_THRESHOLD_MAX 16384
241 #endif
242 
243 #if (PIXIE16_REVISION == PIXIE16_REVD_ITHEMBA) || (PIXIE16_REVISION == PIXIE16_REVD_GENERAL)
244 #define CFDDELAY_MAX 63
245 #define CFDDELAY_MIN 1
246 
247 #define EXTTRIGSTRETCH_MAX 4095
248 #define EXTTRIGSTRETCH_MIN 1
249 
250 #define VETOSTRETCH_MAX 4095
251 #define VETOSTRETCH_MIN 1
252 
253 #define FASTTRIGBACKLEN_MAX 4095
254 #define FASTTRIGBACKLEN_MIN 1
255 
256 #define EXTDELAYLEN_MAX 255
257 #define EXTDELAYLEN_MIN 1
258 
259 #define FASTTRIGBACKDELAY_MAX 127
260 #define FASTTRIGBACKDELAY_MIN 0
261 
262 #define QDCLEN_MAX 32767
263 #define QDCLEN_MIN 1
264 #endif
265 
266 /*-------------------------------------
267  CHANCSRA bits definitions
268  --------------------------------------*/
269 
270 #define CCSRA_GOOD 2 // Channel may be read, good-channel bit
271 #define CCSRA_POLARITY 5 // Control polarity: 1: negative, 0: positive
272 #if (VARIANT == REVD_GENERAL)
273 #define CCSRA_TRACEENA 8 // 1: enable trace capture and associated header data; 0: disable trace capture and associated header data
274 #define CCSRA_QDCENA 9 // 1: enable QDC summing and associated header data; 0: dsiable QDC summing and associated header data
275 #endif
276 #define CCSRA_ENARELAY 14 // Control input relay: 1: connect, 0: disconnect
277 
278  /*-------------------------------------
279  MODCSRB bits definitions
280  --------------------------------------*/
281 
282 #define MODCSRB_PULLUP 0 // Control pullup: 1: pulled up, 0: not pulled up
283 #define MODCSRB_BPCONNECTION 1 // Control BP_Connection: 1: connected, 0: disconnected
284 #define MODCSRB_MASTERMODULE 2 // Control Master/Worker module: 1: Master module, 0: Worker module
285 #define MODCSRB_FASTTRIGSRC 3 // Control fast trigger source in system FPGA: 1: Master module only, 0: all modules wired-or
286 
287 #define MODCSRB_DIRMOD 4 // Control Director module: 1: Director module; 0: other modules
288 #define MODCSRB_RECTRIGENA 5 // Enable Director module's record trigger (1) or disable it (0)
289 #define MODCSRB_CHASSISMASTER 6 // Control chassis master module: 1: chassis master module; 0: chassis non-master module
290 #define MODCSRB_MWMOD 7 // Control Manger/Worker module: 1: Manger/Worker module; 0: other modules
291 #define MODCSRB_RIGHTASTMOD 8 // Control Right Assistant module: 1: Right Assistant module; 0: other modules
292 #define MODCSRB_LEFTASTMOD 9 // Control Left Assistant module: 1: Left Assistant module; 0: other modules
293 #define MODCSRB_INHIBITENA 10 // Control external INHIBIT signal: 1: use INHIBIT; 0: don't use INHIBIT
294 #define MODCSRB_MULTCRATES 11 // Distribute clock and triggers in multiple crates: multiple crates (1) or only single crate (0)
295 
296 /*-------------------------------------
297  Control parameters
298  --------------------------------------*/
299 
300 #define MAX_PAR_NAME_LENGTH 65 // Maximum length of parameter names
301 #define RANDOMINDICES_LENGTH 8192 // number of random indices (currently only used for tau finder)
302 #define MAX_ERRMSG_LENGTH 1024 // Maximum length of error message
303 
304 #define BASELINES_BLOCK_LEN 18 // Length of each baslines length (default: 2 timestamp words + 16 baselines)
305 #define MAX_NUM_BASELINES 3640 // Maximum number of baselines available after each baseline acquisition run
306 
307 #define EXTFIFO_READ_THRESH 1024 // Reading out threshold for external FIFO watermmark level
308 
309 #if (PIXIE16_REVISION == PIXIE16_REVD_ITHEMBA) || (PIXIE16_REVISION == PIXIE16_REVD_GENERAL)
310 #define PCI_STOPRUN_REGADDR 0x44 // PCI register address in the System FPGA for stopping run
311 #endif
312 
313 /*-------------------------------------
314  Frequently used Control Tasks
315  --------------------------------------*/
316 
317 #define SET_DACS 0 // Set DACs
318 #define ENABLE_INPUT 1 // Enable detect signal input
319 #define RAMP_OFFSETDACS 3 // Ramp Offset DACs
320 #define GET_TRACES 4 // Acquire ADC traces
321 #define PROGRAM_FIPPI 5 // Program FIPPIs
322 #define GET_BASELINES 6 // Get baselines
323 #define ADJUST_OFFSETS 7 // Adjust DC-offsets
324 
325 #ifdef __cplusplus
326 }
327 #endif
328 
329 #endif