I am trying to generate single precision floating point random number using FPGA by generating number between 0 and 0x3f80000 (IEEE format for 1). But since there are more number of discreet points near to zero than 1, I am not getting uniform generation. Is there any transformation which I can apply to mimic uniform generation. I am using LFSR(32 Bit) and Xoshiro random number generation.
How to generate uniform single precision floating point random number between 0 and 1 in FPGA?
998 Views Asked by Rishi Jaiswal At
2
There are 2 best solutions below
0
quantum231
On
Please check the xoshiro128+ here https://prng.di.unimi.it/xoshiro128plus.c
The VHDL code written by someone can be found here: https://github.com/jorisvr/vhdl_prng/tree/master/rtl
The seed value is generated from another random number generation algorithm so don't get confused by this.
Depending on the seed value used it should give a uniform distribution.
Related Questions in RANDOM
- issue in my if statement to make comparison in my java program
- Interesting random PHP include issue
- Why do the random number crashes my Android app?
- Unique random character generator
- I made a for loop to swap two indiv char variables in a string
- List with random numbers in Haskell
- Randomly sample lines retaining commented header lines
- How do you generate specific random number?
- Randomizing values accounting for floating point resolution
- Python random use both state and seed?
- Random without repetition?
- How to produce multiple output files with a single input file using the command 'np.random.normal'?
- Generate random ROWID
- Random number generator problems
- How to take same random sample from dataset every time
Related Questions in VERILOG
- Tick-including a header file inside package in systemverilog
- Others => '1' statement in Verilog
- Why there are verilog verification files not in the form of module?
- Creation of array in Verilog that can store real values
- Array initialization error in Verilog
- Verilog signed unsigned operation
- What does Z in Verilog stand for?
- Properly including a .vh in a .sv file?
- Unknown Wrong result when simulating Verilog design in modelsim
- Verilog simulation x's in output
- Verilog generate statement : conditional port connections
- Divide by 2 clock and corresponding reset generation
- What is the meaning of this code statement in verilog?
- Use of << in given Verilog code?
- Verilog Testbench constant exp and pram compilation and simulation errors
Related Questions in FPGA
- Is an inferred latch in Quartus II necessarily transparent
- VHDL, concurrent signal assignment wrong on FPGA but right in Modelsim
- Read file in FPGA
- xilinx sdka error when using lwip library
- How to demonstrate a 32-bit MIPS with FPUs in a FPGA?
- How to get rid of scale factor from CORDIC
- Verilog Inter-FPGA SPI Communication
- Using C programming to call VHDL implementation
- Why we use CORDIC gain?
- Altera UART IP Core
- What is the cause of Vivados 'synth 8-1027' error?
- How to change timescale of VCD file dumped?
- Sync two FPGAs to generate same Sine Wave
- Connect stack of Parallela boards and a rPI via FPGA and 1/0 pins
- Error synthesizing hierarchical names in vivado
Related Questions in NUMBER-THEORY
- How to compute a^^b mod m?
- Number of divisiors upto 10^6
- Riemann Zeta Function in Java - Infinite Recursion with Functional Form
- What is the reason behind calculating GCD in Pollard rho integer factorisation?
- How to make the Sieve of Eratosthenes faster?
- Different ways of generating the partitions of a number in order
- C++ Number theory: Fastest way to compute max(y = a_i * x+ b_i) <= k
- Error in C program to find integer triplets (x,y,z) such that n^x + n^y = n^z for given range of n
- how to calculate a^(b^c) mod n?
- Practical Prime Factorization
- Efficiently compute the modulo of the sum of two numbers
- Algorithms to compute Frobenius Numbers of a set of positive integers
- Python - Combination of Numbers Summing to Greater than or Equal to a Value
- Python : Stairstep DP solution understanding
- Does it gets faster than this?
Related Questions in RANDOMIZED-ALGORITHM
- Creating 5 lists of the 5 same elements in different index order
- Runtime of randomization algorithm to find majority element in an array?
- Shuffling data across rows in a table
- Probabilistic algorithm, can a best case instance depend on the randomized parameter?
- Select random cell in range
- How to use O(log n) mutually independent random bits to generate n pairwise independent random bits
- Is exectution time of Skip list different after every run for same input?
- normal vs randomized quicksort on an array which is 1/3 sorted
- How to change the image of a button in tkinter
- Why is randomised quicksort considered better than standard quicksort?
- Replace commas with spaces ? Fisher-Yates randomization
- Matthew's Correlation Coefficient and Precision throws errors in RandomizedSearchCV
- set input values in array and randomize content to display
- Printing an array as an ArrayType in Pascal
- If A is in RP and there is a polynomial time reduction from B to A then B in RP?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
A standard way to generate uniformly distributed
floats in [0,1) from uniformly distributed 32-bit unsigned integers is to multiply the integers with 2-32. Obviously we wouldn't instantiate a floating-point multiplier on the FPGA just for this purpose, and we do not have to, since the multiplier is a power of two. In essence what is needed is a conversion of the integer to a floating-point number, then decrementing the exponent of the floating-point number by 32. This does not work for a zero input which has to be handled as a special case. In the ISO-C99 code below I am assuming thatfloatis mapped to IEEE-754binary32type.Other than for certain special cases, the significand of an IEEE-754 binary floating-point number is normalized to [1,2). To convert an integer into the significand, we need to normalize it, so the most significant bit is set. We can do this by counting the number of leading zero bits, then left shifting the number by that amount. The count of leading zeros is also needed to adjust the exponent.
The significand of a
binary32number comprises 24 bits, of which only 23 bits are stored; the most significant bit (the integer bit) is always one and therefore implicit. This means not all of the 32 bits of the integer can be incorporated into thebinary32, so in converting a 32-bit unsigned integer one usually rounds to 24-bit precision. To simplify the implementation, in the code below I simply truncate by cutting off the least significant eight bits, which should have no noticeable effect on the uniform distribution. For the exponent part, we can combine the adjustments due to normalization step with the subtraction due to the scale factor of 2-32.The code below is written using hardware-centric primitives. Extracting a bit is just a question of grabbing the correct wire, and shifts by fixed amounts are likewise simply wire shifts. The circuit needed to count the number of leading zeros is typically called a priority encoder.