Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alex037yang
OpenXG-RAN
Commits
4a523a39
Commit
4a523a39
authored
Jun 06, 2018
by
Sebastian Wagner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arrays for CRC calculation are defined as constants.
parent
3fd24705
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
145 deletions
+145
-145
openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c
openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c
+0
-2
openair1/PHY/CODING/TESTBENCH/pdcch_test.c
openair1/PHY/CODING/TESTBENCH/pdcch_test.c
+0
-3
openair1/PHY/CODING/TESTBENCH/viterbi_test.c
openair1/PHY/CODING/TESTBENCH/viterbi_test.c
+0
-2
openair1/PHY/CODING/coding_defs.h
openair1/PHY/CODING/coding_defs.h
+8
-10
openair1/PHY/CODING/crc_byte.c
openair1/PHY/CODING/crc_byte.c
+137
-126
openair1/PHY/INIT/init_top.c
openair1/PHY/INIT/init_top.c
+0
-2
No files found.
openair1/PHY/CODING/3gpplte_turbo_decoder_sse.c
View file @
4a523a39
...
...
@@ -2620,8 +2620,6 @@ int test_logmap8()
test
[
3
]
=
0x92
;
test
[
4
]
=
0xfe
;
crcTableInit
();
crc
=
crc24a
(
test
,
40
)
>>
8
;
...
...
openair1/PHY/CODING/TESTBENCH/pdcch_test.c
View file @
4a523a39
...
...
@@ -52,8 +52,6 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx)
randominit
(
0
);
set_taus_seed
(
0
);
crcTableInit
();
lte_frame_parms
=
&
(
PHY_config
->
lte_frame_parms
);
//openair1/PHY/impl_defs_lte.h
lte_ue_common_vars
=
&
(
PHY_vars
->
lte_ue_common_vars
);
lte_ue_dlsch_vars
=
&
(
PHY_vars
->
lte_ue_dlsch_vars
);
...
...
@@ -249,7 +247,6 @@ int main(int argc, char *argv[])
randominit
(
0
);
set_taus_seed
(
0
);
crcTableInit
();
ccodelte_init
();
ccodelte_init_inv
();
...
...
openair1/PHY/CODING/TESTBENCH/viterbi_test.c
View file @
4a523a39
...
...
@@ -218,8 +218,6 @@ int main(int argc, char *argv[])
randominit
();
set_taus_seed
();
crcTableInit
();
printf
(
"EbN0, sigma, BER, FER
\n
"
);
for
(
SNR
=
0
;
SNR
<
10
;
SNR
++
)
{
...
...
openair1/PHY/CODING/coding_defs.h
View file @
4a523a39
...
...
@@ -29,8 +29,6 @@
#include <stdint.h>
#include "PHY/defs_common.h"
#define CRC24_A 0
#define CRC24_B 1
#define CRC16 2
...
...
@@ -321,7 +319,7 @@ void ccodedab_init_inv(void);
/*!\fn void crcTableInit(void)
\brief This function initializes the different crc tables.*/
void
crcTableInit
(
void
);
//
void crcTableInit (void);
...
...
@@ -331,7 +329,7 @@ based on 3GPP UMTS/LTE specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits
*/
uint32_t
crc24a
(
uint8_t
*
inPtr
,
int32_t
bitlen
);
uint32_t
crc24a
(
uint8_t
*
inptr
,
u
int32_t
bitlen
);
/*!\fn uint32_t crc24b(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 24-bit crc ('b' variant for transport-block segments)
...
...
@@ -339,25 +337,25 @@ based on 3GPP UMTS/LTE specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits
*/
uint32_t
crc24b
(
uint8_t
*
inPtr
,
int32_t
bitlen
);
uint32_t
crc24b
(
uint8_t
*
inptr
,
u
int32_t
bitlen
);
/*!\fn uint32_t crc16(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 16-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t
crc16
(
uint8_t
*
inPtr
,
int32_t
bitlen
);
uint32_t
crc16
(
uint8_t
*
inptr
,
u
int32_t
bitlen
);
/*!\fn uint32_t crc12(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 12-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t
crc12
(
uint8_t
*
inPtr
,
int32_t
bitlen
);
uint32_t
crc12
(
uint8_t
*
inptr
,
u
int32_t
bitlen
);
/*!\fn uint32_t crc8(uint8_t *inPtr, int32_t bitlen)
\brief This computes a 8-bit crc based on 3GPP UMTS specifications.
@param inPtr Pointer to input byte stream
@param bitlen length of inputs in bits*/
uint32_t
crc8
(
uint8_t
*
inPtr
,
int32_t
bitlen
);
uint32_t
crc8
(
uint8_t
*
inptr
,
u
int32_t
bitlen
);
/*!\fn void phy_viterbi_dot11_sse2(int8_t *y, uint8_t *decoded_bytes, uint16_t n,int offset,int traceback)
\brief This routine performs a SIMD optmized Viterbi decoder for the 802.11 64-state convolutional code. It can be
...
...
openair1/PHY/CODING/crc_byte.c
View file @
4a523a39
...
...
@@ -30,38 +30,61 @@
Modified in June, 2001, to include the length non multiple of 8
*/
#include "PHY/types.h"
#include "coding_defs.h"
// For initialization && verification purposes, bit by bit implementation with any polynomial
// The first bit is in the MSB of each byte
// Reference 38.212 V15.1.1 Section 5.1 (36-212 v8.6.0 , pp 8-9)
// The highest degree is set by default
/** 1000 0110 0100 1100 1111 1011 D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1 */
static
const
uint32_t
poly24a
=
0x864cfb00
;
/** 1000 0000 0000 0000 0110 0011 D^24 + D^23 + D^6 + D^5 + D + 1 */
static
const
uint32_t
poly24b
=
0x80006300
;
/** 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1 */
static
const
uint32_t
poly16
=
0x10210000
;
/** 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1 */
static
const
uint32_t
poly12
=
0x80F00000
;
/** 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1 */
static
const
uint32_t
poly8
=
0x9B000000
;
/*ref 36-212 v8.6.0 , pp 8-9 */
/* the highest degree is set by default */
unsigned
int
poly24a
=
0x864cfb00
;
//1000 0110 0100 1100 1111 1011 D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1
unsigned
int
poly24b
=
0x80006300
;
// 1000 0000 0000 0000 0110 0011 D^24 + D^23 + D^6 + D^5 + D + 1
unsigned
int
poly16
=
0x10210000
;
// 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1
unsigned
int
poly12
=
0x80F00000
;
// 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1
unsigned
int
poly8
=
0x9B000000
;
// 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1
/*********************************************************
// The following arrays are generated with the function 'crcTableInit'
/** Encoding table for CRC 24A */
static
const
uint32_t
crc24aTable
[
256
]
=
{
0
,
2253191936
,
2329218304
,
211416576
,
2481381632
,
363469312
,
422833152
,
2675906304
,
2709600512
,
667795968
,
726938624
,
2904084224
,
845666304
,
3022725888
,
3098727680
,
1056845312
,
3310258432
,
1124233728
,
1335591936
,
3386343168
,
1453877248
,
3504640768
,
3699205376
,
1513201152
,
1691332608
,
3800255232
,
3994729728
,
1750484480
,
4146680064
,
1902488064
,
2113690624
,
4222658304
,
215083264
,
2325549568
,
2248467456
,
4726528
,
2671183872
,
427553536
,
367133952
,
2477719040
,
2907754496
,
723266304
,
663084288
,
2714314240
,
1052127488
,
3103443456
,
3026402304
,
841991936
,
3382665216
,
1339267840
,
1128951040
,
3305543168
,
1517912320
,
3694492160
,
3500968960
,
1457551104
,
1746819328
,
3998392832
,
3804976128
,
1686613760
,
4227381248
,
2108965632
,
1898820864
,
4150349312
,
430166528
,
2683250944
,
2474041088
,
356131840
,
2319790848
,
201967616
,
9453056
,
2262615296
,
3089296128
,
1047400448
,
855107072
,
3032161536
,
734267904
,
2911432960
,
2702247680
,
660470784
,
3706542848
,
1520541696
,
1446532608
,
3497307392
,
1326168576
,
3376890112
,
3319707392
,
1133661184
,
2104254976
,
4213217536
,
4156124928
,
1911919616
,
4002054912
,
1757837312
,
1683983872
,
3792925952
,
359807744
,
2470363136
,
2678535680
,
434883840
,
2257902080
,
14164224
,
205641472
,
2316119040
,
3035824640
,
851441920
,
1042681600
,
3094017024
,
655745792
,
2706970624
,
2915102208
,
730600704
,
3493638656
,
1450199296
,
1525268224
,
3701818368
,
1138381568
,
3314984960
,
3373227520
,
1329833216
,
1908247296
,
4159795200
,
4217931264
,
2099543296
,
3797641728
,
1679266048
,
1754162944
,
4005731328
,
860333056
,
3037421312
,
3113396480
,
1071534592
,
2694923520
,
653114880
,
712263680
,
2889396992
,
2462489856
,
344614400
,
403935232
,
2657053440
,
18906112
,
2272036608
,
2348118272
,
230263296
,
4127796480
,
1883624960
,
2094800896
,
4203797248
,
1710214144
,
3819124480
,
4013605120
,
1769355776
,
1468535808
,
3519344384
,
3713865984
,
1527898624
,
3295606016
,
1109528064
,
1320941568
,
3371631360
,
1066814720
,
3118118400
,
3041083392
,
856668928
,
2893065216
,
708597504
,
648388864
,
2699647488
,
2652337152
,
408653568
,
348289280
,
2458812928
,
233936128
,
2344447488
,
2267322368
,
23618304
,
4208509952
,
2090090240
,
1879951616
,
4131467776
,
1765680384
,
4017282560
,
3823839232
,
1705497344
,
1532624128
,
3709142528
,
3515674624
,
1472203520
,
3367967744
,
1324607232
,
1114247424
,
3290884608
,
719615488
,
2896727296
,
2687597312
,
645758976
,
3103954688
,
1062104064
,
869767680
,
3046859008
,
2338672384
,
220836864
,
28328448
,
2281486592
,
411282944
,
2664387840
,
2455151360
,
337270784
,
4020961024
,
1776681984
,
1702883840
,
3811772672
,
2085363200
,
4194362624
,
4137227008
,
1893066752
,
1311491584
,
3362209024
,
3305032448
,
1118973952
,
3721209600
,
1535237120
,
1461201408
,
3511996672
,
641048320
,
2692310016
,
2900398592
,
715942144
,
3050536448
,
866092288
,
1057387264
,
3108669440
,
2276763136
,
33053952
,
224504576
,
2335002624
,
340936448
,
2451487744
,
2659666432
,
416002304
,
3816494592
,
1698163968
,
1773017856
,
4024623104
,
1889400576
,
4140895232
,
4199086592
,
2080637184
,
1123692288
,
3300316160
,
3358532096
,
1315166464
,
3508325888
,
1464874240
,
1539949312
,
3716495360
};
For initialization && verification purposes,
bit by bit implementation with any polynomial
/** Encoding table for CRC 24B */
static
const
uint32_t
crc24bTable
[
256
]
=
{
0
,
2147508992
,
2147525888
,
50688
,
2147559680
,
84480
,
101376
,
2147610368
,
2147627264
,
152064
,
168960
,
2147677952
,
202752
,
2147711744
,
2147728640
,
253440
,
2147746048
,
287232
,
304128
,
2147796736
,
337920
,
2147830528
,
2147847424
,
388608
,
405504
,
2147898112
,
2147915008
,
456192
,
2147948800
,
489984
,
506880
,
2147999488
,
2148032768
,
524800
,
574464
,
2148050688
,
608256
,
2148084480
,
2148134144
,
626176
,
675840
,
2148152064
,
2148201728
,
693760
,
2148235520
,
727552
,
777216
,
2148253440
,
811008
,
2148270848
,
2148320512
,
828928
,
2148354304
,
862720
,
912384
,
2148372224
,
2148421888
,
930304
,
979968
,
2148439808
,
1013760
,
2148473600
,
2148523264
,
1031680
,
2148573440
,
1098240
,
1049600
,
2148558592
,
1148928
,
2148657920
,
2148609280
,
1134080
,
1216512
,
2148725504
,
2148676864
,
1201664
,
2148776192
,
1300992
,
1252352
,
2148761344
,
1351680
,
2148844288
,
2148795648
,
1336832
,
2148894976
,
1436160
,
1387520
,
2148880128
,
2148962560
,
1503744
,
1455104
,
2148947712
,
1554432
,
2149047040
,
2148998400
,
1539584
,
1622016
,
2149098240
,
2149082368
,
1574400
,
2149181696
,
1673728
,
1657856
,
2149134080
,
2149249280
,
1741312
,
1725440
,
2149201664
,
1824768
,
2149300992
,
2149285120
,
1777152
,
2149368064
,
1876480
,
1860608
,
2149320448
,
1959936
,
2149419776
,
2149403904
,
1912320
,
2027520
,
2149487360
,
2149471488
,
1979904
,
2149570816
,
2079232
,
2063360
,
2149523200
,
2149654784
,
2179584
,
2196480
,
2149705472
,
2099200
,
2149608192
,
2149625088
,
2149888
,
2297856
,
2149806848
,
2149823744
,
2348544
,
2149726464
,
2251264
,
2268160
,
2149777152
,
2433024
,
2149925632
,
2149942528
,
2483712
,
2149845248
,
2386432
,
2403328
,
2149895936
,
2150043904
,
2585088
,
2601984
,
2150094592
,
2504704
,
2149997312
,
2150014208
,
2555392
,
2703360
,
2150179584
,
2150229248
,
2721280
,
2150131968
,
2624000
,
2673664
,
2150149888
,
2150330624
,
2822656
,
2872320
,
2150348544
,
2775040
,
2150251264
,
2150300928
,
2792960
,
2150449408
,
2957824
,
3007488
,
2150467328
,
2910208
,
2150370048
,
2150419712
,
2928128
,
3108864
,
2150568704
,
2150618368
,
3126784
,
2150521088
,
3029504
,
3079168
,
2150539008
,
3244032
,
2150753024
,
2150704384
,
3229184
,
2150672640
,
3197440
,
3148800
,
2150657792
,
2150871296
,
3396096
,
3347456
,
2150856448
,
3315712
,
2150824704
,
2150776064
,
3300864
,
2150990080
,
3531264
,
3482624
,
2150975232
,
3450880
,
2150943488
,
2150894848
,
3436032
,
3649536
,
2151142144
,
2151093504
,
3634688
,
2151061760
,
3602944
,
3554304
,
2151046912
,
2151276800
,
3768832
,
3752960
,
2151229184
,
3721216
,
2151197440
,
2151181568
,
3673600
,
3919872
,
2151396096
,
2151380224
,
3872256
,
2151348480
,
3840512
,
3824640
,
2151300864
,
4055040
,
2151514880
,
2151499008
,
4007424
,
2151467264
,
3975680
,
3959808
,
2151419648
,
2151665920
,
4174336
,
4158464
,
2151618304
,
4126720
,
2151586560
,
2151570688
,
4079104
};
The first bit is in the MSB of each byte
/** Encoding table for CRC 16 */
static
const
uint16_t
crc16Table
[
256
]
=
{
0
,
4129
,
8258
,
12387
,
16516
,
20645
,
24774
,
28903
,
33032
,
37161
,
41290
,
45419
,
49548
,
53677
,
57806
,
61935
,
4657
,
528
,
12915
,
8786
,
21173
,
17044
,
29431
,
25302
,
37689
,
33560
,
45947
,
41818
,
54205
,
50076
,
62463
,
58334
,
9314
,
13379
,
1056
,
5121
,
25830
,
29895
,
17572
,
21637
,
42346
,
46411
,
34088
,
38153
,
58862
,
62927
,
50604
,
54669
,
13907
,
9842
,
5649
,
1584
,
30423
,
26358
,
22165
,
18100
,
46939
,
42874
,
38681
,
34616
,
63455
,
59390
,
55197
,
51132
,
18628
,
22757
,
26758
,
30887
,
2112
,
6241
,
10242
,
14371
,
51660
,
55789
,
59790
,
63919
,
35144
,
39273
,
43274
,
47403
,
23285
,
19156
,
31415
,
27286
,
6769
,
2640
,
14899
,
10770
,
56317
,
52188
,
64447
,
60318
,
39801
,
35672
,
47931
,
43802
,
27814
,
31879
,
19684
,
23749
,
11298
,
15363
,
3168
,
7233
,
60846
,
64911
,
52716
,
56781
,
44330
,
48395
,
36200
,
40265
,
32407
,
28342
,
24277
,
20212
,
15891
,
11826
,
7761
,
3696
,
65439
,
61374
,
57309
,
53244
,
48923
,
44858
,
40793
,
36728
,
37256
,
33193
,
45514
,
41451
,
53516
,
49453
,
61774
,
57711
,
4224
,
161
,
12482
,
8419
,
20484
,
16421
,
28742
,
24679
,
33721
,
37784
,
41979
,
46042
,
49981
,
54044
,
58239
,
62302
,
689
,
4752
,
8947
,
13010
,
16949
,
21012
,
25207
,
29270
,
46570
,
42443
,
38312
,
34185
,
62830
,
58703
,
54572
,
50445
,
13538
,
9411
,
5280
,
1153
,
29798
,
25671
,
21540
,
17413
,
42971
,
47098
,
34713
,
38840
,
59231
,
63358
,
50973
,
55100
,
9939
,
14066
,
1681
,
5808
,
26199
,
30326
,
17941
,
22068
,
55628
,
51565
,
63758
,
59695
,
39368
,
35305
,
47498
,
43435
,
22596
,
18533
,
30726
,
26663
,
6336
,
2273
,
14466
,
10403
,
52093
,
56156
,
60223
,
64286
,
35833
,
39896
,
43963
,
48026
,
19061
,
23124
,
27191
,
31254
,
2801
,
6864
,
10931
,
14994
,
64814
,
60687
,
56684
,
52557
,
48554
,
44427
,
40424
,
36297
,
31782
,
27655
,
23652
,
19525
,
15522
,
11395
,
7392
,
3265
,
61215
,
65342
,
53085
,
57212
,
44955
,
49082
,
36825
,
40952
,
28183
,
32310
,
20053
,
24180
,
11923
,
16050
,
3793
,
7920
};
*********************************************************/
unsigned
int
crcbit
(
unsigned
char
*
inputptr
,
int
octetlen
,
unsigned
int
poly
)
/** Encoding table for CRC 12 */
static
const
uint16_t
crc12Table
[
256
]
=
{
0
,
33008
,
33040
,
480
,
33488
,
544
,
960
,
33584
,
34128
,
1440
,
1088
,
33968
,
1920
,
34672
,
34448
,
1632
,
35408
,
2720
,
2880
,
35760
,
2176
,
34928
,
35216
,
2400
,
3840
,
36848
,
36368
,
3808
,
36304
,
3360
,
3264
,
35888
,
37968
,
5280
,
5440
,
38320
,
5760
,
38512
,
38800
,
5984
,
4352
,
37360
,
36880
,
4320
,
37840
,
4896
,
4800
,
37424
,
7680
,
40688
,
40720
,
8160
,
40144
,
7200
,
7616
,
40240
,
39760
,
7072
,
6720
,
39600
,
6528
,
39280
,
39056
,
6240
,
43088
,
10400
,
10560
,
43440
,
10880
,
43632
,
43920
,
11104
,
11520
,
44528
,
44048
,
11488
,
45008
,
12064
,
11968
,
44592
,
8704
,
41712
,
41744
,
9184
,
41168
,
8224
,
8640
,
41264
,
42832
,
10144
,
9792
,
42672
,
9600
,
42352
,
42128
,
9312
,
15360
,
48368
,
48400
,
15840
,
48848
,
15904
,
16320
,
48944
,
47440
,
14752
,
14400
,
47280
,
15232
,
47984
,
47760
,
14944
,
46672
,
13984
,
14144
,
47024
,
13440
,
46192
,
46480
,
13664
,
13056
,
46064
,
45584
,
13024
,
45520
,
12576
,
12480
,
45104
,
53328
,
20640
,
20800
,
53680
,
21120
,
53872
,
54160
,
21344
,
21760
,
54768
,
54288
,
21728
,
55248
,
22304
,
22208
,
54832
,
23040
,
56048
,
56080
,
23520
,
55504
,
22560
,
22976
,
55600
,
57168
,
24480
,
24128
,
57008
,
23936
,
56688
,
56464
,
23648
,
17408
,
50416
,
50448
,
17888
,
50896
,
17952
,
18368
,
50992
,
49488
,
16800
,
16448
,
49328
,
17280
,
50032
,
49808
,
16992
,
52816
,
20128
,
20288
,
53168
,
19584
,
52336
,
52624
,
19808
,
19200
,
52208
,
51728
,
19168
,
51664
,
18720
,
18624
,
51248
,
30720
,
63728
,
63760
,
31200
,
64208
,
31264
,
31680
,
64304
,
64848
,
32160
,
31808
,
64688
,
32640
,
65392
,
65168
,
32352
,
62032
,
29344
,
29504
,
62384
,
28800
,
61552
,
61840
,
29024
,
30464
,
63472
,
62992
,
30432
,
62928
,
29984
,
29888
,
62512
,
60496
,
27808
,
27968
,
60848
,
28288
,
61040
,
61328
,
28512
,
26880
,
59888
,
59408
,
26848
,
60368
,
27424
,
27328
,
59952
,
26112
,
59120
,
59152
,
26592
,
58576
,
25632
,
26048
,
58672
,
58192
,
25504
,
25152
,
58032
,
24960
,
57712
,
57488
,
24672
};
/** Encoding table for CRC 8 */
static
const
uint8_t
crc8Table
[
256
]
=
{
0
,
155
,
173
,
54
,
193
,
90
,
108
,
247
,
25
,
130
,
180
,
47
,
216
,
67
,
117
,
238
,
50
,
169
,
159
,
4
,
243
,
104
,
94
,
197
,
43
,
176
,
134
,
29
,
234
,
113
,
71
,
220
,
100
,
255
,
201
,
82
,
165
,
62
,
8
,
147
,
125
,
230
,
208
,
75
,
188
,
39
,
17
,
138
,
86
,
205
,
251
,
96
,
151
,
12
,
58
,
161
,
79
,
212
,
226
,
121
,
142
,
21
,
35
,
184
,
200
,
83
,
101
,
254
,
9
,
146
,
164
,
63
,
209
,
74
,
124
,
231
,
16
,
139
,
189
,
38
,
250
,
97
,
87
,
204
,
59
,
160
,
150
,
13
,
227
,
120
,
78
,
213
,
34
,
185
,
143
,
20
,
172
,
55
,
1
,
154
,
109
,
246
,
192
,
91
,
181
,
46
,
24
,
131
,
116
,
239
,
217
,
66
,
158
,
5
,
51
,
168
,
95
,
196
,
242
,
105
,
135
,
28
,
42
,
177
,
70
,
221
,
235
,
112
,
11
,
144
,
166
,
61
,
202
,
81
,
103
,
252
,
18
,
137
,
191
,
36
,
211
,
72
,
126
,
229
,
57
,
162
,
148
,
15
,
248
,
99
,
85
,
206
,
32
,
187
,
141
,
22
,
225
,
122
,
76
,
215
,
111
,
244
,
194
,
89
,
174
,
53
,
3
,
152
,
118
,
237
,
219
,
64
,
183
,
44
,
26
,
129
,
93
,
198
,
240
,
107
,
156
,
7
,
49
,
170
,
68
,
223
,
233
,
114
,
133
,
30
,
40
,
179
,
195
,
88
,
110
,
245
,
2
,
153
,
175
,
52
,
218
,
65
,
119
,
236
,
27
,
128
,
182
,
45
,
241
,
106
,
92
,
199
,
48
,
171
,
157
,
6
,
232
,
115
,
69
,
222
,
41
,
178
,
132
,
31
,
167
,
60
,
10
,
145
,
102
,
253
,
203
,
80
,
190
,
37
,
19
,
136
,
127
,
228
,
210
,
73
,
149
,
14
,
56
,
163
,
84
,
207
,
249
,
98
,
140
,
23
,
33
,
186
,
77
,
214
,
224
,
123
};
uint32_t
crcbit
(
uint8_t
*
inputptr
,
int32_t
octetlen
,
uint32_t
poly
)
{
unsigned
int
i
,
crc
=
0
,
c
;
uint32_t
i
;
uint32_t
crc
=
0
;
uint32_t
c
;
while
(
octetlen
--
>
0
)
{
while
(
octetlen
--
>
0
)
{
c
=
(
*
inputptr
++
)
<<
24
;
for
(
i
=
8
;
i
!=
0
;
i
--
)
{
if
((
1
<<
31
)
&
(
c
^
crc
))
for
(
i
=
8
;
i
!=
0
;
i
--
)
{
if
(
(
1
<<
31
)
&
(
c
^
crc
)
)
{
crc
=
(
crc
<<
1
)
^
poly
;
}
else
{
crc
<<=
1
;
}
c
<<=
1
;
}
...
...
@@ -70,134 +93,123 @@ crcbit (unsigned char * inputptr, int octetlen, unsigned int poly)
return
crc
;
}
/*********************************************************
crc table initialization
*********************************************************/
static
unsigned
int
crc24aTable
[
256
];
static
unsigned
int
crc24bTable
[
256
];
static
unsigned
short
crc16Table
[
256
];
static
unsigned
short
crc12Table
[
256
];
static
unsigned
char
crc8Table
[
256
];
// CRC table initialization
/*
void crcTableInit (void)
{
unsigned
char
c
=
0
;
uint8_t
c = 0;
do
{
do
{
crc24aTable[c] = crcbit (&c, 1, poly24a);
crc24bTable[c] = crcbit (&c, 1, poly24b);
crc16Table
[
c
]
=
(
unsigned
short
)
(
crcbit
(
&
c
,
1
,
poly16
)
>>
16
);
crc12Table
[
c
]
=
(
unsigned
short
)
(
crcbit
(
&
c
,
1
,
poly12
)
>>
16
);
crc8Table
[
c
]
=
(
unsigned
char
)
(
crcbit
(
&
c
,
1
,
poly8
)
>>
24
);
}
while
(
++
c
);
crc16Table [c] = (uint16_t) (crcbit (&c, 1, poly16) >> 16);
crc12Table [c] = (uint16_t) (crcbit (&c, 1, poly12) >> 16);
crc8Table [c] = (uint8_t) (crcbit (&c, 1, poly8 ) >> 24);
}
while (++c);
}
/*********************************************************
Byte by byte implementations,
assuming initial byte is 0 padded (in MSB) if necessary
*/
*********************************************************/
unsigned
int
crc24a
(
unsigned
char
*
inptr
,
int
bitlen
)
// Byte by byte implementations, assuming initial byte is 0 padded (in MSB) if necessary
uint32_t
crc24a
(
uint8_t
*
inptr
,
uint32_t
bitlen
)
{
int32_t
octetlen
=
bitlen
/
8
;
int32_t
resbit
=
(
bitlen
%
8
);
uint32_t
crc
=
0
;
int
octetlen
,
resbit
;
unsigned
int
crc
=
0
;
octetlen
=
bitlen
/
8
;
/* Change in octets */
resbit
=
(
bitlen
%
8
);
while
(
octetlen
--
>
0
)
{
// printf("crc24a: in %x => crc %x\n",crc,*inptr);
while
(
octetlen
--
>
0
)
{
crc
=
(
crc
<<
8
)
^
crc24aTable
[(
*
inptr
++
)
^
(
crc
>>
24
)];
}
if
(
resbit
>
0
)
{
crc
=
(
crc
<<
resbit
)
^
crc24aTable
[((
*
inptr
)
>>
(
8
-
resbit
))
^
(
crc
>>
(
32
-
resbit
))];
}
return
crc
;
}
u
nsigned
int
crc24b
(
unsigned
char
*
inptr
,
in
t
bitlen
)
u
int32_t
crc24b
(
uint8_t
*
inptr
,
uint32_
t
bitlen
)
{
int32_t
octetlen
=
bitlen
/
8
;
int32_t
resbit
=
(
bitlen
%
8
);
uint32_t
crc
=
0
;
int
octetlen
,
resbit
;
unsigned
int
crc
=
0
;
octetlen
=
bitlen
/
8
;
/* Change in octets */
resbit
=
(
bitlen
%
8
);
while
(
octetlen
--
>
0
)
{
// printf("crc24b: in %x => crc %x (%x)\n",crc,*inptr,crc24bTable[(*inptr) ^ (crc >> 24)]);
while
(
octetlen
--
>
0
)
{
crc
=
(
crc
<<
8
)
^
crc24bTable
[(
*
inptr
++
)
^
(
crc
>>
24
)];
}
if
(
resbit
>
0
)
{
crc
=
(
crc
<<
resbit
)
^
crc24bTable
[((
*
inptr
)
>>
(
8
-
resbit
))
^
(
crc
>>
(
32
-
resbit
))];
}
return
crc
;
}
unsigned
int
crc16
(
unsigned
char
*
inptr
,
int
bitlen
)
uint32_t
crc16
(
uint8_t
*
inptr
,
uint32_t
bitlen
)
{
int
octetlen
,
resbit
;
unsigned
int
crc
=
0
;
octetlen
=
bitlen
/
8
;
/* Change in octets */
resbit
=
(
bitlen
%
8
);
while
(
octetlen
--
>
0
)
{
int32_t
octetlen
=
bitlen
/
8
;
int32_t
resbit
=
(
bitlen
%
8
);
uint32_t
crc
=
0
;
while
(
octetlen
--
>
0
)
{
crc
=
(
crc
<<
8
)
^
(
crc16Table
[(
*
inptr
++
)
^
(
crc
>>
24
)]
<<
16
);
}
if
(
resbit
>
0
)
{
crc
=
(
crc
<<
resbit
)
^
(
crc16Table
[((
*
inptr
)
>>
(
8
-
resbit
))
^
(
crc
>>
(
32
-
resbit
))]
<<
16
);
}
return
crc
;
}
unsigned
int
crc12
(
unsigned
char
*
inptr
,
int
bitlen
)
uint32_t
crc12
(
uint8_t
*
inptr
,
uint32_t
bitlen
)
{
int
octetlen
,
resbit
;
unsigned
int
crc
=
0
;
octetlen
=
bitlen
/
8
;
/* Change in octets */
resbit
=
(
bitlen
%
8
);
int32_t
octetlen
=
bitlen
/
8
;
int32_t
resbit
=
(
bitlen
%
8
);
uint32_t
crc
=
0
;
while
(
octetlen
--
>
0
)
{
while
(
octetlen
--
>
0
)
{
crc
=
(
crc
<<
8
)
^
(
crc12Table
[(
*
inptr
++
)
^
(
crc
>>
24
)]
<<
16
);
}
if
(
resbit
>
0
)
{
crc
=
(
crc
<<
resbit
)
^
(
crc12Table
[((
*
inptr
)
>>
(
8
-
resbit
))
^
(
crc
>>
(
32
-
resbit
))]
<<
16
);
}
return
crc
;
}
unsigned
int
crc8
(
unsigned
char
*
inptr
,
int
bitlen
)
uint32_t
crc8
(
uint8_t
*
inptr
,
uint32_t
bitlen
)
{
int
octetlen
,
resbit
;
unsigned
int
crc
=
0
;
octetlen
=
bitlen
/
8
;
/* Change in octets */
resbit
=
(
bitlen
%
8
);
int32_t
octetlen
=
bitlen
/
8
;
int32_t
resbit
=
(
bitlen
%
8
);
uint32_t
crc
=
0
;
while
(
octetlen
--
>
0
)
{
while
(
octetlen
--
>
0
)
{
crc
=
crc8Table
[(
*
inptr
++
)
^
(
crc
>>
24
)]
<<
24
;
}
if
(
resbit
>
0
)
{
crc
=
(
crc
<<
resbit
)
^
(
crc8Table
[((
*
inptr
)
>>
(
8
-
resbit
))
^
(
crc
>>
(
32
-
resbit
))]
<<
24
);
}
return
crc
;
}
#ifdef DEBUG_CRC
/*******************************************************************/
/**
Test code
********************************************************************/
// Test code
#include <stdio.h>
...
...
@@ -206,9 +218,8 @@ main()
unsigned
char
test
[]
=
"Thebigredfox"
;
crcTableInit
();
printf
(
"%x
\n
"
,
crcbit
(
test
,
sizeof
(
test
)
-
1
,
poly24
));
printf
(
"%x
\n
"
,
crc24
(
test
,
(
sizeof
(
test
)
-
1
)
*
8
));
printf
(
"%x
\n
"
,
crc24
(
test
,
(
sizeof
(
test
)
-
1
)
*
8
));
printf
(
"%x
\n
"
,
crcbit
(
test
,
sizeof
(
test
)
-
1
,
poly8
));
printf
(
"%x
\n
"
,
crc8
(
test
,
(
sizeof
(
test
)
-
1
)
*
8
));
printf
(
"%x
\n
"
,
crc8
(
test
,
(
sizeof
(
test
)
-
1
)
*
8
));
}
#endif
openair1/PHY/INIT/init_top.c
View file @
4a523a39
...
...
@@ -67,8 +67,6 @@ void generate_qpsk_table(void)
void
init_lte_top
(
LTE_DL_FRAME_PARMS
*
frame_parms
)
{
crcTableInit
();
ccodedot11_init
();
ccodedot11_init_inv
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment