0
votes

I have two files sequence_item.sv and sequencer.sv respectively with the contents below. I am not able to compile sequencer.sv, with the error

** Error: /afs/asu.edu/users/s/m/u/smukerji/UVM_practice/sequencer.sv(6): (vlog-2730) Undefined variable: 'Packet'.

Probably it is a simple mistake. My two classes are as

//Sequence item
import uvm_pkg::*;
`include "uvm_macros.svh"

    class Packet extends uvm_sequence_item;

        typedef enum bit [1:0] {NO_ERROR, SINGLE_ERROR, DOUBLE_ERROR, MULTIPLE_ERROR} err_type;

        rand logic [127:0] correct_data_in;
        rand logic valid_in;
        logic [136:0] corrupted_data_in;
        rand logic corrupt_valid_in;
        rand bit error;
        rand bit [127:0] err_pos;
        randc err_type error_type;
        logic [136:0] corrupt_data;

        constraint type_of_error          { (error == 0) -> error_type == NO_ERROR;    }

        constraint error_sequence { 
            if (error_type == SINGLE_ERROR)         $countones(err_pos) inside {0,1};
            else if (error_type == DOUBLE_ERROR)    $countones(err_pos) inside {1,2};
            else if (error_type == MULTIPLE_ERROR)  $countones(err_pos) inside {2,127};
            else err_pos inside {0, 0};
                      }


        `uvm_object_utils_begin(Packet)
            `uvm_field_enum(err_type, error_type, UVM_ALL_ON)
            `uvm_field_int(correct_data_in, UVM_ALL_ON|UVM_NOPACK)
            `uvm_field_int(valid_in, UVM_ALL_ON|UVM_NOPACK)
            `uvm_field_int(corrupted_data_in, UVM_ALL_ON|UVM_NOPACK)
            `uvm_field_int(corrupt_valid_in, UVM_ALL_ON|UVM_NOPACK)
            `uvm_field_int(error, UVM_ALL_ON)
            `uvm_field_int(err_pos, UVM_ALL_ON)
        `uvm_object_utils_end

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

        function logic [136:0] create_corrupt_data;
            logic [136:0] corrupt_data;
            corrupt_data = err_pos ^ correct_data_in;
            return corrupt_data;
        endfunction

        //virtual function void do_pack (uvm_packer packer);
            //super.do_pack(packer);
            //`uvm_pack_int(correct_data_in);
            //`uvm_pack_int(valid_in);
            //`uvm_pack_int(corrupted_data_in);
            //`uvm_pack_int(corrupt_valid_in);
            //packer.pack_field_int(correct_data_in,$bits(correct_data_in));
            //packer.pack_field_int(valid_in,$bits(valid_in));
            //packer.pack_field_int(corrupted_data_in,$bits(corrupted_data_in));
            //packer.pack_field_int(corrupt_valid_in,$bits(corrupt_valid_in));
        //endfunction

        //virtual function void do_unpack (uvm_packer packer );
                //super.do_unpack(packer);
                //correct_data_in = packer.unpack_field_int($bits(correct_data_in));
            //valid_in = packer.unpack_field_int($bits(valid_in));
            //corrupted_data_in = packer.unpack_field_int($bits(corrupted_data_in));
            //corrupt_valid_in = packer.unpack_field_int($bits(corrupt_valid_in));
            //endfunction


    endclass

And, my sequencer.sv as

//Sequencer
import uvm_pkg::*;
`include "uvm_macros.svh"


typedef uvm_sequencer #(Packet) packet_sequencer;
1

1 Answers

4
votes

You most likely compiled these two code classes separately in separate files. Code compiled in one compilation unit is not visible to another compilation unit. You should be compiling classes into a package.

package my_stuff;
  `include "Packet.svh"
  `include "packet_sequencer.svh"
endpackage