00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef BSCRAM
00019 #define BSCRAM
00020 namespace SPUC {
00029
00030 class bit_scrambler {
00031 public:
00032 unsigned long g;
00033 long span;
00034
00035 public:
00036 unsigned long u;
00037 bit_scrambler(long gen=0x48, long bits=7, long uinit=-1)
00038 : g(gen), span(bits), u(uinit) {;}
00039 void reset() { u=~0; }
00040 bool scramble(bool data_in) {
00041 bool res = xor_bits(u&g);
00042 u <<= 1;
00043 u += res;
00044 return(data_in ^ res);
00045 }
00047 bool xor_bits(long x) {
00048 bool c=0;
00049 for (int i =0;i<span;i++) {
00050 c ^= (x & 0x01);
00051 x >>= 1;
00052 }
00053 return(c);
00054 }
00055 };
00056 }
00057 #endif