Accellera Systems Initiative Forums

  • Remember me Not recommended on shared computers

Forgot your password?

  • UVM SystemVerilog Discussions

problem on clone

By chenyong September 16, 2011 in UVM SystemVerilog Discussions

  • Reply to this topic
  • Start new topic

Recommended Posts

Advanced Member

I met a problem on clone. In my code for scoreboard, I defined a variable as this:

timer_pkt_item chk_pkt;

the timer_pkt_item is defined as a class in other place. I then register it as:

`uvm_component_utils_begin(timer_scoreboard)

`uvm_field_object(chk_pkt, UVM_DEFAULT)

`uvm_component_utils_end

In my write function for export implementation, I would like to do this:

function void write_pkt(timer_pkt_item rcv_pkt);

chk_pkt = rcv_pkt.clone();

endfunction

My purpose is to save received data of rcv_pkt.

When I start to compile the code, irun reports error as:

assignment operator type check failed (expecting datatype compatible with 'class timer_pkt_item' but found 'class uvm_object' instead). so what is the problem to the code? I think I have defined the variable type as timer_pkt_item, why there is problem? please give me some help. thanks.

Link to comment

Share on other sites.

Member

clone() returns a uvm_object, which you need to cast. Your code should be :

$cast ( chk_pkt , rcv_pkt.clone())

  • chandan and ljepson74

Like

yes, you are right. thanks.

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

×   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.

  • Insert image from URL
  • Submit Reply
  • Existing user? Sign In
  • Online Users
  • All Activity
  • Leaderboard
  • Create New...

assignment operator type check failed (expecting datatype compatible with

SystemVerilog queue initialization using ncverilog +sv?

Steven Wilson's profile photo

Steven Wilson

--- news:// freenews.netfront.net/ - complaints: [email protected] ---

Jonathan Bromley's profile photo

Jonathan Bromley

>I have a question for the assembled masses.

>I have a declaration similar to the following: > >integer my_q[$] = {1,2,3,4,5,6}; > >This is accepted by Modelsim using the -sv switch.

>If I compile this with ncverilog +sv I get the following gripes: > >ncvlog: *E,TYCMPAT ( queue.sv ,5|18): assignment operator type check >failed (expecting datatype compatible with 'queue of integer' but >found 'packed array' instead). >integer my_q[$] = {1,2,3,4,5,6}; > | >ncvlog: *E,NONOWD ( queue.sv ,5|19): Illegal use of a constant without >an explicit width specification [4.1.14(IEEE)]. >integer my_q[$] = {1,2,3,4,5,6}; >etc... > >Any suggestions as to what I'm doing wrong here?

I will try to write up an appnote-style description of unpacked array concatenation somewhere, soon; it's a very useful construct, and deserves to be widely known so that people start demanding it from their vendors. -- Jonathan Bromley

SystemVerilog Polymorphism

Polymorphism allows the use of a variable of the base class type to hold subclass objects and to reference the methods of those subclasses directly from the superclass variable. It also allows a child class method to have a different definition than its parent class if the parent class method is virtual in nature.

Parent and Child Assignment

A class handle is just a container to hold either parent or child class objects. It is important to understand how parent class handles holding child objects and vice-versa behave in SystemVerilog.

Assign Child Class to Base Class

Taking the same example from Inheritance , we'll assign a sub/child class instance sc to a base class handle bc .

Even though bc points to the child class instance, when display() function is called from bc it still invoked the display() function within the base class. This is because the function was called based on the type of the handle instead of the type of object the handle is pointing to. Now let's try to reference a subclass member via a base class handle for which you'll get a compilation error.

Assign Base Class to Child Class

It is illegal to directly assign a variable of a superclass type to a variable of one of its subclass types and hence you'll get a compilation error.

However, $cast can be used to assign a superclass handle to a variable of a subclass type provided the superclass handle refers to an object that is assignment compatible with the subclass variable.

Although the code will compile well, it will have a run-time simulation error because of the failure of $cast . This is because bc is not pointing to an object that is compatible with sc .

Let's make bc point to another subclass called sc2 and try the same thing. In this case, bc simply acts like a carrier.

Virtual Methods

A method in the parent class can be declared as virtual which will enable all child classes to override the method with a different definition, but the prototype containing return type and arguments shall remain the same.

Click here to learn more on Virtual Methods

Rules to follow

  • Assignment of derived class handle to base class handle is allowed.
  • Assignment of base class handle to derived class handle is NOT allowed and results in compilation error.
  • $cast returns 0 if the cast failed, so use the return type to throw an error. Use if or assert to ensure that the cast is successful.

DMCA.com Protection Status

IMAGES

  1. [100% Working Code]

    assignment operator type check failed (expecting datatype compatible with

  2. PowerShell Assignment Operators

    assignment operator type check failed (expecting datatype compatible with

  3. Assignment Operator in Python

    assignment operator type check failed (expecting datatype compatible with

  4. Python Check Datatype Using type() and isinstance()

    assignment operator type check failed (expecting datatype compatible with

  5. How Do You Change The Datatype Of A Column In Sql Server

    assignment operator type check failed (expecting datatype compatible with

  6. Assignment Operator in JavaScript

    assignment operator type check failed (expecting datatype compatible with

VIDEO

  1. Section 3 Operators Part 2 UNIT-4: INTRODUCTION TO DYNAMIC WEBSITES USING JAVASCRIPT 803

  2. Bulldozer operator test, loading failed #shorts #buldozer

  3. Another Aadhaar Software 176-1solved for sync issues on anydesk synced,verified and disclosure done

  4. Grass Type Operator

  5. TYPE OF OPERATOR

  6. Adhar UCL Error, Failed to Sync operator details with server Please try again

COMMENTS

  1. Assignment operator type check failed on interface parameters

    1. The problem is that you are trying to place an instance of your interface where the port list of another interface should be. That is illegal syntax. You want to place the interface instance inside the body of a module. Here is a complete code example which shows 2 instances of your interface which use different parameter values:

  2. Expecting datatype compatibility error packed vs unpacked array

    A_reg[m][n] = W[(m*M+n)*16+:16]; | ncelab: *E,TYCMPAT (./mult.sv,126|24): assignment operator type check failed (expecting datatype compatible with 'packed array' but found 'unpacked array [15:0] of signed packed array [15:0] of logic' instead). ... *E,TYCMPAT (./mult.sv,146|40): assignment operator type check failed (expecting datatype ...

  3. problem on clone

    assignment operator type check failed (expecting datatype compatible with 'class timer_pkt_item' but found 'class uvm_object' instead). so what is the problem to the code? I think I have defined the variable type as timer_pkt_item, why there is problem? please give me some help. thanks.

  4. Formal and actual do not have assignment compatible data types

    xmvlog: *E,TYCMPAT (testbench.sv,21|18): formal and actual do not have assignment compatible data types (expecting datatype compatible with 'int' but found 'queue of int' instead). xmvlog: *W,NOTOPL: no top-level unit found, must have recursive instances.

  5. Xmelab: *E,TYCMPAT, (expecting datatype compatible with 'unpacked

    Hi Team. I have created a wrapper around my sv model. Some of the inputs and all the outputs to the wrapper and model is the same. But some of the inputs to the model are created in the wrapper, and the data type of this input is enumerated type. typedef struct { real amplitude; real frequency; real phase; } signal_rf; module rxbb_lp_model_wrapper import analog_pack_sv::*; import analog_model ...

  6. SystemVerilog AMS simulation (ADE) xmelab ERROR, TYCMPAT: port or

    SystemVerilog AMS simulation (ADE) xmelab ERROR, TYCMPAT: port or terminal connection type check failed on instance (expecting datatype compatible with 'packed array' but found 'unpacked array[0:1] of packed array [3:0] of logic' instead) ADJK over 1 year ago.

  7. Incompatible data types when using a package

    You may be assigning incompatible data types in the new function of pbist_agent. can you post some sample code of your pbist_agent. pbist_agent = PbistAgent::type_id::create("pbist_agent", this);

  8. SystemVerilog queue initialization using ncverilog +sv?

    values. Consequently, the "assignment pattern" syntax was invented: int my_int_array[5] = '{1,2,3,4,5}; Note carefully the apostrophe before the opening curly bracket. That turns the concatenation into an "assignment pattern", which cunningly learns its data type by looking across to the left-hand side of the assignment = operator. So the ...

  9. Parameterized UVM Environment Creation Issue

    The original answer was right. The problem is in the declaration of the agent_m array. Because each instance of the parameterized agent is of a different width, each is a completely different type according to SystemVerilog rules. The declaration: agent agent_m[3]; declares an array of 3 handles to agent#(32) class objects.

  10. Packed and unpacked arrays

    Error-[ICTA] Incompatible complex type design.sv, 15 Incompatible complex type assignment Type of source expression is incompatible with type of target expression. Mismatching types cannot be used in assignments, initializations and instantiations. The type of the target is 'reg$[0:3]', while the type of the source is 'int'.

  11. Solved SystemVerilog module CH2EX8; int q[$] = '{1,-1,127 ...

    This code creates an error: assignment operator type check failed (expecting datatype compatible with 'int' but found 'queue of int' instead). What is the correct way to find the min and max of this type of array?

  12. Type compatibility error

    In reply to cgales:. Thanks a lot. I know the mistake i did. I created a different queue of int type and then made the assignment. It worked !!

  13. How to pass transaction from monitor to coverage?

    I have a coverage instantiated in my monitor. I tried to pass a transaction from the monitor to the coverage but I'm having this error: assignment operator type check failed (expecting datatype compatible with 'class uvm_pkg::uvm_analysis_export#(.T(class sent_agent_pkg::packet))' but found 'class uvm_pkg::uvm_analysis_imp#(.T(class sent_agent_pkg::packet),.IMP(class uvm_pkg::uvm ...

  14. Formal and actual do not have assignment compatible data types

    In reply to dave_59:. Thanks for your prompt response Dave. There is nothing much than this to show. It is a simple uvm_analysis_imp with a write function the only message that it receives is of the datatype time.

  15. SystemVerilog Polymorphism

    SystemVerilog Polymorphism. Polymorphism allows the use of a variable of the base class type to hold subclass objects and to reference the methods of those subclasses directly from the superclass variable. It also allows a child class method to have a different definition than its parent class if the parent class method is virtual in nature.

  16. system verilog

    I'm trying to understand Upcasting and Downcasting in SystemVerilog. Upcasting is casting to a supertype, while downcasting is casting to a subtype. Upcasting is always allowed, but Downcasting involves a type check. So I made a simple test code for upcasting and downcasting. 1.Test for upcasting.

  17. Error in device class creation -- *E TYCMPAT

    In reply to Muthuvenkatesh:. Because AVERY_AHB_UVM or AVERY_AHB_OVM macro is defined but you didnt pass any value to 'parent' parameter of new function. Either you pass value to parent or you can set default value for 'parent' (null for example) and call:

  18. Assignment operator, using a dynamic array

    p++; counter++; } This appears to be what I want which means I need the assignment operator but I am a bit confused as to what to put in it and I am getting stack overflow errors, here is what I thought I needed to do: ClassA ClassA::operator =(const ClassA& source) {. ClassA* newObject; newObject = new ClassA;