# Can I have one macro which adds code in 3 different location?

**URL:** <https://verificationacademy.com/forums/t/can-i-have-one-macro-which-adds-code-in-3-different-location/42426>\
**Category:** SystemVerilog\
**Tags:** covergroup, SystemVerilog, macros\
**Created:** [September 19, 2023, 8:53am UTC](https://verificationacademy.com/forums/t/can-i-have-one-macro-which-adds-code-in-3-different-location/42426 "2023-09-19T08:53:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elene](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@Elene](https://verificationacademy.com/forums/u/Elene)\
**Post date:** [September 19, 2023, 8:53am UTC](https://verificationacademy.com/forums/t/can-i-have-one-macro-which-adds-code-in-3-different-location/42426/1 "2023-09-19T08:53:34Z")

</div>

I would like to have one macro which will declare, instantiate and sample covergroup. At the moment I have 3 macros and I use them in different parts of the code. is it possible to do this in better way?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [September 23, 2023, 2:24pm UTC](https://verificationacademy.com/forums/t/can-i-have-one-macro-which-adds-code-in-3-different-location/42426/2 "2023-09-23T14:24:07Z")

</div>

_In reply to [EleneSajaia](https://verificationacademy.com/forums/t/can-i-have-one-macro-which-adds-code-in-3-different-location/42426):_

No. See [The XY Problem](https://xyproblem.info).
