A random number generating device and method

By designing a random number generation device including a linear feedback shift register and a selection circuit, and using the control feedback coefficient and the selection circuit output signal, the problem of requiring two sets of devices to generate pseudo-random numbers and true random numbers in the prior art is solved. The effect of generating two numbers at the same time in one device is achieved, which reduces costs and improves reliability.

CN113760222BActive Publication Date: 2024-10-29LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110876885.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-31
Publication Date
2024-10-29
Estimated Expiration
2041-07-31

AI Technical Summary

Technical Problem

The existing technology requires two sets of devices to generate pseudo-random numbers and true random numbers respectively, resulting in high cost and low reliability, and it is difficult to provide two kinds of random numbers conveniently and effectively at the same time.

Method used

Design a random number generation device, including a linear feedback shift register of n-level flip-flops and n selection circuits. By controlling the feedback coefficient and the selection circuit output signal, it can generate pseudo-random numbers in pseudo-random number mode and achieve true randomness in the pseudo-random number mode. True random numbers are generated in digital mode, and the same linear feedback shift register is used to generate two types of numbers.

Benefits of technology

It realizes the simultaneous generation of pseudo-random numbers and true random numbers in one device, which reduces costs, improves reliability, and has high flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760222B_ABST
    Figure CN113760222B_ABST
Patent Text Reader

Abstract

The present application discloses a random number generating device and method, including: a linear feedback shift register including n-stage triggers; n selection circuits respectively connected to the n-stage triggers, each selection circuit receiving a first clock signal and a second clock signal; a controller, used to: in a pseudo-random number mode, control each feedback coefficient of the linear feedback shift register, and control each selection circuit to select to output the first clock signal or to select to output the second clock signal, so that the random number generating device generates a pseudo-random number; in a true random number mode, control each feedback coefficient of the linear feedback shift register, and control the output signal selected by each selection circuit according to a preset rule, so that the linear feedback shift register appears in a metastable state, so that the random number generating device generates a true random number. The scheme of the present application can generate both pseudo-random numbers and true random numbers, and has high flexibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of circuit technology, and in particular to a random number generating device and method. Background Art

[0002] At present, information security is becoming more and more important in people's lives. The leakage of important information may bring serious consequences to individuals and enterprises. Therefore, strengthening information security is one of the important topics at present. At present, the main way to achieve information security is data encryption, and various encryption algorithms are inseparable from keys. Keys are composed of random numbers. Therefore, random numbers are currently widely used in cryptography. There are two types of random numbers: one is pseudo-random numbers, and the other is true random numbers.

[0003] Pseudo-random numbers can be simulated according to a certain algorithm, and the results are certain and visible. Usually, pseudo-random numbers are generated by computer random functions. The characteristics of pseudo-random numbers are that they can be controlled and reproduced, and they are predictable and have cycles.

[0004] True random numbers rely on physical random number generators. The current solution is to generate them through more advanced and complex physical processes such as noise in electronic components. Their characteristics are that they are uncontrollable and reproducible, unpredictable and non-periodic.

[0005] In many occasions today, both pseudo-random numbers and true random numbers are needed, which means that two sets of devices are needed to generate pseudo-random numbers and true random numbers respectively, which is costly, complex in circuits, and has low reliability.

[0006] To sum up, how to conveniently and effectively provide pseudo-random numbers and true random numbers, reduce costs and improve reliability. Summary of the invention

[0007] The purpose of the present invention is to provide a random number generating device and method, so as to conveniently and effectively provide pseudo-random numbers and true random numbers, reduce costs and improve reliability.

[0008] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0009] A random number generating device, comprising:

[0010] A linear feedback shift register comprising n-stage flip-flops; n is a positive integer not less than 3;

[0011] n selection circuits respectively connected to the n-stage flip-flops, wherein a first input terminal of each selection circuit is used to receive a first clock signal, and a second input terminal of each selection circuit is used to receive a second clock signal;

[0012] A controller connected to the control terminals of the n selection circuits, for: in a pseudo-random number mode, controlling the feedback coefficients of the linear feedback shift register according to the preset first feedback coefficient information, and controlling each of the selection circuits to select to output the first clock signal or the second clock signal, so that the random number generating device generates a pseudo-random number; in a true random number mode, controlling the feedback coefficients of the linear feedback shift register according to the preset second feedback coefficient information, and controlling the output signal selected by each of the selection circuits according to a preset rule, so that the linear feedback shift register is in a metastable state, so that the random number generating device generates a true random number;

