• 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. Efficiency of associative array

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 64
  • Views 6354
  • 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

Efficiency of associative array

Jeff000
Jeff000 over 7 years ago

Hi,
So far as I know, the associative array has better performance in searching items than SV queue.

But in practice the improvement seems not as significant as expected when the index keep growing. E.g, my ENV implemented dummy memory as associative array, where the address is taken as the index_type and the corresponding byte as data_type.

I am wondering if there's any mechanism in Cadence SV to dynamically update the internal hash table to save time on looking up the array item as the array grows bigger and bigger?

  • Cancel
Parents
  • StephenH
    StephenH over 7 years ago

    The simulator uses various algorithms and optimisations for these things, there isn't any end-user control over them. I would suggest that you file a support ticket and share a testcase with the support engineer, so that the R&D team can investigate whether your particular case could be optimised either in the SV code or in the tool itself.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jeff000
    Jeff000 over 7 years ago in reply to StephenH

    I think I've found the cause. It's really bad practice to call 'find with...' function for associative array. A benchmark of locator method for various vectors, like dynamic array, associative array and queue, tells that the performance would drop tremendously if the 'find with...' method was applied on associative array. Admittedly, if we locate the associative array through its index directly, it behaves as expected.

    Though it's not likely to locate the associative array through 'find with...' method instead of its intuitive index, there's chance when users have to apply some complex expression to 'find with...' method, e.g, a_array.find with (item.addr >= MIN; item.addr <= MAX; item.attr == 1;...), where as a result the performance might heavily be impacted. In this case, it's embarrassed when user initially takes advantage of associative array for efficient locating and some time later, he/she somehow has to apply 'find with...' method on the associative array as well.

    Do you have any suggestion on how to balance the pros and cons of associative array?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Tudor Timi
    Tudor Timi over 7 years ago in reply to Jeff000

    Seems like you're looking for a free lunch. 'find with' is inherently expensive, because it has to loop over all elements to find which ones satisfy your expression.

    For your 'a_array.find with (item.address == end_addr)' example that is slow you're comparing apples against oranges. On one side you have an array indexed by address and on the other side you have an array indexed by the item reference itself. You can't draw any conclusions regarding performance from such an experiment...

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jeff000
    Jeff000 over 7 years ago in reply to Tudor Timi

    The point is that 'find with' is slow especially for associative array.
    If apply 'find with' on queue, dynamic array, and associative array respectively with the same expression, we can see the queue and dynamic array cost almost the same time while the associative array spent much more.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Jeff000
    Jeff000 over 7 years ago in reply to Tudor Timi

    The point is that 'find with' is slow especially for associative array.
    If apply 'find with' on queue, dynamic array, and associative array respectively with the same expression, we can see the queue and dynamic array cost almost the same time while the associative array spent much more.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Tudor Timi
    Tudor Timi over 7 years ago in reply to Jeff000

    Set is inherently less iteration friendly than list.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jeff000
    Jeff000 over 7 years ago in reply to Tudor Timi

    Thank you for you comments.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 7 years ago in reply to Jeff000

    Incisive is a legacy product and isn't being developed any more. Its replacement, Xcelium, has many enhancements and optimisations, so if you are concerned about performance, please consider upgrading to Xcelium.

    I would also suggest that rather than worrying about benchmarking individual language features, you'd be better off profiling your real testbench and seeing what are the biggest time consumers overall for a full regression suite. You will probably find that the associative array look-ups are not significant compared to other code that you've written, that you could optimise yourself. Even if VCS is 3x faster to index an associative array, if it's only taking maybe 1% of the simulation time (random number in lieu of real data) then making it 3x faster will save you 0.66% of your regression time. Hardly worth shouting about Slight smile

    Finally, please, for your own benefit, think carefully before posting comparative benchmarking data in public, you might well be violating licence conditions from Cadence and Synopsys, which could land you or your employer in trouble...

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Jeff000
    Jeff000 over 7 years ago in reply to StephenH

    Thank you for your kind suggestion and sorry for my haste. I will recall my post for the comparative data.

    Yes, you're right. The profiling shows I've called so much uvm_top.find() in my testbench, which is the bottleneck for my regression time.

    • 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