# HVL path of uvm\_reg for reg.write construction in function

**URL:** <https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303>\
**Category:** UVM\
**Tags:** SystemVerilog, UVM, create-macros-or-general-functions\
**Created:** [April 23, 2022, 6:01am UTC](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303 "2022-04-23T06:01:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![george7272](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/g/bcef8e/32.png) [@george7272](https://verificationacademy.com/forums/u/george7272)\
**Post date:** [April 23, 2022, 6:01am UTC](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303/1 "2022-04-23T06:01:51Z")

</div>

I am trying to create a function in order to find the ral path instead every user trying to remember or type the big ral path  
i.e  
find\_ral\_path\_reg(input string block, input string reg\_name);

Typical path of a reg of specific block is the below  
m\_tb\_env.m\_Ral2.ial\_tc\_bbs.DVSEC\_FBRANGE1HIGH where the DVSEC\_FBRANGE1HIGH is the register

If I create a uvm\_reg var i.e csr\_name and I assign the full above path the

m\_tb\_env.m\_Ral2.ial\_tc\_bbs.DVSEC\_FBRANGE1HIGH where the DVSEC\_FBRANGE1HIGH.write works. I do see the handler being retrieved

Now I will try to find the handler using the find\_ral\_path\_reg based on the two input arguments  
Inside the code I have

csr\_name = m\_tb\_env.m\_Ral2.ial\_tc\_bbs.`BBS_PATH(reg_name) The macro is defined as `define BBS\_PATH(reg) reg  
It seems the reg\_name can not be evaluated just before the macro as DVSEC\_FBRANGE1HIGH  
so I am getting the reg\_name

Is there a way to evaluate the register name from the input function during the macro call?

Thanks

---

<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:** [April 24, 2022, 6:19pm UTC](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303/2 "2022-04-24T18:19:55Z")

</div>

_In reply to [george7272](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303):_

I am not following what your problem is, or what you are even trying to do. The macro

```verilog
`define BBS_PATH(reg) reg

```

does not do anything. I just passes its argument as if the macro was never there. `BBS\_PATH(XYZ) would just be replaced with XYZ.

---

<div class="post-metadata">

**Author:** ![george7272](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/g/bcef8e/32.png) [@george7272](https://verificationacademy.com/forums/u/george7272)\
**Post date:** [April 25, 2022, 2:58pm UTC](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303/3 "2022-04-25T14:58:30Z")

</div>

Hi Dave  
The issue is that the argument as you pointed out the XYZ is an argument in a function  
The argument is not evaluated before it goes to the macro  
Let’s call the function and the reg\_name le’ts make it uvm\_reg type)  
uvm\_reg csr;

csr=find\_ral\_path\_reg(BBS,DVSEC\_FBRANGE1HIGH);

I should get as csr the following

m\_tb\_env.m\_Ral2.ial\_tc\_bbs.DVSEC\_FBRANGE1HIGH where the DVSEC\_FBRANGE1HIGH

If I call the functions passing a different register name i.e

csr=find\_ral\_path\_reg(BBS,DVSEC\_FBRANGE1HIGH5); I should get as csr

m\_tb\_env.m\_Ral2.ial\_tc\_bbs.DVSEC\_FBRANGE1HIGH5

but I am not getting that  
I am always getting  
m\_tb\_env.m\_Ral2.ial\_tc\_bbs.reg

I am getting the name I use as an argument to the macro  
Is there a way the macro argument to be evaluated to whatever is being passed in the function?

Thanks

---

<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:** [April 26, 2022, 5:40am UTC](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303/4 "2022-04-26T05:40:33Z")

</div>

_In reply to [george7272](https://verificationacademy.com/forums/t/hvl-path-of-uvm-reg-for-reg-write-construction-in-function/40303/3):_

Macros are preprocessing text compiler directives that get expanded before any SystemVerilog code gets parsed.

What is BBS? You cannot covert a string to an identifier name.

The is a uvm\_reg\_block method called get\_reg\_by\_name and get\_field\_by\_name. Maybe that is what you really need instead of what you are trying to do.
