• 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 6829
  • 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
Parents
  • 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
Reply
  • 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
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