edaa-org / pyEDAA.ProjectModel

An abstract model of EDA tool projects.
https://edaa-org.github.io/pyEDAA.ProjectModel
Other
11 stars 1 forks source link

Exception when Setting default fileset in design #59

Open RasmusGOlsen opened 1 year ago

RasmusGOlsen commented 1 year ago

I get an exception when trying to set the default fileset in the design. Using fileset.Name work, but not with the fileset object. Looking at the source it seems like both ways should be supported.

project = Project('default')
fileset = Fileset('myfileset')
project.DefaultDesign.DefaultFileSet = fileset
  File "/home/rgo/devel/simplhdl/src/simplhdl/__main__.py", line 60, in main
    simpl.create_project(args.projectspec)
  File "/home/rgo/devel/simplhdl/src/simplhdl/simplhdl.py", line 30, in create_project
    project.DefaultDesign.DefaultFileSet = fileset
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rgo/devel/project-template/_env/Project-Template/lib/python3.11/site-packages/pyEDAA/ProjectModel/__init__.py", line 1195, in DefaultFileSet
    raise Exception(f"Fileset '{value}' is not associated to this design.")
Exception: Fileset '/home/rgo/devel/project-template/cores/adder.core/sim/import_list' is not associated to this design.

https://github.com/edaa-org/pyEDAA.ProjectModel/blob/38aa30fa778c04e3949ac9599047906628c20d35/pyEDAA/ProjectModel/__init__.py#L1186-L1195

Paebbels commented 1 year ago

The fileset is not linked / in the same project, that's why the error is

Fileset '....' is not associated to this design.

fileset = Fileset('myfileset')

Is a standalone fileset, not linked to project.

Try this:

project = Project('default')
fileset = Fileset('myfileset', project=project)

project.DefaultDesign.DefaultFileSet = fileset

The idea was: If you have 2 projects (A and B) in your application, you can't mix filesets from A and use/assign them in project B. That's why like 1194 looks up the fileset if its a known fileset, but not yet the default fileset.

RasmusGOlsen commented 1 year ago

Ok, that makes sense, that you cannot assign a default fileset if it's not part of the design. However, I find this line confusing.

fileset = Fileset('myfileset', project=project)

If you create a fileset with a reference to the project, it is not clear to me how the project has a reference to the fileset. I would believe I would have to do this.

project = Project('default')
fileset = Fileset('myfileset')
project.project.DefaultDesign.AddFileSet(fileset)
project.DefaultDesign.DefaultFileSet = fileset

The AddFileSet method would then set the references to the project and the design for the FileSet and all its children. I guess the project and design reference should also be a list if the FileSet is part of multiple designs and projects.

Paebbels commented 1 year ago

Almost all objects are double linked. So e.g. a project knows its designs and a design knows its project.

To enhance the speed, keep work from users setting up the linking and ensuring data structure integrity, this linking is done when ever A is linked to B or B to A. I always try to implement data structures that top-down assembly and bottom-up assembly words as well. Sometimes one is slightly faster then the other (usually top-down).

So you can create an object and hand over the parent object (like shown in my example) or you use later a property to set the relation. In both cases the code takes care of linking forward and backward and sometimes ever for updating statistics and fast lookup structures.

Top-down:

project = Project('default')
fileset = Fileset('myfileset', project=project)

Bottom-up:

fileset = Fileset('myfileset')

project = Project('default')
fileset.Project = project

BUG:
As I looked into the code and saw the reverse linking is missing in Fileset. argh