00001 /* 00002 * sct_structures.h 00003 * 00004 * A fresh look at what may be needed for the 00005 * SCT ROD configuration data structures 00006 * 00007 * This is a revised and expanded version of John Hill's "sct_structure.h" 00008 * which can be found here: 00009 * http://sctpixel.home.cern.ch/sctpixel/Cambridge/sct_structure.txt 00010 * 00011 * From our point of view, the layout of the structures is less important 00012 * than their content, so the ROD developers should feel free to suggest 00013 * alternative layouts and/or naming schemes. 00014 * 00015 * Version 0.8 PWP/GFM 2002.06.04 00016 * Version 1.0 PWP 2002.06.17 00017 * Version 1.1 PWP 2003.03.25 00018 * Version 1.2 DPSF 2003.03.27 00019 * Version 1.3 DPSF 2005.03.10 00020 */ 00021 #include "processor.h" 00022 #include "bocStructure.h" 00023 00024 #ifndef SCT_STRUCT_H /* multiple inclusion protection */ 00025 #define SCT_STRUCT_H 00026 00027 #define N_SCT_MODULES 48 /* 48 modules directly attached +12 modules */ 00028 #define N_SCT_EXTMODULES 12 /* using redundant command links OFF ROD */ 00029 #define N_SCT_TOTMODULES ((N_SCT_MODULES)+(N_SCT_EXTMODULES)) 00030 00031 #define N_SCT_CHANS 128 00032 #define N_SCT_CHIPS 12 00033 00034 /* Default & off-ROD positions of a module's TTC fibres. The default primary 00035 TTC fibre location for a module is simply the module's position inside the 00036 structure set. */ 00037 #define DEFAULT_TTC 0x80 00038 #define OFF_ROD_TTC 0xff 00039 00040 //Default & data links which are turned off: 00041 #define DEFAULT_DATA_LINK 0x80 00042 #define DATA_LINK_OFF 0xff 00043 00044 //Flags used internally by MDSP: 00045 #define MODULE_PRESENT 1<<18 00046 #define MODULE_GLOBAL_DATA 1<<17 00047 #define MODULE_MASK_DATA 1<<16 00048 00049 /* Structure Definitions */ 00050 typedef struct { 00051 00052 /* This structure corresponds to the ABCD chip configuration register. 00053 * Aside from one correction to suit the ABCD3T chip (trimRange) it 00054 * is essentially the same as that proposed by John Hill. */ 00055 00056 UINT32 readoutMode : 2; 00057 UINT32 calibMode : 2; 00058 UINT32 trimRange : 2; 00059 UINT32 edgeDetect : 1; 00060 UINT32 mask : 1; 00061 UINT32 accumulate : 1; 00062 UINT32 inputBypass : 1; 00063 UINT32 outputBypass : 1; 00064 UINT32 master : 1; 00065 UINT32 end : 1; 00066 UINT32 feedThrough : 1; 00067 00068 /* Pad to 32 bits to allow input as independent structure in rwModuleData 00069 (min = 1 word): */ 00070 UINT32 padding : 18; 00071 00072 } ABCDConfig; 00073 00074 typedef struct{ 00075 00076 /* This structure holds calibration information about this 00077 * ABCD chip. None of these parameters was present in 00078 * John Hill's version - we probably hadn't thought of it 00079 * two years ago! */ 00080 00081 /* We store a functional representation of the response 00082 * curve (equivalent threshold as a function of charge) 00083 * so that we may request ROD to set the threshold to 00084 * a value specified in fC. */ 00085 00086 UINT8 rc_function; /* Used to denote the type of function which 00087 * has been fitted to the response curve, eg. 00088 * 0 - no calibration information 00089 * 1 - (can't remember, probably exponential) 00090 * 2 - second order polynomial 00091 * 3 - (can't remember, probably "Grillo" func) 00092 * 4 - straight line fit */ 00093 UINT8 unused0[3]; //Make Data alignment explicit. 00094 FLOAT32 rc_params[3]; /* Response Curve Fit */ 00095 00096 FLOAT32 c_factor; /* Capacitor Correction factor */ 00097 00098 UINT32 unused[3]; /* For data alignment */ 00099 /* Other calibration data is available from the wafer test - 00100 * but it's probably irrelevant. */ 00101 00102 /* We had a discussion about putting temperature correction 00103 * coefficients in here, but to avoid the complication of 00104 * delivering recent temperature data to ROD, we conclude 00105 * that temperature corrections are best done offline. */ 00106 00107 } ABCDCaldata; 00108 00109 typedef struct { 00110 00111 /* All registers except the TrimDAC registers. The contents of 00112 * these registers change more often than the TrimDAC settings 00113 * and will most often be loaded as a group. */ 00114 00115 ABCDConfig config; /* Configuration Register 16 bits (+ 16 alignment) */ 00116 00117 UINT8 vthr; /* Threshold, 8 bits */ 00118 UINT8 vcal; /* Calibration Amplitude, 8 bits */ 00119 UINT8 delay; /* Strobe Delay, 6 bits */ 00120 UINT8 preamp; /* Preamp Bias Current, 5 bits */ 00121 00122 UINT8 shaper; /* Shaper Current, 5 bits */ 00123 UINT8 unused[3]; /* For data alignment */ 00124 00125 UINT32 mask[4]; /* Mask Register, 128 bits */ 00126 } ABCDBasic; 00127 00128 typedef struct { 00129 00130 /* This structure includes all register settings and 00131 * calibration information for one ABCD chip. */ 00132 00133 UINT8 active; /* 1 -> participates in scans */ 00134 /* 0 -> register contents unchanged during scanning 00135 * (although the fixed values are still loaded) */ 00136 UINT8 address; /* In SCTDAQ we chose to associate a hardcoded 00137 * chip address with each location on a module. 00138 * That's fine as long as things work correctly. 00139 * If we allow the address to be configurable 00140 * we can recover from (a subset of possible) 00141 * address failure modes. */ 00142 00143 UINT8 normalMasks; /* Set by the MDSP. */ 00144 00145 UINT8 target; /* <= I think this should be correct? */ 00146 00147 ABCDBasic basic; /* All registers apart from the TrimDACs */ 00148 00149 ABCDCaldata caldata; /* Calibration data for this chip */ 00150 00151 UINT8 trim[N_SCT_CHANS]; /* TrimDAC registers, 4 bits/channel 00152 * This could be more tightly packed, but 00153 * unless you need the space, this sounds 00154 * like an unnecessary complication... */ 00155 } ABCDChip; 00156 00157 typedef struct { 00158 00159 /* This structure includes all register settings and 00160 * calibration information for one ABCD module. */ 00161 00162 ABCDChip chip[N_SCT_CHIPS]; 00163 00164 /* The present flag & dataPresent bitfields do not need setting externally; they 00165 are handled by the MDSP. The flag indicates that the full module dataset is 00166 physically present, while the dataPresent bitfield indicates the data status 00167 for the different subsets of module data. */ 00168 UINT32 dataPresent; 00169 UINT8 present; 00170 00171 UINT8 active; /* 1 -> participates in scans */ 00172 /* 0 -> registers unchanged during scanning */ 00173 UINT8 select; /* 1 -> use redundant clk/com; ID4=1 */ 00174 /* 0 -> use primary clk/com; ID4=0 */ 00175 00176 UINT8 groupId; /* The ID of the module's group. This is used to indicate 00177 which slave DSP will receive the module's data (if group 00178 based distribution is set), and also to allow different 00179 module groups to be triggered independently (for 00180 cross-talk studies). Valid range: [0,7] */ 00181 00182 BOCConfig *bocConfig; /* Pointer to the BOC configuration structure. 00183 Does not need setting externally; handled by the MDSP. */ 00184 UINT8 pTTC; /* primary TX channel (used when SELECT = 0) */ 00185 UINT8 rTTC; /* redundant TX channel (used when SELECT = 1) */ 00186 UINT8 rx[2]; /* data links used by module: SCT: 0,1 */ 00187 00188 UINT8 normalMasks, moduleNumber; /* Set by the MDSP. */ 00189 UINT8 unused1[2]; 00190 00191 char serialNumber[16]; 00192 UINT32 mid; 00193 UINT32 unused2[6]; /* align module structures on 8 word boundary */ 00194 00195 /* Each of a module's RX datalinks may or may not be in use 00196 * dependent upon the bypass configuration. ROD should 00197 * consider the settings of the MASTER bit of the 00198 * configuration register of each master chip when 00199 * choosing to enable or disable input streams, 00200 * reallocating buffers as necessary. */ 00201 00202 } ABCDModule; 00203 00204 #endif /*SCT_STRUCT_H */