added time measurement of HDMA receive

This commit is contained in:
2025-09-16 16:51:54 +03:00
parent cf8bdd5b5c
commit dc6e7be012
2 changed files with 74 additions and 52 deletions

Binary file not shown.

126
main.c
View File

@ -68,7 +68,10 @@
#include "l502_fpga_regs.h"
typedef enum {
DUMP_TO_FILE,
FLUSH,
};
typedef enum {
unknown = 0x00,
@ -794,7 +797,7 @@ uint32_t X502_FlushRcv_buff(t_x502_hnd hnd){
return ready;
}
void receive_data(t_x502_hnd hnd, char* logfilename, uint32_t* inp_buff, int data_receive_trys_counter, uint32_t max_total_words){
void receive_data(t_x502_hnd hnd, char* logfilename, uint32_t* inp_buff, int data_receive_trys_counter, uint32_t max_total_words, uint8_t mode){
//int data_receive_trys_counter = 100;
//uint32_t max_total_words = 10000;
uint32_t ready_cnt_Err = 0;
@ -812,49 +815,53 @@ void receive_data(t_x502_hnd hnd, char* logfilename, uint32_t* inp_buff, int dat
ready_cnt_Err = X502_GetRecvReadyCount(hnd, &ready_cnt);
recv_Err_code = X502_Recv(hnd, inp_buff, ready_cnt, 10);
printf("\n\nget counters of calls of SPORT_RX, SPORT_TX, HDMA_RX, HDMA_TX\n");
BF_exec_cmd_with_arr(hnd, 0x8005U, 100, NULL, 0, 1);
printf("\n\request TX_buff_I_shadow value (last size of TX_buff transferred to pc )\n");
BF_exec_cmd_simple(hnd, 0x8009, 10, 1);
if (ready_cnt){
printf("Ready count: %d, Err: %d \n", ready_cnt, ready_cnt_Err);
for (int i = 0; i < ready_cnt; ++i){
//printf("\nabort value: %d\n", abort_crtl_C);
if (abort_crtl_C){
break;
}
--max_total_words;
if (max_total_words == 0){
break;
//printf("\n\nget counters of calls of SPORT_RX, SPORT_TX, HDMA_RX, HDMA_TX\n");
//BF_exec_cmd_with_arr(hnd, 0x8005U, 100, NULL, 0, 1);
//printf("\n\request TX_buff_I_shadow value (last size of TX_buff transferred to pc )\n");
//BF_exec_cmd_simple(hnd, 0x8009, 10, 1);
if (mode == DUMP_TO_FILE){
if (ready_cnt){
printf("Ready count: %d, Err: %d \n", ready_cnt, ready_cnt_Err);
for (int i = 0; i < ready_cnt; ++i){
//printf("\nabort value: %d\n", abort_crtl_C);
if (abort_crtl_C){
break;
}
--max_total_words;
if (max_total_words == 0){
break;
}
char bin_str_val[9] = {0,};
uin32_t_to_bin(inp_buff[i], bin_str_val);
printf(" 0x%08X,", inp_buff[i]);
fprintf(logfile_ptr, "0x%08X \n", inp_buff[i]);
//printf(" 0b%s,", bin_str_val);
++values_in_line;
if (values_in_line == 10){
printf("\n");
values_in_line = 0;
}
}
char bin_str_val[9] = {0,};
uin32_t_to_bin(inp_buff[i], bin_str_val);
printf(" 0x%08X,", inp_buff[i]);
fprintf(logfile_ptr, "0x%08X \n", inp_buff[i]);
//printf(" 0b%s,", bin_str_val);
++values_in_line;
if (values_in_line == 10){
printf("\n");
values_in_line = 0;
}
}
/*
uint32_t process_data_Err = 0;
uint32_t adc_data_size = ready_cnt;
X502_Raw_User_Data_Parser(inp_buff, inp_values_N,
adc_data, adc_chans_N, adc_readouts_N,
&LFSM_res_tmp, &LFSM_res,
&FFT_res_tmp, &FFT_res);
//process_data_Err = X502_ProcessData(hnd, inp_buff, ready_cnt, X502_PROC_FLAGS_VOLT, adc_data, &adc_data_size, NULL, NULL);
uint64_t data_sum = 0;
for (int i = 0; i < ready_cnt; ++i){
data_sum += inp_buff[i];
if (i % 1000 == 1){
//printf(" %e\n", adc_data[i]);
/*
uint32_t process_data_Err = 0;
uint32_t adc_data_size = ready_cnt;
X502_Raw_User_Data_Parser(inp_buff, inp_values_N,
adc_data, adc_chans_N, adc_readouts_N,
&LFSM_res_tmp, &LFSM_res,
&FFT_res_tmp, &FFT_res);
//process_data_Err = X502_ProcessData(hnd, inp_buff, ready_cnt, X502_PROC_FLAGS_VOLT, adc_data, &adc_data_size, NULL, NULL);
uint64_t data_sum = 0;
for (int i = 0; i < ready_cnt; ++i){
data_sum += inp_buff[i];
if (i % 1000 == 1){
//printf(" %e\n", adc_data[i]);
}
}
*/
}
*/
}else if (mode == FLUSH){
;
}
//printf("try: %04d, words ready: %06d, receive_error_code: %05d, data_sum: %d \n", data_receive_trys_counter, ready_cnt, recv_Err_code, data_sum);
}
@ -1078,7 +1085,7 @@ int main(int argc, char** argv) {
time_t seconds;
time(&seconds);
char logfilename[] = " ";
char logfilename[] = " ";
sprintf(&logfilename, "received_data_%ld.csv", seconds);
//logfile_ptr = fopen(logfilename, "w");
printf("dumping to file: %s\n", logfilename);
@ -1144,12 +1151,12 @@ int main(int argc, char** argv) {
BF_exec_cmd_simple(hnd, 0x8010, 10, 1);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words, DUMP_TO_FILE);
/*
data_receive_trys_counter = 100;
max_total_words = 10000;
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words, DUMP_TO_FILE);
*/
@ -1160,8 +1167,9 @@ int main(int argc, char** argv) {
// X502_StreamsStop(hnd);
// X502_StreamsStart(hnd);
BF_exec_cmd_simple(hnd, 0x8008, 2, 1); //start averaging
// BF_exec_cmd_simple(hnd, 0x8007, 2, 1); //start transparent
//BF_exec_cmd_simple(hnd, 0x8008, 2, 1); //start averaging
BF_exec_cmd_simple(hnd, 0x8007, 2, 1); //start transparent
//BF_exec_cmd_simple(hnd, 0x800B, 2, 1); //start HDMA flood for speedtest
printf("\nFlushed from receiving buff: %d\n", X502_FlushRcv_buff(hnd));
@ -1177,12 +1185,26 @@ int main(int argc, char** argv) {
data_receive_trys_counter = 100;
max_total_words = 100000;
// void receive_data(t_x502_hnd hnd, FILE* logfile_ptr, uint32_t* inp_buff, int data_receive_trys_counter, uint32_t max_total_words)
// void receive_data(t_x502_hnd hnd, FILE* logfile_ptr, uint32_t* inp_buff, int data_receive_trys_counter, uint32_t max_total_words, DUMP_TO_FILE)
//printf("\n dbg value: ");
//BF_exec_cmd_simple(hnd, 0x800A, 10, 1);
struct timespec time_receive_started, time_receive_ended;
clock_gettime(CLOCK_MONOTONIC, &time_receive_started);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words, FLUSH);
clock_gettime(CLOCK_MONOTONIC, &time_receive_ended);
double receive_time = (time_receive_ended.tv_sec - time_receive_started.tv_sec);
receive_time += time_receive_ended.tv_nsec*1e-9;
receive_time += time_receive_started.tv_nsec*1e-9;
printf("\n Receive time: %g, %g sec/value \n", receive_time, receive_time/max_total_words);
printf("\n dbg value: ");
BF_exec_cmd_simple(hnd, 0x800A, 10, 1);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words);
printf("\n dbg value: ");
BF_exec_cmd_simple(hnd, 0x800A, 10, 1);
@ -1198,7 +1220,7 @@ int main(int argc, char** argv) {
printf("\n dbg value: ");
BF_exec_cmd_simple(hnd, 0x800A, 10, 1);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words, DUMP_TO_FILE);
printf("\n dbg value: ");
BF_exec_cmd_simple(hnd, 0x800A, 10, 1);
@ -1214,7 +1236,7 @@ int main(int argc, char** argv) {
printf("\n dbg value: ");
BF_exec_cmd_simple(hnd, 0x800A, 10, 1);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words);
receive_data(hnd, logfilename, inp_buff, data_receive_trys_counter, max_total_words, DUMP_TO_FILE);
printf("\n dbg value: ");
BF_exec_cmd_simple(hnd, 0x800A, 10, 1);