Thursday, January 08, 2009     Register | Login | Search | Contact Us
     

Many of you already received communications about the move of the Cadence user community into cadence.com. And many of you have already joined, with over 4000 registrations in the first two weeks.

The new Cadence Community enhances the ability of Cadence users to connect and collaborate. In addition to moving the community into cadence.com -- enabling single sign-on for community, Sourcelink and Cadence events -- the new site is organized around nine technology segments, giving you easy access to product information, training, forums and blogs. Some of the new features include:
  • Ability to respond to posts via e-mail
  • Technology-specific blogs
  • Latest Web 2.0 social networking capabilities
  • Public profile options
  • Private messaging
  • Friends lists
Visit the new Cadence Community today at www.cadence.com/community and join the discussions!

Registration note: Due to the scope of the enhancements and the new SSO registration system, we were not able to migrate existing cdnusers.org member accounts. So new registrations are required, but this enables a broader set of functionality we think you'll enjoy.

Forum note: Under the guidance of forum moderators, we have taken the 20+ cdnusers.org forums and consolidated them into 11 forums on the new site. Posts have been brought over so you can leverage that posting history. CDNusers forums will be set to read only starting 7/30, and cdnusers.org will be redirected to the new community on 8/4.

Best regards,
Mike and Tom

Michael A. Catrambone - Steering Committee Chairman
Distinguished Engineer
PCB/Mechanical
UTStarcom, Inc.

Tom Diederich
Cadence Community Manager
Home
Forums
Subject: Structs and dynamic arrays/queues
Posting to forums is available to community members only.
Login or Register
Rate this topic:
   
Author Messages
Flanter
Posts: 7
Online: User is Offline
3/10/2008 8:14 AM  
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: < ... struct basic_struct { !addr : uint; !trans : uint; !size : uint; !write : uint; !burst : uint; !resp : uint; !data : uint; !data_x : uint; }; struct basic_struct_list_s { !basic_struct_list : list of basic_struct ; }; ... masterΔ] : list of basic_struct_list_s; ... > 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?
tpylant
Posts: 87
Online: User is Offline
3/10/2008 9:42 AM  
A "struct" in 'e' is equivalent to "class" [Dynamic] in SV. A "unit" in 'e' is equivalent [only static part] to "struct" in SV. I think this should solve the issue. Here all fields in basic structs have do-not-generate '!' in its definition. That means, user doesn't want to do any class randomization on these struct fields.

Also, when the struct in instantiated [basic_struct_list_s] , instantiation also has do-not-generate.

class basic_struct;
   int unsigned addr; 
   int unsigned trans; 
   int unsigned size; 
   int unsigned write; 
   int unsigned burst; 
   int unsigned resp; 
   int unsigned data; 
   int unsigned data_x; 
endclass 

class basic_struct_list_s;
  basic_struct basic_struct_list [] 
endclass
 ... 

// master is a static array of basic_struct_list_s [size = 6]. Each item of arry is dynamic array of size 0.
basic_struct_list_s masterΔ] 
Tim (with help from Vishal)
Flanter
Posts: 7
Online: User is Offline
3/12/2008 12:47 AM  
Excellent!
This solved the problem!
Thank you!!!!
Flanter
Posts: 7
Online: User is Offline
3/12/2008 1:42 AM  
Hi again, I implemented the class basic_struct_list_s with a queue as a data member since I want to use some of the built in methods for queues. Is there a way to use these methods (in particular the find methods such as find_first(), find_first_index) when the queue is a queue of classes and other class data member? I tried to do it like this: < ... class basic_struct; uint lo_addr; uint hi_addr; string addr_name; endclass class basic_struct_list_c; basic_struct basic_struct_list[$] endclass basic_struct temp_struct; basic_struct_list_c masterΔ] ... initial begin temp_struct = new; for (i=0 ; i<6 ; i++ ) begin master[i] = new; end // for (i=0 ; i<6 ; i++ ) ... temp_struct = masterΎ].basic_struct_list.find_first((item.lo_addr<=4) && (item.hi_addr>=5)); ... end //initial > I received the folloeing error: temp_struct = masterΎ].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,QAANBI (test_program1.v,91|55): This is not a valid built in method name for this object. [SystemVerilog]. temp_struct = masterΎ].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,NOTFXX (test_program1.v,91|55): expecting a function name ⎖.3.3(IEEE)].
Flanter
Posts: 7
Online: User is Offline
3/12/2008 1:49 AM  
Just posting the reply again in a more understandable way...

