cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
5,401 Views
Registered: ‎03-02-2015

Per-thread random seed

I'm trying to write a SystemVerilog testbench which does something like this:

 

fork
    begin
        // Drive bus master #1 with random commands
    end

    begin
        // Drive bus master #2 with random commands
    end
join

When I do this, each thread receives the same random seed, which is all good -- that's the defined behavior in the LRM. However, I'd like to override that and give each thread a unique random seed so that the two bus masters aren't executing the same sequence.

 

As far as I can tell, this is how you should set the random seed for the current process in SV:

 

process::self.srandom(seed);

 

However, when I try putting one of these in each begin...end block above, XSim errors out with "ERROR: [VRFC 10-91] process is not declared".  What am I doing wrong?  Or, if XSim doesn't support the 'process' class, is there an alternate way of seeding the RNG per-thread?

 

p.s. Does Xilinx have any plans to support join_any and join_none?  I tried to use join_any and got an error message indicating it isn't supported.

0 Kudos
2 Replies
Highlighted
Observer
Observer
5,384 Views
Registered: ‎03-02-2015

Re: Per-thread random seed

Noticed that the LRM says I can give a parameter to $urandom(), and that parameter is used as the random number seed. This seems to work for making my forked threads generate different command sequences.

 

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
5,366 Views
Registered: ‎09-13-2014

Re: Per-thread random seed

fork-join_any/join_none is under development and is planned for future release.

 

--dhiRAj

0 Kudos