# Vsim-3978: Illegal assignment to class: Why is my override parameter not fully applied in my derived class?

**URL:** <https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749>\
**Category:** UVM\
**Tags:** UVM, uvm\_sequence\_item, derived-class, uvm\_sequence\
**Created:** [July 29, 2014, 2:42am UTC](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749 "2014-07-29T02:42:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyle](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tonyle/32/4451_2.png) [@tonyle](https://verificationacademy.com/forums/u/tonyle)\
**Post date:** [July 29, 2014, 2:42am UTC](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749/1 "2014-07-29T02:42:47Z")

</div>

I’m trying to make an extended uvm\_sequence class that auto-encapsulates a uvm\_sequence\_item so it can be forwarded to a sequencer. My aim is to forward predicted transactions from a scoreboard to a sequencer, thereby performing module emulation.

Here is the wrapper definition along with some proprietary class extensions:

```verilog
virtual class k_sequence_item extends uvm_sequence_item;
   ...
endclass

virtual class k_sequencer #(type SEQ=k_sequence_item) extends uvm_sequencer #(SEQ);
   `uvm_component_utils(k_sequencer)
   ...
endclass

virtual class k_sequence_wrapper #(type SEQ=k_sequence_item) extends uvm_sequence #(SEQ);
   `uvm_object_utils(k_sequence_wrapper)

   SEQ seq;

   function new(string name = "k_sequence_wrapper");
      super.new(name);
   endfunction

   virtual function void set_sequence(SEQ seq);
      this.seq = seq;
   endfunction

   virtual task body;
      start_item(seq);
      finish_item(seq);
   endtask
endclass

```

Here is the comparator definition. Predicted transactions come in on **refport**.

```verilog
virtual class k_comparator #(type SEQ=k_sequence_item) extends uvm_component;
   `uvm_component_utils(k_comparator)

   k_sequencer #(SEQ) sqr;
   k_sequence_wrapper #(SEQ) wpr;

   uvm_analysis_export #(SEQ) refport;
   uvm_tlm_analysis_fifo #(SEQ) expfifo;
   /* ... */

   function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      /* ... */

      refport = new("refport", this);
      expfifo = new("expfifo", this);
      /* ... */
   endfunction

   /* ... */

   function void connect_phase(uvm_phase phase);
      super.connect_phase(phase);
      refport.connect(expfifo.analysis_export);
      /* ... */
   endfunction

   /* ... */

   task run_phase(uvm_phase phase);
      /* ... */
      //
      // If we have a DUT, compare the observed transaction to the predicted
      // one.
      //
      if (sqr == null) fork
         /* ... */
      join_none else
      //
      // If we don't have a DUT, forward the expected transaction to the
      // sequencer and use the agent as an emulator.
      //
      fork
         forever begin
            expfifo.get(exp_txn);
            /* ... */
/* >>> */ wpr = k_sequence_wrapper#(SEQ)::type_id::create("wpr", this);
            wpr.set_sequence(exp_txn);
            wpr.start(sqr);
         end
         /* ... */
      join_none

      /* ... */
   endtask
endclass

```

With that set up, I extend this comparator class:

```verilog
class transceiver_cmp extends k_comparator #(transceiver_pkt);
   `uvm_component_utils(transceiver_cmp)

   function new(string name, uvm_component parent);
      super.new(name, parent);
   endfunction
endclass

```

The problem line is **k\_sequence\_wrapper…create**. When I try to load this package into Questasim, I get the following error:

```auto
** Error: (vsim-3978) ...: Illegal assignment to class base.test_pkg::k_sequence_wrapper #(class base.test_pkg::transceiver_pkt) from class base.test_pkg::k_sequence_wrapper #(class base.test_pkg::k_sequence_item)

```

Note how the assignee variable **wpr** has been overridden as expected with the **transceiver\_pkt** type, but the **create** call still has the type **k\_sequence\_item** from the base class. How do I correct this so the variable assignment works?

---

<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:** [July 29, 2014, 7:00am UTC](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749/2 "2014-07-29T07:00:48Z")

</div>

Your problem is you are not using the correct factory registration macros.  
Use `uvm\_component\_param\_utils(k\_sequencer#(SEQ)) and similar \*\_param\_utils macros for the other parametrized classes.

You should have gotten a warning similar to

```verilog
** at file.sv(5): (vlog-2181) Use of a parameterized class k_sequencer as a type creates a default specialization.

```

That is a clue that you had referenced a parameterized class without a parameter list.

---

<div class="post-metadata">

**Author:** ![tonyle](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tonyle/32/4451_2.png) [@tonyle](https://verificationacademy.com/forums/u/tonyle)\
**Post date:** [July 29, 2014, 5:40pm UTC](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749/3 "2014-07-29T17:40:53Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749/2):_

That fixed the problem. I’d disabled vlog-2181 to keep it from reporting on other class extensions that were intentionally written to fall back on default parameters. To be safe, I’ll reactivate this warning and use explicit parameters on all derived class declarations, even if they use defaults from the parent class.

Thanks for your help.

---

<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:** [July 29, 2014, 5:59pm UTC](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749/4 "2014-07-29T17:59:00Z")

</div>

_In reply to [tonyle](https://verificationacademy.com/forums/t/vsim-3978-illegal-assignment-to-class-why-is-my-override-parameter-not-fully-applied-in-my-derived-class/29749/3):_

Two things that may also help

- 
- You can use an empty list #() to say that you want all the default parameter settings.
- You do not always need to provide a default.

```verilog
class k_sequencer #(type SEQ)

```

forces you to always provide an explicit override.