Hi again, I implemented the class basic_struct_list_s with a queue as a data member since I want to use some of the built in methods for queues. Is there a way to use these methods (in particular the find methods such as find_first(), find_first_index) when the queue is a queue of classes and other class data member? I tried to do it like this:
 ... class basic_struct; uint lo_addr; uint hi_addr; string addr_name; endclass class basic_struct_list_c; basic_struct basic_struct_list[$] endclass basic_struct temp_struct; basic_struct_list_c masterΔ] ... initial begin temp_struct = new; for (i=0 ; i<6 ; i++ ) begin master[i] = new; end // for (i=0 ; i&lt;6 ; i++ ) ... temp_struct = masterΎ].basic_struct_list.find_first((item.lo_addr&lt;=4) &amp;&amp; (item.hi_addr>=5)); ... end //initial 
I received the folloeing error: temp_struct = masterΎ].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,QAANBI (test_program1.v,91|55): This is not a valid built in method name for this object. [SystemVerilog]. temp_struct = masterΎ].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) ); | ncvlog: *E,NOTFXX (test_program1.v,91|55): expecting a function name ⎖.3.3(IEEE)].
Flanter
Posts: 7
Online: User is Offline
3/12/2008 1:59 AM  

One more try...

Hi again,
I implemented the class basic_struct_list_s with a queue as a data member since I want to use some of the built in methods for queues. Is there a way to use these methods (in particular the find methods such as find_first(), find_first_index) when the queue is a queue of classes and other class data member? I tried to do it like this:

< code > 
...
class basic_struct;
      uint lo_addr;
      uint hi_addr;
      string addr_name;
endclass

class basic_struct_list_c;
      basic_struct basic_struct_list[$]
endclass basic_struct temp_struct;

basic_struct_list_c masterΔ]
...
initial
begin
      temp_struct = new;
      for (i=0 ; i<6 ; i++ )
            begin master[i] = new;
      end // for (i=0 ; i<6 ; i++ )
... 
      temp_struct = masterΎ].basic_struct_list.find_first((item.lo_addr<=4) && (item.hi_addr>=5)); ...
end //initial
< /code >

I received the following error:

<BR><BR>   temp_struct = masterΎ].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) );<BR>                                                                                  |<BR>ncvlog: *E,QAANBI (test_program1.v,91|55): This is not a valid built in method name for this object. [SystemVerilog].<BR>   temp_struct = masterΎ].basic_struct_list.find_first( (item.lo_addr<=4) && (item.hi_addr>=5) );<BR>                                                                                  |<BR>ncvlog: *E,NOTFXX (test_program1.v,91|55): expecting a function name ⎖.3.3(IEEE)].<BR><BR>


tpylant
Posts: 87
Online: User is Offline
3/12/2008 9:07 AM  
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 Α: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
Flanter
Posts: 7
Online: User is Offline
3/19/2008 3:00 AM  
Hi Tim,
Sorry for the late response. I've just tried to do what you had suggested but I still receive compilation errors. My code is very similar to the code you have given as an example and the compilation errors are same. If i try to compile your code I receive:

    qi = tl.list_q.find_first       with (item.a > 5);
ncvlog: *E,EXPSMC (test_program2.v,18|39): expecting a semicolon (';') Η.2.2(IEEE)].
    qi = tl.list_q.find_first       with (item.a > 5);
ncvlog: *E,NOTSTT (test_program2.v,18|41): expecting a statement Η(IEEE)].
    qi = tl.list_q.find_first       with (item.a > 5);
ncvlog: *E,MISEXX (test_program2.v,18|49): expecting an '=' or '<=' sign in an assignment Η.2(IEEE)].
    qi = tl.list_q.find_first       with (item.a > 5);
ncvlog: *E,NOTSTT (test_program2.v,18|52): expecting a statement Η(IEEE)].



Flanter
pjigar
Posts: 22
Online: User is Offline
3/19/2008 8:30 AM  
Which version of IUS you are using? You should be using latest version available.

Jigar Patel
Lead Consulting Engineer
Cadence Design Systems
jigar@cadence.com
Flanter
Posts: 7
Online: User is Offline
3/23/2008 3:08 AM  
I was using IUS 6.1.1-s003. With IUs 6.20-p001 it works!
Thank you
Posting to forums is available to community members only.
Login or Register

Forums > Functional Verification > SystemVerilog > Structs and dynamic arrays/queues


ActiveForums 3.6
     
Copyright 2006 Cadence Design Systems, Inc.