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: What is wrong with this code ? I'm trying to use a Queue of classes..
Posting to forums is available to community members only.
Login or Register
Rate this topic:
   
Author Messages
mirzani
Posts: 0
Online: User is Offline
12/14/2006 1:14 AM  
module top;
timeunit 1ns;

class genfra;
rand bit [31:0] dword1;
rand bit [31:0] dword2;
endclass :genfra

integer success,i,dly;
genfra temp1,temp2;

genfra fifo[$] ;
initial
begin
temp1=new();
for(i = 0 ; i < 20 ;i++)
begin
success = temp1.randomize();
success = randomize(dly) with {dly > 2;dly < 5;};
$display("time=%d.. temp1.dword1 = %08x ",$time,temp1.dword1);
$display("time=%d.. temp1.dword2 = %08x ",$time,temp1.dword2);
fifo.push_back(temp1);
#dly;
end
$finish;
end

initial
begin
#15;
forever
begin
$display("time=%d..before pop ",$time);
if(fifo.size())
begin
$display("fifo size before pop ",fifo.size());
temp2=fifo.pop_front();
$display("time=%d.. temp2.dword1 = %08x ",$time,temp2.dword1);
$display("time=%d.. temp2.dword2 = %08x ",$time,temp2.dword2);
$display("fifo size after pop ",fifo.size());
end
else
#1;
end
end

endmodule


I'm getting the following output.. The

temp2=fifo.pop_front();
doesn't seem to do what it should.. It prints the last object and doesn't remove it from the queue ..
can someone point out whats wrong!! (see
--????? below..)
ncverilog: 05.83-p002: (c) Copyright 1995-2006 Cadence Design Systems, Inc.
TOOL: ncverilog 05.83-p002: Started on Dec 14, 2006 at 13:49:26 IST
.
.
.
ncsim> run
SVSEED set from command line: 60
time= 0.. temp1.dword1 = e68182cd
time= 0.. temp1.dword2 = 0321b106
time= 4.. temp1.dword1 = 7bd6b7f7
time= 4.. temp1.dword2 = a9586452
time= 7.. temp1.dword1 = a51a824a
time= 7.. temp1.dword2 = c78e9c8f
time= 10.. temp1.dword1 = 9ba71c37
time= 10.. temp1.dword2 = 106de120
time= 13.. temp1.dword1 = 8798120f
time= 13.. temp1.dword2 = 3b6a8d76
time= 15..before pop
fifo size before pop 5
time= 15.. temp2.dword1 = 8798120f --?????
time= 15.. temp2.dword2 = 3b6a8d76 --?????
fifo size after pop 4
time= 15..before pop
fifo size before pop 4
time= 15.. temp2.dword1 = 8798120f --?????
time= 15.. temp2.dword2 = 3b6a8d76 --?????
fifo size after pop 3
time= 15..before pop
fifo size before pop 3
time= 15.. temp2.dword1 = 8798120f
time= 15.. temp2.dword2 = 3b6a8d76
fifo size after pop 2
time= 15..before pop
fifo size before pop 2
time= 15.. temp2.dword1 = 8798120f
time= 15.. temp2.dword2 = 3b6a8d76
fifo size after pop 1
time= 15..before pop
fifo size before pop 1
time= 15.. temp2.dword1 = 8798120f
time= 15.. temp2.dword2 = 3b6a8d76
fifo size after pop 0
time= 15..before pop
time= 16..before pop
time= 17.. temp1.dword1 = 8e68b41c
time= 17.. temp1.dword2 = 5e7ba1bc
time= 17..before pop
fifo size before pop 1
time= 17.. temp2.dword1 = 8e68b41c
time= 17.. temp2.dword2 = 5e7ba1bc
fifo size after pop 0
time= 17..before pop
time= 18..before pop
time= 19..before pop
time= 20..before pop
time= 21.. temp1.dword1 = 2a916b55
time= 21.. temp1.dword2 = 0dcdad1b
time= 21..before pop
fifo size before pop 1
time= 21.. temp2.dword1 = 2a916b55
time= 21.. temp2.dword2 = 0dcdad1b
fifo size after pop 0
time= 21..before pop
time= 22..before pop
time= 23..before pop
time= 24.. temp1.dword1 = bdfc1c7b
time= 24.. temp1.dword2 = e2a8aec5
time= 24..before pop
fifo size before pop 1
time= 24.. temp2.dword1 = bdfc1c7b
time= 24.. temp2.dword2 = e2a8aec5

.
.
.
 

Thanks..
kameade
Posts: 13
Online: User is Offline
12/14/2006 4:49 AM  
Hello,

I looked at your code and see that you are only calling new() once during the simulation.  So it is only allocating space for one genfra class item.  When you place the item on the queue, you are actually only placing the pointer to genfra.  So it will always remember the last item you randomized.

To fix the problem, move the temp1=new() inside the for-loop.  It will generate a new item every time.

initial
  begin
     for (i=0; i<20; i++)
        begin
           temp1=new();  // MOVE HERE!
            success = temp1.randomize();
  ....

I hope this helps!

Kathleen Meade
mirzani
Posts: 0
Online: User is Offline
12/14/2006 5:24 AM  
Thanks..
Posting to forums is available to community members only.
Login or Register

Forums > Functional Verification > SystemVerilog > What is wrong with this code ? I'm trying to use a Queue of classes..


ActiveForums 3.6
     
Copyright 2006 Cadence Design Systems, Inc.