• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. Packing of Random variables into List of bytes

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 64
  • Views 13899
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Packing of Random variables into List of bytes

archive
archive over 17 years ago

Example:

// class -1
  class fc_field;
   
    rand bit [1:0] protocol_ver;
      constraint pro_ver {
          protocol_ver == 0;
      }
 
    rand bit [1:0] pkt_type;
      constraint Pkt_type {
          pkt_type == 2;
      }
 
    rand bit [3:0] pkt_sub_type;
      constraint Pkt_sub_type {
          pkt_sub_type == 11;
      }
 
    rand bit to_ds;
      constraint To_ds {
          to_ds == 0;
      }
 
    rand bit from_ds;
      constraint From_ds {
          from_ds == 0;
      }
 
    rand bit more_fragment;
      constraint More_fragment {
          more_fragment == 0;
      }
 
    rand bit retry;
      constraint Retry {
          retry == 1;
      }
 
    rand bit pwr_mgmt;
      constraint Pwr_mgmt {
          pwr_mgmt == 0;
      }
 
    rand bit more_data;
      constraint More_data {
          more_data == 0;
      }
 
    rand bit protected_frame;
      constraint Protected_frame {
          protected_frame == 1;
      }
 
    rand bit order;
      constraint Order {
          order == 1;
      }
 
  endclass
 
// Class-2

  class seq_control_field;
   
    rand bit [3:0] fragment_number;
      constraint Fragment_number {
          fragment_number == 0;
      }

    rand bit [11:0] sequence_number;
      constraint Sequence_number {
          sequence_number == 0;
      }

  endclass   

// Main Class. This instantiates the fc_field and seq_control_field class objects

  class mac_header;
   
    rand fc_field fc_obj = new();       // Object of fc_field
   
    rand bit [15:0] duration_id;
      constraint Duration_id {
          duration_id == 0;
      }

    rand bit [47:0] address_1;
      constraint Address_1 {
          address_1 == 48'h001122334455;
      }

    rand bit [47:0] address_2;
      constraint Address_2 {
          address_2 == 48'h009988776655;
      }

    rand bit [47:0] address_3;

    rand seq_control_field seq_obj = new();      // Object of fc_field

    rand bit [47:0] address_4;

    rand bit [15:0] qos;
      constraint Qos {
          qos == 16'h0000;
      }

  endclass   

In the above example, how can i pack the mac_header into list of bytes? This shouldn't affect the constraints on the class member functions, of all the threee different classes.

Also, is there any way to print the class object?

All of the above can be done eeasily in specman, is it possible in the systemverilog implicitly?

-Vivek Prasad


Originally posted in cdnusers.org by prasad_vc
  • Cancel
Parents
  • archive
    archive over 17 years ago

    NCSim is giving error for that statement. "Illegal Expression Primary".



    I would imagine that may be Unsupported in your version. Write a simple function to to the pack - make it hierarchical - each class will pack its own contents and the derived classes would simply use the super.pack() and build on it.

    HTH
    Ajeetha, CVC
    www.noveldv.com


    Originally posted in cdnusers.org by ajeetha
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • archive
    archive over 17 years ago

    NCSim is giving error for that statement. "Illegal Expression Primary".



    I would imagine that may be Unsupported in your version. Write a simple function to to the pack - make it hierarchical - each class will pack its own contents and the derived classes would simply use the super.pack() and build on it.

    HTH
    Ajeetha, CVC
    www.noveldv.com


    Originally posted in cdnusers.org by ajeetha
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information