Continue to Site

Welcome to EDAboard.com

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.

Random number generator, algorithm question.

Status
Not open for further replies.

zuzu

Member level 3
Joined
Jul 10, 2007
Messages
54
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,817
Hello friends,

Trying to distribute packet error over time in some protocol, I need to generate a custom (pseudo) random sequence up to certain number.
I my MCU I have only rand() and srand(int seed) functions.

But I need to generate a PR number from 0 to N where N can be anywhere up to 2047. The seed is not important, but non-repetitive values are, and cycle them all up to N.

Any idea appreciated.
 

Hi Zuzu,
Pseudo random sequence can be generated by using shift-registers with the XNOR feed back. kindly check these links.
**broken link removed**
**broken link removed**
These googled links may help you write pseudo random sequence.
 

Hi zuzu,

If you rand() generator gives random numbers in 16 bits, and you need numbers ranging from 0 to 2047 (i.e. 11 bits) you can call rand() function and take the 11 least significant bits of the value it returns.
This does not give a cycle of 2048 values, but longer (with pseudo-random repetitions). Is it really important that all values don't repeat before a whole cycle is completed?
Regards

Z
 
Last edited:

I'm not aware of algorithm to generate a 0 to N PR sequence. Popular LFSR (Linear Feedback Shift Registers) generators have fixed 2^n -1 sequence length, all numbers of a binary range excluding 0.

As a simple straightforward solution, I would use a 12 Bit LFSR generator, map N to 0 and drop numbers > N. If you are required to supply a new number every clock cycle, use a precalculated table.
 

Thanks all for comments,

I think I need to detail some more, maybe another idea comes up :).

I have a unidirectional (no reverse link, like sat downlink) transmission of packets over a (quite susceptible) noisy channel. Number of packets in burst can vary up to 2048 and now, the burst is implemented to send linear, from 0 -> N. Now the receiver can catch all N or may loose one and in real life, if one bit is lost, CRC will reject entire packet. Note: FEC is impractical at the moment due to computing limmitations which wasn't encountered in this hw.

So the chance for receiver to catch next lost is at next burst, at minimum distance N*tpacket time. If on next burst packets are in different order (aka random up to N) the time to catch lost packet is probably reduced.

Appreciate your comments,
 

Hi zuzu,

Sorry, my question can be silly. But if I understant you, if in the next burst packets are in different order, then the time to catch lost packet(s) could be reduced or increased. Right? Is the expected (mean) time reduced?
Regards

Z
 

In most test generator applications PR numbers are used to get a deterministic random like data stream, that can be compared against the expected signal at the receiver. You apparently intend something different, but the specification isn't clear.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top