• 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. how to enumerate the fields of all the registers in vr_...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 66
  • Views 14906
  • 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

how to enumerate the fields of all the registers in vr_ad_reg_file

FlyingHeart
FlyingHeart over 11 years ago

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?

  • Cancel
  • StephenH
    StephenH over 11 years ago

    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.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FlyingHeart
    FlyingHeart over 11 years ago

     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.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 11 years ago

    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;
          };
        };
      };

    };

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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