# These are the records that transform tick counts to time in nanoseconds, # by using the sampling frequency of the ADCs. # Giving the frequency in Hz, calculate the time in ns between each sample record (calc, "BLEN:$(AREA):$(POS):$(INST):SAMP_TIME") { field(DESC, "Time between samples in ns") field(INPA, "BLEN:$(AREA):$(POS):$(INST):AmcClkFreq CP") field(CALC, "1000000000/(2 * A)") } # Calculate the time correspondent to the number of samples of the pre-edge # of the weight function record (calc, "BLEN:$(AREA):$(POS):$(INST):TIME_PRE_RBV") { field(DESC, "Duration of pre-edge in ns") field(INPA, "BLEN:$(AREA):$(POS):$(INST):SAMP_TIME CP") field(INPB, "BLEN:$(AREA):$(POS):$(INST):NumSamp0RBV") field(CALC, "A * B") } # Calculate the time correspondent to the number of samples of between edges # of the weight function. It must be at least the same size of the # pre-edge time because the time counts from the beginning of the pre-edge. record (calc, "BLEN:$(AREA):$(POS):$(INST):TIME_MID_RBV") { field(DESC, "Duration between edges in ns") field(INPA, "BLEN:$(AREA):$(POS):$(INST):SAMP_TIME CP") field(INPB, "BLEN:$(AREA):$(POS):$(INST):TrigDelay1RBV") field(CALC, "B*2 * A") } # Calculate the time correspondent to the number of samples of the pos-edge # of the weight function record (calc, "BLEN:$(AREA):$(POS):$(INST):TIME_POS_RBV") { field(DESC, "Duration of pos-edge in ns") field(INPA, "BLEN:$(AREA):$(POS):$(INST):SAMP_TIME CP") field(INPB, "BLEN:$(AREA):$(POS):$(INST):NumSamp1RBV") field(CALC, "A * B") } # Desired time of the weight function pre-edge record (ao, "BLEN:$(AREA):$(POS):$(INST):TIME_PRE") { field(DESC, "Duration of pre-edge in ns") info(autosaveFields, "VAL") } # Calculate the number of samples of the pre-edge of the weight function # giving the correspondent time and writes it to the firmware. Only even # numbers are allowed in the FPGA register (that is why we use ((~0)-1)& record (calcout, "BLEN:$(AREA):$(POS):$(INST):NumSamp0_CLC") { field(DESC, "Number samples of pre-edge") field(INPA, "BLEN:$(AREA):$(POS):$(INST):TIME_PRE CP") field(INPB, "BLEN:$(AREA):$(POS):$(INST):AmcClkFreq CP") field(CALC, "((~0)-1)&FLOOR((2*A*B)/1000000000)") field(OUT, "BLEN:$(AREA):$(POS):$(INST):NumSamp0 PP") field(DOPT, "Use CALC") } # Desired time of the weight function between edges record (ao, "BLEN:$(AREA):$(POS):$(INST):TIME_MID") { field(DESC, "Duration of between edge in ns") info(autosaveFields, "VAL") } # Time between edges is doubled related to the edges. Also, timing zero for # this time is exactly timing zero for the pre-edge. So, we must not allow # that the between edges time keeps greater than the pre-edge. record (calc, "BLEN:$(AREA):$(POS):$(INST):TIME_MIDC") { field(DESC, "Duration of between edge in ns") field(INPA, "BLEN:$(AREA):$(POS):$(INST):TIME_PRE CP") field(INPB, "BLEN:$(AREA):$(POS):$(INST):TIME_MID CP") field(CALC, "A