CN105045561A - Pseudo-random number generating method - Google Patents
Pseudo-random number generating method Download PDFInfo
- Publication number
- CN105045561A CN105045561A CN201510494086.2A CN201510494086A CN105045561A CN 105045561 A CN105045561 A CN 105045561A CN 201510494086 A CN201510494086 A CN 201510494086A CN 105045561 A CN105045561 A CN 105045561A
- Authority
- CN
- China
- Prior art keywords
- pseudo
- random number
- shift register
- linear feedback
- generated
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title abstract description 32
- 230000008520 organization Effects 0.000 claims 2
- 238000004519 manufacturing process Methods 0.000 claims 1
- 238000009826 distribution Methods 0.000 abstract description 24
- WVCHIGAIXREVNS-UHFFFAOYSA-N 2-hydroxy-1,4-naphthoquinone Chemical compound C1=CC=C2C(O)=CC(=O)C(=O)C2=C1 WVCHIGAIXREVNS-UHFFFAOYSA-N 0.000 description 48
- 238000010586 diagram Methods 0.000 description 21
- 230000003595 spectral effect Effects 0.000 description 13
- 230000000875 corresponding effect Effects 0.000 description 6
- 230000015556 catabolic process Effects 0.000 description 5
- 230000002596 correlated effect Effects 0.000 description 4
- 230000007274 generation of a signal involved in cell-cell signaling Effects 0.000 description 4
- 238000009827 uniform distribution Methods 0.000 description 4
- 230000001186 cumulative effect Effects 0.000 description 3
- 238000005315 distribution function Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000005070 sampling Methods 0.000 description 3
- 230000000903 blocking effect Effects 0.000 description 2
- 239000000969 carrier Substances 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 239000004020 conductor Substances 0.000 description 2
- 230000003111 delayed effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 230000003321 amplification Effects 0.000 description 1
- 238000005311 autocorrelation function Methods 0.000 description 1
- 239000003990 capacitor Substances 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000005314 correlation function Methods 0.000 description 1
- 238000009795 derivation Methods 0.000 description 1
- 230000005284 excitation Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003199 nucleic acid amplification method Methods 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 238000000053 physical method Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 239000000941 radioactive substance Substances 0.000 description 1
- 230000000630 rising effect Effects 0.000 description 1
- 238000001228 spectrum Methods 0.000 description 1
Landscapes
- Tests Of Electronic Circuits (AREA)
Abstract
Description
技术领域technical field
本发明涉及信号发生领域,具体是一种伪随机数产生方法。The invention relates to the field of signal generation, in particular to a pseudo-random number generation method.
背景技术Background technique
理想白噪声信号的功率谱密度函数在所有频率上是一个常数,其功率无穷大,因此是不能物理实现的。一个噪声信号在感兴趣的频率范围内其功率谱密度函数近似为一个常数,被称为带限白噪声信号,物理上是能够实现的。带限白噪声信号与理想白噪声信号的性质类似。实际电路系统的带宽是有限的,只要产生的带限白噪声信号的频率范围宽于实际电路的带宽,其对信号系统的影响跟相同谱密度、相同概率分布的理想白噪声信号的影响是相同的。将模拟白噪声信号的电压数字化后,可形成较为理想的随机数。The power spectral density function of an ideal white noise signal is a constant at all frequencies, and its power is infinite, so it cannot be realized physically. A noise signal whose power spectral density function is approximately a constant in the frequency range of interest is called a band-limited white noise signal, which can be realized physically. Band-limited white noise signals have properties similar to ideal white noise signals. The bandwidth of the actual circuit system is limited. As long as the frequency range of the band-limited white noise signal generated is wider than the bandwidth of the actual circuit, its influence on the signal system is the same as that of the ideal white noise signal with the same spectral density and the same probability distribution. of. After the voltage of the analog white noise signal is digitized, a more ideal random number can be formed.
传统上噪声信号发生是基于物理技术。例如,利用放射性物质的放射性,使用探测器对其计数产生随机数。利用气体放电管的放电产生噪声信号。在上世纪六七十年代,气体放电管作为噪声标准在国内外曾得到广泛的应用。以上产生噪声的方法技术复杂、安全性不高,因此又诞生了基于电路噪声的固态噪声发生技术。例如,利用电阻的热噪声或半导体器件的噪声,可产生宽带噪声信号,其原理框图如图1所示。Noise signal generation is traditionally based on physical techniques. For example, using the radioactivity of radioactive substances, using detectors to count them to generate random numbers. The noise signal is generated by the discharge of the gas discharge tube. In the 1960s and 1970s, gas discharge tubes were widely used as noise standards at home and abroad. The above methods of generating noise are technically complex and not very safe, so a solid-state noise generation technology based on circuit noise was born. For example, the thermal noise of resistors or the noise of semiconductor devices can be used to generate broadband noise signals, as shown in Figure 1.
导体中载流子随机热运动而产生的起伏噪声叫热噪声,热噪声电压与温度有关,其均方值为:The fluctuating noise generated by the random thermal movement of carriers in the conductor is called thermal noise, and the thermal noise voltage is related to temperature, and its mean square value is:
V2=4kTBRV 2 =4kTBR
其中R为导体的电阻,B为电路的带宽,k为波尔兹曼常数,T为绝对温度。因为热噪声起源于多数载流子的运动,所以它的瞬时幅值服从均值为零的高斯分布,当温度和阻值一定时,热噪声电压的谱密度与频率无关,因此,电阻的热噪声是高斯型的白噪声。Where R is the resistance of the conductor, B is the bandwidth of the circuit, k is Boltzmann's constant, and T is the absolute temperature. Because thermal noise originates from the movement of majority carriers, its instantaneous amplitude obeys a Gaussian distribution with a mean value of zero. When the temperature and resistance are constant, the spectral density of thermal noise voltage has nothing to do with frequency. Therefore, the thermal noise of a resistor is Gaussian white noise.
一个半导体二极管反向偏置工作于雪崩击穿状态,在雪崩区内,由于电子-空穴对产生速率的随机起伏性质而产生雪崩散弹噪声。在一定的雪崩频率下,雪崩散弹噪声与白噪声相似,其噪声功率谱密度均匀分布。因此,反向工作于雪崩击穿状态的二极管可成为一个较理想的噪声源。利用齐纳二极管或PIN二极管的雪崩击穿产生噪声信号,再经宽带放大,可产生宽带噪声信号。A semiconductor diode is reverse-biased and works in an avalanche breakdown state. In the avalanche region, avalanche shot noise is generated due to the random fluctuation of the electron-hole pair generation rate. At a certain avalanche frequency, avalanche shot noise is similar to white noise, and its noise power spectral density is uniformly distributed. Therefore, a diode operating in reverse in the avalanche breakdown state can be an ideal noise source. The avalanche breakdown of Zener diode or PIN diode is used to generate noise signal, and then amplified by broadband to generate broadband noise signal.
固态噪声发生器频率范围较宽,可覆盖至微波频段,输出信号的概率密度符合高斯分布,属于高斯白噪声信号。传统噪声信号发生器的缺点是输出信号的概率分布不能调整、谱密度调整困难。实际应用中,经常需要数字型的随机数或噪声信号。将固态噪声发生器的输出量化,可产生数字型的噪声信号。The solid-state noise generator has a wide frequency range and can cover the microwave frequency band. The probability density of the output signal conforms to the Gaussian distribution, which belongs to the Gaussian white noise signal. The disadvantage of the traditional noise signal generator is that the probability distribution of the output signal cannot be adjusted, and the adjustment of the spectral density is difficult. In practical applications, digital random numbers or noise signals are often required. The output of the solid-state noise generator is quantized to generate a digital noise signal.
下面阐述基于物理技术产生真随机数的方法。利用齐纳二极管的雪崩击穿产生的噪声,经隔直与宽带放大,可产生模拟的宽带白噪声信号,该噪声信号是高斯分布的。使用高速的A/D转换器将模拟噪声信号数字化,可产生高斯分布的数字噪声信号,原理框图如图2所示。图中Vcc为直流电压源,R为限流电阻,以使二极管D工作在雪崩击穿区。L提供直流通路,同时隔离交流信号,C为隔直流电容,同时将噪声信号耦合输出,N是放大电路。量化的噪声信号再跟数值0比较,如果数值大于等于0就输出1,如果小于0就输出0,用这种方法产生了一个均匀分布的二进制随机数,原理框图如图3所示。当然也可以使用高速的模拟比较器将模拟噪声信号转换成二进制的数字噪声信号。The method for generating true random numbers based on physical technology is described below. Using the noise generated by the avalanche breakdown of the Zener diode, the analog broadband white noise signal can be generated through DC blocking and broadband amplification, and the noise signal is Gaussian distributed. Using a high-speed A/D converter to digitize the analog noise signal can produce a Gaussian-distributed digital noise signal. The block diagram is shown in Figure 2. In the figure, Vcc is a DC voltage source, and R is a current-limiting resistor, so that the diode D works in the avalanche breakdown region. L provides a DC path and isolates the AC signal at the same time, C is a DC blocking capacitor, and couples the noise signal to the output at the same time, N is an amplifier circuit. The quantized noise signal is compared with the value 0. If the value is greater than or equal to 0, it will output 1, and if it is less than 0, it will output 0. In this way, a uniformly distributed binary random number is generated. The block diagram is shown in Figure 3. Of course, a high-speed analog comparator can also be used to convert the analog noise signal into a binary digital noise signal.
序列周期有限的随机数称为伪随机数,序列周期有限的随机信号称为伪随机信号。伪随机数的序列周期越长,其统计特性越好,越接近真随机数。由于真随机数的产生电路较为复杂,工程上,常使用伪随机数代替真随机数,因为其数学性质类似,能够满足工程需要。A random number with a finite sequence period is called a pseudorandom number, and a random signal with a finite sequence period is called a pseudorandom signal. The longer the sequence period of the pseudo-random number is, the better its statistical properties are, and the closer it is to a true random number. Due to the complexity of the generation circuit of true random numbers, in engineering, pseudo-random numbers are often used instead of true random numbers, because their mathematical properties are similar and can meet engineering needs.
利用计算机可以方便的产生均匀分布伪随机数。产生伪随机数的方法有平方取中法、乘同余法、线性同余算法。平方取中法、乘同余法产生伪随机数的质量不高。在计算机上,常用线性同余算法产生伪随机数。线性同余法递推公式为:A computer can be used to generate uniformly distributed pseudo-random numbers conveniently. The methods for generating pseudo-random numbers include the square method, the multiplication congruence method, and the linear congruence algorithm. The quality of the pseudo-random numbers generated by the square method and the multiplication congruence method is not high. On computers, the linear congruential algorithm is commonly used to generate pseudorandom numbers. The linear congruence method recursion formula is:
rand(n)=(rand(n-1)*mult+inc)modMrand(n)=(rand(n-1)*mult+inc) mod M
其中rand(n)是当前随机数,rand(n-1)是前一时刻随机数,mult是乘数因子,M=2L为模值。inc是增量,通常情况下可取小于M的奇数。C语言编译器中函数rand()可产生0~32767之间的随机整数。VC中产生伪随机数的公式为:Where rand(n) is the current random number, rand(n-1) is the random number at the previous moment, mult is the multiplier factor, M=2 and L is the modulus value. inc is an increment, usually an odd number smaller than M can be used. The function rand() in the C language compiler can generate random integers between 0 and 32767. The formula for generating pseudo-random numbers in VC is:
rand(n)=((rand(n-1)*214013+2531011)mod65536)&0x7fffrand(n)=((rand(n-1)*214013+2531011)mod65536)&0x7fff
BC中产生伪随机数的公式为:The formula for generating pseudo-random numbers in BC is:
rand(n)=((rand(n-1)*22695477+1)mod65536)&0x7fffrand(n)=((rand(n-1)*22695477+1)mod65536)&0x7fff
利用数字技术,产生均匀分布伪随机数后,可方便的产生其它分布伪随机数,例如高斯分布伪随机序列,以及均值、方差、谱密度可调的伪随机数字白噪声信号。Using digital technology, after generating uniformly distributed pseudo-random numbers, other distributed pseudo-random numbers can be easily generated, such as Gaussian distribution pseudo-random sequences, and pseudo-random digital white noise signals with adjustable mean, variance, and spectral density.
m序列又称最长线性反馈移位寄存器序列,是研究得比较深入的一种二进制伪随机序列。常用于扩频通信、测距、电路测试等领域。它由带线性反馈的移位寄存器产生,如图4所示。图中一位移位寄存器的状态用ai表示,ai=0或ai=1,i为整数。反馈线的连接状态用Ci表示,Ci=0表示该反馈线断开,Ci=1表示反馈存在。The m-sequence, also known as the longest linear feedback shift register sequence, is a binary pseudo-random sequence that has been studied in depth. Commonly used in spread spectrum communication, ranging, circuit testing and other fields. It is generated by a shift register with linear feedback, as shown in Figure 4. In the figure, the state of a bit shift register is represented by a i , a i =0 or a i =1, and i is an integer. The connection state of the feedback line is represented by C i , where C i =0 means that the feedback line is disconnected, and C i =1 means that the feedback exists.
移位寄存器在时钟信号的控制下,一步步向外移位输出。由于反馈的存在,若初始状态为全“0”,则移位后得到的仍为全“0”,因此应避免出现全“0”状态;又因为n级移存器共有2n种可能的不同状态,除全“0”状态外,剩下2n-1种状态可用。每移位一次,就出现一种状态,在移位若干次后,一定能重复出现前某一状态,其后的过程便周而复始,也就是说,输出信号一定是周期信号。反馈线位置不同将出现不同周期的不同序列,希望找到合适的线性反馈逻辑,能使移位寄存器产生的序列最长,即达到周期M=2n-1。按图中连线关系,移位寄存器组左端所得到的输入可以写为:Under the control of the clock signal, the shift register shifts the output step by step. Due to the existence of feedback, if the initial state is all "0", the result obtained after shifting is still all "0", so the state of all "0" should be avoided; and because n-level shift registers have 2 n possible Different states, except for all "0" states, there are 2 n -1 states available. Every time it is shifted, a state will appear. After shifting several times, the previous state must be repeated, and the subsequent process will repeat itself. That is to say, the output signal must be a periodic signal. Different positions of the feedback line will result in different sequences of different periods. It is hoped to find a suitable linear feedback logic that can make the sequence generated by the shift register the longest, that is, the period M=2 n -1. According to the connection relationship in the figure, the input obtained at the left end of the shift register group can be written as:
an=c1an-1⊕c2an-2⊕c3an-3⊕...⊕cn-1a1⊕cna0 a n =c 1 a n-1 ⊕c 2 a n-2 ⊕c 3 a n-3 ⊕...⊕c n-1 a 1 ⊕c n a 0
式中⊕是异或运算符。选择合适的线性反馈逻辑时,输出序列就是一个周期为2n-1的m序列。Where ⊕ is an XOR operator. When choosing an appropriate linear feedback logic, the output sequence is an m-sequence with a period of 2 n -1.
Ci的取值决定了具体移位寄存器的反馈连接、序列结构和周期,为便于表达Ci的状态,引进多项式:The value of C i determines the feedback connection, sequence structure and period of the specific shift register. In order to facilitate the expression of the state of C i , a polynomial is introduced:
f(x)=c0+c1x+c2x2+...+cn-1xn-1+cnxn f(x)=c 0 +c 1 x+c 2 x 2 +...+c n-1 x n-1 +c n x n
该式称为特征多项式。当知道一个线性反馈移位寄存器的特征多项式,就可以决定线性反馈移位寄存器的结构。已经证明,若线性反馈移位寄存器的特征多项式为本原多项式,则此线性反馈移位寄存器能产生m序列。这是线性反馈移位寄存器产生m序列的充分必要条件。在实际应用中,根据数据位数需要首先确定m序列的长度,然后通过查表就可以方便地得到m序列发生器的反馈逻辑。一定长度的线性反馈移位寄存器,有很多个本原多项式,对应不同的m序列。常用的本原多项式,前人已经以表格的形式给出。例如,当n=31时,f(x)=1+x3+x31为本原多项式,可产生m序列。对应公式中的C0=1,C3=1,C31=1。序列周期为231-1,恰好为一个梅森素数。m序列有以下性质:This formula is called the characteristic polynomial. When the characteristic polynomial of a linear feedback shift register is known, the structure of the linear feedback shift register can be determined. It has been proved that if the characteristic polynomial of the linear feedback shift register is a primitive polynomial, the linear feedback shift register can generate m sequences. This is a necessary and sufficient condition for the linear feedback shift register to generate m-sequences. In practical applications, the length of the m-sequence needs to be determined first according to the number of data bits, and then the feedback logic of the m-sequence generator can be easily obtained by looking up the table. A linear feedback shift register of a certain length has many primitive polynomials corresponding to different m-sequences. Commonly used primitive polynomials have been given in the form of tables. For example, when n=31, f(x)=1+x 3 +x 31 is a primitive polynomial, which can generate m sequences. Corresponding to C 0 =1, C 3 =1, and C 31 =1 in the formula. The sequence period is 2 31 -1, which is exactly a Mersenne prime. The m-sequence has the following properties:
(1)平衡特性。在m序列的每个2n-1周期中,“1”码元出现的数目为2n-1次,“0”码元出现的数目为2n-1-1次,即“0”的个数总是比“1”的个数少一个,这表明,序列平均值极小。(1) Balance characteristics. In each 2 n -1 period of the m sequence, the number of occurrences of "1" symbols is 2 n-1 times, and the number of occurrences of "0" symbols is 2 n-1 -1 times, that is, the number of occurrences of "0" The number is always one less than the number of "1", which shows that the sequence mean is extremely small.
(2)游程特性。游程是指在一个序列周期中连续排列的且取值相同的码元的合称,在一个游程中的码元的个数为游程长度。m序列中共有2n-1个游程。其中长度为k(1≤k≤n-2)的游程数目占总游程数的2-k,长度为n-1的连“0”的游程数为1,长度为n的连“1”游程数为1。(2) Run length characteristics. The run length refers to the collective name of symbols that are arranged continuously in a sequence period and take the same value, and the number of symbols in a run length is the run length. There are 2 n-1 runs in the m sequence. Among them, the number of runs with length k (1≤k≤n-2) accounts for 2 -k of the total number of runs, the number of runs with "0"s of length n-1 is 1, and the number of runs with "1"s with length n The number is 1.
(3)移位相加特性。一个m序列{an}与其任意次延迟移位后产生的另一个不同序列{an+k}模2相加,得到的仍是该m序列的延迟移位序列。如,01001l1右移1次产生另一个序列1010011,模2相加后的序列为1l10100,相当于原序列右移3次后得到的序列。(3) Shift-add feature. An m-sequence {a n } is added modulo 2 to another different sequence {a n+k } generated after any number of delayed shifts, and the obtained m-sequence is still the delayed shifted sequence of the m-sequence. For example, shifting 01001l1 to the right once produces another sequence 1010011, and the sequence after adding modulo 2 is 1l10100, which is equivalent to the sequence obtained by shifting the original sequence to the right three times.
(4)m序列具有优良的自相关特性,其自相关函数:(4) The m-sequence has excellent autocorrelation properties, and its autocorrelation function:
最长线性反馈移位寄存器通常存在很多个m序列。例如3位的最长线性反馈移位寄存器存在2个m序列,4位的最长线性反馈移位寄存器存在2个m序列,5位的最长线性反馈移位寄存器存在6个m序列,6位的最长线性反馈移位寄存器存在6个m序列,7位的最长线性反馈移位寄存器存在18个m序列,8位的最长线性反馈移位寄存器存在16个m序列,9位的最长线性反馈移位寄存器存在48个m序列,10位的最长线性反馈移位寄存器存在60个m序列,11位的最长线性反馈移位寄存器存在176个m序列,12位的最长线性反馈移位寄存器存在144个m序列,13位的最长线性反馈移位寄存器存在630个m序列,14位的最长线性反馈移位寄存器存在756个m序列,15位的最长线性反馈移位寄存器存在1800个m序列。随着最长线性反馈移位寄存器位数的增加,m序列的个数迅速增加。There are usually many m-sequences in the longest linear feedback shift register. For example, there are 2 m-sequences in the 3-bit longest linear feedback shift register, 2 m-sequences in the 4-bit longest linear feedback shift register, 6 m-sequences in the 5-bit longest linear feedback shift register, and 6 There are 6 m-sequences in the longest linear feedback shift register of 7 bits, 18 m-sequences in the longest linear feedback shift register of 7 bits, 16 m-sequences in the longest linear feedback shift register of 8 bits, and 16 m-sequences in the 9-bit longest linear feedback shift register. There are 48 m sequences in the longest linear feedback shift register, 60 m sequences in the longest linear feedback shift register of 10 bits, 176 m sequences in the longest linear feedback shift register of 11 bits, and 176 m sequences in the longest linear feedback shift register of 12 bits. There are 144 m-sequences in the linear feedback shift register, 630 m-sequences in the longest linear feedback shift register of 13 bits, 756 m-sequences in the longest linear feedback shift register of 14 bits, and the longest linear feedback shift register of 15 bits There are 1800 m-sequences in the shift register. With the increase of the number of bits of the longest linear feedback shift register, the number of m-sequences increases rapidly.
系数为5个的19位最长线性反馈移位寄存器存在158个m序列。其本原多项式为1+x+x2+x5+x19、1+x+x2+x6+x19、1+x+x4+x6+x19、1+x3+x4+x6+x19、1+x+x5+x6+x19、1+x+x4+x7+x19、1+x5+x6+x7+x19、1+x+x6+x8+x19、…、1+x13+x17+x18+x19、1+x14+x17+x18+x19。系数为3个的25位最长线性反馈移位寄存器存在4个m序列。其本原多项式为1+x3+x25、1+x7+x25、1+x18+x25、1+x22+x25。一个本原多项式通常存在一个镜像本原多项式,这两个本原多项式系数的个数相同,系数的阶数以最长线性反馈移位寄存器的位数对称。例如19阶本原多项式1+x+x2+x5+x19与1+x14+x17+x18+x19镜像,1+x+x2+x6+x19与1+x13+x17+x18+x19镜像。25阶本原多项式1+x3+x25与1+x22+x25镜像,1+x7+x25与1+x18+x25镜像。两个镜像的本原多项式生成的m序列有较强的相关性。没有镜像关系的本原多项式生成的m序列的互相关函数几乎为零,可以认为是不相关的。例如本原多项式1+x+x2+x5+x19、1+x+x2+x6+x19、1+x+x4+x6+x19、1+x3+x4+x6+x19、1+x+x5+x6+x19、1+x+x4+x7+x19、1+x5+x6+x7+x19、1+x+x6+x8+x19、1+x3+x25、1+x7+x25之间互不相关。There are 158 m-sequences in the 19-bit longest linear feedback shift register with 5 coefficients. Its primitive polynomials are 1+x+x 2 +x 5 +x 19 , 1+x+x 2 +x 6 +x 19 , 1+x+x 4 +x 6 +x 19 , 1+x 3 +x 4 +x 6 +x 19 , 1+x+x 5 +x 6 +x 19 , 1+x+x 4 +x 7 +x 19 , 1+x 5 +x 6 +x 7 +x 19 , 1+ x+x 6 +x 8 +x 19 ,..., 1+x 13 +x 17 +x 18 +x 19 , 1+x 14 +x 17 +x 18 +x 19 . There are 4 m-sequences for the 25-bit longest linear feedback shift register with 3 coefficients. Its primitive polynomials are 1+x 3 +x 25 , 1+x 7 +x 25 , 1+x 18 +x 25 , 1+x 22 +x 25 . A primitive polynomial usually has a mirror primitive polynomial, the number of coefficients of the two primitive polynomials is the same, and the order of the coefficients is symmetrical to the number of bits of the longest linear feedback shift register. For example, the 19th-order primitive polynomial 1+x+x 2 +x 5 +x 19 is the mirror image of 1+x 14 +x 17 +x 18 +x 19 , and 1+x+x 2 +x 6 +x 19 is the mirror image of 1+x 13 +x 17 +x 18 +x 19 mirrored. The 25th-order primitive polynomial 1+x 3 +x 25 is the mirror image of 1+x 22 +x 25 , and the mirror image of 1+x 7 +x 25 is the mirror image of 1+x 18 +x 25 . The m-sequences generated by the two mirrored primitive polynomials have a strong correlation. The cross-correlation function of m-sequences generated by primitive polynomials without mirror image relationship is almost zero, which can be considered as uncorrelated. For example, primitive polynomials 1+x+x 2 +x 5 +x 19 , 1+x+x 2 +x 6 +x 19 , 1+x+x 4 +x 6 +x 19 , 1+x 3 +x 4 +x 6 +x 19 , 1+x+x 5 +x 6 +x 19 , 1+x+x 4 +x 7 +x 19 , 1+x 5 +x 6 +x 7 +x 19 , 1+x +x 6 +x 8 +x 19 , 1+x 3 +x 25 , 1+x 7 +x 25 are not correlated with each other.
m序列的伪随机性很好,但它每次只能输出一位。要想产生一个多数据位的伪随机数,很自然的想法是从最长线性反馈移位寄存器中直接抽取几位,得到一个多位的随机数。图5是一个从8位的最长线性反馈移位寄存器中得到4位伪随机数的电路示意图。其线性反馈逻辑电路对应的本原多项式可选择1+x2+x3+x4+x8,即a6、a5、a4、a0数据位对应的反馈线处于连接状态。但这种方法不好,因为本时刻输出的伪随机数,与下一时刻输出的伪随机数,除一个数据位是新生成的外,其它几个数据位是相同的,只不过位置偏移了一位。本时刻输出的伪随机数,与下一下一时刻输出的伪随机数,除两个数据位是新生成的外,其它两个数据位是相同的,只不过位置偏移了两位。依次类推。也就是说用这种方法生成的伪随机数前后之间有较强的相关性,因此其质量不够好。The pseudo-randomness of m-sequence is very good, but it can only output one bit at a time. To generate a pseudo-random number with multiple data bits, the natural idea is to directly extract several bits from the longest linear feedback shift register to obtain a multi-bit random number. Fig. 5 is a schematic diagram of a circuit for obtaining a 4-bit pseudo-random number from an 8-bit longest linear feedback shift register. The primitive polynomial corresponding to the linear feedback logic circuit can be selected as 1+x 2 +x 3 +x 4 +x 8 , that is, the feedback lines corresponding to the data bits a6, a5, a4, and a0 are in a connected state. But this method is not good, because the pseudo-random number output at this moment and the pseudo-random number output at the next moment, except for one data bit is newly generated, the other several data bits are the same, but the position is offset one. The pseudo-random number output at this moment is the same as the pseudo-random number output at the next moment, except that the two data bits are newly generated, and the other two data bits are the same, except that the position is shifted by two bits. And so on. That is to say, there is a strong correlation between the pseudo-random numbers generated by this method, so its quality is not good enough.
发明内容Contents of the invention
本发明的目的是提供一种伪随机数产生方法,以解决现有技术存在的问题。The purpose of the present invention is to provide a pseudo-random number generation method to solve the problems in the prior art.
为了达到上述目的,本发明所采用的技术方案为:In order to achieve the above object, the technical scheme adopted in the present invention is:
一种伪随机数产生方法,其特征在于:基于并行结构最长线性反馈移位寄存器的Na位伪随机数发生器A,生成了m位的均匀分布伪随机数,记为A[k],以二进制表示为Am-1[k]Am-2[k]...A1[k]A0[k];基于并行结构的Nb位最长线性反馈移位寄存器的伪随机数发生器B,生成了m位的均匀分布伪随机数,记为B[k],以二进制表示为Bm-1[k]Bm-2[k]...B1[k]B0[k];伪随机数A[k]与伪随机数B[k]中对应数据位进行异或运算,生成伪随机数D[k],以二进制表示为Dm-1[k]Dm-2[k]...D1[k]D0[k];要求伪随机数发生器A生成的伪随机数A[k]与伪随机数发生器B生成的伪随机数B[k]不相关,即伪随机数发生器A的本原多项式与伪随机数发生器B的本原多项式不能是镜像本原多项式,由于伪随机数发生器A与伪随机数发生器B之间不相关,生成的伪随机数D[k]中的每一位是均匀分布的,因此D[k]是m位均匀分布伪随机数。A kind of pseudo-random number generation method, it is characterized in that: based on the N a bit pseudo-random number generator A of the longest linear feedback shift register of parallel structure, the evenly distributed pseudo-random number of m bit has been generated, and is denoted as A[k] , represented in binary as A m-1 [k]A m-2 [k]...A 1 [k]A 0 [k]; Pseudo -random The number generator B generates a uniformly distributed pseudo-random number of m bits, denoted as B[k], expressed in binary as B m-1 [k]B m-2 [k]...B 1 [k]B 0 [k]; the pseudo-random number A[k] and the corresponding data bits in the pseudo-random number B[k] are XORed to generate a pseudo-random number D[k], expressed in binary as D m-1 [k]D m-2 [k]...D 1 [k]D 0 [k]; It is required that the pseudo-random number A[k] generated by pseudo-random number generator A and the pseudo-random number B[k] generated by pseudo-random number generator B[ k] is irrelevant, that is, the primitive polynomial of pseudo-random number generator A and the primitive polynomial of pseudo-random number generator B cannot be mirror primitive polynomials, because the relationship between pseudo-random number generator A and pseudo-random number generator B Irrelevant, each bit in the generated pseudo-random number D[k] is uniformly distributed, so D[k] is an m-bit uniformly distributed pseudo-random number.
本发明为一种对两个以上伪随机数发生器进行运算,产生长序列周期高速伪随机数的方法;其中每个伪随机数的产生基于并行结构最长线性反馈移位寄存器电路;要求参与运算的伪随机数发生器产生的伪随机数互不相关。本发明能实时产生有多个数据位的均匀分布伪随机数,也能产生其它分布的伪随机数,还能产生宽频带的数字白噪声信号,其均值、方差等参数可调节。The invention is a method for operating two or more pseudo-random number generators to generate high-speed pseudo-random numbers with a long sequence period; wherein each pseudo-random number is generated based on the longest linear feedback shift register circuit in a parallel structure; participation is required The pseudo-random numbers generated by the pseudo-random number generator of the operation are not correlated with each other. The invention can generate evenly distributed pseudo-random numbers with a plurality of data bits in real time, as well as other distributed pseudo-random numbers, and can also generate wide-band digital white noise signals, whose parameters such as mean value and variance can be adjusted.
附图说明Description of drawings
图1固态噪声信号发生器原理框图。Figure 1 Block diagram of solid-state noise signal generator.
图2高斯分布数字噪声信号发生器原理框图。Figure 2 Gaussian distribution digital noise signal generator block diagram.
图3二进制均匀分布数字噪声信号发生器原理框图。Figure 3 is a block diagram of a digital noise signal generator with binary uniform distribution.
图4最长线性反馈移位寄存器原理框图。Figure 4. Block diagram of longest linear feedback shift register.
图5从8位最长线性反馈移位寄存器抽取4位数的原理框图。Fig. 5 is a functional block diagram of extracting 4 digits from an 8-bit longest linear feedback shift register.
图6并行结构伪随机数发生电路原理框图。Figure 6 is a schematic block diagram of a pseudo-random number generating circuit with a parallel structure.
图7发明的长序列周期高速伪随机数产生电路原理框图。Figure 7 is a schematic block diagram of a long sequence period high-speed pseudo-random number generation circuit invented.
图8有三个电路单元的高速伪随机数产生电路原理框图。Fig. 8 is a schematic block diagram of a high-speed pseudo-random number generating circuit with three circuit units.
图9不同分布伪随机数产生电路原理框图。Fig. 9 is a schematic block diagram of a pseudo-random number generation circuit with different distributions.
图10伪随机数产生电路的一个具体实施原理框图。Fig. 10 is a functional block diagram of a specific implementation of the pseudo-random number generating circuit.
图11伪随机数产生电路的另一个具体实施原理框图。Fig. 11 is a functional block diagram of another specific implementation of the pseudo-random number generating circuit.
图12高斯分布伪随机数概率密度曲线。Figure 12 Gaussian distribution pseudo-random number probability density curve.
图13高斯分布伪随机数累积分布函数曲线。Figure 13 Gaussian distribution pseudo-random number cumulative distribution function curve.
图14产生高斯分布伪随机数时查找表中的数值曲线。Fig. 14 is the numerical curve in the lookup table when generating Gaussian distributed pseudo-random numbers.
图158位伪随机数发生器示意图。Figure 158 Schematic diagram of a pseudo-random number generator.
图16模式选择控制电路。Figure 16 mode selection control circuit.
具体实施方式Detailed ways
从最长线性反馈移位寄存器中抽取几位数的方法中相临伪随机数之间有部分数据位是相同的,只不过位置有所偏移,生成的伪随机数质量不好,需要做出改进。In the method of extracting several digits from the longest linear feedback shift register, some data bits between adjacent pseudo-random numbers are the same, but the positions are shifted, and the quality of the generated pseudo-random numbers is not good, so it needs to be done out improvement.
对于n位的最长线性反馈移位寄存器,内部寄存器的值表示了电路的状态{Q[k]},当前时刻寄存器的值记为Qn-1[k]、Qn-2[k]、Qn-3[k]...Q1[k]、Q0[k],Qn[k]为For an n-bit longest linear feedback shift register, the value of the internal register represents the state of the circuit {Q[k]}, and the value of the register at the current moment is recorded as Q n-1 [k], Q n-2 [k] , Q n-3 [k]...Q 1 [k], Q 0 [k], Q n [k] is
Qn[k]=c1Qn-1[k]⊕c2Qn-2[k]⊕c3Qn-3[k]⊕...⊕cn-1Q1[k]⊕cnQ0[k]Q n [k]=c 1 Q n-1 [k]⊕c 2 Q n-2 [k]⊕c 3 Q n-3 [k]⊕...⊕c n-1 Q 1 [k]⊕ c n Q 0 [k]
下时刻电路的状态记为{Q[k+1]},寄存器的值为Qn-1[k+1]、Qn-2[k+1]、Qn-3[k+1]...Q1[k+1]、Q0[k+1],则The state of the circuit at the next moment is recorded as {Q[k+1]}, and the values of the registers are Q n-1 [k+1], Q n-2 [k+1], Q n-3 [k+1]. ..Q 1 [k+1], Q 0 [k+1], then
Qn-1[k+1]=Qn[k]Qn -1 [k + 1]=Qn[k]
Qn-2[k+1]=Qn-1[k]Qn -2 [k+1]=Qn -1 [k]
Qn-3[k+1]=Qn-2[k]Qn -3 [k+1]=Qn -2 [k]
......
Q1[k+1]=Q2[k]Q 1 [k+1] = Q 2 [k]
Q0[k+1]=Q1[k]Q 0 [k+1]=Q 1 [k]
Qn[k+1]=c1Qn-1[k+1]⊕c2Qn-2[k+1]⊕c3Qn-3[k+1]⊕...⊕cn-1Q1[k+1]⊕cnQ0[k+1]Q n [k+1]=c 1 Q n-1 [k+1]⊕c 2 Q n-2 [k+1]⊕c 3 Q n-3 [k+1]⊕...⊕c n -1 Q 1 [k+1]⊕c n Q 0 [k+1]
下下时刻电路的状态记为{Q[k+2]},寄存器的值为Qn-1[k+2]、Qn-2[k+2]、Qn-3[k+2]...Q1[k+2]、Q0[k+2],则The state of the circuit at the next moment is recorded as {Q[k+2]}, and the values of the registers are Q n-1 [k+2], Q n-2 [k+2], Q n-3 [k+2] ...Q 1 [k+2], Q 0 [k+2], then
Qn-1[k+2]=Qn[k+1]Qn -1 [k+2]=Qn[k + 1]
Qn-2[k+2]=Qn-1[k+1]Qn -2 [k+2]=Qn -1 [k+1]
Qn-3[k+2]=Qn-2[k+1]Qn -3 [k+2]=Qn -2 [k+1]
......
Q1[k+2]=Q2[k+1]Q 1 [k+2] = Q 2 [k+1]
Q0[k+2]=Q1[k+1]Q 0 [k+2]=Q 1 [k+1]
Qn[k+2]=c1Qn-1[k+2]⊕c2Qn-2[k+2]⊕c3Qn-3[k+2]⊕...⊕cn-1Q1[k+2]⊕cnQ0[k+2]Q n [k+2]=c 1 Q n-1 [k+2]⊕c 2 Q n-2 [k+2]⊕c 3 Q n-3 [k+2]⊕...⊕c n -1 Q 1 [k+2]⊕c n Q 0 [k+2]
依次类推。如果准备并行输出m位的二进制数据,为了克服前述方法生成伪随机数的缺点,需要来m个时钟,将电路的状态从{Q[k]}变为{Q[k+m]},寄存器的值为Qn-1[k+m]、Qn-2[k+m]、Qn-3[k+m]...Q1[k+m]、Q0[k+m]。用这种方法生成的m位的二进制数据为Qm-1[k+m]、Qm-2[k+m]、...、Q1[k+m]、Q0[k+m]。这样生成的m位伪随机数前后之间没有任何数据位是相同的,很好地的克服了数据之间的相关性,伪随机数的质量得到了极大改善。由于每位二进制数“0”与“1”码元的概率是相同的,因此生成的m位的伪随机数是均匀分布的。当m位的伪随机数看作补码时,数值范围为[-2m-1,2m-1-1]。当m位的伪随机数看作无符号数时,数值范围为[0,2m-1]。And so on. If you plan to output m-bit binary data in parallel, in order to overcome the shortcomings of the aforementioned method to generate pseudo-random numbers, m clocks are needed to change the state of the circuit from {Q[k]} to {Q[k+m]}, register The values of Q n-1 [k+m], Q n-2 [k+m], Q n-3 [k+m]...Q 1 [k+m], Q 0 [k+m] . The m-bit binary data generated in this way are Q m-1 [k+m], Q m-2 [k+m], ..., Q 1 [k+m], Q 0 [k+m ]. No data bit is the same before and after the m-bit pseudo-random number generated in this way, the correlation between data is well overcome, and the quality of the pseudo-random number is greatly improved. Since the probability of each binary number "0" and "1" symbols is the same, the generated m-bit pseudo-random numbers are evenly distributed. When the m-bit pseudo-random number is regarded as a complement code, the value range is [-2 m-1 , 2 m-1 -1]. When the m-bit pseudo-random number is regarded as an unsigned number, the value range is [0,2 m -1].
上述方法的缺点是每来m次时钟,才能得到一个伪随机数,因此电路生成伪随机数的速度下降了m倍。如果对上述电路的状态{Q[k]}递推,依次得到{Q[k+1]}...{Q[k+m]},将电路状态{Q[k+m]}的逻辑推导出只依赖于{Q[k]}的状态,那么设计出来的最长线性反馈移位寄存器每来一个时钟,就能输出一个m位的伪随机数,生成伪随机数的速度得到了极大提高,其内部状态相当于原来的最长线性反馈移位寄存器改变m次的状态。这种并行结构的最长线性反馈移位寄存器原理框图如图6所示。The disadvantage of the above method is that a pseudo-random number can only be obtained every m times of the clock, so the speed of the circuit to generate pseudo-random numbers is reduced by m times. If the state {Q[k]} of the above circuit is deduced recursively, {Q[k+1]}...{Q[k+m]} is obtained in turn, and the logic of the circuit state {Q[k+m]} It is deduced that it only depends on the state of {Q[k]}, then the designed longest linear feedback shift register can output an m-bit pseudo-random number every time a clock comes, and the speed of generating pseudo-random numbers has been greatly improved. It is greatly improved, and its internal state is equivalent to the original state of the longest linear feedback shift register changing m times. The block diagram of the longest linear feedback shift register with this parallel structure is shown in Figure 6.
本发明提出了一种将一个并行结构最长线性反馈移位寄存器与一个以上并行结构最长线性反馈移位寄存器相结合产生长序列周期伪随机数的方法,原理框图如图7所示。The present invention proposes a method for generating pseudo-random numbers with a long sequence period by combining a longest linear feedback shift register with a parallel structure and more than one longest linear feedback shift register with a parallel structure. The principle block diagram is shown in FIG. 7 .
如果基于并行结构最长线性反馈移位寄存器的Na位伪随机数发生器A,生成了m位的均匀分布伪随机数,记为A[k],以二进制表示为Am-1[k]Am-2[k]...A1[k]A0[k]。基于并行结构的Nb位最长线性反馈移位寄存器的伪随机数发生器B,生成了m位的均匀分布伪随机数,记为B[k],以二进制表示为Bm-1[k]Bm-2[k]...B1[k]B0[k]。伪随机数A[k]与伪随机数B[k]中对应数据位进行异或运算,生成伪随机数D[k],以二进制表示为Dm-1[k]Dm-2[k]...D1[k]D0[k]。要求伪随机数发生器A生成的伪随机数A[k]与伪随机数发生器B生成的伪随机数B[k]不相关,即伪随机数发生器A的本原多项式与伪随机数发生器B的本原多项式不能是镜像本原多项式。由于伪随机数发生器A与伪随机数发生器B之间不相关,生成的伪随机数D[k]中的每一位是均匀分布的,因此D[k]是m位均匀分布伪随机数。If the N a -bit pseudo-random number generator A based on the longest linear feedback shift register in parallel structure generates a uniformly distributed pseudo-random number of m bits, which is recorded as A[k] and expressed in binary as A m-1 [k ]A m-2 [k]...A 1 [k]A 0 [k]. Based on the pseudo-random number generator B of N b -bit longest linear feedback shift register with parallel structure, a uniformly distributed pseudo-random number of m bits is generated, denoted as B[k], expressed in binary as B m-1 [k ]B m-2 [k]...B 1 [k]B 0 [k]. The pseudo-random number A[k] is XORed with the corresponding data bits in the pseudo-random number B[k] to generate a pseudo-random number D[k], which is expressed in binary as D m-1 [k]D m-2 [k ]... D 1 [k] D 0 [k]. It is required that the pseudo-random number A[k] generated by pseudo-random number generator A is not related to the pseudo-random number B[k] generated by pseudo-random number generator B, that is, the original polynomial of pseudo-random number generator A and the pseudo-random number The primitive polynomial of generator B cannot be a mirror primitive polynomial. Since there is no correlation between pseudo-random number generator A and pseudo-random number generator B, each bit in the generated pseudo-random number D[k] is uniformly distributed, so D[k] is m-bit uniformly distributed pseudo-random number.
当m为偶数时,并行结构伪随机数发生器A的序列周期为2Na-1,并行结构伪随机数发生器B的序列周期为2Nb-1。伪随机数D[k]的序列周期为伪随机数发生器A与B序列周期的最小公倍数。因此伪随机数D[k]的序列周期得到了极大扩展。When m is an even number, the sequence period of the parallel structure pseudo-random number generator A is 2 Na -1, and the sequence period of the parallel structure pseudo-random number generator B is 2 Nb -1. The sequence period of the pseudo-random number D[k] is the least common multiple of the sequence periods of the pseudo-random number generators A and B. Therefore, the sequence period of the pseudo-random number D[k] has been greatly extended.
采用三级伪随机数发生器电路结构时,原理框图如图8所示。基于并行结构最长线性反馈移位寄存器的Na位伪随机数发生器A,生成了m位的均匀分布伪随机数,记为A[k]。基于并行结构最长线性反馈移位寄存器的Nb位伪随机数发生器B,生成了m位的均匀分布伪随机数,记为B[k]。基于并行结构最长线性反馈移位寄存器的Nc位伪随机数发生器C,生成了m位的均匀分布伪随机数,记为C[k]。A[k]与B[k]与C[k]进行异或运算,生成m位的均匀分布伪随机数D[k]。要求伪随机数发生器A与伪随机数发生器B与伪随机数发生器C互不相关。When the three-stage pseudo-random number generator circuit structure is adopted, the functional block diagram is shown in Figure 8. Based on the N a -bit pseudo-random number generator A with the longest linear feedback shift register in parallel structure, a uniformly distributed pseudo-random number of m bits is generated, which is denoted as A[k]. Based on the N b -bit pseudo-random number generator B of the longest linear feedback shift register in parallel structure, a uniformly distributed pseudo-random number of m bits is generated, which is denoted as B[k]. Based on the N c -bit pseudo-random number generator C of the longest linear feedback shift register in parallel structure, a uniformly distributed pseudo-random number of m bits is generated, which is denoted as C[k]. A[k], B[k] and C[k] perform XOR operation to generate m-bit uniformly distributed pseudo-random number D[k]. It is required that pseudo-random number generator A, pseudo-random number generator B, and pseudo-random number generator C are not correlated with each other.
当m为偶数时,并行结构伪随机数发生器A的序列周期为2Na-1,并行结构伪随机数发生器B的序列周期为2Nb-1,并行结构伪随机数发生器C的序列周期为2Nc-1。伪随机数D[k]的序列周期为伪随机数发生器A与B与C序列周期的最小公倍数。因此伪随机数D[k]的序列周期得到了极大扩展。When m is an even number, the sequence period of the parallel structure pseudo-random number generator A is 2 Na -1, the sequence period of the parallel structure pseudo-random number generator B is 2 Nb -1, and the sequence period of the parallel structure pseudo-random number generator C is The period is 2 Nc -1. The sequence period of the pseudo-random number D[k] is the least common multiple of the sequence periods of the pseudo-random number generators A, B and C. Therefore, the sequence period of the pseudo-random number D[k] has been greatly expanded.
可以设计有更多电路单元的伪随机数发生器。例如可以设计有四个并行结构最长线性反馈移位寄存器的伪随机数发生器,将这四个伪随机数发生器的输出进行异或运算,生成有多个数据位的均匀分布伪随机数。要求这四个伪随机数发生器互不相关。生成伪随机数的序列周期为这四个伪随机数发生器序列周期的最小公倍数。A pseudo-random number generator with more circuit elements can be designed. For example, a pseudo-random number generator with four longest linear feedback shift registers in parallel structure can be designed, and the outputs of these four pseudo-random number generators can be XORed to generate uniformly distributed pseudo-random numbers with multiple data bits. . The four pseudo-random number generators are required to be uncorrelated with each other. The sequence period for generating pseudo-random numbers is the least common multiple of the sequence periods of the four pseudo-random number generators.
生成均匀分布的伪随机数后,就容易生成各种分布的伪随机数及噪声信号了。例如可以产生均匀分布、高斯分布、其它分布伪随机数,也可以产生均匀分布、高斯分布、其它分布数字白噪声信号,其均值、方差、谱密度可调节。由均匀分布伪随机数转换成其它分布伪随机数的电路框图如图9所示。生成其它分布伪随机数时,均匀分布伪随机数经过查找表转换成所需分布的伪随机数。改变查找表中的数值,可以改变伪随机数的分布、均值、方差。也可以生成所需分布、均值、方差、谱密度的伪随机数字白噪声信号。生成伪随机数字白噪声信号时,输出的数字噪声信号带宽最高约为电路时钟频率的一半。After generating uniformly distributed pseudo-random numbers, it is easy to generate pseudo-random numbers and noise signals of various distributions. For example, uniform distribution, Gaussian distribution, and other pseudo-random numbers can be generated, and digital white noise signals with uniform distribution, Gaussian distribution, and other distributions can also be generated. The mean, variance, and spectral density can be adjusted. The block diagram of the circuit for converting uniformly distributed pseudo-random numbers into other distributed pseudo-random numbers is shown in FIG. 9 . When generating pseudo-random numbers with other distributions, the uniformly distributed pseudo-random numbers are converted into pseudo-random numbers of the required distribution through a lookup table. Changing the values in the lookup table can change the distribution, mean and variance of the pseudo-random numbers. It is also possible to generate pseudo-random digital white noise signals with desired distribution, mean, variance, and spectral density. When generating a pseudo-random digital white noise signal, the bandwidth of the output digital noise signal is at most about half of the circuit clock frequency.
具体实施例:Specific examples:
以32位最长线性反馈移位寄存器生成8位伪随机数为例,说明本发明中用到的高速伪随机数生成方法的具体实现。取本原多项式1+x2+x6+x7+x32,当前时刻k的电路状态为{Q[k]},其寄存器值为Q31[k]、Q30[k]、...、Q1[k]、Q0[k],Q32[k]为Taking the 8-bit pseudo-random number generated by the 32-bit longest linear feedback shift register as an example, the specific implementation of the high-speed pseudo-random number generation method used in the present invention is described. Take the primitive polynomial 1+x 2 +x 6 +x 7 +x 32 , the circuit state of k at the current moment is {Q[k]}, and its register values are Q 31 [k], Q 30 [k], .. ., Q 1 [k], Q 0 [k], Q 32 [k] are
Q32[k]=Q30[k]⊕Q26[k]⊕Q25[k]⊕Q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q 32 [k+1]
⊕Q32[k]⊕Q7[k]=Q30[k]⊕Q29[k]⊕Q28[k]⊕Q27[k]⊕Q26[k]⊕Q 32 [k]⊕Q 7 [k]=Q 30 [k]⊕Q 29 [k]⊕Q 28 [k]⊕Q 27 [k]⊕Q 26 [k]
⊕Q5[k]⊕Q3[k]⊕Q1[k]⊕Q31[k]⊕Q27[k]⊕Q26[k]⊕Q1[k]⊕Q 5 [k]⊕Q 3 [k]⊕Q 1 [k]⊕Q 31 [k]⊕Q 27 [k]⊕Q 26 [k]⊕Q 1 [k]
⊕Q30[k]⊕Q26[k]⊕Q25[k]⊕Q0[k]⊕Q7[k]⊕Q 30 [k]⊕Q 26 [k]⊕Q 25 [k]⊕Q 0 [k]⊕Q 7 [k]
=Q31[k]⊕Q29[k]⊕Q28[k]⊕Q26[k]⊕Q25[k]⊕Q7[k]⊕Q5[k]⊕Q3[k]=Q 31 [k]⊕Q 29 [k]⊕Q 28 [k]⊕Q 26 [k]⊕Q 25 [k]⊕Q 7 [k]⊕Q 5 [k]⊕Q 3 [k]
⊕Q0[k]⊕Q 0 [k]
Q32[k+8]=Q30[k+8]⊕Q26[k+8]⊕Q25[k+8]⊕Q0[k+8]Q 32 [k+8]=Q 30 [k+8]⊕Q 26 [k+8]⊕Q 25 [k+8]⊕Q 0 [k+8]
推导出的上述各式中,k+8时刻的电路状态只依赖于k时刻的电路状态。用这种方法设计出的并行结构最长线性反馈移位寄存器每来一个时钟,就相当于原来的最长线性反馈移位寄存器的内部状态改变了8次,能输出1个8位的伪随机数,改进了串行输出方法速度慢的缺点。由于32位最长线性反馈移位寄存器有232-1个状态,其不能被8整除,因此8位伪随机数的周期为232-1。In the deduced above formulas, the state of the circuit at time k+8 only depends on the state of the circuit at time k. Each clock of the longest linear feedback shift register with parallel structure designed in this way is equivalent to the internal state of the original longest linear feedback shift register changing 8 times, and can output an 8-bit pseudo-random Number, improve the shortcoming of the slow speed of the serial output method. Since the 32-bit longest linear feedback shift register has 2 32 -1 states, which cannot be divisible by 8, the period of the 8-bit pseudo-random number is 2 32 -1.
用相同的方法可以推导出31位最长线性反馈移位寄存器的并行结构反馈逻辑电路。以生成8位伪随机数为例,取本原多项式1+x3+x31,当前时刻k的电路状态为{Q[k]},其寄存器值为Q30[k]、Q29[k]、...、Q1[k]、Q0[k],Q31[k]为The parallel structure feedback logic circuit of the longest linear feedback shift register of 31 bits can be deduced by the same method. Taking the generation of 8-bit pseudo-random numbers as an example, take the primitive polynomial 1+x 3 +x 31 , the circuit state of k at the current moment is {Q[k]}, and its register values are Q 30 [k], Q 29 [k ], ..., Q 1 [k], Q 0 [k], Q 31 [k] are
Q31[k]=Q28[k]⊕Q0[k]Q 31 [k]=Q 28 [k]⊕Q 0 [k]
则递推式中k+8时刻的电路状态{Q[k+8]}为Then the circuit state {Q[k+8]} at time k+8 in the recursive formula is
Q0[k+8]=Q8[k]Q 0 [k+8]=Q 8 [k]
Q1[k+8]=Q9[k]Q 1 [k+8] = Q 9 [k]
......
Q22[k+8]=Q30[k]Q 22 [k+8] = Q 30 [k]
Q23[k+8]=Q31[k]=Q28[k]⊕Q0[k]Q 23 [k+8]=Q 31 [k]=Q 28 [k]⊕Q 0 [k]
Q24[k+8]=Q31[k+1]=Q28[k+1]⊕Q0[k+1]Q 24 [k+8]=Q 31 [k+1]=Q 28 [k+1]⊕Q 0 [k+1]
=Q29[k]⊕Q1[k]=Q 29 [k]⊕Q 1 [k]
Q25[k+8]=Q31[k+2]=Q28[k+2]⊕Q0[k+2]Q 25 [k+8]=Q 31 [k+2]=Q 28 [k+2]⊕Q 0 [k+2]
=Q30[k]⊕Q2[k]=Q 30 [k]⊕Q 2 [k]
Q26[k+8]=Q31[k+3]=Q28[k+3]⊕Q0[k+3]Q 26 [k+8]=Q 31 [k+3]=Q 28 [k+3]⊕Q 0 [k+3]
=Q28[k]⊕Q3[k]⊕Q0[k]=Q 28 [k]⊕Q 3 [k]⊕Q 0 [k]
Q27[k+8]=Q31[k+4]=Q28[k+4]⊕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+1]⊕Q0[k+1]⊕Q4[k]⊕Q7[k]=Q 31 [k+1]⊕Q 4 [k]⊕Q 7 [k]=Q 28 [k+1]⊕Q 0 [k+1]⊕Q 4 [k]⊕Q 7 [k]
=Q29[k]⊕Q7[k]⊕Q4[k]⊕Q1[k]=Q 29 [k]⊕Q 7 [k]⊕Q 4 [k]⊕Q 1 [k]
Q31[k+8]=Q28[k+8]⊕Q0[k+8]=Q30[k]⊕Q8[k]⊕Q5[k]⊕Q2[k]Q 31 [k+8]=Q 28 [k+8]⊕Q 0 [k+8]=Q 30 [k]⊕Q 8 [k]⊕Q 5 [k]⊕Q 2 [k]
推导出的上述各式中,k+8时刻的电路状态只依赖于k时刻的电路状态。用这种方法设计出的并行结构最长线性反馈移位寄存器每来一个时钟,就相当于原来的最长线性反馈移位寄存器的内部状态改变了8次,能输出1个8位的伪随机数,改进了串行输出方法速度慢的缺点。由于31位最长线性反馈移位寄存器有231-1个状态,其不能被8整除,因此8位伪随机数的周期为231-1。In the deduced above formulas, the state of the circuit at time k+8 only depends on the state of the circuit at time k. Each clock of the longest linear feedback shift register with parallel structure designed in this way is equivalent to the internal state of the original longest linear feedback shift register changing 8 times, and can output an 8-bit pseudo-random Number, improve the shortcoming of the slow speed of the serial output method. Since the 31-bit longest linear feedback shift register has 2 31 -1 states, which cannot be divisible by 8, the period of the 8-bit pseudo-random number is 2 31 -1.
下面以两个电路单元的伪随机数发生器为例,说明本发明的一个具体实施。电路框图如图10所示。伪随机数发生器A为32位并行结构最长线性反馈移位寄存器,每来一个时钟输出一个8位伪随机数A[k],选择本原多项式1+x2+x6+x7+x32,其并行结构反馈逻辑前面已做过推导。伪随机数发生器B为31位并行结构最长线性反馈移位寄存器,每来一个时钟输出一个8位伪随机数B[k],选择本原多项式1+x3+x31,其并行结构反馈逻辑前面已做过推导。伪随机数A[k]与B[k]进行异或运算,生成伪随机数D[k]。伪随机数A[k]的序列周期为232-1。伪随机数B[k]的序列周期为231-1,是一个梅森素数。伪随机数D[k]的序列周期为伪随机数A[k]的序列周期与伪随机数B[k]的序列周期的最小公倍数,为(232-1)(231-1),约为263,比A[k]的序列周期大大增加。伪随机数的序列周期越长,性能越接近理想随机数。A specific implementation of the present invention will be described below by taking a pseudo-random number generator with two circuit units as an example. The block diagram of the circuit is shown in Figure 10. The pseudo-random number generator A is the longest linear feedback shift register with a 32-bit parallel structure, and outputs an 8-bit pseudo-random number A[k] every time a clock comes, and selects the primitive polynomial 1+x 2 +x 6 +x 7 + x 32 , its parallel structure feedback logic has been deduced earlier. The pseudo-random number generator B is the longest linear feedback shift register with a 31-bit parallel structure, and outputs an 8-bit pseudo-random number B[k] every time a clock comes, and selects the primitive polynomial 1+x 3 +x 31 , and its parallel structure The feedback logic has been deduced earlier. The pseudo-random number A[k] is XORed with B[k] to generate the pseudo-random number D[k]. The sequence period of the pseudo-random number A[k] is 2 32 -1. The sequence period of the pseudo-random number B[k] is 2 31 -1, which is a Mersenne prime number. The sequence period of the pseudo-random number D[k] is the least common multiple of the sequence period of the pseudo-random number A[k] and the sequence period of the pseudo-random number B[k], which is (2 32 -1)(2 31 -1), It is about 2 63 , which is greatly increased than the sequence period of A[k]. The longer the sequence period of the pseudo-random number is, the closer the performance is to the ideal random number.
下面以三个电路单元的伪随机数发生器为例,说明本发明的另一个具体实施。电路框图如图11所示。伪随机数发生器A为32位并行结构最长线性反馈移位寄存器,每来一个时钟输出一个8位伪随机数A[k],选择本原多项式1+x2+x6+x7+x32。伪随机数发生器B为31位并行结构最长线性反馈移位寄存器,每来一个时钟输出一个8位伪随机数B[k],其本原多项式为1+x3+x31。伪随机数发生器C为19位并行结构最长线性反馈移位寄存器,每来一个时钟输出一个8位伪随机数C[k],其本原多项式为1+x+x2+x5+x19,其并行结构反馈逻辑可参考前面的推导方法。伪随机数A[k]与B[k]与C[k]进行异或运算,生成8位伪随机数D[k]。伪随机数A[k]的序列周期为232-1。伪随机数B[k]的序列周期为231-1,是一个梅森素数。伪随机数C[k]的序列周期为219-1,是一个梅森素数。伪随机数D[k]的序列周期为伪随机数A[k]与B[k]与C[k]的序列周期的最小公倍数,为(232-1)(231-1)(219-1),约为282,比A[k]的序列周期大大增加。应说明,本例中伪随机数发生器A与伪随机数发生器B与伪随机数发生器C的阶数选择是任意的,只要三者互不相关即可。Another specific implementation of the present invention will be described below by taking a pseudo-random number generator with three circuit units as an example. The block diagram of the circuit is shown in Figure 11. The pseudo-random number generator A is the longest linear feedback shift register with a 32-bit parallel structure, and outputs an 8-bit pseudo-random number A[k] every time a clock comes, and selects the primitive polynomial 1+x 2 +x 6 +x 7 + x32 . Pseudo-random number generator B is the longest linear feedback shift register with 31-bit parallel structure, and outputs an 8-bit pseudo-random number B[k] every clock, and its primitive polynomial is 1+x 3 +x 31 . Pseudo-random number generator C is the longest linear feedback shift register with 19-bit parallel structure, and outputs an 8-bit pseudo-random number C[k] every time a clock comes, and its primitive polynomial is 1+x+x 2 +x 5 + x 19 , its parallel structure feedback logic can refer to the previous derivation method. Pseudo-random numbers A[k], B[k] and C[k] are XORed to generate 8-bit pseudo-random numbers D[k]. The sequence period of the pseudo-random number A[k] is 2 32 -1. The sequence period of the pseudo-random number B[k] is 2 31 -1, which is a Mersenne prime number. The sequence period of the pseudo-random number C[k] is 2 19 -1, which is a Mersenne prime number. The sequence period of the pseudo-random number D[k] is the least common multiple of the sequence periods of the pseudo-random numbers A[k], B[k] and C[k], which is (2 32 -1)(2 31 -1)(2 19 -1), about 2 82 , which is greatly increased than the sequence period of A[k]. It should be noted that in this example, the selection of the order of pseudo-random number generator A, pseudo-random number generator B, and pseudo-random number generator C is arbitrary, as long as the three are not correlated with each other.
本发明可产生均匀分布伪随机数、高斯分布伪随机数,也可以产生其它分布伪随机数,其均值、方差可调节。The invention can generate pseudo-random numbers with uniform distribution, pseudo-random numbers with Gaussian distribution, and pseudo-random numbers with other distributions, and the mean value and variance can be adjusted.
要产生概率密度为f(x)的随机数,其累积分布函数为F(x),有To generate a random number with probability density f(x), its cumulative distribution function is F(x), there is
当y为[0,1.0]之间的均匀分布伪随机数序列时,x即为概率密度为f(x)的伪随机数序列。When y is a uniformly distributed pseudo-random number sequence between [0,1.0], x is a pseudo-random number sequence with probability density f(x).
工程实践中,产生的伪随机数范围不是从负无穷大到正无穷大,而是一个有位数限制的伪随机数。因此,实际产生的某种分布的随机数,是对这种分布的理想随机数的一种近似。例如要产生一个8位的伪随机数,其数值范围为-128~127,要产生一个16位的伪随机数,其数值范围为-32768~32767。由y值得到x值可通过一个查找表电路实现。查找表是一个通过输入地址值查找得到输出数值的电路,一般用RAM实现。In engineering practice, the range of pseudo-random numbers generated is not from negative infinity to positive infinity, but a pseudo-random number with a limit on the number of digits. Therefore, the random numbers of a certain distribution actually generated are an approximation of the ideal random numbers of this distribution. For example, to generate an 8-bit pseudo-random number, its value range is -128 to 127, and to generate a 16-bit pseudo-random number, its value range is -32768 to 32767. Obtaining the x value from the y value can be realized by a look-up table circuit. A lookup table is a circuit that obtains an output value by looking up an input address value, and is generally implemented with RAM.
产生均匀分布伪随机数时,由以上方法得知,查找表中存储的数值曲线为一条直的斜线。When generating uniformly distributed pseudo-random numbers, it can be known from the above method that the numerical curve stored in the lookup table is a straight oblique line.
产生高斯分布伪随机数时,其概率密度曲线如图12所示,其累积分布函数曲线如图13所示,查找表中存储的数值曲线如图14所示。When the Gaussian distribution pseudo-random number is generated, its probability density curve is shown in Figure 12, its cumulative distribution function curve is shown in Figure 13, and the numerical curve stored in the lookup table is shown in Figure 14.
用以上方法,可产生其它分布的伪随机数。生成不同的伪随机数,只需按要求,计算好查找表中的数值曲线,进行装载即可。Using the above method, pseudo-random numbers of other distributions can be generated. To generate different pseudo-random numbers, you only need to calculate the numerical curve in the lookup table as required and load it.
本发明可产生长序列周期伪随机数,也可产生宽频带的数字白噪声信号,其均值、方差等参数可调节。当产生伪随机数时,外部CPU通过读接口电路将伪随机数读出,每读一次,读出当前伪随机数,并生成下一个伪随机数。当产生数字白噪声信号时,需要一个时钟,在时钟的激励下生成高速数字噪声信号。The invention can generate pseudo-random numbers with a long sequence period, and can also generate wide-band digital white noise signals, whose parameters such as mean value and variance can be adjusted. When the pseudo-random number is generated, the external CPU reads the pseudo-random number through the read interface circuit, reads the current pseudo-random number every time, and generates the next pseudo-random number. When generating a digital white noise signal, a clock is needed to generate a high-speed digital noise signal under the excitation of the clock.
下面以产生8位伪随机数与数字噪声信号为例,说明其工作原理。当伪随机数发生电路以图15表示时,伪随机数及数字噪声信号发生控制电路如图16所示。电路中MODE_SEL为模式选择输入信号,为0时选择产生噪声信号,为1时选择产生伪随机数。CLK为输入时钟信号。/CS为片选输入信号,当为0时,表示对本电路进行操作。/RD为CPU发出的读输入信号,当为0时,表示进行读操作。RNG[7..0]为伪随机数输入信号,来自伪随机数发生电路。RNGCLK为时钟输出信号,连接至上图,作为伪随机数发生电路的时钟。Q[7..0]为数字噪声输出信号,当选择产生噪声信号模式时,每一个时钟的上升沿输出一个数字噪声信号,输出数字白噪声信号的带宽最大约为时钟频率的一半。DB[7..0]为伪随机数输出信号,连接至CPU的数据总线上,为三态信号,当选择产生伪随机数模式时,CPU对本电路每读一次,伪随机数发生电路输出一个伪随机数,同时产生下一个伪随机数。The following takes the generation of 8-bit pseudo-random numbers and digital noise signals as an example to illustrate its working principle. When the pseudo-random number generation circuit is shown in FIG. 15 , the pseudo-random number and digital noise signal generation control circuit is shown in FIG. 16 . In the circuit, MODE_SEL is the mode selection input signal. When it is 0, it selects to generate a noise signal, and when it is 1, it selects to generate a pseudo-random number. CLK is the input clock signal. /CS is the chip select input signal, when it is 0, it means that the circuit is operated. /RD is the read input signal sent by the CPU. When it is 0, it means that the read operation is performed. RNG[7..0] is a pseudo-random number input signal, which comes from a pseudo-random number generation circuit. RNGCLK is the clock output signal, which is connected to the above figure as the clock of the pseudo-random number generator circuit. Q[7..0] is the digital noise output signal. When the noise signal generation mode is selected, a digital noise signal is output at each rising edge of the clock, and the bandwidth of the output digital white noise signal is at most about half of the clock frequency. DB[7..0] is a pseudo-random number output signal, which is connected to the data bus of the CPU and is a three-state signal. When the pseudo-random number generation mode is selected, the CPU reads this circuit once, and the pseudo-random number generation circuit outputs a Pseudo-random number, while generating the next pseudo-random number.
对伪随机数或数字噪声信号进行采样,采样序列设为{xi},N个样本的均值u为:Sampling the pseudo-random number or digital noise signal, the sampling sequence is set to { xi }, and the mean value u of N samples is:
方差σ2相当于求信号交流部分的功率,公式为:The variance σ 2 is equivalent to finding the power of the AC part of the signal, the formula is:
当N值较大时,采样序列的均值u、方差σ2可以作为该信号的真实均值、真实方差的一个估计,其误差很小。When the value of N is large, the mean u and variance σ2 of the sampling sequence can be used as an estimate of the true mean and true variance of the signal, and its error is very small.
把均值为u、方差为σ2的伪随机数序列{xi}归一化成均值为0、方差为1的伪随机数序列{yi},公式为:Normalize the pseudo-random number sequence {x i } with mean u and variance σ 2 into a pseudo-random number sequence {y i } with mean 0 and variance 1, the formula is:
用均值为0、方差为1的伪随机数序列{xi}构造均值为u、方差为σ2的伪随机数序列{yi},公式为:Use the pseudo-random number sequence {x i } with mean value 0 and variance 1 to construct a pseudo-random number sequence {y i } with mean value u and variance σ 2 , the formula is:
yi=u+σ*xi y i =u+σ*x i
设带限数字白噪声信号的带宽为B、均值为0、方差为σ2,则其幅度谱密度为:Assuming that the bandwidth of the band-limited digital white noise signal is B, the mean is 0, and the variance is σ 2 , then its amplitude spectral density is:
A(f)=σ/BA(f)=σ/B
功率谱密度为:The power spectral density is:
P(f)=σ2/BP(f)=σ 2 /B
用以上方法,可控制输出伪随机数的均值、方差,以及数字白噪声信号的均值、方差、幅度谱密度或功率谱密度。With the above method, the mean value and variance of the output pseudo-random number, and the mean value, variance, amplitude spectral density or power spectral density of the digital white noise signal can be controlled.
使用高速FPGA电路实现本文论述的方法,时钟频率可达500MHz,可每秒产生500M个伪随机数,可输出200MHz带宽以上的宽带数字噪声信号。使用超高速的数字电路实现,可输出更高带宽的数字噪声信号。Using a high-speed FPGA circuit to implement the method discussed in this paper, the clock frequency can reach 500MHz, can generate 500M pseudo-random numbers per second, and can output broadband digital noise signals with a bandwidth of 200MHz or more. Realized by ultra-high-speed digital circuits, it can output digital noise signals with higher bandwidth.
应当理解本文所述的例子和实施方式仅为了说明,本领域技术人员可根据它做出各种修改或变化,在不脱离本发明的精神实质的情况下,都属于本发明的保护范围。It should be understood that the examples and implementations described herein are only for illustration, and those skilled in the art can make various modifications or changes based on them, all of which belong to the protection scope of the present invention without departing from the spirit of the present invention.
Claims (1)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510494086.2A CN105045561A (en) | 2015-08-12 | 2015-08-12 | Pseudo-random number generating method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510494086.2A CN105045561A (en) | 2015-08-12 | 2015-08-12 | Pseudo-random number generating method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105045561A true CN105045561A (en) | 2015-11-11 |
Family
ID=54452128
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510494086.2A Pending CN105045561A (en) | 2015-08-12 | 2015-08-12 | Pseudo-random number generating method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105045561A (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106844411A (en) * | 2016-10-19 | 2017-06-13 | 中科聚信信息技术(北京)有限公司 | A kind of big data random access system and method based on reducing subspaces |
CN107733547A (en) * | 2017-09-26 | 2018-02-23 | 国网山西省电力公司电力科学研究院 | The spread spectrum coded signal and its generation system of a kind of electromagnetic surveying |
CN109697048A (en) * | 2017-10-20 | 2019-04-30 | 图核有限公司 | Randomness is generated in neural network |
CN110633070A (en) * | 2019-09-12 | 2019-12-31 | 成都锐成芯微科技股份有限公司 | Pseudo-random number generator and pseudo-random number generation method |
CN110780846A (en) * | 2019-09-29 | 2020-02-11 | 太原理工大学 | Method and device for generating high-speed physical random number from low-speed physical random number |
CN110909375A (en) * | 2019-10-12 | 2020-03-24 | 浙江工业大学 | An Address Desensitization Method Preserving Distribution Features |
CN111538476A (en) * | 2020-04-20 | 2020-08-14 | 佳缘科技股份有限公司 | Fine-grained correction method for improving randomness of output sequence |
CN112840543A (en) * | 2018-08-21 | 2021-05-25 | 德克萨斯仪器股份有限公司 | Spectrum shaping of spread spectrum clock/frequency by post-processing |
CN112947895A (en) * | 2021-01-28 | 2021-06-11 | 长春汇通光电技术有限公司 | Position reading obtaining method, position reading obtaining device, encoder and storage medium |
CN114416024A (en) * | 2022-01-24 | 2022-04-29 | 扬州宇安电子科技有限公司 | Noise modulation method and modulator combining Gaussian distribution and pseudo-random distribution |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1914590A (en) * | 2004-01-30 | 2007-02-14 | 日本胜利株式会社 | Pseudo random number generation device and pseudo random number generation program |
CN102314332A (en) * | 2011-07-27 | 2012-01-11 | 中国科学院计算机网络信息中心 | Pseudo random number generation device and method |
CN102736891A (en) * | 2011-12-22 | 2012-10-17 | 云南大学 | Design of parallel adjustable pseudorandom sequence generator |
-
2015
- 2015-08-12 CN CN201510494086.2A patent/CN105045561A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1914590A (en) * | 2004-01-30 | 2007-02-14 | 日本胜利株式会社 | Pseudo random number generation device and pseudo random number generation program |
CN102314332A (en) * | 2011-07-27 | 2012-01-11 | 中国科学院计算机网络信息中心 | Pseudo random number generation device and method |
CN102736891A (en) * | 2011-12-22 | 2012-10-17 | 云南大学 | Design of parallel adjustable pseudorandom sequence generator |
Non-Patent Citations (3)
Title |
---|
戴志平 等: "《SystemView数字通信系统仿真设计》", 31 August 2011, 北京邮电大学出版社 * |
王华奎 等: "《移动通信原理》", 31 January 2009, 清华大学出版社 * |
王澜涛 等: "基于m序列的可重构线性反馈移位寄存器研究", 《电脑与信息技术》 * |
Cited By (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106844411A (en) * | 2016-10-19 | 2017-06-13 | 中科聚信信息技术(北京)有限公司 | A kind of big data random access system and method based on reducing subspaces |
CN106844411B (en) * | 2016-10-19 | 2020-03-17 | 中科聚信信息技术(北京)有限公司 | Joseph ring-based big data random access system and method |
CN107733547B (en) * | 2017-09-26 | 2019-11-08 | 国网山西省电力公司电力科学研究院 | A method and system for generating spread-spectrum coded signals for electromagnetic detection |
CN107733547A (en) * | 2017-09-26 | 2018-02-23 | 国网山西省电力公司电力科学研究院 | The spread spectrum coded signal and its generation system of a kind of electromagnetic surveying |
CN109697048A (en) * | 2017-10-20 | 2019-04-30 | 图核有限公司 | Randomness is generated in neural network |
CN109697048B (en) * | 2017-10-20 | 2024-03-22 | 图核有限公司 | Generating randomness in a neural network |
CN112840543A (en) * | 2018-08-21 | 2021-05-25 | 德克萨斯仪器股份有限公司 | Spectrum shaping of spread spectrum clock/frequency by post-processing |
CN110633070A (en) * | 2019-09-12 | 2019-12-31 | 成都锐成芯微科技股份有限公司 | Pseudo-random number generator and pseudo-random number generation method |
CN110780846A (en) * | 2019-09-29 | 2020-02-11 | 太原理工大学 | Method and device for generating high-speed physical random number from low-speed physical random number |
CN110909375A (en) * | 2019-10-12 | 2020-03-24 | 浙江工业大学 | An Address Desensitization Method Preserving Distribution Features |
CN110909375B (en) * | 2019-10-12 | 2022-04-08 | 浙江工业大学 | Address desensitization method for reserving distribution characteristics |
CN111538476A (en) * | 2020-04-20 | 2020-08-14 | 佳缘科技股份有限公司 | Fine-grained correction method for improving randomness of output sequence |
CN112947895A (en) * | 2021-01-28 | 2021-06-11 | 长春汇通光电技术有限公司 | Position reading obtaining method, position reading obtaining device, encoder and storage medium |
CN114416024A (en) * | 2022-01-24 | 2022-04-29 | 扬州宇安电子科技有限公司 | Noise modulation method and modulator combining Gaussian distribution and pseudo-random distribution |
CN114416024B (en) * | 2022-01-24 | 2022-12-02 | 扬州宇安电子科技有限公司 | Noise modulation method and modulator combining Gaussian distribution and pseudo-random distribution |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105045561A (en) | Pseudo-random number generating method | |
CN105138306A (en) | Generation method for pseudo-random signals with optional data bits | |
Masoodi et al. | An analysis of linear feedback shift registers in stream ciphers | |
CN102314332B (en) | Pseudo random number generation device and method | |
CN105138307B (en) | It is a kind of that true random-number generating method and device are integrated based on phase noise | |
CN105183428A (en) | Pseudo-random signal generation method | |
WO2020014993A1 (en) | Fpga-based method for designing parallel pseudo-random sequence generator | |
CN105183427A (en) | Method for generating different-distribution high-speed noise signals | |
CN109039522B (en) | An Optimization Method of Spreading Code Balance Based on Chaotic Sequence | |
US3885139A (en) | Wideband digital pseudo-gaussian noise generator | |
CN204856461U (en) | Optional pseudo -random signal generator of data bits | |
CN204883682U (en) | Multichannel pseudo -random signal generator | |
CN106293615B (en) | True Random Number Generator based on fully connected network | |
CN103441813B (en) | A kind of low associated binary sequence set creation method for cdma system | |
CN106201436B (en) | True Random Number Generator based on double coupling Fibonacci oscillation rings | |
Ramasamy et al. | A modified PRBS: vertical stacked LFSR primitive polynomial for secure data communication | |
CN106230579B (en) | A Chaos-Based Pseudo-Random Signal Generation Method and Generator | |
CN105159652A (en) | Multi-channel pseudo-random signal generation method | |
TWI387921B (en) | A normal distributed random number generator by using the clt and the random number generating method thereof | |
RU2246129C2 (en) | Random numbers generation method | |
Ma et al. | A pseudo-random sequence generation scheme based on RNS and permutation polynomials | |
CN109947397A (en) | A kind of no inductance high-speed multichannel can integrate Chaotic Random Number Generator | |
Jonatan et al. | Gaussian Pseudo-Random Number Generator using LFSR's Rotation and Split | |
Goankar | Design of 8 bit 16 bit and 32 bit LFSR for PN Sequence Generation using VHDL | |
CN106325814A (en) | Real random number generator based on double-loop coupling oscillation circuit |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20151111 |