Re: multiple instances and (e.g.) vhdl_code

Henry Gomersall <[email protected]>
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
On 08/06/15 13:41, Christopher Felton 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
>
>

Thanks Chris,

That is essentially what I've done (albeit with a global list keeping 
track of the allocated values). I do think there is probably grounds for 
an ID to be set by the converter.

Cheers,

Henry

------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.