How to identify myself in an instance array

S

SysTom

Guest
Hello,

If I am a module that is instantiated as an array how can I identify
which element in the array I in?

I suppose I could cherrypick the bits I need from a string set to %m -
any more elegant solution?

Thanks, Tom
 
I have submodules which readmemb data. I would like each instance to
readmemb a different file.
 
Your %m approach is the only thing that came to mind for the instance
to figure this out on its own.

If it can get some help from outside, there are other approaches. For
example, you could use defparams to set a parameter differently for
each instance. Or you could have a dummy input port on the instance
array to receive a number, and pass in a vector value wide enough to
provide a different value to each instance.

But if you want the instances to be subtly different like this, you
might want to switch from an instance array to a generate-for-loop.
That makes it easy to pass the specific index into each instance with
an instantiation parameter override. Or for an uglier solution, the
instances could do an upward hierarchical reference to access the
implicit localparam with the same name as the genvar, instead of
passing it down via a parameter override.
 
Use generate-for and genvar to solve the problem ...

Joe,
LogicSim - Your Personal Verilog Simulator
http://www.logicsim.com

SysTom wrote:
Hello,

If I am a module that is instantiated as an array how can I identify
which element in the array I in?

I suppose I could cherrypick the bits I need from a string set to %m -
any more elegant solution?

Thanks, Tom
 

Welcome to EDABoard.com

Sponsor

Back
Top