• 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. Structs and dynamic arrays/queues

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 64
  • Views 6827
  • 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

Structs and dynamic arrays/queues

archive
archive over 17 years ago

Hi all, I'm trying to rewrite an e code to SV that includes a list of structs when those structs contain a list of structs themselves. The e code: As you can notice the code creates a 3-dimensions array which the size of one of its dimensions isn't predefined. The equivalent option for a list, which its size isn't predefined in SV, is a dynamic array or a queue. The problem is that none of them can be used as a data member in struct. I also tried to create a 3-D array with one of its dimension as a dynamic array but this failed also. Can anybody think of a way to implement it in SV?


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

    A "struct" in 'e' is equivalent to "class" [Dynamic] in SV. A "unit" in 'e' is equivalent [only static part] to "struct" in SV. I think this should solve the issue. Here all fields in basic structs have do-not-generate '!' in its definition. That means, user doesn't want to do any class randomization on these struct fields.

    Also, when the struct in instantiated [basic_struct_list_s] , instantiation also has do-not-generate. class basic_struct; int unsigned addr; int unsigned trans; int unsigned size; int unsigned write; int unsigned burst; int unsigned resp; int unsigned data; int unsigned data_x; endclass class basic_struct_list_s; basic_struct basic_struct_list []; endclass ... // master is a static array of basic_struct_list_s [size = 6]. Each item of arry is dynamic array of size 0. basic_struct_list_s master[6]; Tim (with help from Vishal)


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

    Excellent!
    This solved the problem!
    Thank you!!!!


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

    Hi again, I implemented the class basic_struct_list_s with a queue as a data member since I want to use some of the built in methods for queues. Is there a way to use these methods (in particular the find methods such as find_first(), find_first_index) when the queue is a queue of classes and other class data member? I tried to do it like this: < ... class basic_struct; uint lo_addr; uint hi_addr; string addr_name; endclass class basic_struct_list_c; basic_struct basic_struct_list[$]; endclass basic_struct temp_struct; basic_struct_list_c master[6]; ... initial begin temp_struct = new; for (i=0 ; i<6 ; i++ ) begin master[i] = new; end // for (i=0 ; i<6 ; i++ ) ... temp_struct = master[0].basic_struct_list.find_first((item.lo_addr<=4) && (item.hi_addr>=5)); ... end //initial > I received the folloeing error: temp_struct = master[0].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,QAANBI (test_program1.v,91|55): This is not a valid built in method name for this object. [SystemVerilog]. temp_struct = master[0].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,NOTFXX (test_program1.v,91|55): expecting a function name [10.3.3(IEEE)].


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

    Just posting the reply again in a more understandable way...

    Hi again, I implemented the class basic_struct_list_s with a queue as a data member since I want to use some of the built in methods for queues. Is there a way to use these methods (in particular the find methods such as find_first(), find_first_index) when the queue is a queue of classes and other class data member? I tried to do it like this:
     ... class basic_struct; uint lo_addr; uint hi_addr; string addr_name; endclass class basic_struct_list_c; basic_struct basic_struct_list[$] endclass basic_struct temp_struct; basic_struct_list_c master?] ... initial begin temp_struct = new; for (i=0 ; i<6 ; i++ ) begin master[i] = new; end // for (i=0 ; i<6 ; i++ ) ... temp_struct = master?].basic_struct_list.find_first((item.lo_addr<=4) && (item.hi_addr>=5)); ... end //initial I received the folloeing error: temp_struct = master?].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,QAANBI (test_program1.v,91|55): This is not a valid built in method name for this object. [SystemVerilog]. temp_struct = master?].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,NOTFXX (test_program1.v,91|55): expecting a function name ?.3.3(IEEE)].


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

    One more try...

    Hi again,
    I implemented the class basic_struct_list_s with a queue as a data member since I want to use some of the built in methods for queues. Is there a way to use these methods (in particular the find methods such as find_first(), find_first_index) when the queue is a queue of classes and other class data member? I tried to do it like this:

    < code > 
    ...
    class basic_struct;
          uint lo_addr;
          uint hi_addr;
          string addr_name;
    endclass

    class basic_struct_list_c;
          basic_struct basic_struct_list[$];
    endclass basic_struct temp_struct;

    basic_struct_list_c master[6]
    ...
    initial
    begin
          temp_struct = new;
          for (i=0 ; i<6 ; i++ )
                begin master[i] = new;
          end // for (i=0 ; i<6 ; i++ )
    ... 
          temp_struct = master[0].basic_struct_list.find_first((item.lo_addr<=4) && (item.hi_addr>=5)); ...
    end //initial
    < /code >

    I received the following error:


       temp_struct = master[0].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) );
                                                                                      |
    ncvlog: *E,QAANBI (test_program1.v,91|55): This is not a valid built in method name for this object. [SystemVerilog].
       temp_struct = master[0].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) );
                                                                                      |
    ncvlog: *E,NOTFXX (test_program1.v,91|55): expecting a function name [10.3.3(IEEE)].




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

    I use the "Add Reply" button instead of the Reply box at the bottom. I've found that I have better luck with formatting that way.

    Some of your code example was garbled but here is a working example that I think shows what you want to do:

    module test; class test_c; rand bit [3:0] a; endclass class test_list_c; test_c list_q [$]; endclass test_list_c tl = new; test_c qi[$]; test_c t; initial begin repeat (5) begin t = new; void'(t.randomize()); $display("t = %d", t.a); tl.list_q.push_back(t); end qi = tl.list_q.find_first with (item.a > 5); t = qi.pop_front(); $display("first item = %d", t.a); end endmodule
    Tim


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

    Hi Tim,
    Sorry for the late response. I've just tried to do what you had suggested but I still receive compilation errors. My code is very similar to the code you have given as an example and the compilation errors are same. If i try to compile your code I receive:
    qi = tl.list_q.find_first with (item.a > 5); ncvlog: *E,EXPSMC (test_program2.v,18|39): expecting a semicolon (';') [9.2.2(IEEE)]. qi = tl.list_q.find_first with (item.a > 5); ncvlog: *E,NOTSTT (test_program2.v,18|41): expecting a statement [9(IEEE)]. qi = tl.list_q.find_first with (item.a > 5); ncvlog: *E,MISEXX (test_program2.v,18|49): expecting an '=' or '<=' sign in an assignment [9.2(IEEE)]. qi = tl.list_q.find_first with (item.a > 5); ncvlog: *E,NOTSTT (test_program2.v,18|52): expecting a statement [9(IEEE)].

    Flanter


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

    Which version of IUS you are using? You should be using latest version available.


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

    I was using IUS 6.1.1-s003. With IUs 6.20-p001 it works!
    Thank you


    Originally posted in cdnusers.org by Flanter
    • 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