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: A question about randomize()
Posting to forums is available to community members only.
Login or Register
Rate this topic:
   
Author Messages
jt27560
Posts: 2
Online: User is Offline
10/01/2007 4:10 AM  
In the following code,  when BCDA.randomize() is excuted, it seems to me methd ADD() is also excuted at same time even though it is not explicitly called. How does randomize() work exactly? Thanks in advance!

//BCD addition testbench
//www.asichowto.com

module BCDAddition_tb();

class BCDAdd;
    rand logicΑ:0] BCD1,BCD2;
    logicΕ:0] result;
    
    function new();
        BCD1=0;
        BCD2=0;
    endfunction
    
    constraint c
    {
        BCD1<10;
        BCD2<10;
    }

    function void ADD();
        result=BCD1+BCD2;
        if(result>9)
           result=result+6;
    endfunction
endclass



BCDAdd BCDA;
logicΑ:0] b1,b2;
logicΕ:0] r;

BCDAddition U(b1,b2,r);

initial
begin
    repeat(10)
    begin
        BCDA=new;
        if(BCDA.randomize())
        begin
            b1=BCDA.BCD1;
            b2=BCDA.BCD2;
//            BCDA.ADD();
            if(r!=BCDA.result)
            begin
                $display("Class:  BCD1=%d BCD2=%d result=%d", BCDA.BCD1,BCDA.BCD2,BCDA.result);
                $display("Module: BCD1=%d BCD2=%d result=%d", b1,b2,r);
            end
        end
        #10ns;
    end
end
endmodule
stephenh
Posts: 77
Online: User is Offline
10/01/2007 4:29 AM  
Why do you think ADD() is called?
I don't see anything that calls it explicitly (ignoring the commented out line).
I pasted this code into a file and it ran without calling ADD()...

Steve H.
jt27560
Posts: 2
Online: User is Offline
10/02/2007 3:06 PM  
Thanks, Steve.

It does not display anything whether I comment out BCDA.ADD() or not, which gives me an impression that ADD() is executed too when randomize is executed.
I should use !== instead of !=. And should put a delay right after ADD();
kameade
Posts: 13
Online: User is Offline
10/02/2007 3:22 PM  
Hello,

In your example above, ADD is not called unless it is called specifically via the BCDA.ADD() function call. What's happening in your code is that the begin/end block after calling randomize() executes to completion before the BCDAddition() module instance is evaluated so you are getting strange results. If you put a delay after the b1/b2 assignments, you will get the expected behavior.

I hope this helps.

Kathleen
Posting to forums is available to community members only.
Login or Register

Forums > Functional Verification > SystemVerilog > A question about randomize()


ActiveForums 3.6
     
Copyright 2006 Cadence Design Systems, Inc.