Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
using LFSR(Linear feedback Shift Register) u can generate pseudo random numbers out of them use 3 bits to 44 so that u will random numbers from 44 to 52, now add two different bits from LFSR register to this u will get random numbers between 44 and 55.
I think if you use a LFSR that have a very long period should give uniform distribution but as you are saying than it may not. However than what other way is to get uniform distribution?
By adding two random numbers, you already change the distribution. You can use a mapping of the 1...2^n-1 LFSR number range to 44..55 by a table or a mod 12 operation. In case of a sufficient LFSR bitwidth, the distribution unsymmetry is only small. Dropping the unwanted numbers is another option.
LFSR random number generators have an uniform distribution over their respective number range of 1...2^n-1, where n ist the number of stages.
To get an uniform distribution over the range 44..55 respectvively 0..11, you need a mapping that keeps the uiniformity.
I was discussing different mapping options: e.g. look up table or mod 12 operation. Your original suggestion creates also a mapping, but it violates uniformity and has a range of 0..10 instead of required 0..11.
I tryed to use the syntax you have given but its printing different values
which are in not range
code follows here
-----------
module test();
reg a;
reg b;
reg c;
wire out;
reg[7] range;
always
repeat(24)
begin
#100
a = 1'b1;
b = 1'b1;
#100
a = 1'b0;
b = 1'b1;
end
always@(a or b)
begin
repeat(24)
begin
range = 55 + $random % 16;
end
$monitor(" ‰d ",range);
end
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.