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
- 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.