Config_db - parameters for set/get method

In reply to dave_59:

Sorry. I disagree. For me, UVM reference manual is closest to language LRM that we have. If that does not explain clearly the meaning of parameters that designers of UVM defined, what else will?

In reply to dave_59:

In reply to verif_learner:
There is a mistake here. The first argument to the set/get methods is a context handle. That is an instance of a uvm_component. These methods take the first two arguments and concatenates them together [sv]{ arg1.get_full_name() , arg2 }

. 
Normally arg1 is **this** or **null** depending if you want to specify a relative or absolute path. Only the result of the concatenation matters, not how the original two strings piece together.



Hi Dave,

How can I solve the problem ***"Range width must be constant expression"*** in an assignment like the following, when I get the value of this constant from database?:

``` verilog

data_a = data_b [RDW*i +: RDW];

To make more clear:
In my top test I have a parameter that I receive as a generic from cmd line when I simulate the test:


module test_top #(RDW= 16);
    initial begin
        uvm_config_db #(int)::set(null, "uvm_test_top.*", "RDW", RDW);
    end
endmodule

Then in my scoreboard I have:


int RDW;
function void build_phase (uvm_phase phase);
   void'(uvm_config_db #(int)::get(this, "*", "RDW", RDW));
endfunction

task write ();
   data_a = data_b [RDW*i +: RDW];
endtask

Thank you very much!

In reply to germanbravolopez:

The value to the right of ‘+:’ needs to be a constant. In your case, it is a variable.

Typically you would use a static value or a parameter.

In reply to cgales:

Yes, that’s it. I thought to define “RDW” as a parameter, but the problem is that I cannot change the value of a parameter with the function “uvm_config_db()”.

I also thought to define my scoreboard parametric, like this:


class my_scoreboard #(RDW = 8) extends uvm_scoreboard;

But now I am force to define as parametric the environment and the test also. And to call the test from the “test_top” do I need to do something similar to the following code?


initial begin
   run_test("base_test(RDW)");
end

I don’t know what to do…

In reply to germanbravolopez:

I think it is a good idea to revisit a bit your approach to the problem you need to solve, most of the times what may seem a parameter, it is not and can be passed using a config object. Now if you really need to pass the parameter from command line normally simulators provide some switches to do so (not the purpose nor this forum), also you could selectively add to the compile list a file or package with the parameters you need and import that package where needed.

Also with the first code shown you could assign in a for loop the bits you want.


task write();
  for (int i=0; i<RDW; i++)begin
    data_b[i] = data_a[i+RDW]; //Or whatever logic meet your requirements
  end
endtask

Probably somebody else will provide you a more elaborate solution.

Anyways hope this helps.

-R

PS: I think it would be better to ask a new question as your problem is a bit different from what the original thread was about.

In reply to germanbravolopez:

Create a package of design parameters, and use that package to specialize your scoreboard in the environment:


typedef my_scoreboard#(param_pkg::RDW) my_scoreboard_t;

In reply to cgales:

I can edit this pkg from command line each time that I want to perform a simulation with different values in the parameters, but in that case I need to recompile with this new values, right?

In reply to germanbravolopez:

No you do not need recompile your code. You are passing the actual parameter values as switches of the simulator command to your code.

In reply to chr_sue:

Okey thank you very much!!