Jump to content
Sign in to follow this  
saxmanlogic

uvm_config_db and arrays

Recommended Posts

Given a class that defines a field:

bit [31:0] foo [4];
and with said field added to field automation:

`uvm_field_sarray_int(foo, UVM_ALL_ON)
I proceed to add a call to my component's build_phase to obtain the results of any configuration changes:

void'(uvm_config_db#(bit[31:0])::get(this, $psprintf("foo[%0d]",i), foo[i]));
Doesn't compile.

I try:

void'(uvm_config_db#(bit[31:0][4])::get(this, "foo"), foo));
Doesn't compile.

It try various other possible permutations. Eventually, I arrive using typedef to avoid syntax limitations in the parameterization clause:

typedef bit[31:0] DW;
typedef DW[0:3]   DW_ARRAY;
(NOTE: Had to use the [0:3] dimensioning ala Verilog rather than the [4] dimensioning allowed in SV.)

I am now able to deal with uvm_config_db, so long as I deal in terms of the entire array:

void'(uvm_config_db#(DW_ARRAY)::get(this, "", "foo", foo));

This is tolerable, if not ideal, for dealing with static arrays. It does require that configuration overrides deal with the array on an all or nothing basis, but does not permit of modifying a single entry within the array by means of uvm_config_db, so far as I can gather.

So, to the questions:

1) Am I missing something in the syntax? Is it REALLY necessary to do this typedef stuff to con UVM into accepting my data type? If so, couldn't this have been documented up front?

2) Is there any means by which uvm_config_db can be used to modify only a subset of array elements, rather than overriding the entire array?

3) What if some lower-level entity is intended to modify other entries in this array?

4) What about dynamic arrays? In particular, if I have an associative array and wish to override some few specific locations, am I still going to be required to create a separate dynamic array, set my values there, and then pass it in?

Thank you.

Share this post


Link to post
Share on other sites

First, the syntax issues. You have to realize that SystemVerilog has packed and unpacked kinds of array dimensions. When you declare

bit [31:0] foo [4];

This in an unpacked array[4] of a packed array [31:0]. Because of some parsing issues, there are places where you must use a typedef so that dimension kinds can be distinguished. You could have used a single typedef.

typedef [31:0] DW_ARRAY[4];

As far as setting individual elements, we recommend using a single configuration object for each component instead of multiple configuration settings. You can then use uvm_config_db#(my_config_object) to access its handle, and you have access to each individual element.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×