Re: multiple instances and (e.g.) vhdl_code
Ben <[email protected]>
| Newsgroups | gmane.comp.python.myhdl |
|---|---|
| Message-ID | <CAL-sJLJTVjdnsp1XwQiBy_sGL+QKtNC=wkF_ye77SXe5E26oPw@mail.gmail.com> |
That is a frequent request, and as such, I think it would make sense to implement, document such an automatic method in the core of MyHDL. Regards, Ben. On Mon, Jun 8, 2015 at 2:41 PM, Christopher Felton <[email protected]> wrote: > On 6/8/2015 7:05 AM, Henry Gomersall wrote: >> Is there a template string for getting an identifier for the current >> instance when using vhdl_code? >> >> That is, I want the name of the function inside the vhdl code to be >> different for each call to the instance constructor. So the vhdl_code >> could look something like: >> FOO_BAR.vhdl_code = ''' >> foo_bar_$this_id: entity work.SOME_BLOCK(MyHDL) >> ... >> ''' > > I don't believe there exists an automatic method for > doing this, you would need to manage it yourself. You > could have a random unique value created or use a `id` > string argument to the module (function). > > You could use a function attribute and increment on > each call [1]: > > def vhdl_stub(...) > vhdl_stub.id = vhdl_stub.id + 1 > this_id = vhdl_stib_id > > Regards, > Chris > > [1] https://gist.github.com/cfelton/79012fa54868fbd2ebf7 > > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > myhdl-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/myhdl-list ------------------------------------------------------------------------------