1

In the following Systemverilog code snippet:

xxx_model #    (.inst_name({inst_name,".ce_0"})) ce_0 (
...
..
);

I can't understand this part inst_name({inst_name,".ce_0"}). Kindly help me understand.

Puneet Goel
  • 858
  • 5
  • 8
bang
  • 121
  • 2
  • 2
  • 9

1 Answers1

3

From your code snippet:

  1. xxx_model is a parameterized module that takes a parameter of type string named inst_name.
  2. you are instantiating this module and ce_0 is the name of the instance.
  3. you are passing value {inst_name,".ce_0"} as the value of the parameter.

In this context Systemverilog will interpret curly braces as concatenation operator. inst_name in this line is probably a parameter being passed from the upper hierarchy. For the value for inst_name, kindly look for the instantiation of the enveloping module (the module one step upward in the module hierarchy).

Since inst_name is being used in a nested/recursive fashion here, the pattern in the code snippet seems to indicate that probably your code would have inst_name as a parameter in all the modules in the hierarchy. And the purpose is to have a reflection of the hierarchical name of the instance available as a string parameter.

With this scheme of recursive parameter passing, if your module hierarchy is foo->bar->frop->zoo, the parameter inst_name inside the lower most instance in the hierarchy zoo would have a value {inst_name, ".zoo"}. Here inst_name being passed from above would recursively evaluate to "foo.bar.frop**, and as a result the value of inst_name in the instantiation would be foo.bar.frop.zoo.

Puneet Goel
  • 858
  • 5
  • 8
  • Can I exactly declare like this inst_name = "foo.bar.frop";? Or inst_name = "foo.bar.frop**"; – bang Jun 22 '15 at 09:03
  • 1
    You do not want to do that. The very idea of using parameters is to make the code generic so that the same parameterized module can be used in some other hierarchy as well. – Puneet Goel Jun 22 '15 at 10:07