Jump to content

Recommended Posts

Hi Team ,

import uvm_pkg::*;
class hello extends uvm_transaction;
  rand bit [31:0]b1;
  rand bit [31:0]b2;
  
  `uvm_object_utils_begin(hello)
  `uvm_field_int(b1, UVM_PACK)
  `uvm_field_int(b2, UVM_PACK)
  `uvm_object_utils_end
   function new(string name  = "");
    super.new(name);
  endfunction
endclass
typedef struct {rand int s; rand int s3;}ss;
class par extends uvm_transaction;
  
  function new(string name  = "");
    super.new(name);
  endfunction
  rand bit [31:0]s1;
  rand bit [31:0]s2;  
  ss se;
  rand hello h1;
  
  
endclass
class par1 extends par;
  `uvm_object_utils_begin(par1)
  `uvm_field_int(s2, UVM_PACK)
  `uvm_field_int(s1, UVM_PACK)
  `uvm_field_int(se.s, UVM_PACK)
    `uvm_field_object(h1, UVM_PACK)
  `uvm_field_int(h1.b1, UVM_PACK)
  `uvm_field_int(h1.b2, UVM_PACK)

  
  `uvm_object_utils_end
   function new(string name  = "");
    super.new(name);
  endfunction
endclass
module top;
  par1 p;
  bit [7:0]que[];
  initial begin
    p = par1::type_id::create("p");
    p.randomize();
    p.pack_bytes(que);
    //p.s1 = 3; p.s2 = 4;
    $display("%h, %h", p.s1, p.s2);
    //que = {p};
    $display("%p", que);
    //$display("%p", p);
    //que = p;
    //que = {<<8{new(p)}};
  end
endmodule

 

 

 

I want to pack in form of bits in below format

que = {<<8{p.s2, p.s1, p.se.s, h1.b1, b2}}

How do i achieve this..?? // 

que = {<<8{p.s2, p.s1, p.se.s}} //this one is working using uvm field macros.

but when i add h1.b1 and h1.b2 which are sub class variables it is not working. How do i acheive this.?

 

 

Link to post
Share on other sites

The UVM field macros do not handle OOP very well, and is one of the many reason we do not recommend using them. It would be much simpler and more efficient to use the streaming operator exactly as you wrote it in a do_pack method. 

Link to post
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...