mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-19 20:48:40 +01:00
added correct decoder for ADC-SAR-05-06-07-08 ASIC (#266)
Adding function to correctly decode the ADC-SAR-05-06-07-08 Chip. Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
This commit is contained in:
@@ -4,6 +4,39 @@
|
||||
#include <cmath>
|
||||
namespace aare {
|
||||
|
||||
uint16_t adc_sar_05_06_07_08decode64to16(uint64_t input) {
|
||||
|
||||
// we want bits 29,17,28,18,31,21,27,20,24,23,25,22 and then pad to 16
|
||||
uint16_t output = 0;
|
||||
output |= ((input >> 22) & 1) << 11;
|
||||
output |= ((input >> 25) & 1) << 10;
|
||||
output |= ((input >> 23) & 1) << 9;
|
||||
output |= ((input >> 24) & 1) << 8;
|
||||
output |= ((input >> 20) & 1) << 7;
|
||||
output |= ((input >> 27) & 1) << 6;
|
||||
output |= ((input >> 21) & 1) << 5;
|
||||
output |= ((input >> 31) & 1) << 4;
|
||||
output |= ((input >> 18) & 1) << 3;
|
||||
output |= ((input >> 28) & 1) << 2;
|
||||
output |= ((input >> 17) & 1) << 1;
|
||||
output |= ((input >> 29) & 1) << 0;
|
||||
return output;
|
||||
}
|
||||
|
||||
void adc_sar_05_06_07_08decode64to16(NDView<uint64_t, 2> input,
|
||||
NDView<uint16_t, 2> output) {
|
||||
if (input.shape() != output.shape()) {
|
||||
throw std::invalid_argument(LOCATION +
|
||||
" input and output shapes must match");
|
||||
}
|
||||
|
||||
for (ssize_t i = 0; i < input.shape(0); i++) {
|
||||
for (ssize_t j = 0; j < input.shape(1); j++) {
|
||||
output(i, j) = adc_sar_05_06_07_08decode64to16(input(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t adc_sar_05_decode64to16(uint64_t input) {
|
||||
|
||||
// we want bits 29,19,28,18,31,21,27,20,24,23,25,22 and then pad to 16
|
||||
|
||||
Reference in New Issue
Block a user