From 6e5379ed71b438cb394bda26a479a013bb630c09 Mon Sep 17 00:00:00 2001 From: Peace Kotamnives Date: Sun, 4 Feb 2024 10:55:53 -0500 Subject: [PATCH] Upgrade packer and send more FF data (#201) * upgrade packer * apply bug fix and correction in #204 and ff_laser_fault #202 * Update PL_MEM_CM_rev*.yml Co-authored-by: Peter Wittich Co-authored-by: pwittich --- projects/cm_mcu/LocalTasks.c | 138 +++++++++++------------ projects/cm_mcu/MonitorI2CTask.c | 2 +- projects/cm_mcu/MonitorI2CTask.h | 4 +- projects/cm_mcu/Tasks.h | 6 +- projects/cm_mcu/ZynqMonTask.c | 102 +++++++++++++---- projects/cm_mcu/commands/SensorControl.c | 47 ++------ projects/cm_mcu/commands/SensorControl.h | 21 ++++ sm_cm_config/data/PL_MEM_CM_rev2.yml | 29 ++--- sm_cm_config/src/xml_generate.py | 86 ++++++++++---- 9 files changed, 263 insertions(+), 172 deletions(-) diff --git a/projects/cm_mcu/LocalTasks.c b/projects/cm_mcu/LocalTasks.c index f0dfdc74..5ddb15b4 100644 --- a/projects/cm_mcu/LocalTasks.c +++ b/projects/cm_mcu/LocalTasks.c @@ -173,10 +173,10 @@ struct sm_command_t sm_command_ffldaq_f1[] = { {1, 0x00, 0x16, 2, "FF_TEMPERATURE", 0xff, "C", PM_STATUS}, {1, 0x00, 0x03, 1, "FF_LOS_ALARM", 0xff, "", PM_STATUS}, {1, 0x00, 0x05, 1, "FF_CDR_LOL_ALARM", 0xff, "", PM_STATUS}, - {2, 0x00, 0x22, 1, "FF_CH01_OPT_POW", 0xff, "mw", PM_STATUS}, // read 4 Rx-ch registers with increasing addresses - {2, 0x00, 0x24, 1, "FF_CH02_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x00, 0x26, 1, "FF_CH03_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x00, 0x28, 1, "FF_CH04_OPT_POW", 0xff, "mw", PM_STATUS}, + {2, 0x00, 0x22, 2, "FF_CH01_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, // read 4 Rx-ch registers with increasing addresses + {2, 0x00, 0x24, 2, "FF_CH02_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x00, 0x26, 2, "FF_CH03_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x00, 0x28, 2, "FF_CH04_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, }; uint16_t ffldaq_f1_values[NSUPPLIES_FFLDAQ_F1 * NCOMMANDS_FFLDAQ_F1]; @@ -204,23 +204,23 @@ struct MonitorI2CTaskArgs_t ffldaq_f1_args = { struct sm_command_t sm_command_fflit_f1[] = { {1, 0x00, 0x02, 2, "FF_STATUS_REG", 0xff, "", PM_STATUS}, {1, 0x00, 0x16, 2, "FF_TEMPERATURE", 0xff, "C", PM_STATUS}, - {2, 0x00, 0x07, 1, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, - {2, 0x00, 0x14, 1, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x00, 0x07, 2, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x00, 0x14, 2, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, // there are no registers to read optical power for 14Gbps ECUO. // registers below are a placeholder with a reading equal to zero // the reason we need them because n_commands is fixed - {1, 0x00, 0x00, 1, "FF_CH01_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH02_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH03_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH04_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH05_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH06_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH07_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH08_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH09_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH10_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH11_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH12_OPT_POW", 0xff, "mw", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH01_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH02_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH03_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH04_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH05_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH06_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH07_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH08_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH09_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH10_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH11_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH12_OPT_POW", 0xff, "0.1uW", PM_STATUS}, }; // register maps for OT-DTC Fireflies 12-ch part -- 25Gbps ECUO (no connected devices to test as of 08.04.22) @@ -228,20 +228,20 @@ struct sm_command_t sm_command_fflit_f1[] = { struct sm_command_t sm_command_fflot_f1[] = { {1, 0x00, 0x02, 2, "FF_STATUS_REG", 0xff, "", PM_STATUS}, {1, 0x00, 0x16, 2, "FF_TEMPERATURE", 0xff, "C", PM_STATUS}, - {2, 0x00, 0x07, 1, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, - {2, 0x00, 0x14, 1, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, - {2, 0x01, 0xe4, 1, "FF_CH01_OPT_POW", 0xff, "mw", PM_STATUS}, // read 12 Rx-ch registers with decreasing addresses - {2, 0x01, 0xe2, 1, "FF_CH02_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xe0, 1, "FF_CH03_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xde, 1, "FF_CH04_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xdc, 1, "FF_CH05_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xda, 1, "FF_CH06_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd8, 1, "FF_CH07_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd6, 1, "FF_CH08_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd4, 1, "FF_CH09_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd2, 1, "FF_CH10_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd0, 1, "FF_CH11_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xce, 1, "FF_CH12_OPT_POW", 0xff, "mw", PM_STATUS}, + {2, 0x00, 0x07, 2, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x00, 0x14, 2, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x01, 0xe4, 2, "FF_CH01_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, // read 12 Rx-ch registers with decreasing addresses + {2, 0x01, 0xe2, 2, "FF_CH02_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xe0, 2, "FF_CH03_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xde, 2, "FF_CH04_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xdc, 2, "FF_CH05_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xda, 2, "FF_CH06_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd8, 2, "FF_CH07_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd6, 2, "FF_CH08_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd4, 2, "FF_CH09_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd2, 2, "FF_CH10_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd0, 2, "FF_CH11_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xce, 2, "FF_CH12_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, }; @@ -319,10 +319,10 @@ struct sm_command_t sm_command_ffldaq_f2[] = { {1, 0x00, 0x16, 2, "FF_TEMPERATURE", 0xff, "C", PM_STATUS}, {1, 0x00, 0x03, 1, "FF_LOS_ALARM", 0xff, "", PM_STATUS}, {1, 0x00, 0x05, 1, "FF_CDR_LOL_ALARM", 0xff, "", PM_STATUS}, - {2, 0x00, 0x22, 1, "FF_CH01_OPT_POW", 0xff, "mw", PM_STATUS}, // read 4 Rx-ch registers with increasing addresses - {2, 0x00, 0x24, 1, "FF_CH02_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x00, 0x26, 1, "FF_CH03_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x00, 0x28, 1, "FF_CH04_OPT_POW", 0xff, "mw", PM_STATUS}, + {2, 0x00, 0x22, 2, "FF_CH01_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, // read 4 Rx-ch registers with increasing addresses + {2, 0x00, 0x24, 2, "FF_CH02_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x00, 0x26, 2, "FF_CH03_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x00, 0x28, 2, "FF_CH04_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, }; uint16_t ffldaq_f2_values[NSUPPLIES_FFLDAQ_F2 * NCOMMANDS_FFLDAQ_F2]; @@ -349,43 +349,43 @@ struct MonitorI2CTaskArgs_t ffldaq_f2_args = { struct sm_command_t sm_command_fflit_f2[] = { {1, 0x00, 0x02, 2, "FF_STATUS_REG", 0xff, "", PM_STATUS}, {1, 0x00, 0x16, 2, "FF_TEMPERATURE", 0xff, "C", PM_STATUS}, - {2, 0x00, 0x07, 1, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, - {2, 0x00, 0x14, 1, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x00, 0x07, 2, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x00, 0x14, 2, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, // there are no registers to read optical power for 14Gbps ECUO. // registers below are a placeholder with a reading equal to zero // the reason we need them because n_commands is fixed - {1, 0x00, 0x00, 1, "FF_CH01_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH02_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH03_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH04_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH05_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH06_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH07_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH08_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH09_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH10_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH11_OPT_POW", 0xff, "mw", PM_STATUS}, - {1, 0x00, 0x00, 1, "FF_CH12_OPT_POW", 0xff, "mw", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH01_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH02_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH03_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH04_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH05_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH06_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH07_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH08_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH09_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH10_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH11_OPT_POW", 0xff, "0.1uW", PM_STATUS}, + {1, 0x00, 0x00, 1, "FF_CH12_OPT_POW", 0xff, "0.1uW", PM_STATUS}, }; // register maps for OT-DTC Fireflies 12-ch part -- 25Gbps ECUO (no connected devices to test as of 08.04.22) // **commands below have not been tested yet** struct sm_command_t sm_command_fflot_f2[] = { {1, 0x00, 0x02, 2, "FF_STATUS_REG", 0xff, "", PM_STATUS}, {1, 0x00, 0x16, 2, "FF_TEMPERATURE", 0xff, "C", PM_STATUS}, - {2, 0x00, 0x07, 1, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, - {2, 0x00, 0x14, 1, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, - {2, 0x01, 0xe4, 1, "FF_CH01_OPT_POW", 0xff, "mw", PM_STATUS}, // read 12 Rx-ch registers with decreasing addresses - {2, 0x01, 0xe2, 1, "FF_CH02_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xe0, 1, "FF_CH03_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xde, 1, "FF_CH04_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xdc, 1, "FF_CH05_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xda, 1, "FF_CH06_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd8, 1, "FF_CH07_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd6, 1, "FF_CH08_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd4, 1, "FF_CH09_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd2, 1, "FF_CH10_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xd0, 1, "FF_CH11_OPT_POW", 0xff, "mw", PM_STATUS}, - {2, 0x01, 0xce, 1, "FF_CH12_OPT_POW", 0xff, "mw", PM_STATUS}, + {2, 0x00, 0x07, 2, "FF_LOS_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x00, 0x14, 2, "FF_CDR_LOL_ALARM", 0xffff, "", PM_STATUS}, + {2, 0x01, 0xe4, 2, "FF_CH01_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, // read 12 Rx-ch registers with decreasing addresses + {2, 0x01, 0xe2, 2, "FF_CH02_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xe0, 2, "FF_CH03_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xde, 2, "FF_CH04_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xdc, 2, "FF_CH05_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xda, 2, "FF_CH06_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd8, 2, "FF_CH07_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd6, 2, "FF_CH08_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd4, 2, "FF_CH09_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd2, 2, "FF_CH10_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xd0, 2, "FF_CH11_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, + {2, 0x01, 0xce, 2, "FF_CH12_OPT_POW", 0xffff, "0.1uW", PM_STATUS}, }; #ifdef REV1 @@ -447,8 +447,7 @@ struct dev_moni2c_addr_t clk_moni2c_addrs[CLOCK_NUM_SI5395] = { struct sm_command_t sm_command_clk[] = { // device information on page 0 : table 16.2 and 16.4 - {1, 0x00, 0x02, 1, "PN_BASE", 0xff, "", PM_STATUS}, // page 0x00 - {1, 0x00, 0x03, 1, "PN_BASE", 0xff, "", PM_STATUS}, // page 0x00 + {1, 0x00, 0x02, 2, "PN_BASE", 0xffff, "", PM_STATUS}, // page 0x00 {1, 0x00, 0x05, 1, "DEVICE_REV", 0xff, "", PM_STATUS}, // page 0x00 {1, 0x00, 0x0B, 1, "I2C_ADDR", 0x7f, "", PM_STATUS}, // page 0x00 // internal statuses on page 0 : table 16.8 and 16.9 @@ -484,8 +483,7 @@ struct dev_moni2c_addr_t clkr0a_moni2c_addrs[CLOCK_NUM_SI5341] = { struct sm_command_t sm_command_clkr0a[] = { // device information on page 0 : table 14.4 and 14.6 - {1, 0x00, 0x02, 1, "PN_BASE", 0xff, "", PM_STATUS}, // page 0x00 - {1, 0x00, 0x03, 1, "PN_BASE", 0xff, "", PM_STATUS}, // page 0x00 + {1, 0x00, 0x02, 2, "PN_BASE", 0xffff, "", PM_STATUS}, // page 0x00 {1, 0x00, 0x05, 1, "DEVICE_REV", 0xff, "", PM_STATUS}, // page 0x00 {1, 0x00, 0x0B, 1, "I2C_ADDR", 0xff, "", PM_STATUS}, // page 0x00 // internal statuses on page 0 : table 14.5 @@ -719,7 +717,7 @@ uint16_t getFFtemp(const uint8_t i) } #ifdef REV2 -uint16_t getFFoptpow(const uint8_t i) +uint16_t getFFavgoptpow(const uint8_t i) { uint16_t avg_val = 0; @@ -818,7 +816,7 @@ void getFFpart() strncpy(vendor_string, vendor_string_rxch, nstring); } else { - if (strncmp(vendor_string_rxch, vendor_string, nstring) == 0 && (strstr(vendor_string_rxch, "14") == NULL) && (strstr(vendor_string_rxch, "CRRNB") == NULL)) { + if (strstr(vendor_string_rxch, "14") == NULL && strstr(vendor_string_rxch, "CRRNB") == NULL) { tmp_ffpart_bit_mask = tmp_ffpart_bit_mask | (0x1U << n); // bit 1 for a 25Gbs ch and assign to a Bit-mask of Firefly 12-ch part } else { diff --git a/projects/cm_mcu/MonitorI2CTask.c b/projects/cm_mcu/MonitorI2CTask.c index f1f23534..48ce969b 100644 --- a/projects/cm_mcu/MonitorI2CTask.c +++ b/projects/cm_mcu/MonitorI2CTask.c @@ -89,7 +89,7 @@ void MonitorI2CTask(void *parameters) // grab the semaphore to ensure unique access to I2C controller if (args->xSem != NULL) { if (acquireI2CSemaphore(args->xSem) == pdFAIL) { - log_warn(LOG_SERVICE, "%s could not get semaphore in time; delay & continue\r\n", args->name); + log_debug(LOG_SERVICE, "%s could not get semaphore in time; delay & continue\r\n", args->name); vTaskDelayUntil(&(args->updateTick), pdMS_TO_TICKS(10)); // wait continue; } diff --git a/projects/cm_mcu/MonitorI2CTask.h b/projects/cm_mcu/MonitorI2CTask.h index 29bcc5b5..5dd5e065 100644 --- a/projects/cm_mcu/MonitorI2CTask.h +++ b/projects/cm_mcu/MonitorI2CTask.h @@ -89,11 +89,11 @@ extern struct MonitorI2CTaskArgs_t ffl12_f2_args; extern struct MonitorI2CTaskArgs_t ffldaq_f2_args; #define NSUPPLIES_CLK (4) -#define NCOMMANDS_CLK 8 // number of commands +#define NCOMMANDS_CLK 7 // number of commands #define NCOMMANDS_FLG_CLK 1 // number of sticky commands #define NPAGES_CLK 1 // #define NSUPPLIES_CLKR0A (1) -#define NCOMMANDS_CLKR0A 8 // number of commands +#define NCOMMANDS_CLKR0A 7 // number of commands #define NCOMMANDS_FLG_CLKR0A 2 // number of sticky commands #define NPAGES_CLKR0A 1 // diff --git a/projects/cm_mcu/Tasks.h b/projects/cm_mcu/Tasks.h index 5c19c334..36cf1ddd 100644 --- a/projects/cm_mcu/Tasks.h +++ b/projects/cm_mcu/Tasks.h @@ -199,7 +199,7 @@ bool isEnabledFF(int ff); void setFFmask(uint32_t ff_combined_mask); void readFFpresent(void); uint16_t getFFtemp(const uint8_t i); -uint16_t getFFoptpow(const uint8_t i); +uint16_t getFFavgoptpow(const uint8_t i); uint16_t getFFpresentbit(const uint8_t i); #ifdef REV2 void getFFpart(void); @@ -331,9 +331,9 @@ void EEPROMTask(void *parameters); extern QueueHandle_t xZynqMonQueue; void ZynqMonTask(void *parameters); // data for zynqmon task to be sent to Zynq -#define ZM_NUM_ENTRIES 256 +#define ZM_NUM_ENTRIES 1024 struct zynqmon_data_t { - uint8_t sensor; + uint16_t sensor; union convert_16_t { uint16_t us; // cppcheck-suppress unusedStructMember uint8_t uc[2]; // cppcheck-suppress unusedStructMember diff --git a/projects/cm_mcu/ZynqMonTask.c b/projects/cm_mcu/ZynqMonTask.c index f2980528..61d44f5a 100644 --- a/projects/cm_mcu/ZynqMonTask.c +++ b/projects/cm_mcu/ZynqMonTask.c @@ -27,6 +27,7 @@ #include "Tasks.h" #include "MonitorTask.h" #include "MonitorI2CTask.h" +#include "commands/SensorControl.h" #include "clocksynth.h" #include "common/log.h" @@ -43,27 +44,36 @@ // Register List // See Google Docs, 'CM uC Sensor register map' -#define SENSOR_MESSAGE_START_OF_FRAME_NIB 2 -#define SENSOR_MESSAGE_DATA_FRAME_NIB 0 -#define SENSOR_MESSAGE_HEADER_OFFSET 6 -#define SENSOR_SIX_BITS 0x3F +#define RESERVED_DATA 0x9 // 0b1001 +#define SENSOR_MESSAGE_HEADER_OFFSET 6 +#define SENSOR_SIX_BITS 0x3F #define SENSOR_MESSAGE_START_OF_FRAME \ - (SENSOR_MESSAGE_START_OF_FRAME_NIB << SENSOR_MESSAGE_HEADER_OFFSET) -#define SENSOR_MESSAGE_DATA_FRAME (SENSOR_MESSAGE_DATA_FRAME_NIB << SENSOR_MESSAGE_HEADER_OFFSET) + (2 << SENSOR_MESSAGE_HEADER_OFFSET) +#define SENSOR_MESSAGE_START_OF_FRAME_V2 \ + (3 << SENSOR_MESSAGE_HEADER_OFFSET) +#define SENSOR_MESSAGE_DATA_FRAME (0 << SENSOR_MESSAGE_HEADER_OFFSET) -static void format_data(const uint8_t sensor, const uint16_t data, uint8_t message[4]) +#define MESSAGE_SIZE 5 + +static void format_data(const uint16_t sensor, const uint16_t data, uint8_t message[MESSAGE_SIZE]) { - // header and start of sensor (6 bits, sensor[7:2] - message[0] = SENSOR_MESSAGE_START_OF_FRAME | ((sensor >> 2) & SENSOR_SIX_BITS); - // data frame 1, rest of sensor[1:0] (2 bits) and start of data[15:12] (4 bits) + // header for v2 (0b11) and start of sensor[9:4] (6 bits) + message[0] = SENSOR_MESSAGE_START_OF_FRAME_V2 | ((sensor >> 4) & SENSOR_SIX_BITS); + + // rest of sensor[3:0] (4 bits) and start of reserved[3:2] (2 bits) message[1] = SENSOR_MESSAGE_DATA_FRAME; - message[1] |= ((sensor & 0x3) << 4) | ((data >> 12) & 0xF); - // data frame 2, data[11:6] (6 bits) + message[1] |= ((sensor & 0xf) << 2) | ((RESERVED_DATA >> 2) & 0x3); + + // rest of reserved[1:0] (2 bits) and start of data[15:12] (4 bits) message[2] = SENSOR_MESSAGE_DATA_FRAME; - message[2] |= (data >> 6) & 0x3F; - // data frame 3, data[5:0] ( 6 bits ) + message[2] |= ((RESERVED_DATA & 0x3) << 4) | ((data >> 12) & 0xF); + + // data[11:6] (6 bits) message[3] = SENSOR_MESSAGE_DATA_FRAME; - message[3] |= data & 0x3F; + message[3] |= (data >> 6) & 0x3F; + // data[5:0] ( 6 bits ) + message[4] = SENSOR_MESSAGE_DATA_FRAME; + message[4] |= data & 0x3F; } #ifdef ZYNQMON_TEST_MODE @@ -288,7 +298,39 @@ void zm_set_firefly_temps(struct zynqmon_data_t data[], int start) } #ifdef REV2 -// updated once per loop. Store the ffpart-bit (1 for 25GBs FFL, else 0) and present-bit data +uint16_t getFFtXdisenablebit(const uint8_t i) +{ + if (i > NFIREFLIES_F1 + NFIREFLIES_F2) { + log_warn(LOG_SERVICE, "caught %d > total fireflies %d\r\n", i, NFIREFLIES); + return 56; + } + uint8_t val = 56; + int i2c_dev; + if (!isEnabledFF(i)) // skip the FF if it's not enabled via the FF config + return val; + if (i < NFIREFLIES_F1) { + i2c_dev = I2C_DEVICE_F1; + } + else { + i2c_dev = I2C_DEVICE_F2; + } + int ret = -99; + if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) { + ret = read_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_TX_DISABLE_REG, &val, 1, i2c_dev); + } + else if (strstr(ff_moni2c_addrs[i].name, "Tx") != NULL) { + ret = read_ff_register(ff_moni2c_addrs[i].name, ECU0_14G_TX_DISABLE_REG, &val, 1, i2c_dev); + } + if (ret != 0) + return 56; + else + return val; +} +// updated once per loop. +// For each firefly device, send +// (1) ffpart-bit (1 for 25GBs FFL, else 0) +// (2) present-bit +// (3) tx-disable-bit (e.g. via ECU0_14G_TX_DISABLE_REG) void zm_set_firefly_bits(struct zynqmon_data_t data[], int start) { @@ -378,12 +420,23 @@ void zm_set_firefly_info(struct zynqmon_data_t data[], int start) } data[ll].sensor = ll + start; ++ll; + + if (isFFStale()) { + data[ll].data.us = 0xff; // special stale value + } + else { + data[ll].data.us = getFFavgoptpow(j); // sensor value and type + log_debug(LOG_SERVICE, "opt power ? for ff %d: 0x%02x\r\n", j, getFFavgoptpow(j)); + } + data[ll].sensor = ll + start; + ++ll; + if (isFFStale()) { data[ll].data.us = 0xff; // special stale value } else { - data[ll].data.us = getFFoptpow(j); // sensor value and type - log_debug(LOG_SERVICE, "opt power ? for ff %d: 0x%02x\r\n", j, getFFoptpow(j)); + data[ll].data.us = getFFtXdisenablebit(j); // sensor value and type + log_debug(LOG_SERVICE, "TX-disenabled? for ff argv %d: 0x%02x\r\n", j, getFFtXdisenablebit(j)); } data[ll].sensor = ll + start; ++ll; @@ -528,9 +581,9 @@ void zm_send_data(struct zynqmon_data_t data[]) { // https://docs.google.com/spreadsheets/d/1E-JD7sRUnkbXNqfgCUgriTZWfCXark6IN9ir_9b362M/edit#gid=0 for (int i = 0; i < ZMON_VALID_ENTRIES; ++i) { - uint8_t message[4]; + uint8_t message[MESSAGE_SIZE]; format_data(data[i].sensor, data[i].data.us, message); - for (int j = 0; j < 4; ++j) { + for (int j = 0; j < MESSAGE_SIZE; ++j) { ZMUartCharPut(message[j]); } } @@ -545,7 +598,7 @@ void ZynqMonTask(void *parameters) // will be done centrally in Rev 2 #ifdef ZYNQMON_TEST_MODE - uint8_t message[4] = {0x9c, 0x2c, 0x2b, 0x3e}; + uint8_t message[MESSAGE_SIZE] = {0xf7, 0x0a, 0x1c, 0x2b, 0x3e}; #endif // ZYNQMON_TEST_MODE // reset the data we will send @@ -591,6 +644,7 @@ void ZynqMonTask(void *parameters) message[1] = 0xaa; message[2] = 0x55; message[3] = 0xaa; + message[4] = 0x55; inTestMode = true; enable = true; testmode = 2; @@ -609,7 +663,7 @@ void ZynqMonTask(void *parameters) // non-incrementing, single word if (testmode == 0) { format_data(testaddress, testdata, message); - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < MESSAGE_SIZE; ++i) { ZMUartCharPut(message[i]); } // one shot mode -- disable @@ -622,13 +676,13 @@ void ZynqMonTask(void *parameters) testdata++; testaddress++; format_data(testaddress, testdata, message); - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < MESSAGE_SIZE; ++i) { ZMUartCharPut(message[i]); } } } else if (testmode == 2) { // test mode, no formatting - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < MESSAGE_SIZE; ++i) { ZMUartCharPut(message[i]); } } diff --git a/projects/cm_mcu/commands/SensorControl.c b/projects/cm_mcu/commands/SensorControl.c index bf652600..9204160a 100644 --- a/projects/cm_mcu/commands/SensorControl.c +++ b/projects/cm_mcu/commands/SensorControl.c @@ -13,26 +13,7 @@ #include "common/smbus_helper.h" #include "Tasks.h" -// Register definitions -// ------------------------------------------------- -// 8 bit 2's complement signed int, valid from 0-80 C, LSB is 1 deg C -// Same address for 4 XCVR and 12 Tx/Rx devices - -// two bytes, 12 FF to be disabled -#define ECU0_14G_TX_DISABLE_REG 0x34U -// one byte, 4 FF to be enabled/disabled (only 4 LSB are used) -#define ECU0_25G_XVCR_TX_DISABLE_REG 0x56U -// two bytes, 12 FF to be disabled -#define ECU0_14G_RX_DISABLE_REG 0x34U -// one byte, 4 FF to be enabled/disabled (only 4 LSB are used) -#define ECU0_25G_XVCR_RX_DISABLE_REG 0x35U -// one byte, 4 FF to be enabled/disabled (4 LSB are Rx, 4 LSB are Tx) -#define ECU0_25G_XVCR_CDR_REG 0x62U -// two bytes, 12 FF to be enabled/disabled. The byte layout -// is a bit weird -- 0-3 on byte 4a, 4-11 on byte 4b -#define ECU0_25G_TXRX_CDR_REG 0x4AU - -static int read_ff_register(const char *name, uint16_t packed_reg_addr, uint8_t *value, size_t size, int i2c_device) +int read_ff_register(const char *name, uint16_t packed_reg_addr, uint8_t *value, size_t size, int i2c_device) { memset(value, 0, size); // find the appropriate information for this FF device @@ -138,7 +119,7 @@ static int disable_transmit(bool disable, int num_ff) { int ret = 0, i = num_ff, imax = num_ff + 1; // i and imax are used as limits for the loop below. By default, only iterate once, with i=num_ff. - uint16_t value = 0x3ff; + uint16_t value = 0xfff; if (disable == false) value = 0x0; if (num_ff == NFIREFLIES) { // if NFIREFLIES is given for num_ff, loop over ALL transmitters. @@ -155,7 +136,9 @@ static int disable_transmit(bool disable, int num_ff) else { i2c_dev = I2C_DEVICE_F2; } + if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) { + value = 0xf; ret += write_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_TX_DISABLE_REG, value, 1, i2c_dev); } else if (strstr(ff_moni2c_addrs[i].name, "Tx") != NULL) { @@ -169,7 +152,7 @@ static int disable_receivers(bool disable, int num_ff) { int ret = 0, i = num_ff, imax = num_ff + 1; // i and imax are used as limits for the loop below. By default, only iterate once, with i=num_ff. - uint16_t value = 0x3ff; + uint16_t value = 0xfff; if (disable == false) value = 0x0; if (num_ff == NFIREFLIES) { // if NFIREFLIES is given for num_ff, loop over ALL transmitters. @@ -187,6 +170,7 @@ static int disable_receivers(bool disable, int num_ff) i2c_dev = I2C_DEVICE_F2; } if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) { + value = 0xf; ret += write_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_RX_DISABLE_REG, value, 1, i2c_dev); } else if (strstr(ff_moni2c_addrs[i].name, "Rx") != NULL) { @@ -956,17 +940,8 @@ BaseType_t ff_ctl(int argc, char **argv, char *m) { // argument handling int copied = 0; - // check for stale data - TickType_t now = pdTICKS_TO_MS(xTaskGetTickCount()) / 1000; - if (isFFStale()) { - TickType_t last = pdTICKS_TO_S(getFFupdateTick(isFFStale())); - int mins = (now - last) / 60; - copied += snprintf(m + copied, SCRATCH_SIZE - copied, - "%s: stale data, last update %d minutes ago\r\n", argv[0], mins); - } if (argc == 2) { - snprintf(m + copied, SCRATCH_SIZE - copied, "%s: %s not understood", argv[0], argv[1]); return pdFALSE; } @@ -1160,8 +1135,10 @@ BaseType_t clkmon_ctl(int argc, char **argv, char *m) if (i == 0) { for (; c < clockr0a_args.n_commands; ++c) { - uint8_t val = clockr0a_args.sm_values[c]; - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%-15s : 0x%04x 0x%02x 0x%04x\r\n", clockr0a_args.commands[c].name, clockr0a_args.commands[c].command, clockr0a_args.commands[c].bit_mask, val); + uint16_t val = clockr0a_args.sm_values[c]; + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%-15s : 0x%04x 0x%04x 0x%04x\r\n", + clockr0a_args.commands[c].name, clockr0a_args.commands[c].command, + clockr0a_args.commands[c].bit_mask, val); // copied += snprintf(m + copied, SCRATCH_SIZE - copied, "\r\n"); if ((SCRATCH_SIZE - copied) < 50) { @@ -1188,8 +1165,8 @@ BaseType_t clkmon_ctl(int argc, char **argv, char *m) else { for (; c < clock_args.n_commands; ++c) { - uint8_t val = clock_args.sm_values[(i - 1) * (clock_args.n_commands * clock_args.n_pages) + c]; - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%-15s : 0x%04x 0x%02x 0x%04x\r\n", clock_args.commands[c].name, clock_args.commands[c].command, clock_args.commands[c].bit_mask, val); + uint16_t val = clock_args.sm_values[(i - 1) * (clock_args.n_commands * clock_args.n_pages) + c]; + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%-15s : 0x%04x 0x%04x 0x%04x\r\n", clock_args.commands[c].name, clock_args.commands[c].command, clock_args.commands[c].bit_mask, val); if ((SCRATCH_SIZE - copied) < 50) { ++c; return pdTRUE; diff --git a/projects/cm_mcu/commands/SensorControl.h b/projects/cm_mcu/commands/SensorControl.h index 2168e18d..e2ac6985 100644 --- a/projects/cm_mcu/commands/SensorControl.h +++ b/projects/cm_mcu/commands/SensorControl.h @@ -9,6 +9,25 @@ #define SENSOR_CONTROL_H_ #include "parameters.h" +// Register definitions +// ------------------------------------------------- +// 8 bit 2's complement signed int, valid from 0-80 C, LSB is 1 deg C +// Same address for 4 XCVR and 12 Tx/Rx devices + +// two bytes, 12 FF to be disabled +#define ECU0_14G_TX_DISABLE_REG 0x34U +// one byte, 4 FF to be enabled/disabled (only 4 LSB are used) +#define ECU0_25G_XVCR_TX_DISABLE_REG 0x56U +// two bytes, 12 FF to be disabled +#define ECU0_14G_RX_DISABLE_REG 0x34U +// one byte, 4 FF to be enabled/disabled (only 4 LSB are used) +#define ECU0_25G_XVCR_RX_DISABLE_REG 0x35U +// one byte, 4 FF to be enabled/disabled (4 LSB are Rx, 4 LSB are Tx) +#define ECU0_25G_XVCR_CDR_REG 0x62U +// two bytes, 12 FF to be enabled/disabled. The byte layout +// is a bit weird -- 0-3 on byte 4a, 4-11 on byte 4b +#define ECU0_25G_TXRX_CDR_REG 0x4AU + BaseType_t sensor_summary(int argc, char **argv, char *m); // Power @@ -44,4 +63,6 @@ BaseType_t fpga_ctl(int argc, char **argv, char *m); BaseType_t fpga_reset(int argc, char **argv, char *m); BaseType_t fpga_flash(int argc, char **argv, char *m); +int read_ff_register(const char *name, uint16_t packed_reg_addr, uint8_t *value, size_t size, int i2c_device); + #endif diff --git a/sm_cm_config/data/PL_MEM_CM_rev2.yml b/sm_cm_config/data/PL_MEM_CM_rev2.yml index ad4bb7bc..cfefc8dc 100644 --- a/sm_cm_config/data/PL_MEM_CM_rev2.yml +++ b/sm_cm_config/data/PL_MEM_CM_rev2.yml @@ -8,7 +8,7 @@ revision: 1 config: - name: firefly start: 0 - count: 40 + count: 60 mcu_call: firefly_info mcu_extra_call: null type: uint16_t @@ -37,8 +37,9 @@ config: postfixes: - Temp_C - OptPow + - TxDisabled - name: uptime - start: 44 + start: 60 count: 2 type: uint32_t mcu_call: uptime @@ -47,7 +48,7 @@ config: names: - MCU_UPTIME - name: psmon - start: 47 + start: 62 count: 84 mcu_call: psmon mcu_extra_call: null @@ -76,7 +77,7 @@ config: - IOUT - STATUS_WORD - name: gitversion - start: 132 + start: 146 count: 10 type: char size: 5 @@ -85,7 +86,7 @@ config: names: - MCU_FW_VER - name: adcmon - start: 143 + start: 156 count: 21 mcu_call: adcmon mcu_extra_call: null @@ -114,7 +115,7 @@ config: - F2_TEMP - TM4C_TEMP - name: fpga - start: 165 + start: 177 count: 8 type: fp16 extra: Table=CM_MON;Column=Temp_C;Status=2; @@ -130,7 +131,7 @@ config: - F2_TEMP_SLR2 - F2_TEMP_SLR3 - name: clkmonr0a - start: 174 + start: 185 count: 8 type: uint16_t extra: Table=CM_CLK_MON;Status=1 @@ -148,7 +149,7 @@ config: - LOSIN_FLG_OR_LOL - STICKY_FLG - name: clkmon - start: 182 + start: 194 count: 32 type: uint16_t extra: Table=CM_CLK_MON;Status=1 @@ -169,7 +170,7 @@ config: - LOSIN_FLG_OR_LOL - STICKY_FLG - name: clkr0aconfigversion - start: 216 + start: 228 count: 4 type: char size: 2 @@ -178,7 +179,7 @@ config: names: - MCU_CLKR0A_VER - name: clkr0bconfigversion - start: 220 + start: 233 count: 4 type: char size: 2 @@ -187,7 +188,7 @@ config: names: - MCU_CLKR0B_VER - name: clkr1aconfigversion - start: 224 + start: 238 count: 4 type: char size: 2 @@ -196,7 +197,7 @@ config: names: - MCU_CLKR1A_VER - name: clkr1bconfigversion - start: 228 + start: 243 count: 4 type: char size: 2 @@ -205,7 +206,7 @@ config: names: - MCU_CLKR1B_VER - name: clkr1cconfigversion - start: 232 + start: 248 count: 4 type: char size: 2 @@ -214,7 +215,7 @@ config: names: - MCU_CLKR1C_VER - name: firefly_bits - start: 236 + start: 253 count: 8 type: uint16_t extra: Table=CM_FFARGV_MON;Status=1 diff --git a/sm_cm_config/src/xml_generate.py b/sm_cm_config/src/xml_generate.py index 92d7d983..320fbe99 100644 --- a/sm_cm_config/src/xml_generate.py +++ b/sm_cm_config/src/xml_generate.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python """Generate XML file from YAML input""" import xml.etree.ElementTree as ET from pprint import pprint @@ -6,18 +6,20 @@ import os import yaml +zm_num_entries = 1024 + #% % -def make_node(parent: ET.Element, myid: str, thedict: dict, addr2: int, +def make_node(parent: ET.Element, myid: str, thedict: dict, addr2: int, bit: int, parent_id: str) -> ET.Element: """create the node to be inserted into the xml tree""" # pylint: disable=too-many-branches -# I disable this check because as far as I can tell it's wrong +#I disable this check because as far as I can tell it's wrong thenode = ET.SubElement(parent, 'node') myid = myid.replace(' ', '_') thenode.set('id', myid) #address is half of the sensor address since these are 32 bit addresses theaddr = int(addr2/2) - remain = addr2 % 2 + remain = bit thenode.set('address', str(hex(theaddr))) #this appears to be on all the nodes thenode.set("permission", "r") @@ -90,11 +92,12 @@ def calc_size(thedict: dict) -> int: #and a pretty print method class reg: """create an object with a name, and a start end end register""" - def __init__(self, name, sta, end, sz): + def __init__(self, name, sta, end, sz, width): self.name = name self.start = sta self.end = end self.size = sz + self.width = width def __str__(self): return "name: " + self.name + " start: " + str(self.start) + \ @@ -112,12 +115,11 @@ def overlaps(self, other): def overloads(self): """check if the object overloads the register space""" - if self.start + self.size >= 255: + if self.start + self.size >= zm_num_entries - 1: return True return False - -# custom file type for yaml file, to be used with argparse +#custom file type for yaml file, to be used with argparse def yaml_file(filename): """custom file type for yaml file, to be used with argparse""" if not filename.endswith('.yml'): @@ -128,7 +130,7 @@ def yaml_file(filename): parser.add_argument('-v', '--verbose', action='store_true', help='increase output verbosity') parser.add_argument('-d', '--directory', type=str, help='output directory') -# this argument is required, one input file ending with yaml extension +#this argument is required, one input file ending with yaml extension parser.add_argument('input_file', metavar='file', type=yaml_file, help='input yaml file name') @@ -153,39 +155,64 @@ def yaml_file(filename): cm = ET.Element('node') cm.set('id', 'CM') cm.set('address', '0x00000000') - +prev_addr = 0x0 #keep track of the most recent address that comes into a pair of bytes for 8-bit masking +prev_j = 0x0 #keep track of the order of postfixes in each name node +prev_bit = 0x0 #keep track of the even or odd order of bytes globally sent for masking #% % config = y['config'] - for c in config: # loop over entries in configuration (sensor category) i = 0 # counter over the number of sensors within a category names = c['names'] + start = c['start'] + count = c['count'] for n in names: # loop over names of sensors within a category + if (n=="R0B" and start!=prev_start+prev_count+1): #clkmonr0a and clkmon are from the same function in zynqmontask + print("warning: the start address of clkmon should continue from clkr0a") if 'postfixes' in c: - pp = node = ET.SubElement(cm, 'node') - pp.set('id', n) - start = c['start'] - addr = int((start + i)/2) - pp.set('address', str(hex(addr))) postfixes = c['postfixes'] j = 0 for p in postfixes: + addr = int((start + i)/2) + bit = i%2 if p == 'RESERVED': i += 1 j += 1 continue - if args.verbose: - print("adding postfix", p, "to node", n) - node = make_node(pp, p, c, j, n) + if (bit == 1 and j == 0): #the previous name node has odd bytes so this postfix node uses the previous postfix address but masks off the lower byte + pp = node = ET.SubElement(cm, 'node') + pp.set('id', n) + pp.set('address', str(hex(prev_addr))) + node = make_node(pp, p, c, j, bit, n) + elif (bit == 0 and j == 0): #starting a new postfix node in a new name node + pp = node = ET.SubElement(cm, 'node') + pp.set('id', n) + pp.set('address', str(hex(addr))) + node = make_node(pp, p, c, j, bit, n) + else: # any non-first byte in a name node + if (prev_bit == 0): #the upper byte of the previous postfix node + node = make_node(pp, p, c, j, bit, n) + else : #the low byte with an increasing postfix node by one + node = make_node(pp, p, c, j+1, bit, n) + if (prev_bit == bit and prev_addr == addr and prev_addr != 0) : + print("warning : please check if masks overlapped at node ", n, " addr ", hex(prev_addr)) + prev_addr = addr + prev_j = j + prev_bit = bit i += 1 j += 1 else: - start = c['start'] - make_node(cm, n, c, start+i, "") + make_node(cm, n, c, start+i, (start+i)%2, "") + if (prev_bit == (start+i)%2 and prev_addr == int((start+i)/2) and prev_addr != 0) : + print("warning : please check if masks overlapped at node ", n, " addr ", hex(prev_addr)) + prev_addr = int((start + i)/2) + prev_bit = (start+i)%2 i += 1 + prev_start = start + prev_count = count + tree = ET.ElementTree(cm) ET.indent(tree, space='\t') -# create output file name based on input file, replacing 'yml' with 'xml' +#create output file name based on input file, replacing 'yml' with 'xml' out_name = os.path.basename(args.input_file)[:-len('.yml')] + '.xml' out_name = args.directory + '/' + out_name if args.verbose: @@ -209,7 +236,20 @@ def yaml_file(filename): postfixes = ' ' size = calc_size(c) thislength = len(postfixes) * len(names)*size - entries.append(reg(c['name'], start, start + thislength - 1, thislength)) + width = 99 + if c['type'] == 'int8': + width = 8 + elif c['type'] == 'int16': + width = 16 + elif c['type'] == 'fp16': + width = 16 + elif c['type'] == 'char': + width = 16 + elif c['type'] == 'uint32_t': + width = 32 + elif c['type'] == 'uint16_t': + width = 16 + entries.append(reg(c['name'], start, start + thislength - 1, thislength, width)) if args.verbose: for e in entries: print(e)