[0013] The first clock signal and the second clock signal have different phases and frequencies.

[0014] Preferably, the preset rules include:

[0015] The output signals selected by two adjacent selection circuits are different.

[0016] Preferably, the preset rules include:

[0017] When the output signal selected by the first selection circuit located at the head is the first clock signal, the output signal selected by the nth selection circuit located at the tail is the second clock signal; when the output signal selected by the first selection circuit located at the head is the second clock signal, the output signal selected by the nth selection circuit located at the tail is the first clock signal.

[0018] Preferably, when the controller controls each feedback coefficient of the linear feedback shift register according to the preset second feedback coefficient information, it is specifically used to:

[0019] The feedback coefficients of the linear feedback shift register are controlled to be 1, so that the feedback circuits in the linear feedback shift register are in an effective state.

[0020] Preferably, the true random number generated by the random number generating device each time is a true random number of m bits; m is a positive integer set by the controller;

[0021] The pseudo-random number generated by the random number generating device each time is a pseudo-random number of n bits.

[0022] Preferably, the n selection circuits all adopt selection circuits based on 2-stage triggers.

[0023] Preferably, the controller is also used for:

[0024] When receiving the first adjustment information, adjusting the first feedback coefficient information according to the first adjustment information;

[0025] When receiving the second adjustment information, adjusting the second feedback coefficient information according to the second adjustment information;

[0026] When the rule adjustment information is received, the preset rule is adjusted according to the rule adjustment information.

[0027] Preferably, the first adjustment information, the second adjustment information, and the rule adjustment information are all output from the host computer to the controller via an APB bus.

[0028] A random number generation method, applied to any of the random number generation devices described above, comprising:

[0029] In the pseudo-random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset first feedback coefficient information, and each selection circuit is controlled to select to output the first clock signal or the second clock signal, so that the random number generating device generates a pseudo-random number;

[0030] In the true random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset second feedback coefficient information, and the output signal selected by each selection circuit is controlled according to a preset rule, so that the linear feedback shift register is in a metastable state, so that the random number generating device generates a true random number;

[0031] The first clock signal and the second clock signal have different phases and frequencies.

[0032] Preferably, the preset rules include:

[0033] The output signals selected by two adjacent selection circuits are different.

[0034] By applying the technical solution provided in the embodiment of the present invention, the random number generating device can generate both pseudo-random numbers and true random numbers. Specifically, the present application connects n selection circuits to n-level triggers respectively, and the first input end of each selection circuit is used to receive the first clock signal, and the second input end of each selection circuit is used to receive the second clock signal. In the pseudo-random number mode, the controller controls each feedback coefficient of the linear feedback shift register according to the preset first feedback coefficient information, and the controller controls each selection circuit to select to output the first clock signal or to select to output the second clock signal, that is, the clocks used by the n-level triggers at this time are consistent, and at this time, the linear feedback shift register including the n-level triggers can be used as a pseudo-random number generating device. In the true random number mode, the controller controls each feedback coefficient of the linear feedback shift register according to the preset second feedback coefficient information. In addition, in order to make the linear feedback shift register appear in a metastable state, the controller controls the output signal selected by each selection circuit according to the preset rules. Since the linear feedback shift register is caused to appear in a metastable state, the output of the linear feedback shift register cannot be predicted, which makes the random number generating device of the present application able to generate true random numbers.

[0035] In summary, the random number generating device of the present application can generate both pseudo-random numbers and true random numbers, and has high flexibility. Compared with the traditional solution that requires the setting of two sets of random number generating devices, the solution of the present application is conducive to reducing costs and improving reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0037] Figure 1 It is a structural schematic diagram of a random number generating device in the present invention;

[0038] Figure 2 It is a structural schematic diagram of a feedback circuit in a specific implementation manner of the present invention;

[0039] Figure 3 A schematic diagram of the structure of a selection circuit in a specific implementation manner of the present invention;

[0040] Figure 4 The present invention is a flowchart of a random number generation method. DETAILED DESCRIPTION

[0041] The core of the present invention is to provide a random number generating device, which can generate both pseudo-random numbers and true random numbers, has high flexibility, is conducive to reducing costs and improving reliability.

[0042] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0043] Please refer to Figure 1 , Figure 1 Schematic diagram of the structure of a random number generating device in the present invention, the random number generating device may include:

