
_START_ARTICLE_
偽亂數二進位數列
_START_SECTION_
实际的实现
_START_PARAGRAPH_
伪乱数二进制数列可以用线性反馈移位寄存器产生。_NEWLINE_一些常见的的数列产生多项式为_NEWLINE_PRBS7 = _NEWLINE_PRBS15 = _NEWLINE_PRBS23 = _NEWLINE_PRBS31 = _NEWLINE_以下是一个用PRBS-7 产生伪乱数二进制数列的C语言程式_NEWLINE_#include <stdio.h>#include <stdint.h>#include <stdlib.h>_NEWLINE_    _NEWLINE_int main(int argc, char* argv[]) {_NEWLINE_    uint8_t start = 0x02;_NEWLINE_    uint8_t a = start;_NEWLINE_    int i;    _NEWLINE_    for(i = 1;; i++) {_NEWLINE_        int newbit = (((a >> 6) ^ (a >> 5)) & 1);_NEWLINE_        a = ((a << 1) | newbit) & 0x7f;_NEWLINE_        printf("%x\n", a);_NEWLINE_        if (a == start) {_NEWLINE_            printf("repetition period is %d\n", i);_NEWLINE_            break;_NEWLINE_        }_NEWLINE_    }}_NEWLINE_此例中，PRBS-7的周期为127位元。