jungfrau module id (#581)

* connected module id to detid_jungfrau.txt
* fixed module id register in jungfrau
This commit is contained in:
Dhanya Thattil 2022-11-23 12:01:22 +01:00 committed by GitHub
parent 8dbcfc2ca8
commit 911b2f678f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 126 additions and 91 deletions

View File

@ -127,6 +127,8 @@ This document describes the differences between v7.0.0 and v6.x.x
- gui nios temperature added
- detector header change (bunchid, reserved, debug, roundRnumber) ->detSpec1 - 4
-ctb and moench (allowing all clkdivs (totaldiv was a float instead of int))
- jungfrau connected moduleid to detid_jungfrau.txt on board
2. Resolved Issues
==================

View File

@ -42,3 +42,4 @@ install(TARGETS jungfrauDetectorServer_virtual
)
configure_file(config_jungfrau.txt ${CMAKE_BINARY_DIR}/bin/config_jungfrau.txt COPYONLY)
configure_file(detid_jungfrau.txt ${CMAKE_BINARY_DIR}/bin/detid_jungfrau.txt COPYONLY)

View File

@ -37,6 +37,7 @@ $(PROGS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
cp config_jungfrau.txt $(DESTDIR)
cp detid_jungfrau.txt $(DESTDIR)
rm *.gdb
rm $(main_src)*.o $(md5_dir)*.o

View File

@ -440,13 +440,11 @@ Time before end of exposure when comparator is disabled */
#define COORD_COL_INNER_OFST (16)
#define COORD_COL_INNER_MSK (0x0000FFFF << COORD_COL_INNER_OFST)
/** Module column coordinates */
#define COORD_RESERVED_REG (0x7E << MEM_MAP_SHIFT)
/** Module ID coordinates */
#define MOD_ID_REG (0x7E << MEM_MAP_SHIFT)
#define COORD_RESERVED_OUTER_OFST (0)
#define COORD_RESERVED_OUTER_MSK (0x0000FFFF << COORD_RESERVED_OUTER_OFST)
#define COORD_RESERVED_INNER_OFST (16)
#define COORD_RESERVED_INNER_MSK (0x0000FFFF << COORD_RESERVED_INNER_OFST)
#define MOD_ID_OFST (0)
#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST)
/* ASIC Control Register */
#define ASIC_CTRL_REG (0x7F << MEM_MAP_SHIFT)

View File

@ -0,0 +1 @@
1234

View File

@ -42,6 +42,7 @@ char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
int virtual_image_test_mode = 0;
int virtual_moduleid = 0;
#endif
enum detectorSettings thisSettings = UNINITIALIZED;
@ -326,6 +327,29 @@ u_int32_t getDetectorNumber() {
return bus_r(MOD_SERIAL_NUM_REG);
}
int getModuleId(int *ret, char *mess) {
return ((bus_r(MOD_ID_REG) & MOD_ID_MSK) >> MOD_ID_OFST);
}
void setModuleId(int modid) {
LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid));
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG,
bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
}
int updateModuleId() {
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return FAIL;
}
#ifdef VIRTUAL
virtual_moduleid = modid;
#endif
setModuleId(modid);
return OK;
}
u_int64_t getDetectorMAC() {
#ifdef VIRTUAL
return 0;
@ -469,6 +493,10 @@ void setupDetector() {
return;
}
if (updateModuleId() == FAIL) {
return;
}
setReadoutSpeed(HALF_SPEED);
cleanFifos();
resetCore();
@ -2648,7 +2676,7 @@ void *start_timer(void *arg) {
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = pnum;
header->modId = 0;
header->modId = virtual_moduleid;
header->row = row0;
header->column = col0;
@ -2675,7 +2703,7 @@ void *start_timer(void *arg) {
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = pnum;
header->modId = 0;
header->modId = virtual_moduleid;
header->row = row1;
header->column = col1;

View File

@ -8,80 +8,12 @@
#define REQRD_FRMWRE_VRSN_BOARD2 0x220421 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x220422 // 2.0 pcb (version = 011)
#define ID_FILE "detid_jungfrau.txt"
#define LINKED_SERVER_NAME "jungfrauDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
/* Struct Definitions */
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
uint16_t udp_srcmac_msb;
uint16_t udp_destmac_lsb;
uint32_t udp_srcmac_lsb;
uint8_t ip_tos;
uint8_t ip_ihl : 4, ip_ver : 4;
uint16_t udp_ethertype;
uint16_t ip_identification;
uint16_t ip_totallength;
uint8_t ip_protocol;
uint8_t ip_ttl;
uint16_t ip_fragmentoffset : 13, ip_flags : 3;
uint16_t ip_srcip_msb;
uint16_t ip_checksum;
uint16_t ip_destip_msb;
uint16_t ip_srcip_lsb;
uint16_t udp_srcport;
uint16_t ip_destip_lsb;
uint16_t udp_checksum;
uint16_t udp_destport;
} udp_header;
#define IP_HEADER_SIZE (20)
#define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */
enum ADCINDEX { TEMP_FPGA, TEMP_ADC };
enum DACINDEX {
J_VB_COMP,
J_VDD_PROT,
J_VIN_COM,
J_VREF_PRECH,
J_VB_PIXBUF,
J_VB_DS,
J_VREF_DS,
J_VREF_COMP
};
#define DAC_NAMES \
"vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
"vref_ds", "vref_comp"
#define DEFAULT_DAC_VALS \
{ \
1220, /* J_VB_COMP */ \
3000, /* J_VDD_PROT */ \
1053, /* J_VIN_COM */ \
1450, /* J_VREF_PRECH */ \
750, /* J_VB_PIXBUF */ \
1000, /* J_VB_DS */ \
480, /* J_VREF_DS */ \
420 /* J_VREF_COMP */ \
};
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define NUMSETTINGS (2)
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1450, 480, 420 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
{ 1550, 450, 620 }
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "dbit"
/* Hardware Definitions */
#define NCHAN (256 * 256)
#define NCHIP (8)
@ -207,3 +139,73 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define ADC_OFST_HALF_SPEED_BOARD2_VAL (0x10)
#define ADC_OFST_QUARTER_SPEED_BOARD2_VAL (0x08)
/* Struct Definitions */
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
uint16_t udp_srcmac_msb;
uint16_t udp_destmac_lsb;
uint32_t udp_srcmac_lsb;
uint8_t ip_tos;
uint8_t ip_ihl : 4, ip_ver : 4;
uint16_t udp_ethertype;
uint16_t ip_identification;
uint16_t ip_totallength;
uint8_t ip_protocol;
uint8_t ip_ttl;
uint16_t ip_fragmentoffset : 13, ip_flags : 3;
uint16_t ip_srcip_msb;
uint16_t ip_checksum;
uint16_t ip_destip_msb;
uint16_t ip_srcip_lsb;
uint16_t udp_srcport;
uint16_t ip_destip_lsb;
uint16_t udp_checksum;
uint16_t udp_destport;
} udp_header;
#define IP_HEADER_SIZE (20)
#define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */
enum ADCINDEX { TEMP_FPGA, TEMP_ADC };
enum DACINDEX {
J_VB_COMP,
J_VDD_PROT,
J_VIN_COM,
J_VREF_PRECH,
J_VB_PIXBUF,
J_VB_DS,
J_VREF_DS,
J_VREF_COMP
};
#define DAC_NAMES \
"vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
"vref_ds", "vref_comp"
#define DEFAULT_DAC_VALS \
{ \
1220, /* J_VB_COMP */ \
3000, /* J_VDD_PROT */ \
1053, /* J_VIN_COM */ \
1450, /* J_VREF_PRECH */ \
750, /* J_VB_PIXBUF */ \
1000, /* J_VB_DS */ \
480, /* J_VREF_DS */ \
420 /* J_VREF_COMP */ \
};
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define NUMSETTINGS (2)
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1450, 480, 420 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
{ 1550, 450, 620 }
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "dbit"

View File

@ -93,15 +93,16 @@ void setChipVersion(int version);
#ifndef EIGERD
u_int32_t getDetectorNumber();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D)
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) || \
defined(JUNGFRAUD)
int getModuleId(int *ret, char *mess);
#endif
#if defined(EIGERD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int updateModuleId();
#endif
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
#ifndef EIGERD
void setModuleId(int modid);
#endif
#endif
u_int64_t getDetectorMAC();
u_int32_t getDetectorIP();
#ifdef GOTTHARDD

