• 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. No run time error for out of boundry access to array

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 64
  • Views 15262
  • 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

No run time error for out of boundry access to array

archive
archive over 17 years ago

Hi, The following code: module x; bit[1:0] y[]; initial begin y = new[2]; y[0] = 2; y[1] = 3; for (int i=0; i


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

    In standard Verilog, out-of-bounds array access is permitted by the HDL language. The value returned is simply 'bx or the unknown value. This is the way that hardware would work, you can index with an invalid address and the hardware will return something, you just don't know what it will be.

    Since you are using an array of 'bit', you won't see an unknown value returned since 'bit' is only 2-state. So instead you see 'b0 as the return value.

    Here's what the SV LRM says in section 5.3.

    If an index expression is out of the address bounds or if any bit in the address is X or Z, then the index shall
    be invalid. The result of reading from an array with an invalid index shall return the default uninitialized
    value for the array element type.


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

    In standard Verilog, out-of-bounds array access is permitted by the HDL language. The value returned is simply 'bx or the unknown value. This is the way that hardware would work, you can index with an invalid address and the hardware will return something, you just don't know what it will be.

    Since you are using an array of 'bit', you won't see an unknown value returned since 'bit' is only 2-state. So instead you see 'b0 as the return value.

    Here's what the SV LRM says in section 5.3.

    If an index expression is out of the address bounds or if any bit in the address is X or Z, then the index shall
    be invalid. The result of reading from an array with an invalid index shall return the default uninitialized
    value for the array element type.


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