Hi,
i want to generate a random number in between (32’h0200_0000,32’h0200_8FFF)or (32’h4000_2000,32’h40000_3FFFF) any of these two ranges. can you help to generate this.
In reply to murali.gubba:
class myclass
rand bit [31:0] number;
constraint ranges {
number inside { [32'h0200_0000:32'h0200_8FFF],
[32'h4000_2000:32'h4000_3FFF]}; }
endclass
I assume your last number was a typo.
In reply to dave_59:
Hi,
Thanks dave.
Here iam implementing function call, depends on input number to the function, i should get random address in ranges like below
function bit [31:0] Get_addr(int a);
bit [31:0] temp_addr;
if(a == 0)
temp_addr = $urandom_range(32’h6000_0000,32’h6000_1fff);
else if(a == 1)
temp_addr = $urandom_range(32’h6000_2000,32’h6000_3fff);
else if(a == 2)
temp_addr = $urandom_range(32’h6000_4000,32’h6000_5fff);
else if(a == 3)
temp_addr = $urandom_range(32’h6000_6000,32’h6000_7fff);
else
temp_addr = $urandom_range(32’h0200_0000:32’h0200_8FFF),
// or (32’h4000_2000:32’h4000_3FFF)};
retrun (temp_addr);
endfunction