View File

@ -9009,7 +9009,8 @@ int get_module_id(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
#if !(defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D))
#if !(defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) || \
defined(JUNGFRAUD))
functionNotImplemented();
#else
retval = getModuleId(&ret, mess);

View File

@ -85,8 +85,8 @@ class Detector {
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
Result<int64_t> getSerialNumber(Positions pos = {}) const;
/** [Eiger][Gotthard2][Mythen3] 6 bit value (ideally unique) that is
* streamed out in the UDP header of the detector.*/
/** [Eiger][Gotthard2][Mythen3][Jungfrau] 6 bit value (ideally unique) that
* is streamed out in the UDP header of the detector.*/
Result<int> getModuleId(Positions pos = {}) const;
Result<std::string> getReceiverVersion(Positions pos = {}) const;

View File

@ -1246,9 +1246,9 @@ class CmdProxy {
"Serial number of detector.");
GET_COMMAND(moduleid, getModuleId,
"\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) "
"that is streamed out in the UDP header of the detector. "
"Picked up from a file on the module.");
"\n\t[Gotthard2][Eiger][Mythen3][Jungfrau] 16 bit value "
"(ideally unique) that is streamed out in the UDP header of "
"the detector. Picked up from a file on the module.");
GET_COMMAND(type, getDetectorType,
"\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, "

View File

@ -137,7 +137,7 @@ TEST_CASE("moduleid", "[.cmd]") {
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2 || det_type == defs::MYTHEN3 ||
det_type == defs::EIGER) {
det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
REQUIRE_NOTHROW(proxy.Call("moduleid", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("moduleid", {}, -1, GET));

View File

@ -5,9 +5,9 @@
#define APICTB "developer 0x221108"
#define APIGOTTHARD "developer 0x221108"
#define APIGOTTHARD2 "developer 0x221108"
#define APIJUNGFRAU "developer 0x221108"
#define APIMYTHEN3 "developer 0x221108"
#define APIMOENCH "developer 0x221108"
#define APIEIGER "developer 0x221108"
#define APILIB "developer 0x221108"
#define APIRECEIVER "developer 0x221108"
#define APIJUNGFRAU "developer 0x221118"