Skip to content

Commit

Permalink
update list of monitorables and script to generate MCU code
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich committed Feb 21, 2022
1 parent fb6f0d2 commit 69ee66c
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 7 deletions.
12 changes: 10 additions & 2 deletions data/zynqmon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ config:
- name: firefly
start: 0
count: 25
mcu_call: firefly
mcu_call: firefly_temps
type: int8
names:
- K01 12 Tx GTH
Expand Down Expand Up @@ -37,7 +37,7 @@ config:
- V12 12 Rx GTY
- name: psmon
start: 20
count: 20
count: 64
mcu_call: psmon
type: fp16
single_instance: &psmon_one [TEMP1, TEMP3, VIN, VOUT, IOUT, RESERVED, RESERVED, RESERVED]
Expand Down Expand Up @@ -83,3 +83,11 @@ config:
mcu_call: gitversion
names:
- Git_Version
- name: fpga
start: 128
count: 2
type: float16
mcu_call: fpga
names:
- F1_TEMP
- F2_TEMP
115 changes: 115 additions & 0 deletions src/mcu_generate.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import yaml\n",
"from pprint import pprint\n",
"import dicttoxml\n",
"# there is also dict2xml available in pypy (python3)\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"with open('../data/zynqmon.yml') as f:\n",
" data = yaml.load(f, Loader=yaml.FullLoader)\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"firefly\n",
"psmon\n",
"adcmon\n",
"uptime\n",
"gitversion\n",
"fpga\n"
]
}
],
"source": [
"config = data['config']\n",
"for c in config:\n",
" print(c['name'])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"// firefly, size 25\n",
"zm_set_firefly_temps(&zynqmon_data[0], 0);\n",
"// psmon, size 64\n",
"zm_set_psmon(&zynqmon_data[25], 20);\n",
"// adcmon, size 21\n",
"zm_set_adcmon(&zynqmon_data[89], 40);\n",
"// uptime, size 2\n",
"zm_set_uptime(&zynqmon_data[110], 192);\n",
"// gitversion, size 20\n",
"zm_set_gitversion(&zynqmon_data[112], 194);\n",
"// fpga, size 2\n",
"zm_set_fpga(&zynqmon_data[132], 128);\n"
]
}
],
"source": [
"size = 0\n",
"for c in config:\n",
" # generate C call\n",
" print(f\"// {c['name']}, size {c['count']}\")\n",
" print(f\"zm_set_{c['mcu_call']}(&zynqmon_data[{size}], {c['start']});\")\n",
" size = size + int(c['count'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "d1bcf2015140efba1309a3b878c8a09b28a5da1fac13dcbb304588e5a25844fe"
},
"kernelspec": {
"display_name": "Python 3.8.12 64-bit ('base': conda)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
176 changes: 171 additions & 5 deletions src/yamltest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -14,9 +14,166 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'cm_hw_rev': '1A',\n",
" 'config': [{'count': 25,\n",
" 'mcu_call': 'firefly',\n",
" 'name': 'firefly',\n",
" 'names': ['K01 12 Tx GTH',\n",
" 'K01 12 Rx GTH',\n",
" 'K02 12 Tx GTH',\n",
" 'K02 12 Rx GTH',\n",
" 'K03 12 Tx GTH',\n",
" 'K03 12 Rx GTH',\n",
" 'K04 4 XCVR GTY',\n",
" 'K05 4 XCVR GTY',\n",
" 'K06 4 XCVR GTY',\n",
" 'K07 12 Tx GTY',\n",
" 'K07 12 Rx GTY',\n",
" 'V01 4 XCVR GTY',\n",
" 'V02 4 XCVR GTY',\n",
" 'V03 4 XCVR GTY',\n",
" 'V04 4 XCVR GTY',\n",
" 'V05 4 XCVR GTY',\n",
" 'V06 4 XCVR GTY',\n",
" 'V07 4 XCVR GTY',\n",
" 'V08 4 XCVR GTY',\n",
" 'V09 4 XCVR GTY',\n",
" 'V10 4 XCVR GTY',\n",
" 'V11 12 Tx GTY',\n",
" 'V11 12 Rx GTY',\n",
" 'V12 12 Tx GTY',\n",
" 'V12 12 Rx GTY'],\n",
" 'start': 0,\n",
" 'type': 'int8'},\n",
" {'count': 20,\n",
" 'mcu_call': 'psmon',\n",
" 'name': 'psmon',\n",
" 'names': [['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED']],\n",
" 'single_instance': ['TEMP1',\n",
" 'TEMP3',\n",
" 'VIN',\n",
" 'VOUT',\n",
" 'IOUT',\n",
" 'RESERVED',\n",
" 'RESERVED',\n",
" 'RESERVED'],\n",
" 'start': 20,\n",
" 'type': 'fp16'},\n",
" {'count': 21,\n",
" 'mcu_call': 'adcmon',\n",
" 'name': 'adcmon',\n",
" 'names': ['VCC_12V',\n",
" 'VCC_2V5',\n",
" 'VCC_M3V3',\n",
" 'VCC_3V3',\n",
" 'VCC_1V8',\n",
" 'VCC_M1V8',\n",
" 'V_VCCINT',\n",
" 'K_VCCINT',\n",
" 'V_MGTY1_AVTT',\n",
" 'V_MGTY2_AVTT',\n",
" 'K_MGTH_AVTT',\n",
" 'K_MGTY_AVTT',\n",
" 'V_MGTY1_VCCAUX',\n",
" 'V_MGTY2_VCCAUX',\n",
" 'K_MGTY_VCCAUX',\n",
" 'K_MGTH_VCCAUX',\n",
" 'V_MGTY1_AVCC',\n",
" 'V_MGTY2_AVCC',\n",
" 'K_MGTY_AVCC',\n",
" 'K_MGTH_AVCC',\n",
" 'TM4C_TEMP'],\n",
" 'start': 40,\n",
" 'type': 'fp16'},\n",
" {'count': 2,\n",
" 'mcu_call': 'uptime',\n",
" 'name': 'uptime',\n",
" 'names': ['Uptime'],\n",
" 'start': 192,\n",
" 'type': 'uint16'},\n",
" {'count': 20,\n",
" 'mcu_call': 'gitversion',\n",
" 'name': 'gitversion',\n",
" 'names': ['Git_Version'],\n",
" 'start': 194,\n",
" 'type': 'char'}],\n",
" 'name': 'zynqmon configuration file',\n",
" 'revision': 1,\n",
" 'sm_fw_rev': '1A',\n",
" 'sm_hw_rev': '1A'}\n"
]
}
],
"source": [
"with open('../data/zynqmon.yml') as f:\n",
" data = yaml.load(f, Loader=yaml.FullLoader)\n",
Expand All @@ -25,9 +182,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"b'<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root><name>zynqmon configuration file</name><cm_hw_rev>1A</cm_hw_rev><sm_hw_rev>1A</sm_hw_rev><sm_fw_rev>1A</sm_fw_rev><revision>1</revision><config><item><name>firefly</name><start>0</start><count>25</count><mcu_call>firefly</mcu_call><type>int8</type><names><item>K01 12 Tx GTH</item><item>K01 12 Rx GTH</item><item>K02 12 Tx GTH</item><item>K02 12 Rx GTH</item><item>K03 12 Tx GTH</item><item>K03 12 Rx GTH</item><item>K04 4 XCVR GTY</item><item>K05 4 XCVR GTY</item><item>K06 4 XCVR GTY</item><item>K07 12 Tx GTY</item><item>K07 12 Rx GTY</item><item>V01 4 XCVR GTY</item><item>V02 4 XCVR GTY</item><item>V03 4 XCVR GTY</item><item>V04 4 XCVR GTY</item><item>V05 4 XCVR GTY</item><item>V06 4 XCVR GTY</item><item>V07 4 XCVR GTY</item><item>V08 4 XCVR GTY</item><item>V09 4 XCVR GTY</item><item>V10 4 XCVR GTY</item><item>V11 12 Tx GTY</item><item>V11 12 Rx GTY</item><item>V12 12 Tx GTY</item><item>V12 12 Rx GTY</item></names></item><item><name>psmon</name><start>20</start><count>20</count><mcu_call>psmon</mcu_call><type>fp16</type><single_instance><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></single_instance><names><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item></names></item><item><name>adcmon</name><start>40</start><count>21</count><mcu_call>adcmon</mcu_call><type>fp16</type><names><item>VCC_12V</item><item>VCC_2V5</item><item>VCC_M3V3</item><item>VCC_3V3</item><item>VCC_1V8</item><item>VCC_M1V8</item><item>V_VCCINT</item><item>K_VCCINT</item><item>V_MGTY1_AVTT</item><item>V_MGTY2_AVTT</item><item>K_MGTH_AVTT</item><item>K_MGTY_AVTT</item><item>V_MGTY1_VCCAUX</item><item>V_MGTY2_VCCAUX</item><item>K_MGTY_VCCAUX</item><item>K_MGTH_VCCAUX</item><item>V_MGTY1_AVCC</item><item>V_MGTY2_AVCC</item><item>K_MGTY_AVCC</item><item>K_MGTH_AVCC</item><item>TM4C_TEMP</item></names></item><item><name>uptime</name><start>192</start><count>2</count><type>uint16</type><mcu_call>uptime</mcu_call><names><item>Uptime</item></names></item><item><name>gitversion</name><start>194</start><count>20</count><type>char</type><mcu_call>gitversion</mcu_call><names><item>Git_Version</item></names></item></config></root>'\n",
"b'<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root><item><name>firefly</name><start>0</start><count>25</count><mcu_call>firefly</mcu_call><type>int8</type><names><item>K01 12 Tx GTH</item><item>K01 12 Rx GTH</item><item>K02 12 Tx GTH</item><item>K02 12 Rx GTH</item><item>K03 12 Tx GTH</item><item>K03 12 Rx GTH</item><item>K04 4 XCVR GTY</item><item>K05 4 XCVR GTY</item><item>K06 4 XCVR GTY</item><item>K07 12 Tx GTY</item><item>K07 12 Rx GTY</item><item>V01 4 XCVR GTY</item><item>V02 4 XCVR GTY</item><item>V03 4 XCVR GTY</item><item>V04 4 XCVR GTY</item><item>V05 4 XCVR GTY</item><item>V06 4 XCVR GTY</item><item>V07 4 XCVR GTY</item><item>V08 4 XCVR GTY</item><item>V09 4 XCVR GTY</item><item>V10 4 XCVR GTY</item><item>V11 12 Tx GTY</item><item>V11 12 Rx GTY</item><item>V12 12 Tx GTY</item><item>V12 12 Rx GTY</item></names></item><item><name>psmon</name><start>20</start><count>20</count><mcu_call>psmon</mcu_call><type>fp16</type><single_instance><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></single_instance><names><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item><item ><item>TEMP1</item><item>TEMP3</item><item>VIN</item><item>VOUT</item><item>IOUT</item><item>RESERVED</item><item>RESERVED</item><item>RESERVED</item></item></names></item><item><name>adcmon</name><start>40</start><count>21</count><mcu_call>adcmon</mcu_call><type>fp16</type><names><item>VCC_12V</item><item>VCC_2V5</item><item>VCC_M3V3</item><item>VCC_3V3</item><item>VCC_1V8</item><item>VCC_M1V8</item><item>V_VCCINT</item><item>K_VCCINT</item><item>V_MGTY1_AVTT</item><item>V_MGTY2_AVTT</item><item>K_MGTH_AVTT</item><item>K_MGTY_AVTT</item><item>V_MGTY1_VCCAUX</item><item>V_MGTY2_VCCAUX</item><item>K_MGTY_VCCAUX</item><item>K_MGTH_VCCAUX</item><item>V_MGTY1_AVCC</item><item>V_MGTY2_AVCC</item><item>K_MGTY_AVCC</item><item>K_MGTH_AVCC</item><item>TM4C_TEMP</item></names></item><item><name>uptime</name><start>192</start><count>2</count><type>uint16</type><mcu_call>uptime</mcu_call><names><item>Uptime</item></names></item><item><name>gitversion</name><start>194</start><count>20</count><type>char</type><mcu_call>gitversion</mcu_call><names><item>Git_Version</item></names></item></root>'\n"
]
}
],
"source": [
"\n",
"xml = dicttoxml.dicttoxml(data, attr_type=False)\n",
Expand Down

0 comments on commit 69ee66c

Please sign in to comment.