The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Simulators >> Circuit Simulators >> generate two different random integers on HSPICE https://designers-guide.org/forum/YaBB.pl?num=1479588462 Message started by AA on Nov 19th, 2016, 12:47pm |
Title: generate two different random integers on HSPICE Post by AA on Nov 19th, 2016, 12:47pm Is there a way to generate two distinct random integers on HSPICE? For example, I can generate two random integers, a and b, from 0 to 9 as follows: Code:
However, I want a and b to be two different numbers, with some sort of randomness. The code above may generate the same value for a and b. How to make sure a and b are always different and within the range? |
Title: Re: generate two different random integers on HSPICE Post by Geoffrey_Coram on Nov 21st, 2016, 12:12pm Why not do Code:
? |
Title: Re: generate two different random integers on HSPICE Post by AA on Nov 22nd, 2016, 3:32pm Two reasons: (1) I need a and b to be integers (2) I need a and b to be different numbers on every Monte Carlo iteration ,i.e., when performing MONTE sweep. For example, if a=4, then b cannot be 4. In other words, the random number generator should reject the value of b when it equals to a, and keeps regenerating b until b!=a. The code you provided may generate the same value for a and b (especially when converted to integers) in the subsequent Monte Carlo iterations. I hope there is a way to do this in HSPICE. Otherwise, I will probably need to write a Verilog-A module. Also, if this is not possible in HSPICE, please provide a hint on the best way to implement this functionality on Verilog-A. I especially need to know how to consume the Verilog-A module's outputs (a and b) as HSPICE parameters. |
Title: Re: generate two different random integers on HSPICE Post by Geoffrey_Coram on Nov 28th, 2016, 10:48am I missed the point that you want to enforce a != b, sorry. What about something like Code:
'temp' should be from 0 to 8, and when it's the same as a, b is set to 9. |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |