• 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. array access thorugh a variable (non costant expression...

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 64
  • Views 19719
  • 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

array access thorugh a variable (non costant expression)

archive
archive over 18 years ago

I have this metodology issue.
The access to an array (index of the array) is allowed only to be  a constant expression.
In case of a parametric array (the size of the array is a parameter) in order to mux a sub-part of the vector I use an expression of this type:

i_rdata[(px_max-cmd_exe_cnt_d1*shm_width)*px_width-1:(px_max-cmd_exe_cnt_d1*shm_width-shm_width)*px_width] = rdata_shram;

where cmd_exe_cnt_d1 is a variable and others are constant.

Obviously I get an error about the usage of a non costant expression, following reported.


Compiling SHM component...
file: /IPREUSE/DATABASE/INTERNAL/DIG/INPROGRESS/gborgo/simd_A0_a/config/../generic/rtl/svlog/shm.v
    i_rdata[(px_max-cmd_exe_cnt_d1*shm_width)*px_width-1:(px_max-cmd_exe_cnt_d1*shm_width-shm_width)*px_width] = rdata_shram;
                                 |
ncvlog: *E,NOTPAR (/IPREUSE/DATABASE/INTERNAL/DIG/INPROGRESS/gborgo/simd_A0_a/config/../generic/rtl/svlog/shm.v,377|33): Illegal operand for constant expression [4(IEEE)].
    i_rdata[(px_max-cmd_exe_cnt_d1*shm_width)*px_width-1:(px_max-cmd_exe_cnt_d1*shm_width-shm_width)*px_width] = rdata_shram;


I found a simple work-around using a case structure:

      unique case (cmd_exe_cnt_d1)
        0      : i_rdata[(px_max-0*shm_width)*px_width-1:(px_max-0*shm_width-shm_width)*px_width] = rdata_shram;
        1      : i_rdata[(px_max-1*shm_width)*px_width-1:(px_max-1*shm_width-shm_width)*px_width] = rdata_shram;

....
...
...

        31     : i_rdata[(px_max-1*shm_width)*px_width-31:(px_max-31*shm_width-shm_width)*px_width] = rdata_shram;
        default:  i_rdata = 0;
      endcase   



but in this case I have an implicit limitation on the upper limit of the vector size. In this case 31 elements.

Is there any other mode to address this methodology issue ?

The code must be synthesizable.

Thanks
BR
Giampiero


Originally posted in cdnusers.org by borgonov69
  • Cancel
  • archive
    archive over 18 years ago

    When you use the [a:b] syntax to select a slice of a vector, both expressions need to be compile-time constants. But you can vary the bit range if you specify the left-hand-bit using a variable and keep a fixed width using [a -: width] or [a +: width].

    i_rdata[(px_max-cmd_exe_cnt_d1*shm_width)*px_width-1-:px_width] = rdata_shram;


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