Jump to content

How to using package rightly in UVM?


Recommended Posts

Hi!

 

 

often,in uvm test, host controller write or read registers through  addresses,so, I define some parameter in a package using `define in replace of register address.

   then , import the package into my test lib package,

compile in order , test lib package is compiled lastly,

but when compling code ,report macro address can't find?

How to using package rightly in UVM?

 

Large projects may have many packages with complex interdependencies,How to using it rightly ?

 

 

 

 

thanks.

 

/wszhong

 

Link to comment
Share on other sites

`define won't do the job because that is a compile-time feature.

You should define your constants with sized enum's or const in the package:

Never use `define if you can avoid it, because macros are hard to debug, don't have an underlying data type and have to be recompiled at every turn.

package My_pkg;
  typedef bit [31:0] address_t;
  typedef enum address_t { timer_config_reg = 'h2800; timer_start_reg = 'h2804, timer_current_reg = 'h2808, ... } registers_e;
  const address_t timer_base_addr = 'h2800;
endpackage

Notice that I also abstract the base type because it will likely be used in the verification and design environments. This also makes the code more portable.

Link to comment
Share on other sites

A `define macro is part of the compilation unit and does not belong to any package or other scope. Compiler directives like `define and `ifdef are compiled away as the first step in compilation process before any SystemVerilog syntax is parsed.

 

I would use an actual Verilog parameter inside a package rather than a const variable because parameters can be used in more places than variables; like range declarations. I have a DVCon paper that has a section on explaining the difference between parameters and const variables.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...