Verification Guild
A Community of Verification Professionals

 Create an AccountHome | Calendar | Downloads | FAQ | Links | Site Admin | Your Account  

Login
Nickname

Password

Security Code: Security Code
Type Security Code
BACKWARD

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Modules
· Home
· Downloads
· FAQ
· Feedback
· Recommend Us
· Web Links
· Your Account

Advertising

Who's Online
There are currently, 93 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

  
Verification Guild: Forums

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile  ProfileDigest    Log inLog in 

sv : associative array class as key

 
Post new topic   Reply to topic    Verification Guild Forum Index -> Main
View previous topic :: View next topic  
Author Message
sharanbr
Senior
Senior


Joined: Sep 27, 2004
Posts: 194

PostPosted: Fri Sep 28, 2007 7:19 am    Post subject: sv : associative array class as key Reply with quote

Has anyone used ass array with class objects as the key. I get compilation error (line AssArr[x] is declared) when I try the following code ..

Code:

module AssClass ;

  class x ;
  endclass

  integer AssArr[x];

  initial
  begin
    x x_i1 ;
    x x_i2 ;

    x_i1 = new;
    x_i2 = new;

    AssArr[x_i1] = 20 ;
    AssArr[x_i2] = 30 ;
  end
endmodule
Back to top
View user's profile
carolina
Junior
Junior


Joined: Sep 03, 2007
Posts: 5
Location: Brazil

PostPosted: Fri Sep 28, 2007 8:50 am    Post subject: Reply with quote

Hi,
My name is Carolina and I'm a SystemVerilog beginner. I don't know if I had understand your code, but I will try to help you.
So, first you had define a class called x.. After, you try to create a Integer array called AssArr[] using x to represent the array size.
But, is possible to use a class to represent an integer value?
Back to top
View user's profile
avidane
Senior
Senior


Joined: Feb 17, 2006
Posts: 34
Location: Jerusalem, Israel

PostPosted: Fri Sep 28, 2007 9:04 am    Post subject: Your code is perfectly legal... Reply with quote

Hi,
It compiles and runs perfectly on Questa 6.3...

Carolina: x is not representing the array size but the type of the index. This is an associative array, not an ordinary array.

Avidan Efody
Verilab
www.specman-verification.com
Back to top
View user's profile Visit poster's website
carolina
Junior
Junior


Joined: Sep 03, 2007
Posts: 5
Location: Brazil

PostPosted: Fri Sep 28, 2007 9:29 am    Post subject: Reply with quote

Hi Avidan,
Thank you for the replay. Wink
Back to top
View user's profile
sharanbr
Senior
Senior


Joined: Sep 27, 2004
Posts: 194

PostPosted: Fri Sep 28, 2007 12:43 pm    Post subject: Reply with quote

Thanks Avidan,

I will give a try on questa and see what happens ..
Back to top
View user's profile
AKSI
Junior
Junior


Joined: Aug 21, 2007
Posts: 7

PostPosted: Mon Oct 01, 2007 9:32 am    Post subject: Reply with quote

I have some problems with associative arrays as well, but when I changed the "indexing type" to wildcard (*), I no longer got the error and it's running fine. As long as your indexing type is integral, using wildcard is one way to bypass the error (although this would be the laziest way to do things).
Back to top
View user's profile
dave_59
Senior
Senior


Joined: Jun 22, 2004
Posts: 981
Location: Fremont, CA

PostPosted: Mon Oct 01, 2007 12:33 pm    Post subject: Reply with quote

AKSI wrote:
I have some problems with associative arrays as well, but when I changed the "indexing type" to wildcard (*), I no longer got the error and it's running fine. As long as your indexing type is integral, using wildcard is one way to bypass the error (although this would be the laziest way to do things).


I strongly do not recommend ever using the wildcard index type. Use an integral type large enough to hold whatever value you expect to use an an index. The problem with the wildcard index type is that you can't use other features like foreach or the find() methods because the the wildcard index does not have a fixed type. (This is being clarified in P1800-2008)

Dave
Back to top
View user's profile Send e-mail Visit poster's website
AKSI
Junior
Junior


Joined: Aug 21, 2007
Posts: 7

PostPosted: Mon Oct 01, 2007 1:00 pm    Post subject: Reply with quote

dave_59 wrote:
I strongly do not recommend ever using the wildcard index type. Use an integral type large enough to hold whatever value you expect to use an an index. The problem with the wildcard index type is that you can't use other features like foreach or the find() methods because the the wildcard index does not have a fixed type. (This is being clarified in P1800-2008)

Dave


Thanks for the tip~
Back to top
View user's profile
sraman
Newbie
Newbie


Joined: Mar 22, 2005
Posts: 1

PostPosted: Tue Nov 29, 2011 6:40 pm    Post subject: Reply with quote

Hi Dave,
I was able to use foreach and find in assoc array.
can you pls. clarify what do you mean by "you can't use other features like foreach or the find() methods because the the wildcard index does not have a fixed type."
Thanks,
Sathya
Back to top
View user's profile
dave_59
Senior
Senior


Joined: Jun 22, 2004
Posts: 981
Location: Fremont, CA

PostPosted: Wed Nov 30, 2011 1:18 pm    Post subject: Reply with quote

The following code is illegal as defined by the 1800-2009 LRM.
Code:
module top;
   bit list[*];
   bit [8*23:1] line1 = "a line of 23 characters";
   bit [8*29:1] line2 = "another line of 29 characters";
   bit [8*31:1] line3;
   
   initial begin
      list[line1] = 1;
      list[line2] = 1;
      foreach(list[line]) // What is the data type of line????
        begin
           line3 = {"\"",line,"\""};
           $display("%s",line3);
        end
   end
endmodule
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Verification Guild Forum Index -> Main All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Verification Guild ? 2006 Janick Bergeron
Web site engine's code is Copyright © 2003 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.284 Seconds