[0044] A linear feedback shift register 10 comprising n-stage flip-flops; n is a positive integer not less than 3;

[0045] n selection circuits 20 respectively connected to the n-stage flip-flops, the first input end of each selection circuit 20 being used to receive the first clock signal, and the second input end of each selection circuit 20 being used to receive the second clock signal;

[0046] The controller 30 connected to the control ends of the n selection circuits 20 is used to: in a pseudo-random number mode, control the feedback coefficients of the linear feedback shift register 10 according to the preset first feedback coefficient information, and control each selection circuit 20 to select to output the first clock signal or the second clock signal, so that the random number generating device generates a pseudo-random number; in a true random number mode, control the feedback coefficients of the linear feedback shift register 10 according to the preset second feedback coefficient information, and control the output signal selected by each selection circuit 20 according to a preset rule, so that the linear feedback shift register 10 is in a metastable state, so that the random number generating device generates a true random number;

[0047] The first clock signal and the second clock signal have different phases and frequencies.

[0048] First, the pseudo-random number pattern will be described.

[0049] Specifically, the present application adopts a linear feedback shift register 10, namely, LFSR (Linear Feedback Shift Register, linear feedback shift register 10), which includes n stages of triggers, and usually all of them can be D triggers.

[0050] When the n-stage flip-flops all receive the same clock signal, the linear feedback shift register 10 can generate pseudo-random numbers.

[0051] Figure 1 g0 to gn in the figure can be called feedback coefficients, and g1 to g(n-1) can be used to control whether the corresponding feedback circuit is effective. Generally, 1 indicates effective and 0 indicates ineffective. In addition, the first trigger at the head needs to receive feedback from the nth trigger at the tail. Therefore, g0 and gn need to be 1.

[0052] When the feedback circuit is effective, the output Qi of the previous stage trigger is XORed with the output Qn of the nth trigger, and the result is used as the input of the next stage trigger. Conversely, when the feedback circuit is not effective, the output Qi of the previous stage trigger is directly used as the input of the next stage trigger.

[0053] The specific circuit structure of the feedback circuit can be set and adjusted according to actual needs, for example Figure 2 It is a structural diagram of a feedback circuit in a specific implementation mode, which is composed of an XOR operation unit Xor and a 2-to-1 selector MUX, with low cost and high reliability.

[0054] Take the feedback circuit between the second flip-flop and the first flip-flop at the head as an example. When g1 is 0, it means that the feedback circuit is not effective. Therefore, the output Q1 of the first flip-flop is directly used as the input of the second flip-flop, that is, Figure 2 When g1 is 1, it means that the feedback circuit needs to be effective. Therefore, the output Q1 of the first trigger is XORed with the output Qn of the nth trigger, and the result of XOR is used as the input of the second trigger, that is, Figure 2 Di+1 selects the XOR result of Qi and Qn.

[0055] The values ​​of g0 to gn can be preset and adjusted to determine different circuit states of the linear feedback shift register 10. A set of pseudo-random numbers can be generated in each circuit state.

[0056] In the pseudo-random number mode, all n-stage triggers need to receive the same clock signal. Therefore, the controller 30 of the present application controls each selection circuit 20 to select to output the first clock signal or the second clock signal.

[0057] In each clock cycle, the linear feedback shift register 10 can output a data, for example, the data can be put into the result register result_reg, and the result register needs to have n bits. After n cycles, the circuit returns to the starting state and generates n data, which are stored in the result register. These n data constitute an n-bit random data. That is to say, in the pseudo-random number mode, the pseudo-random number generated by the random number generator each time is a pseudo-random number of n bits. Through software or hardware, data can be read from the result register result_reg for use.

[0058] In addition, it should be noted that, as described above, the values ​​of g0 to gn can be preset and adjusted, and in the solution of the present application, the controller 30 can control the various feedback coefficients of the linear feedback shift register 10 according to the preset first feedback coefficient information, and in the true random number mode, the controller 30 can control the various feedback coefficients of the linear feedback shift register 10 according to the preset second feedback coefficient information. Therefore, the present application can conveniently set the various feedback coefficients of the linear feedback shift register 10, thereby improving the implementation flexibility and convenience of the solution of the present application. In addition, since the controller 30 controls each selection circuit 20 to select to output the first clock signal or to select to output the second clock signal, it is also very convenient when the clock domain needs to be switched in the pseudo-random number mode.

