Jump to content
  • 0

Using $urandom() function in vivado(ZYBO BOARD)


Aditya Gedela

Question

I am using urandom() function to generate a random number. But while generating bitstream it is showing error in the implementation stage.

So,please help me with this.

 

Errors:

  • [Place 30-494] The design is empty
  • [Common 17-69] Command failed: Placer could not place all instances
  •  

My code:

module random();
integer unsigned add;
initial
begin
repeat(5)
begin 
add=$urandom();
$display("address=%d",add);
end
end
endmodule

 

Thanks in advance......

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

@jpeyron, @Aditya Gedela,

LFSR's are wonderful.  I love using them.  They are useful for a great many things.  However, you may wish to be aware that an N-bit LFSR can be determined (state and taps) with only 2N output bits via nothing more than a set of simple linear equations.  Further, they work great when you want a series of (pretend) random bits, they aren't nearly as good when you want a random number, such as between 0 and 15.  Sure, you could grab 4-bits of an LFSR, but you tend to lose your randomness as you go about this.  So ... just be aware, they aren't really random: don't use them for cryptography.

If you are just trying to generate a somewhat random address, you might wish to use a bit-reversed counter.  It's not really random, but it might be random enough.  It'll also prevent whatever memory controller you are testing from optimizing sequential accesses ....

Dan

Link to comment
Share on other sites

@Aditya Gedela,

Let's see if I can reproduce it ... (I use it in this pwm project, and in the S6SoC that uses that):

reg	[(NBITS-1):0]	counter;
always @(posedge clk)
	counter <= counter + 1'b1;

wire [(NBITS-1):0]	address;
genvar	k;
generate for(k=0; k<NBITS; k=k+1)
begin : bit_reversal_loop
	assign address[k] = counter[(NBITS-1-k)];
end

That's how bit reversal works.  Now, for how random it is, consider a 3-bit sequence: 0, 1, 2, 3, 4, 5, 6, 7.  When bit reversed, it becomes: 0, 4, 2, 6, 1, 5, 3, 7.  It bounces back and forth between halves of the space: left half, right half, left half, right half, as opposed to bouncing between odd and even addresses.  The fun part of bit reversal is that it doesn't cost any logic to do.  The synthesizer just re-orders the wires and off you go.

Dan

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...