Home > Community > Forums > Functional Verification > how to enumerate the fields of all the registers in vr_ad_reg_file

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 how to enumerate the fields of all the registers in vr_ad_reg_file 

Last post Mon, Apr 14 2014 1:48 AM by StephenH. 3 replies.
Started by FlyingHeart 03 Apr 2014 09:28 PM. Topic has 3 replies and 198 views
Page 1 of 1 (4 items)
Sort Posts:
  • Thu, Apr 3 2014 9:28 PM

    how to enumerate the fields of all the registers in vr_ad_reg_file Reply

    I need to do a full read/write/softreset test on register module and need to enumerate the fields of all the registers, but I checked the help documents and didn't find the solution. Could anyone tell me how to enumerate that?

    • Post Points: 20
  • Fri, Apr 4 2014 2:00 AM

    • StephenH
    • Top 25 Contributor
    • Joined on Tue, Sep 2 2008
    • Bristol, Avon
    • Posts 268
    • Points 4,310
    Re: how to enumerate the fields of all the registers in vr_ad_reg_file Reply

    You need first to declare all your registers using the reg_def macro. Have a look at the examples under `sn_which.sh vr_ad`/examples/ directory. The file vr_ad_reg_def_example.e would be a good starting point.

    You will see a number of lines like this:

    reg_def  VR_AD_TX_MODE  XCORE  8'h01 {
       reg_fld resv       : uint(bits:4) : RW : 0;                    // bits[7:4]
       reg_fld frame_kind : vr_ad_tx_mode_frame_kind : RW : A : cov;  // bits[3:2]
       reg_fld dest       : uint(bits:2) : RW : 0;                    // bits[1:0]
    };

     
    reg_def declares the register itself, and reg_fld enumerates the fields of the register from MSB down to LSB, as per the comments. You can use any numeric type to declare the fields, including enumerated types.

    As for the read/write/reset tests, vr_ad supplies a number of sequences that do this, either on a whole reg file or a user-defined subset. Take a look at vr_ad_reg_sequence_lib.e to see how the sequences are defined and how to use them. You can copy these and edit them if they don't do exactly what you want.

     

    Steve Hobbs / Applications Engineer / Cadence Functional Verification
    • Post Points: 20
  • Sun, Apr 13 2014 7:38 PM

    Re: how to enumerate the fields of all the registers in vr_ad_reg_file Reply

     Hi StephenH,

       Maybe I didn't make it clear. I mean I have all register definition, and now I plan to iterate registers to do the check on every register, in this scenario,  I could not use the specific register fields because every register has different fieids definition, I need a method like that in linked-list of high-level language to iterate all the fields. If I write code on specific fields, then the code will be very tedious and redundant.

    • Post Points: 20
  • Mon, Apr 14 2014 1:48 AM

    • StephenH
    • Top 25 Contributor
    • Joined on Tue, Sep 2 2008
    • Bristol, Avon
    • Posts 268
    • Points 4,310
    Re: how to enumerate the fields of all the registers in vr_ad_reg_file Reply

    Hi.

    Thanks for clarifying your request.

    If you look at the register sequences that I previously pointed you to, you'll see how it's possible to do reset/read/write tests on the entire register model without having to write any specific code. Now, this is done register by register, not field by field. I can't see why you'd want to test each field separately, and never heard of anyone doing that.

    Still, if you really do want to test every field separately, it's not too hard. We don't need to construct complicated linked lists, simply use the powerful reflection (introspection) mechanism built into e. Reflection enables you to take a pointer to a vr_ad_reg, find out what (physical) fields it has, and iterate over them. You'd probably want to start from the example sequences I showed you, modifying them so that after they select a register to work on, you then use reflection to get a list of the fields, and iterate on the fields instead of simply do-ing the selected register...

     Here's a little vr_ad + reflection example I did for someone recently. This example simply allows you to test for the existence of, and then read, a named field in a register, so it's not quite what you would need, but hopefully it's enough to give you a flavour of how reflection works, and why e is such a powerful language!

    extend vr_ad_reg {
      // Read a reg field by name, returning TRUE if the named field exists
      // or FALSE if the field does not exist in this exact reg subtype.
      // Data is returned in data.
      read_field( field_name : string, data : *vr_ad_data_t ) : bool is {
        result = FALSE;
        var rf_s := rf_manager.get_exact_subtype_of_instance(me); // returns an rf_struct
        var rf_field := rf_s.get_field( field_name ); // returns NULL if no such field
        if ( NULL != rf_field ) {
          var rf_value := rf_field.get_value(me); // returns rf_value_holder
          // check it's an integral type not a struct unit pointer etc!
          if ( rf_value.get_type() is a rf_scalar ) {
            data = rf_value.get_value().as_a(vr_ad_data_t);  // returns untyped
            result = TRUE;
          };
        };
      };

    };

    Steve Hobbs / Applications Engineer / Cadence Functional Verification
    • Post Points: 5
Page 1 of 1 (4 items)
Sort Posts:
Started by FlyingHeart at 03 Apr 2014 09:28 PM. Topic has 3 replies.