tudortimi / rgen

IP-XACT based register generator
Apache License 2.0
9 stars 4 forks source link

Principles of adding fields in Mako-templates #1

Closed iDoka closed 7 years ago

iDoka commented 7 years ago

I just now solved how to support default reset values in yaml-template: https://github.com/olofk/ipyxact/issues/7

Because I'm not python-guru (HW Designer) I have troubles to adding default reset values in uvm_reg.mako: The variable ${field.resets.reset.value} inside cycle for field in reg.field: don't work

Traceback (most recent call last):
  File "./rgen.py", line 31, in <module>
    template.render_context(ctx)
  File "/usr/lib/python2.7/site-packages/mako/template.py", line 466, in render_context
    **kwargs)
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 815, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 841, in _exec_template
    callable_(context, *args, **kwargs)
  File "uvm_reg_mako", line 70, in render_body
AttributeError: 'Field' object has no attribute 'resets'

How to I can use value of this chain in mako-template: register -> field -> resets -> reset -> value ?

tudortimi commented 7 years ago

It seems to me like you're using a property that isn't defined in the specific class (Field). rgen comes bundled with ipyxact (in the dependencies directory). I noticed you opened a case against that project to related to adding new properties and that you've made modifications to it. You'll need to point to your repository version either by changing what gets populated in dependencies (via Git) or by changing your PYTHONPATH to contain your local ipyxact repository.

iDoka commented 7 years ago

I'm already changed ipyxact project for supporting chain register -> field -> resets -> reset -> value; see https://github.com/olofk/ipyxact/issues/7 (I hope it works) In parse_tree function proceed dynamically create object (based on YAML-template) BTW, I can find field-word only in ipyxact/ipxact_yaml.py file.

My suggestion that I add in YAML required field in right way, but in my wrong way calling the object ${field.resets.reset.value} (I'm almost don't know python). Which one right way to call object field -> resets -> reset -> value (described my own in YAML) into mako template uvm_reg.mako?

tudortimi commented 7 years ago

What you wrote should have worked, that's why I'm saying that you're probably pointing to the old version of ipyxact.

iDoka commented 7 years ago

The root of problem was in not all fileds has default reset value, I just added exception handler in uvm_reg.mako. It solved my task. Mentioned changes contain into my fork https://github.com/iDoka/ipxact-cli-tools