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?
999 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
- Producing filtered random samples which can be replicated using the same seed
- Random getting value from a range or a specific value
- Unique and random selection of 10 rows per user in a table
- How to calculate the accuracy in number guessing game?
- Using attributes from instances of array of objects in other classes
- How do I write such a random source code generator?
- How to randomly load html file inside a html page on page load using javascript?
- New error on random number assigned to local variable , Rails
- Why does the code return the same 5 random numbers every time
- How can I efficiently find two numbers in an array that sum up to a given target without using the same element twice?
- How can I use a variable that is defined in one script in a different script in Unity
- Why is C# BigInteger not always the same bit length?
- Choosing a sequence of bitwise operations
- java: method nextLong in class java.util.Random cannot be applied to given types;
- How to add the outout the random element from array and keep adding 1 by 1 in empty array?
Related Questions in VERILOG
- Error message coming up when compiling iVerilog Code
- Communicate/transfer data between two different programs. JAVA & VERILOG
- Spiking neural network on FPGA
- Matrix Multiplication Testbench Yields Inconsistent Results
- Formal verification of state machine with SymbiYosys not giving expected results
- How to compile only the changed files in Verilator?
- 4-bit ALU SLT operation
- How to connect combo code to a module's interface modport?
- 4-bit ALU using 1-bit ALU in verilog
- Is there a difference when using the ternary operator in always and assign statements?
- Verilog Implementation: Detecting Overflow and Rolling Up Result
- IO placement is infeasible error in Vivado
- How do I deploy this polynomial multiplication algorithm to verilog
- always block not always triggering at event
- Multiple modules in FSM and how it's working?
Related Questions in FPGA
- uart in vhdl send a string
- A FPGA Project Proposal where I can use both PS and PL
- IO placement is infeasible error in Vivado
- Why RTOS is needed for FPGA based real-time embedded system?
- Padding zeros with std_logic_vector results in Implementation Error
- How to write into 12 addresses at the same cycle in vivado and still be recognized as BRAM
- PLL not showing output on ModelSim
- Using FPGA to sample and filter audio based off switch selection
- Why is there no output from the verilog test bench?
- Freeze after two subsequent software resets for Zynq 7000 FPGA (with SoC)
- Verilog module always going to default case when assigning value to input
- Where do I find the Xilinx xc7z007sclg400-1 master constaint file?
- Failed to use memory bits in fpga
- How to increase baudrate on Device Manager Windows?
- Gate-Level Sim: Hold time violation between testbench and first registers?
Related Questions in NUMBER-THEORY
- Enumerate unique multiples of numbers
- regex for [2,4,p^t,2p^t] where p is prime and t is any positive integer
- simplest one line code to calculate the amount of even integers in a range {n1,n2} (n1,n2 included )
- Optimize calculation related to `repeater(range1, repeater(range2, george))`
- Method for deterministic shuffling
- How many distinct digit permutations exist for a specific N-digit number?
- How to rewrite my CPILL procedure to calculate Pi value, with use multithreading to shorten the time of calculation?
- Is there a way to find a Carmichael number having N prime factors in a given range?
- Sieve of Eratosthenes: speeding up the "cross off multiples" step
- Remove duplicate during count in PARI GP
- How would I solve a linear Diophantine congruence in Python?
- How to determine reachable states in 3 water jug problem?
- RSA Oracle - Getting the flag by using chosen ciphertext attack
- Euler's Criterion using BigIntegers given RSA n=p*q
- Find the primitive root of n closest to n/φ faster than O(n)
Related Questions in RANDOMIZED-ALGORITHM
- Randomized Relaxation of Complex Linear Assignment Problem
- How to randomize an object: Map<Author, List<Book>> with EasyRandom in Java?
- I was trying to solve Card flipping problem with randomized algorithm, but I can't get the expectation of each flip
- Shuffling data across rows in a table
- Runtime of randomization algorithm to find majority element in an array?
- Creating 5 lists of the 5 same elements in different index order
- Random sampling: scanning and selecting in Rust
- Feature selection, Converting Boxplot to a barH
- ValueError: Input contains NaN, infinity or a value too large for dtype('float64') when using randomizedSearch
- How to randomly permute elements from two lists while respecting a non-consecutive ordering constraint?
- How to shuffle cards - JavaScript
- Google Apps Script randomize certain cells function not working
- Need help on solving this Arrays problem using java
- how to shuffle an array except for the item in the middle?
- Attempt to randomize image generation with javascript?
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 # Hahtags
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.