Jump to content

Recommended Posts

Posted

pack function in UVM

I have a class

class A extends uvm_sequence_item;

...

rand bit[3:0]a;

rand bit[121:0]b;

rand bit[162:122]c;

rand bit[511:163]d;

...

endclass

I have another class

class B extends uvm_sequence_item;

....

rand bit[511:0]field;

...

endclass

I would like to assign to field the packed version of all the fields of class A.

ie. B b1;

A a1;

b1 = pack(all fields of a1);

How can i use the uvm pack function for this??

Need immediate help

Posted

hi,

why not

module test187;
   import uvm_pkg::*;
   `include "uvm_macros.svh"

   class ac extends uvm_object;
       rand bit[3:0]a;
       rand bit[121:0]b;
       rand bit[162:122]c;
       rand bit[511:163]d;

       `uvm_object_utils_begin(ac)
       `uvm_field_int(a,UVM_DEFAULT)
       `uvm_field_int(b,UVM_DEFAULT)
       `uvm_field_int(c,UVM_DEFAULT)
       `uvm_field_int(d,UVM_DEFAULT)   
       `uvm_object_utils_end     

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

   class bc extends uvm_object;
       rand bit[511:0]field;
       `uvm_object_utils(bc)   
       function new (string name="");
           super.new(name);
       endfunction     
   endclass

   initial begin
       ac ma = new;
       bc mb = new;
       bit d[];

       ma.pack(d);
       $display({>>{d}});

   end
endmodule

Posted

hi,

why not

module test187;
    import uvm_pkg::*;
    `include "uvm_macros.svh"

    class ac extends uvm_object;
        rand bit[3:0]a;
        rand bit[121:0]b;
        rand bit[162:122]c;
        rand bit[511:163]d;

        `uvm_object_utils_begin(ac)
        `uvm_field_int(a,UVM_DEFAULT)
        `uvm_field_int(b,UVM_DEFAULT)
        `uvm_field_int(c,UVM_DEFAULT)
        `uvm_field_int(d,UVM_DEFAULT)   
        `uvm_object_utils_end     

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

    class bc extends uvm_object;
        rand bit[511:0]field;
        `uvm_object_utils(bc)   
        function new (string name="");
            super.new(name);
        endfunction     
    endclass

    initial begin
        ac ma = new;
        bc mb = new;
        bit d[];
        
        ma.pack(d);
        $display({>>{d}});
    
    end
endmodule

Hi uwes

This packs into bits. If i would like to pack them into bytes, what should i use ?

  • 4 weeks later...
Posted (edited)

use pack_bytes instead of pack

it works pretty well, but now i face a different situation .

what if

module test187;

import uvm_pkg::*;

`include "uvm_macros.svh"

class ac extends uvm_object;

rand bit[31:0]a;

rand bit[121:32]b;

rand bit[162:122]c;

rand bit[511:163]d;

`uvm_object_utils_begin(ac)

`uvm_field_int(a,UVM_DEFAULT)

`uvm_field_int(b,UVM_DEFAULT)

`uvm_field_int(c,UVM_DEFAULT)

`uvm_field_int(d,UVM_DEFAULT)

`uvm_object_utils_end

function new (string name="");

super.new(name);

endfunction

endclass

class bc extends uvm_object;

rand bit[511:0]field;

`uvm_object_utils(bc)

function new (string name="");

super.new(name);

endfunction

endclass

initial begin

ac ma = new;

bc mb = new;

bit d[];

ma.pack(d);

$display({>>{d}});

end

endmodule

Am assigning variable a of class ac with the value {16'h00,8'h5,8'h5} via a task.

When i pack, the value am expecting is

byte 0 = 0

byte 1 = 5

byte 2 = 0

byte 3 = 5

byte 4 = 0

byte 5 = 0

byte 6 =0

byte 7= 0

all bytes are packed properly, except for the first eight bytes which are packed in reverse order :

byte 0 = 0

byte 1 = 0

byte 2 = 0

byte 3 = 0

byte 4 = 0

byte 5 = 5

byte 6 =0

byte 7=5

byte 8=..

.

.

.

byte 63=..

why does this happen?

Edited by meenu

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