[0059] Next, the true random number mode is described.

[0060] For any selection circuit 20 , the selection circuit 20 can receive a first clock signal and a second clock signal, and the controller 30 can control which clock signal the selection circuit 20 specifically outputs.

[0061] The specific circuit structure of the selection circuit 20 can be set and adjusted according to actual needs. For example, in a specific embodiment of the present invention, n selection circuits 20 are all configured as follows: Figure 3 The selection circuit 20 based on the two-stage trigger shown in the figure has high stability and is not prone to glitches in the output clock signal. Of course, in other occasions, other specific selection circuit 20 structures can be selected as needed, as long as the functional requirements of the selection circuit 20 of the present application can be achieved.

[0062] In the true random number mode, the controller 30 controls the various feedback coefficients of the linear feedback shift register 10 according to the preset second feedback coefficient information. In addition, in practical applications, in order to ensure good randomness and considering the propagation properties of the metastable state, the controller 30 can control the various feedback coefficients of the linear feedback shift register 10 to be 1, that is, Figure 1g0 to gn in are all 1, so that each feedback circuit in the linear feedback shift register 10 is in an effective state.

[0063] The controller 30 controls the output signal selected by each selection circuit 20 according to the preset rules. The preset rules can be set and adjusted according to actual needs, but it is necessary to enable the linear feedback shift register 10 to enter a metastable state, so that the linear feedback shift register 10 generates true random numbers, and the random number generating device of the present application can generate true random numbers.

[0064] A flip-flop is metastable when it cannot reach a verifiable state within a specified period of time. That is, it is impossible to predict the output level of the flip-flop, nor when the output will stabilize at a correct level. In a metastable state, the flip-flop may output some intermediate level, or may be in an oscillating state, and this useless output level can be cascaded along the flip-flops on the signal path.

[0065] In a specific implementation of the present invention, the preset rules include:

[0066] The output signals selected by two adjacent selection circuits 20 are different.

[0067] For example Figure 1 In the case of, the controller 30 controls n selection circuits 20 respectively through the level states of n pins, for example, n=10, then according to the preset rules in this implementation, Sel-1 to Sel-n can be expressed as 1010101010, or 0101010101, so that the output signals selected by two adjacent selection circuits 20 are different.

[0068] When the clock of a certain trigger is different from the clock of the nth trigger, the two input signals of the XOR operation unit in the feedback circuit at the output end of the trigger are in different clock domains, which is conducive to causing the linear feedback shift register 10 to have a metastable phenomenon. The preset rule makes the output signals selected by the two adjacent selection circuits 20 different, which makes such XOR operation units appear at intervals, which is more likely to cause the linear feedback shift register 10 to have a metastable phenomenon.

[0069] In a specific embodiment of the present invention, considering that the randomness in the true random number mode is higher, each bit should have true randomness. Therefore, the metastable phenomenon begins to appear from the head, which is beneficial to improve the randomness of the true random number generated by the linear feedback shift register 10 where the metastable phenomenon occurs.

[0070] In this embodiment, when the output signal selected by the first selection circuit 20 at the head is the first clock signal, the output signal selected by the nth selection circuit 20 at the tail is the second clock signal; when the output signal selected by the first selection circuit 20 at the head is the second clock signal, the output signal selected by the nth selection circuit 20 at the tail is the first clock signal. In this way, the two input signals of the XOR operation unit of the feedback circuit connected to the first trigger at the head are in different clock domains, which is conducive to the occurrence of metastable phenomena starting from the head.

[0071] In addition, it can be seen that in the aforementioned embodiment, the preset rule includes an embodiment in which the output signals selected by the two adjacent selection circuits 20 are different. In this embodiment, the output signal selected by the first selection circuit 20 located at the head is different from the output signal selected by the nth selection circuit 20 located at the tail. Therefore, in practical applications, n can be selected as an even number, and the control level output by the controller 30 to each selection circuit 20 can be in the form of 1010101010 as above, or 0101010101.

[0072] In each clock cycle, the linear feedback shift register 10 can output a data, for example, the data can be put into the result register result_reg, and the length of the result register can be set and adjusted as needed.

[0073] Since the output is a true random number, the true random number generated by the random number generating device each time can be a true random number of m bits, and m can be a positive integer set by the controller 30, that is, the bit length of the true random number generated by the random number generating device can be flexibly set and adjusted by the controller 30.

[0074] In a specific embodiment of the present invention, the controller 30 may also be used to:

[0075] When receiving the first adjustment information, adjusting the first feedback coefficient information according to the first adjustment information;

[0076] When receiving the second adjustment information, adjusting the second feedback coefficient information according to the second adjustment information;

[0077] When the rule adjustment information is received, the preset rule is adjusted according to the rule adjustment information.

[0078] In this implementation manner, considering that the present application is implemented by the controller 30 using the preset first feedback coefficient information, the second feedback coefficient information and the preset rules, when the first feedback coefficient information, the second feedback coefficient information, or the preset rules need to be adjusted, the adjustment can be achieved by directly sending the first adjustment information, the second adjustment information and the rule adjustment information to the controller 30, which makes the adjustment very flexible, that is, the adjustment of the first feedback coefficient information, the second feedback coefficient information and the preset rules can be achieved directly through software.

[0079] In practical applications, the first adjustment information, the second adjustment information, and the rule adjustment information can all be output by the host computer to the controller 30 through the APB (Advanced Peripheral Bus) bus, which is simple and convenient to implement. In addition, the controller 30 can also choose to read relevant data from the storage, thereby realizing the configuration and adjustment of the first feedback coefficient information, the second feedback coefficient information and the preset rules.

[0080] By applying the technical solution provided by the embodiment of the present invention, the random number generating device can generate both pseudo-random numbers and true random numbers. Specifically, the present application connects n selection circuits 20 to n-level triggers respectively, and the first input end of each selection circuit 20 is used to receive the first clock signal, and the second input end of each selection circuit 20 is used to receive the second clock signal. In the pseudo-random number mode, the controller 30 controls the various feedback coefficients of the linear feedback shift register 10 according to the preset first feedback coefficient information, and the controller 30 controls each selection circuit 20 to select to output the first clock signal or to select to output the second clock signal, that is, the clocks used by the n-level triggers at this time are consistent, and at this time, the linear feedback shift register 10 including the n-level trigger can be used as a pseudo-random number generating device. In the true random number mode, the controller 30 controls the various feedback coefficients of the linear feedback shift register 10 according to the preset second feedback coefficient information. In addition, in order to make the linear feedback shift register 10 appear in a metastable state, the controller 30 controls the output signal selected by each selection circuit 20 according to the preset rules. Since the linear feedback shift register 10 is in a metastable state, the output of the linear feedback shift register 10 cannot be predicted, which enables the random number generating device of the present application to generate true random numbers.

[0081] In summary, the random number generating device of the present application can generate both pseudo-random numbers and true random numbers, and has high flexibility. Compared with the traditional solution that requires the setting of two sets of random number generating devices, the solution of the present application is conducive to reducing costs and improving reliability.

[0082] Corresponding to the above random number generation device embodiment, the embodiment of the present invention further provides a random number generation method, which can be referred to in correspondence with the above.

[0083] See also Figure 4 FIG. 1 is a flowchart of a random number generation method in the present invention, which can be applied to the random number generation device in any of the above embodiments, and includes:

[0084] Step S401: in a pseudo-random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset first feedback coefficient information, and each selection circuit is controlled to select to output the first clock signal or the second clock signal, so that the random number generating device generates a pseudo-random number;

[0085] Step S402: in the true random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset second feedback coefficient information, and the output signal selected by each selection circuit is controlled according to the preset rule, so that the linear feedback shift register is in a metastable state, so that the random number generating device generates a true random number;

[0086] The first clock signal and the second clock signal have different phases and frequencies.

[0087] In a specific implementation of the present invention, the preset rules include:

[0088] The output signals selected by two adjacent selection circuits are different.

[0089] In a specific implementation of the present invention, the preset rules include:

[0090] When the output signal selected by the first selection circuit at the head is the first clock signal, the output signal selected by the nth selection circuit at the tail is the second clock signal; when the output signal selected by the first selection circuit at the head is the second clock signal, the output signal selected by the nth selection circuit at the tail is the first clock signal.

[0091] In a specific implementation of the present invention, the step S402 described in which each feedback coefficient of the linear feedback shift register is controlled according to the preset second feedback coefficient information includes:

[0092] The feedback coefficients of the linear feedback shift register are controlled to be 1, so that the feedback circuits in the linear feedback shift register are in an effective state.

[0093] In a specific implementation of the present invention, the true random number generated by the random number generating device each time is a true random number of m bits; m is a positive integer set by the controller;

[0094] The pseudo-random number generated by the random number generating device each time is a pseudo-random number of n bits.

[0095] In a specific implementation of the present invention, the n selection circuits all use selection circuits based on 2-stage triggers.

[0096] In a specific embodiment of the present invention, it also includes:

[0097] When receiving the first adjustment information, adjusting the first feedback coefficient information according to the first adjustment information;

[0098] When receiving the second adjustment information, adjusting the second feedback coefficient information according to the second adjustment information;

[0099] When the rule adjustment information is received, the preset rule is adjusted according to the rule adjustment information.

[0100] In a specific implementation manner of the present invention, the first adjustment information, the second adjustment information, and the rule adjustment information are all output from the host computer to the controller via the APB bus.

[0101] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0102] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0103] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the technical solution and core ideas of the present invention. It should be pointed out that for ordinary technicians in this technical field, the present invention can also be improved and modified without departing from the principles of the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. A random number generating device, characterized in that: include: A linear feedback shift register including n-stage flip-flops; n is a positive integer not less than 3; n selection circuits respectively connected to the n-stage flip-flops, wherein a first input terminal of each selection circuit is used to receive a first clock signal, and a second input terminal of each selection circuit is used to receive a second clock signal; A controller connected to the control terminals of the n selection circuits, configured to: in a pseudo-random number mode, control the feedback coefficients of the linear feedback shift register according to the preset first feedback coefficient information, and control each of the selection circuits to select to output the first clock signal or the second clock signal, so that the random number generating device generates a pseudo-random number; In the true random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset second feedback coefficient information, and the output signal selected by each selection circuit is controlled according to a preset rule, so that the linear feedback shift register is in a metastable state, so that the random number generating device generates a true random number; The first clock signal and the second clock signal have different phases and frequencies.

2. The random number generating device according to claim 1, characterized in that: The preset rules include: The output signals selected by two adjacent selection circuits are different.

3. The random number generating device according to claim 1, characterized in that: The preset rules include: When the output signal selected by the first selection circuit located at the head is the first clock signal, the output signal selected by the nth selection circuit located at the tail is the second clock signal; when the output signal selected by the first selection circuit located at the head is the second clock signal, the output signal selected by the nth selection circuit located at the tail is the first clock signal.

4. The random number generating device according to claim 1, characterized in that: When the controller controls each feedback coefficient of the linear feedback shift register according to the preset second feedback coefficient information, it is specifically used to: The feedback coefficients of the linear feedback shift register are controlled to be 1, so that the feedback circuits in the linear feedback shift register are in an effective state.

5. The random number generating device according to claim 1, characterized in that: The true random number generated by the random number generating device each time is a true random number of m bits; m is a positive integer set by the controller; The pseudo-random number generated by the random number generating device each time is a pseudo-random number of n bits.

6. The random number generating device according to claim 1, characterized in that: The n selection circuits all use a selection circuit based on a two-stage trigger.

7. The random number generating device according to any one of claims 1 to 6, characterized in that: The controller is also used for: When receiving the first adjustment information, adjusting the first feedback coefficient information according to the first adjustment information; When receiving the second adjustment information, adjusting the second feedback coefficient information according to the second adjustment information; When the rule adjustment information is received, the preset rule is adjusted according to the rule adjustment information.

8. The random number generating device according to claim 7, characterized in that: The first adjustment information, the second adjustment information, and the rule adjustment information are all output from the host computer to the controller via the APB bus.

9. A random number generation method, characterized in that: Applicable to the random number generating device according to any one of claims 1 to 8, comprising: In the pseudo-random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset first feedback coefficient information, and each selection circuit is controlled to select to output the first clock signal or the second clock signal, so that the random number generating device generates a pseudo-random number; In the true random number mode, each feedback coefficient of the linear feedback shift register is controlled according to the preset second feedback coefficient information, and the output signal selected by each selection circuit is controlled according to a preset rule, so that the linear feedback shift register is in a metastable state, so that the random number generating device generates a true random number; The first clock signal and the second clock signal have different phases and frequencies.

10. The random number generation method according to claim 9, characterized in that: The preset rules include: The output signals selected by two adjacent selection circuits are different.

Citation Information

Patent Citations

  • Method and device for generating pseudo random numbers

    CN101019099A

  • True random number generator and realization method thereof

    CN102662625A