Git Product home page Git Product logo

Comments (7)

andreasWallner avatar andreasWallner commented on June 15, 2024

Hi lycfly,

The first component that is instantiated registers itself as the toplevel component, which is later used e.g. for the name of the module. (it has to so that components inside it can add themselves as subcomponents).
modB in your first example is never really inserted into the internal data model.
I think we should add an error for this corner case.

What's your use-case, what would you like to achieve in the end?

from spinalhdl.

lycfly avatar lycfly commented on June 15, 2024

Hi andreasWallner,
Actually I define an SpinalEnum in moduleA and some elements is dynamically added when moduleA is instanced according to the Config. ModuleB will use this dynamically added elements of Enum object so I need to instance moduleA before.
I am just testing whether ModuleB can get this elements, so I write this code in the generate function and find it does not generate the rtl code as I expected.

from spinalhdl.

andreasWallner avatar andreasWallner commented on June 15, 2024

@lycfly As it is at the moment that doesn't work (for the reason I desribed above) - is it possible for you to move the "common code" outside of ModuleA so that both can call it?

from spinalhdl.

lycfly avatar lycfly commented on June 15, 2024

@lycfly As it is at the moment that doesn't work (for the reason I desribed above) - is it possible for you to move the "common code" outside of ModuleA so that both can call it?

Yes, these two modules can be instantiated in an top module.
The code above is for test, and I was just confused about the generate function's behavior.
Thanks for your reply and I will avoid this usage next time.

from spinalhdl.

andreasWallner avatar andreasWallner commented on June 15, 2024

@Dolu1990 I think it would make sense to generate sat least a warning for the case above, what do you think about that?

from spinalhdl.

Dolu1990 avatar Dolu1990 commented on June 15, 2024

Yes, i added a check for it to make an error.
Will give you a "MULTIPLE TOPLEVEL : SpinalHDL only allows a single toplevel Component."

from spinalhdl.

Dolu1990 avatar Dolu1990 commented on June 15, 2024

The check can be turned off via the SpinalConfig(singleTopLevel = false)

from spinalhdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.