Commit 88695b22 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files
parents eb7f9976 27cc2ee1
......@@ -21,15 +21,24 @@ char p_szGlobalState[10] = "modeX";
char globalFpgaStatus_gnc[20] = FPGA_DISABLED;
char globalFpgaStatus_gnc2[20] = FPGA_DISABLED;
//uncomment the following define to print debug level info
//#define DEBUG_RECONF
int get_bitfile_info(char *config, char **global_status_var, asn1SccMyInteger *offset, asn1SccMyInteger *size)
{
int headerfile_entries = 0;
headerfile_entries = sizeof(bitfiles)/sizeof(struct config_bitfile);
#ifdef DEBUG_RECONF
printf("[get_bitfile_info] There are %d headerfile entries.\n", headerfile_entries);
#endif
for(int i = 0; i < headerfile_entries; i++){
#ifdef DEBUG_RECONF
printf("[get_bitfile_info] Mode index %d is %s\n", i, bitfiles[i].config);
#endif
if (strcmp(config, bitfiles[i].config) == 0) {
#ifdef DEBUG_RECONF
printf("[get_bitfile_info] Mode found in index %d which is %s\n", i, bitfiles[i].config);
#endif
*global_status_var = bitfiles[i].global_status_var;
*offset = bitfiles[i].offset;
*size = bitfiles[i].size;
......@@ -52,7 +61,7 @@ void calling_startup()
void calling_PI_changeMode()
{
/* Write your code here! */
printf("\n[calling_PI_changeMode] Current mode is %s\n", p_szGlobalState);
// printf("\n[calling_PI_changeMode] Current mode is %s\n", p_szGlobalState);
/* FPGA reconfiguration engine part */
static asn1SccMyInteger fpga_status = 1;
......@@ -82,36 +91,41 @@ void calling_PI_changeMode()
offset = -1;
size = -1;
if (!get_bitfile_info(new_config, &global_status_var, &offset, &size)){
#ifdef DEBUG_RECONF
printf("[calling_PI_changeMode] bitfile info is: global_status_var prev - %s, offset - %lld, size - %lld\n", global_status_var, offset, size);
#endif
// DISABLE ALL
strcpy(globalFpgaStatus_gnc, FPGA_DISABLED);
strcpy(globalFpgaStatus_gnc2, FPGA_DISABLED);
// SET NEXT AS RECONFIGURING
strcpy(global_status_var, FPGA_RECONFIGURING);
#ifdef DEBUG_RECONF
printf("[calling_PI_changeMode] global_status_var now is - %s\n", global_status_var);
printf("[calling_PI_changeMode] cross check: globalFpgaStatus_gnc now is - %s\n", globalFpgaStatus_gnc);
printf("[calling_PI_changeMode] cross check: globalFpgaStatus_gnc2 now is - %s\n", globalFpgaStatus_gnc2);
#endif
// CALL engine
/* ## FPGA reconfiguration engine status */
calling_RI_status(&fpga_status);
#ifdef DEBUG_RECONF
printf("[calling_PI_changeMode] FPGA STATUS before reconf = %lld\n", fpga_status);
#endif
/* ## FPGA reconfiguration engine configuration */
calling_RI_run(&offset, &size);
/* ## FPGA reconfiguration engine status */
calling_RI_status(&fpga_status);
#ifdef DEBUG_RECONF
printf("[calling_PI_changeMode] FPGA STATUS after reconf = %lld\n", fpga_status);
#endif
// update again global variables to new value depending on the FPGA state: FPGA_READY? FPGA_ERROR?
if (fpga_status){
if (!fpga_status){
strcpy(global_status_var, FPGA_READY);
printf("[calling_PI_changeMode] New config loaded with success.\n");
strcpy(p_szGlobalState, new_config);
printf("[calling_PI_changeMode] NEW mode is %s\n", p_szGlobalState);
//printf("[calling_PI_changeMode] NEW mode is %s\n", p_szGlobalState);
}else{
strcpy(global_status_var, FPGA_ERROR);
printf("[calling_PI_changeMode] New config could not be loaded!\n");
......@@ -120,7 +134,7 @@ void calling_PI_changeMode()
}else{
printf("[calling_PI_changeMode] New (HW) config not found... SW mode applies.\n");
strcpy(p_szGlobalState, new_config);
printf("[calling_PI_changeMode] NEW mode is %s\n", p_szGlobalState);
//printf("[calling_PI_changeMode] NEW mode is %s\n", p_szGlobalState);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment