Connector Generator: Implement dynamic evaluation of YAML parameters (using `$(...)` syntax)
Summary
This MR adds the following improvements to the connector generator:
-
Any field of the YAML file can contain Python expressions enclosed in
$(...)
which get dynamically evaluated at run-time using the ASTevaluator (see MR !1009 (merged)). - Each expression can refer to the YAML itself:
- all entries of the
parameter
dictionary are valid symbol names - any value of the YAML spec can be accessed using dot-notation (e.g.,
body_size.x_offset
)
- all entries of the
- For the
body_shape
andrule_areas
, all entries of theparameter
dict are also known symbols, allowing more flexibility - The
doc_parameters
field is dropped,parameters
is used instead for the formatting offp_name
,fp_suffix
,description
, andtags
Note: this basically obsoletes features introduced in !926 (merged) (eval(...)
and doc_parameters
is removed, $(...)
is allowed everywhere now.
In case doc_parameters
is still used in some of the YAMLs (as of now there is only samtec_hsec8.yaml
and samtec_micromate.yaml
), an deprecation exception is raised.
Example
To demonstrate the possibilities consider the following YAML:
AST_Test:
library: 'Test'
description: 'AST test'
fp_name: 'ast_test-{num_pos:02d}-{mount_pad_angle:d}'
fp_suffix: '' # optional: defaults to ''
source: '~'
tags: 'test'
parameters:
mount_pad_offset: 3.7
mount_pad_angle: 30
mount_pad_radians : $(radians(mount_pad_angle))
positions: [2, 3, 4]
pad_pitch: $(sqrt(4))
row_pitch: 0
pads:
size: [ 1.5, 2.5 ]
body_size:
x_offset: $((mount_pad_offset + mount_pads.pad_tr.size * cos(mount_pad_radians)) if (num_pos < 3) else 5.0)
y: $(pads.size[1] + 2 * mount_pad_offset * sin(mount_pad_radians))
first_pin:
position: 'top'
body_chamfer: 0.5
marker:
shape: 'triangle'
mount_pads:
pad_tr:
center:
x_offset: $(mount_pad_offset * cos(mount_pad_radians))
y: $(mount_pad_offset * sin(mount_pad_radians))
size: $(0.25 * mount_pad_offset)
rotation: $(mount_pad_angle)
Requirements:
This MR requires !1009 (merged); once merged, the changes will exclusively relate to connector_generator.py
and samtec_hsec8.yaml
.
Edited by Armin Schoisswohl