BU-Tools / uHAL_AXI_regmap

Tools for building AXI slave VHDL from uHAL address tables.
Apache License 2.0
4 stars 4 forks source link

Issue with uHAL parsing due to missing import #25

Closed andrewpeck closed 2 years ago

andrewpeck commented 2 years ago

The method readpermission translates between uHAL permission classes and permission strings

    @staticmethod
    def readpermission(permission):
#        import uhal
        if permission == uhal.NodePermission.READ:
            return 'r'
        elif permission == uhal.NodePermission.READWRITE:
            return 'rw'
        elif permission == uhal.NodePermission.WRITE:
            return 'w'
        else:
            return ""

Running the program with the uHAL parser generates an error, however, since uHAL is unimported in this module

Traceback (most recent call last):
  File "test_vhdl_packages.py", line 97, in <module>
    test.test_parser(["uhal", "simple"])
  File "test_vhdl_packages.py", line 78, in test_parser
    parse_xml(test_xml=test_xml_name, HDLPath=test["path"],
  File "/home/andrew/Downloads/uHAL_AXI_regmap/tester/../build_vhdl_packages.py", line 95, in parse_xml
    func(test_xml, HDLPath, regMapTemplate, pkgTemplate,
  File "/home/andrew/Downloads/uHAL_AXI_regmap/tester/../build_vhdl_packages.py", line 133, in useUhalParser
    mytree = tree.tree(device.getNode(i), log, yml2hdl=yml2hdl)
  File "/home/andrew/Downloads/uHAL_AXI_regmap/tester/../parsers/tree.py", line 61, in __init__
    self.root = node.node(root, baseAddress=0, tree=self)
  File "/home/andrew/Downloads/uHAL_AXI_regmap/tester/../parsers/node.py", line 45, in __init__
    self.permission = self.readpermission(nodeObj.getPermission())
  File "/home/andrew/Downloads/uHAL_AXI_regmap/tester/../parsers/node.py", line 230, in readpermission
    if permission == uhal.NodePermission.READ:
NameError: name 'uhal' is not defined

The import was commented out in commit c1376870f7 "Fixed possible uHAL dependency"

I don't see how this function can work without importing uhal unless e.g. we pass these objects into the node class at construction

Do you have any preferences for how to fix this @dgastler ? uncommented the import resolves it but maybe there is a better way to implement this

andrewpeck commented 2 years ago

It can be reproduced with the command from the README

./build_vhdl_packages.py -x example_xml/MEM_TEST.xml -o test/uHAL/ \
    --mapTemplate templates/axi_generic/template_map_withbram.vhd MEM_TEST
dgastler commented 2 years ago

This is uHAL library path issue. if you run it with LD_LIBRARY_PATH+=:/opt/cactus/lib/ in front, then it works. I guess we should fail if uHAL is requested and not found.

dgastler commented 2 years ago

[dan@tesla regmap_helper]$ ./build_vhdl_packages.py -x example_xml/MEM_TEST.xml -o test/uHAL/ --mapTemplate templates/axi_generic/template_map_withbram.vhd MEM_TEST Using uHAL parser Traceback (most recent call last): File "./build_vhdl_packages.py", line 191, in args.yaml File "./build_vhdl_packages.py", line 162, in build_vhdl_packages parser=parser, verbose=verbose, debug=debug) File "./build_vhdl_packages.py", line 88, in parse_xml verbose, debug, yml2hdl) File "./build_vhdl_packages.py", line 102, in useUhalParser uhal.setLogLevelTo(uhal.LogLevel.WARNING) NameError: name 'uhal' is not defined

[dan@tesla regmap_helper]$ LD_LIBRARY_PATH+=:/opt/cactus/lib/ ./build_vhdl_packages.py -x example_xml/MEM_TEST.xml -o test/uHAL/ --mapTemplate templates/axi_generic/template_map_withbram.vhd MEM_TEST Using uHAL parser

andrewpeck commented 2 years ago

For me at least it doesn't work either way:

LD_LIBRARY_PATH+=:/opt/cactus/lib/  ./build_vhdl_packages.py -x example_xml/MEM_TEST.xml -o test/uHAL/ --mapTemplate templates/axi_generic/template_map_withbram.vhd MEM_TEST
Using uHAL parser
Traceback (most recent call last):
  File "./build_vhdl_packages.py", line 195, in <module>
    build_vhdl_packages(args.simple,
  File "./build_vhdl_packages.py", line 173, in build_vhdl_packages
    parse_xml(test_xml, outpath, mapTemplate, pkgTemplate, yml2hdl=yml2hdl,
  File "./build_vhdl_packages.py", line 95, in parse_xml
    func(test_xml, HDLPath, regMapTemplate, pkgTemplate,
  File "./build_vhdl_packages.py", line 133, in useUhalParser
    mytree = tree.tree(device.getNode(i), log, yml2hdl=yml2hdl)
  File "/home/andrew/Downloads/uHAL_AXI_regmap/parsers/tree.py", line 61, in __init__
    self.root = node.node(root, baseAddress=0, tree=self)
  File "/home/andrew/Downloads/uHAL_AXI_regmap/parsers/node.py", line 45, in __init__
    self.permission = self.readpermission(nodeObj.getPermission())
  File "/home/andrew/Downloads/uHAL_AXI_regmap/parsers/node.py", line 230, in readpermission
    if permission == uhal.NodePermission.READ:
NameError: name 'uhal' is not defined
andrewpeck commented 2 years ago

And the first error that you posted is actually different from the one I am seeing, crashing in a different file :(

dgastler commented 2 years ago

Fixed in merge #30