Commit 11758458 authored by Raymond Knopp's avatar Raymond Knopp

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5480 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent c3ab6a9f
# compiles the openair_usrp
#OPENAIRTARGETS_DIR ?=../../../..
#OPENAIROBJS += $(OPENAIRTARGETS_DIR)/ARCH/USRP/USERSPACE/LIB/openair0_lib.o
#CFLAGS += -I$(OPENAIRTARGETS_DIR)/ARCH/USRP/USERSPACE/LIB -I$(OPENAIRTARGETS_DIR)/ARCH/USRP/DEFS
#example: example.o $(OPENAIROBJS)
# gcc -o $@ $(CFLAGS) -lm $(OPENAIROBJS) $<
#openair_usrp.o:
# $(CXX) -c openair_usrp.cpp -o openair_usrp.o
#clean:
# rm -f *.o *~
#a rm -f example
USRP_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/openair_usrp.o
USRP_FILE_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/openair_usrp.cpp
USRP_CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/
# compiles the openair_usrp
#OPENAIRTARGETS_DIR ?=../../../..
#OPENAIROBJS += $(OPENAIRTARGETS_DIR)/ARCH/USRP/USERSPACE/LIB/openair0_lib.o
#CFLAGS += -I$(OPENAIRTARGETS_DIR)/ARCH/USRP/USERSPACE/LIB -I$(OPENAIRTARGETS_DIR)/ARCH/USRP/DEFS
#example: example.o $(OPENAIROBJS)
# gcc -o $@ $(CFLAGS) -lm $(OPENAIROBJS) $<
#openair_usrp.o:
# $(CXX) -c openair_usrp.cpp -o openair_usrp.o
#clean:
# rm -f *.o *~
#a rm -f example
USRP_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/openair_usrp.o
PPS_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/polyphaseResample.o
USRP_FILE_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/openair_usrp.cpp
PPS_FILE_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/polyphaseResample.cpp
USRP_CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/
Now we are using USRP N200/210 and working with OAI v4164.
** Get source code of UHD
git clone git://github.com/EttusResearch/uhd.git
** Install prerequisites
sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-cheetah doxygen python-docutils
** Install UHD
cd <uhd-repo-path>/host
mkdir build
cd build
cmake ../
make
make test
sudo make install
sudo ldconfig
** Check the speed of USRP
The results should have almost no overflows and underflows, otherwise the OAI cannot work in realtime.
./benchmark_rate --tx_rate 6.25e6 --rx_rate 6.25e6 --duration 30
** Build lte-softmodem-usrp
cd targets/RTAI/USER
./make_for_usrp.sh
** Run lte-softmodem-usrp
./lte-softmodem-usrp
short coeff_25_to_3072[] = {26,25,25,25,25,25,25,25,25,25,25,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,23,23,22,22,22,22,22,22,22,22,21,21,21,21,21,21,21,21,20,20,20,20,20,20,20,19,19,19,19,19,19,19,18,18,18,18,18,18,17,17,17,17,17,17,17,16,16,16,16,16,16,15,15,15,15,15,15,14,14,14,14,14,13,13,13,13,13,13,12,12,12,12,12,11,11,11,11,11,11,10,10,10,10,10,9,9,9,9,9,8,8,8,8,8,7,7,7,7,6,6,6,6,6,5,5,5,5,5,4,4,4,4,3,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,0,-0,-0,-0,-0,-0,-1,-1,-1,-1,-2,-2,-2,-2,-3,-3,-3,-3,-4,-4,-4,-4,-5,-5,-5,-5,-6,-6,-6,-7,-7,-7,-7,-8,-8,-8,-8,-9,-9,-9,-9,-10,-10,-10,-11,-11,-11,-11,-12,-12,-12,-12,-13,-13,-13,-14,-14,-14,-14,-15,-15,-15,-16,-16,-16,-16,-17,-17,-17,-18,-18,-18,-18,-19,-19,-19,-20,-20,-20,-20,-21,-21,-21,-22,-22,-22,-23,-23,-23,-23,-24,-24,-24,-25,-25,-25,-26,-26,-26,-27,-27,-27,-27,-28,-28,-28,-29,-29,-29,-30,-30,-30,-31,-31,-31,-32,-32,-32,-32,-33,-33,-33,-34,-34,-34,-35,-35,-35,-36,-36,-36,-37,-37,-37,-38,-38,-38,-39,-39,-39,-40,-40,-40,-41,-41,-41,-41,-42,-42,-42,-43,-43,-43,-44,-44,-44,-45,-45,-45,-46,-46,-46,-47,-47,-47,-48,-48,-48,-49,-49,-49,-50,-50,-50,-51,-51,-51,-52,-52,-52,-53,-53,-53,-54,-54,-54,-55,-55,-55,-56,-56,-56,-57,-57,-57,-58,-58,-58,-59,-59,-59,-60,-60,-60,-61,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-65,-65,-65,-66,-66,-66,-67,-67,-67,-68,-68,-68,-69,-69,-69,-70,-70,-70,-71,-71,-71,-72,-72,-72,-73,-73,-73,-74,-74,-74,-74,-75,-75,-75,-76,-76,-76,-77,-77,-77,-78,-78,-78,-79,-79,-79,-80,-80,-80,-81,-81,-81,-81,-82,-82,-82,-83,-83,-83,-84,-84,-84,-85,-85,-85,-86,-86,-86,-86,-87,-87,-87,-88,-88,-88,-89,-89,-89,-89,-90,-90,-90,-91,-91,-91,-91,-92,-92,-92,-93,-93,-93,-93,-94,-94,-94,-95,-95,-95,-95,-96,-96,-96,-97,-97,-97,-97,-98,-98,-98,-98,-99,-99,-99,-100,-100,-100,-100,-101,-101,-101,-101,-102,-102,-102,-102,-103,-103,-103,-103,-104,-104,-104,-104,-105,-105,-105,-105,-106,-106,-106,-106,-106,-107,-107,-107,-107,-108,-108,-108,-108,-109,-109,-109,-109,-109,-110,-110,-110,-110,-110,-111,-111,-111,-111,-111,-112,-112,-112,-112,-112,-113,-113,-113,-113,-113,-114,-114,-114,-114,-114,-115,-115,-115,-115,-115,-115,-116,-116,-116,-116,-116,-116,-117,-117,-117,-117,-117,-117,-117,-118,-118,-118,-118,-118,-118,-118,-119,-119,-119,-119,-119,-119,-119,-120,-120,-120,-120,-120,-120,-120,-120,-120,-121,-121,-121,-121,-121,-121,-121,-121,-121,-121,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-121,-121,-121,-121,-121,-121,-121,-121,-121,-120,-120,-120,-120,-120,-120,-120,-120,-119,-119,-119,-119,-119,-119,-119,-118,-118,-118,-118,-118,-118,-117,-117,-117,-117,-117,-117,-116,-116,-116,-116,-116,-115,-115,-115,-115,-115,-114,-114,-114,-114,-114,-113,-113,-113,-113,-112,-112,-112,-112,-111,-111,-111,-111,-110,-110,-110,-110,-109,-109,-109,-109,-108,-108,-108,-107,-107,-107,-107,-106,-106,-106,-105,-105,-105,-105,-104,-104,-104,-103,-103,-103,-102,-102,-102,-101,-101,-101,-100,-100,-100,-99,-99,-99,-98,-98,-97,-97,-97,-96,-96,-96,-95,-95,-94,-94,-94,-93,-93,-92,-92,-92,-91,-91,-90,-90,-90,-89,-89,-88,-88,-87,-87,-87,-86,-86,-85,-85,-84,-84,-83,-83,-83,-82,-82,-81,-81,-80,-80,-79,-79,-78,-78,-77,-77,-76,-76,-75,-75,-74,-74,-73,-73,-72,-72,-71,-71,-70,-70,-69,-69,-68,-68,-67,-67,-66,-65,-65,-64,-64,-63,-63,-62,-62,-61,-60,-60,-59,-59,-58,-58,-57,-56,-56,-55,-55,-54,-53,-53,-52,-52,-51,-50,-50,-49,-49,-48,-47,-47,-46,-45,-45,-44,-44,-43,-42,-42,-41,-40,-40,-39,-38,-38,-37,-36,-36,-35,-34,-34,-33,-32,-32,-31,-30,-30,-29,-28,-28,-27,-26,-25,-25,-24,-23,-23,-22,-21,-21,-20,-19,-18,-18,-17,-16,-16,-15,-14,-13,-13,-12,-11,-10,-10,-9,-8,-7,-7,-6,-5,-4,-4,-3,-2,-1,-1,-0,0,1,2,2,3,4,5,5,6,7,8,9,9,10,11,12,13,13,14,15,16,17,17,18,19,20,21,21,22,23,24,25,26,26,27,28,29,30,30,31,32,33,34,35,36,36,37,38,39,40,41,41,42,43,44,45,46,47,47,48,49,50,51,52,53,53,54,55,56,57,58,59,60,60,61,62,63,64,65,66,67,68,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,85,86,87,88,89,90,91,92,93,94,94,95,96,97,98,99,100,101,102,103,104,105,105,106,107,108,109,110,111,112,113,114,115,115,116,117,118,119,120,121,122,123,124,125,126,126,127,128,129,130,131,132,133,134,135,136,137,137,138,139,140,141,142,143,144,145,146,147,148,148,149,150,151,152,153,154,155,156,157,158,158,159,160,161,162,163,164,165,166,167,167,168,169,170,171,172,173,174,175,176,176,177,178,179,180,181,182,183,184,184,185,186,187,188,189,190,191,191,192,193,194,195,196,197,197,198,199,200,201,202,203,203,204,205,206,207,208,209,209,210,211,212,213,214,214,215,216,217,218,219,219,220,221,222,223,223,224,225,226,227,228,228,229,230,231,231,232,233,234,235,235,236,237,238,239,239,240,241,242,242,243,244,245,245,246,247,248,248,249,250,251,251,252,253,253,254,255,256,256,257,258,258,259,260,261,261,262,263,263,264,265,265,266,267,267,268,269,269,270,271,271,272,273,273,274,275,275,276,276,277,278,278,279,279,280,281,281,282,282,283,284,284,285,285,286,286,287,288,288,289,289,290,290,291,291,292,292,293,294,294,295,295,296,296,297,297,298,298,299,299,299,300,300,301,301,302,302,303,303,304,304,304,305,305,306,306,306,307,307,308,308,308,309,309,310,310,310,311,311,311,312,312,312,313,313,313,314,314,314,315,315,315,316,316,316,316,317,317,317,317,318,318,318,318,319,319,319,319,320,320,320,320,320,321,321,321,321,321,321,322,322,322,322,322,322,322,323,323,323,323,323,323,323,323,323,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,323,323,323,323,323,323,323,323,323,322,322,322,322,322,322,321,321,321,321,321,321,320,320,320,320,319,319,319,319,319,318,318,318,317,317,317,317,316,316,316,315,315,315,314,314,314,313,313,313,312,312,312,311,311,310,310,310,309,309,308,308,307,307,307,306,306,305,305,304,304,303,303,302,302,301,301,300,300,299,299,298,297,297,296,296,295,295,294,293,293,292,292,291,290,290,289,288,288,287,286,286,285,284,284,283,282,282,281,280,279,279,278,277,276,276,275,274,273,273,272,271,270,269,269,268,267,266,265,264,264,263,262,261,260,259,258,257,257,256,255,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,222,221,220,219,218,217,216,215,213,212,211,210,209,208,206,205,204,203,202,200,199,198,197,195,194,193,192,190,189,188,187,185,184,183,182,180,179,178,176,175,174,172,171,170,168,167,166,164,163,161,160,159,157,156,154,153,152,150,149,147,146,144,143,142,140,139,137,136,134,133,131,130,128,127,125,124,122,121,119,118,116,115,113,111,110,108,107,105,104,102,100,99,97,96,94,92,91,89,88,86,84,83,81,79,78,76,74,73,71,69,68,66,64,63,61,59,58,56,54,52,51,49,47,46,44,42,40,39,37,35,33,31,30,28,26,24,23,21,19,17,15,14,12,10,8,6,4,3,1,-0,-2,-4,-6,-7,-9,-11,-13,-15,-17,-19,-20,-22,-24,-26,-28,-30,-32,-34,-36,-37,-39,-41,-43,-45,-47,-49,-51,-53,-55,-57,-59,-60,-62,-64,-66,-68,-70,-72,-74,-76,-78,-80,-82,-84,-86,-88,-90,-92,-94,-96,-98,-100,-102,-104,-106,-108,-110,-112,-114,-116,-118,-120,-122,-124,-126,-128,-130,-132,-134,-136,-138,-140,-142,-144,-146,-148,-150,-152,-154,-156,-158,-160,-162,-164,-166,-168,-171,-173,-175,-177,-179,-181,-183,-185,-187,-189,-191,-193,-195,-197,-199,-201,-203,-205,-207,-210,-212,-214,-216,-218,-220,-222,-224,-226,-228,-230,-232,-234,-236,-238,-241,-243,-245,-247,-249,-251,-253,-255,-257,-259,-261,-263,-265,-267,-269,-272,-274,-276,-278,-280,-282,-284,-286,-288,-290,-292,-294,-296,-298,-300,-302,-304,-306,-309,-311,-313,-315,-317,-319,-321,-323,-325,-327,-329,-331,-333,-335,-337,-339,-341,-343,-345,-347,-349,-351,-353,-355,-357,-359,-361,-363,-365,-367,-369,-371,-373,-375,-377,-379,-381,-383,-385,-387,-389,-391,-393,-395,-397,-399,-401,-403,-405,-407,-409,-411,-413,-414,-416,-418,-420,-422,-424,-426,-428,-430,-432,-434,-436,-437,-439,-441,-443,-445,-447,-449,-451,-453,-454,-456,-458,-460,-462,-464,-465,-467,-469,-471,-473,-475,-476,-478,-480,-482,-484,-485,-487,-489,-491,-493,-494,-496,-498,-500,-501,-503,-505,-507,-508,-510,-512,-513,-515,-517,-519,-520,-522,-524,-525,-527,-529,-530,-532,-534,-535,-537,-539,-540,-542,-543,-545,-547,-548,-550,-551,-553,-555,-556,-558,-559,-561,-562,-564,-565,-567,-568,-570,-571,-573,-574,-576,-577,-579,-580,-582,-583,-585,-586,-588,-589,-590,-592,-593,-595,-596,-597,-599,-600,-602,-603,-604,-606,-607,-608,-610,-611,-612,-614,-615,-616,-617,-619,-620,-621,-622,-624,-625,-626,-627,-628,-630,-631,-632,-633,-634,-636,-637,-638,-639,-640,-641,-642,-643,-644,-646,-647,-648,-649,-650,-651,-652,-653,-654,-655,-656,-657,-658,-659,-660,-661,-662,-663,-664,-664,-665,-666,-667,-668,-669,-670,-671,-671,-672,-673,-674,-675,-676,-676,-677,-678,-679,-679,-680,-681,-682,-682,-683,-684,-684,-685,-686,-686,-687,-688,-688,-689,-689,-690,-691,-691,-692,-692,-693,-693,-694,-694,-695,-695,-696,-696,-697,-697,-698,-698,-698,-699,-699,-700,-700,-700,-701,-701,-701,-702,-702,-702,-703,-703,-703,-703,-704,-704,-704,-704,-705,-705,-705,-705,-705,-705,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-705,-705,-705,-705,-705,-705,-704,-704,-704,-704,-703,-703,-703,-703,-702,-702,-702,-701,-701,-701,-700,-700,-699,-699,-699,-698,-698,-697,-697,-696,-696,-695,-695,-694,-694,-693,-693,-692,-691,-691,-690,-690,-689,-688,-688,-687,-686,-686,-685,-684,-683,-683,-682,-681,-680,-679,-679,-678,-677,-676,-675,-674,-674,-673,-672,-671,-670,-669,-668,-667,-666,-665,-664,-663,-662,-661,-660,-659,-658,-657,-656,-654,-653,-652,-651,-650,-649,-647,-646,-645,-644,-643,-641,-640,-639,-637,-636,-635,-633,-632,-631,-629,-628,-627,-625,-624,-622,-621,-619,-618,-616,-615,-613,-612,-610,-609,-607,-606,-604,-603,-601,-599,-598,-596,-594,-593,-591,-589,-588,-586,-584,-582,-581,-579,-577,-575,-573,-572,-570,-568,-566,-564,-562,-560,-559,-557,-555,-553,-551,-549,-547,-545,-543,-541,-539,-537,-535,-533,-531,-528,-526,-524,-522,-520,-518,-516,-514,-511,-509,-507,-505,-502,-500,-498,-496,-493,-491,-489,-486,-484,-482,-479,-477,-475,-472,-470,-468,-465,-463,-460,-458,-455,-453,-450,-448,-445,-443,-440,-438,-435,-432,-430,-427,-425,-422,-419,-417,-414,-411,-409,-406,-403,-401,-398,-395,-392,-390,-387,-384,-381,-379,-376,-373,-370,-367,-364,-362,-359,-356,-353,-350,-347,-344,-341,-338,-335,-332,-329,-326,-323,-320,-317,-314,-311,-308,-305,-302,-299,-296,-293,-290,-287,-283,-280,-277,-274,-271,-268,-264,-261,-258,-255,-251,-248,-245,-242,-238,-235,-232,-229,-225,-222,-219,-215,-212,-209,-205,-202,-198,-195,-192,-188,-185,-181,-178,-174,-171,-168,-164,-161,-157,-154,-150,-147,-143,-139,-136,-132,-129,-125,-122,-118,-115,-111,-107,-104,-100,-96,-93,-89,-86,-82,-78,-74,-71,-67,-63,-60,-56,-52,-49,-45,-41,-37,-34,-30,-26,-22,-18,-15,-11,-7,-3,0,3,7,11,15,19,23,27,30,34,38,42,46,50,54,58,62,66,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,174,178,182,186,190,194,198,202,206,210,214,218,223,227,231,235,239,243,247,251,256,260,264,268,272,276,280,285,289,293,297,301,305,310,314,318,322,326,330,335,339,343,347,351,356,360,364,368,372,377,381,385,389,393,398,402,406,410,414,419,423,427,431,435,440,444,448,452,456,461,465,469,473,478,482,486,490,494,499,503,507,511,515,520,524,528,532,536,541,545,549,553,557,562,566,570,574,578,582,587,591,595,599,603,608,612,616,620,624,628,632,637,641,645,649,653,657,661,666,670,674,678,682,686,690,694,698,703,707,711,715,719,723,727,731,735,739,743,747,751,755,759,763,767,771,775,779,783,787,791,795,799,803,807,811,815,819,823,827,831,835,839,843,846,850,854,858,862,866,870,874,877,881,885,889,893,896,900,904,908,912,915,919,923,927,930,934,938,941,945,949,952,956,960,963,967,971,974,978,982,985,989,992,996,999,1003,1007,1010,1014,1017,1021,1024,1028,1031,1034,1038,1041,1045,1048,1052,1055,1058,1062,1065,1068,1072,1075,1078,1082,1085,1088,1092,1095,1098,1101,1104,1108,1111,1114,1117,1120,1124,1127,1130,1133,1136,1139,1142,1145,1148,1151,1154,1157,1160,1163,1166,1169,1172,1175,1178,1181,1184,1187,1189,1192,1195,1198,1201,1204,1206,1209,1212,1215,1217,1220,1223,1225,1228,1231,1233,1236,1238,1241,1244,1246,1249,1251,1254,1256,1259,1261,1264,1266,1268,1271,1273,1275,1278,1280,1282,1285,1287,1289,1292,1294,1296,1298,1300,1302,1305,1307,1309,1311,1313,1315,1317,1319,1321,1323,1325,1327,1329,1331,1333,1335,1337,1338,1340,1342,1344,1346,1347,1349,1351,1352,1354,1356,1357,1359,1361,1362,1364,1365,1367,1368,1370,1371,1373,1374,1376,1377,1378,1380,1381,1382,1384,1385,1386,1388,1389,1390,1391,1392,1393,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1405,1406,1407,1408,1409,1410,1410,1411,1412,1413,1413,1414,1415,1415,1416,1416,1417,1417,1418,1418,1419,1419,1420,1420,1421,1421,1421,1422,1422,1422,1422,1423,1423,1423,1423,1423,1423,1424,1424,1424,1424,1424,1424,1424,1424,1423,1423,1423,1423,1423,1423,1422,1422,1422,1422,1421,1421,1421,1420,1420,1419,1419,1418,1418,1417,1417,1416,1416,1415,1414,1414,1413,1412,1412,1411,1410,1409,1408,1408,1407,1406,1405,1404,1403,1402,1401,1400,1399,1398,1397,1396,1394,1393,1392,1391,1389,1388,1387,1386,1384,1383,1381,1380,1378,1377,1375,1374,1372,1371,1369,1368,1366,1364,1363,1361,1359,1357,1356,1354,1352,1350,1348,1346,1344,1342,1340,1338,1336,1334,1332,1330,1328,1326,1323,1321,1319,1317,1314,1312,1310,1307,1305,1302,1300,1298,1295,1293,1290,1287,1285,1282,1280,1277,1274,1272,1269,1266,1263,1260,1258,1255,1252,1249,1246,1243,1240,1237,1234,1231,1228,1225,1222,1218,1215,1212,1209,1205,1202,1199,1196,1192,1189,1185,1182,1178,1175,1172,1168,1164,1161,1157,1154,1150,1146,1143,1139,1135,1131,1127,1124,1120,1116,1112,1108,1104,1100,1096,1092,1088,1084,1080,1076,1072,1067,1063,1059,1055,1051,1046,1042,1038,1033,1029,1024,1020,1015,1011,1007,1002,997,993,988,984,979,974,970,965,960,955,951,946,941,936,931,926,921,916,911,906,901,896,891,886,881,876,871,866,860,855,850,845,839,834,829,823,818,812,807,801,796,790,785,779,774,768,763,757,751,746,740,734,729,723,717,711,705,699,694,688,682,676,670,664,658,652,646,640,634,628,621,615,609,603,597,590,584,578,572,565,559,553,546,540,533,527,521,514,508,501,495,488,481,475,468,462,455,448,442,435,428,421,415,408,401,394,387,381,374,367,360,353,346,339,332,325,318,311,304,297,290,283,276,269,261,254,247,240,233,225,218,211,204,196,189,182,174,167,159,152,145,137,130,122,115,107,100,92,85,77,70,62,54,47,39,32,24,16,9,1,-6,-14,-21,-29,-37,-45,-52,-60,-68,-76,-84,-92,-99,-107,-115,-123,-131,-139,-147,-155,-163,-171,-179,-187,-195,-203,-211,-219,-227,-235,-243,-251,-259,-268,-276,-284,-292,-300,-308,-317,-325,-333,-341,-349,-358,-366,-374,-382,-391,-399,-407,-415,-424,-432,-440,-449,-457,-465,-474,-482,-490,-499,-507,-516,-524,-532,-541,-549,-558,-566,-575,-583,-591,-600,-608,-617,-625,-634,-642,-651,-659,-668,-676,-685,-693,-702,-710,-719,-727,-736,-744,-753,-762,-770,-779,-787,-796,-804,-813,-822,-830,-839,-847,-856,-864,-873,-882,-890,-899,-907,-916,-925,-933,-942,-950,-959,-968,-976,-985,-994,-1002,-1011,-1019,-1028,-1037,-1045,-1054,-1062,-1071,-1080,-1088,-1097,-1105,-1114,-1123,-1131,-1140,-1148,-1157,-1166,-1174,-1183,-1191,-1200,-1209,-1217,-1226,-1234,-1243,-1251,-1260,-1269,-1277,-1286,-1294,-1303,-1311,-1320,-1328,-1337,-1345,-1354,-1362,-1371,-1379,-1388,-1396,-1405,-1413,-1422,-1430,-1439,-1447,-1456,-1464,-1472,-1481,-1489,-1498,-1506,-1514,-1523,-1531,-1540,-1548,-1556,-1565,-1573,-1581,-1590,-1598,-1606,-1614,-1623,-1631,-1639,-1647,-1656,-1664,-1672,-1680,-1688,-1697,-1705,-1713,-1721,-1729,-1737,-1745,-1754,-1762,-1770,-1778,-1786,-1794,-1802,-1810,-1818,-1826,-1834,-1842,-1850,-1858,-1866,-1874,-1881,-1889,-1897,-1905,-1913,-1921,-1928,-1936,-1944,-1952,-1959,-1967,-1975,-1983,-1990,-1998,-2006,-2013,-2021,-2028,-2036,-2043,-2051,-2059,-2066,-2074,-2081,-2088,-2096,-2103,-2111,-2118,-2125,-2133,-2140,-2147,-2155,-2162,-2169,-2176,-2183,-2191,-2198,-2205,-2212,-2219,-2226,-2233,-2240,-2247,-2254,-2261,-2268,-2275,-2282,-2289,-2296,-2303,-2309,-2316,-2323,-2330,-2336,-2343,-2350,-2356,-2363,-2370,-2376,-2383,-2389,-2396,-2402,-2409,-2415,-2421,-2428,-2434,-2440,-2447,-2453,-2459,-2465,-2472,-2478,-2484,-2490,-2496,-2502,-2508,-2514,-2520,-2526,-2532,-2538,-2544,-2550,-2555,-2561,-2567,-2573,-2578,-2584,-2590,-2595,-2601,-2606,-2612,-2617,-2623,-2628,-2634,-2639,-2644,-2650,-2655,-2660,-2665,-2670,-2676,-2681,-2686,-2691,-2696,-2701,-2706,-2711,-2716,-2720,-2725,-2730,-2735,-2739,-2744,-2749,-2753,-2758,-2762,-2767,-2771,-2776,-2780,-2785,-2789,-2793,-2798,-2802,-2806,-2810,-2814,-2818,-2822,-2826,-2830,-2834,-2838,-2842,-2846,-2850,-2854,-2857,-2861,-2865,-2868,-2872,-2875,-2879,-2882,-2886,-2889,-2892,-2896,-2899,-2902,-2905,-2909,-2912,-2915,-2918,-2921,-2924,-2927,-2930,-2932,-2935,-2938,-2941,-2943,-2946,-2949,-2951,-2954,-2956,-2958,-2961,-2963,-2966,-2968,-2970,-2972,-2974,-2976,-2978,-2980,-2982,-2984,-2986,-2988,-2990,-2992,-2993,-2995,-2997,-2998,-3000,-3001,-3003,-3004,-3005,-3007,-3008,-3009,-3010,-3011,-3012,-3014,-3015,-3015,-3016,-3017,-3018,-3019,-3020,-3020,-3021,-3021,-3022,-3022,-3023,-3023,-3024,-3024,-3024,-3024,-3025,-3025,-3025,-3025,-3025,-3025,-3025,-3024,-3024,-3024,-3024,-3023,-3023,-3022,-3022,-3021,-3021,-3020,-3019,-3019,-3018,-3017,-3016,-3015,-3014,-3013,-3012,-3011,-3010,-3008,-3007,-3006,-3004,-3003,-3001,-3000,-2998,-2996,-2995,-2993,-2991,-2989,-2987,-2985,-2983,-2981,-2979,-2977,-2975,-2973,-2970,-2968,-2966,-2963,-2961,-2958,-2955,-2953,-2950,-2947,-2944,-2941,-2938,-2935,-2932,-2929,-2926,-2923,-2920,-2916,-2913,-2910,-2906,-2903,-2899,-2895,-2892,-2888,-2884,-2880,-2876,-2872,-2868,-2864,-2860,-2856,-2852,-2847,-2843,-2839,-2834,-2830,-2825,-2821,-2816,-2811,-2806,-2802,-2797,-2792,-2787,-2782,-2777,-2771,-2766,-2761,-2756,-2750,-2745,-2739,-2734,-2728,-2722,-2717,-2711,-2705,-2699,-2693,-2687,-2681,-2675,-2669,-2663,-2656,-2650,-2644,-2637,-2631,-2624,-2618,-2611,-2604,-2597,-2591,-2584,-2577,-2570,-2563,-2555,-2548,-2541,-2534,-2526,-2519,-2512,-2504,-2496,-2489,-2481,-2473,-2465,-2458,-2450,-2442,-2434,-2426,-2417,-2409,-2401,-2393,-2384,-2376,-2367,-2359,-2350,-2341,-2333,-2324,-2315,-2306,-2297,-2288,-2279,-2270,-2261,-2252,-2242,-2233,-2223,-2214,-2204,-2195,-2185,-2175,-2166,-2156,-2146,-2136,-2126,-2116,-2106,-2096,-2086,-2075,-2065,-2054,-2044,-2034,-2023,-2012,-2002,-1991,-1980,-1969,-1958,-1947,-1936,-1925,-1914,-1903,-1892,-1880,-1869,-1857,-1846,-1834,-1823,-1811,-1799,-1788,-1776,-1764,-1752,-1740,-1728,-1716,-1704,-1691,-1679,-1667,-1654,-1642,-1629,-1617,-1604,-1591,-1579,-1566,-1553,-1540,-1527,-1514,-1501,-1488,-1475,-1461,-1448,-1435,-1421,-1408,-1394,-1380,-1367,-1353,-1339,-1326,-1312,-1298,-1284,-1270,-1256,-1241,-1227,-1213,-1199,-1184,-1170,-1155,-1141,-1126,-1111,-1097,-1082,-1067,-1052,-1037,-1022,-1007,-992,-977,-962,-946,-931,-916,-900,-885,-869,-854,-838,-822,-807,-791,-775,-759,-743,-727,-711,-695,-678,-662,-646,-630,-613,-597,-580,-564,-547,-530,-514,-497,-480,-463,-446,-429,-412,-395,-378,-361,-343,-326,-309,-291,-274,-256,-239,-221,-204,-186,-168,-150,-132,-114,-96,-78,-60,-42,-24,-6,11,30,48,67,85,104,122,141,160,178,197,216,235,254,273,292,311,330,349,368,388,407,426,446,465,485,504,524,543,563,583,603,622,642,662,682,702,722,742,763,783,803,823,844,864,884,905,925,946,967,987,1008,1029,1050,1070,1091,1112,1133,1154,1175,1196,1217,1239,1260,1281,1302,1324,1345,1367,1388,1410,1431,1453,1474,1496,1518,1540,1561,1583,1605,1627,1649,1671,1693,1715,1737,1760,1782,1804,1826,1849,1871,1893,1916,1938,1961,1984,2006,2029,2051,2074,2097,2120,2143,2165,2188,2211,2234,2257,2280,2303,2326,2350,2373,2396,2419,2443,2466,2489,2513,2536,2560,2583,2607,2630,2654,2677,2701,2725,2748,2772,2796,2820,2844,2868,2891,2915,2939,2963,2987,3012,3036,3060,3084,3108,3132,3157,3181,3205,3230,3254,3278,3303,3327,3352,3376,3401,3425,3450,3475,3499,3524,3549,3573,3598,3623,3648,3673,3697,3722,3747,3772,3797,3822,3847,3872,3897,3922,3947,3973,3998,4023,4048,4073,4099,4124,4149,4174,4200,4225,4251,4276,4301,4327,4352,4378,4403,4429,4454,4480,4505,4531,4557,4582,4608,4634,4659,4685,4711,4736,4762,4788,4814,4840,4865,4891,4917,4943,4969,4995,5021,5047,5073,5099,5125,5151,5177,5203,5229,5255,5281,5307,5333,5359,5385,5411,5437,5464,5490,5516,5542,5568,5594,5621,5647,5673,5699,5726,5752,5778,5804,5831,5857,5883,5910,5936,5962,5988,6015,6041,6068,6094,6120,6147,6173,6199,6226,6252,6279,6305,6331,6358,6384,6411,6437,6463,6490,6516,6543,6569,6596,6622,6648,6675,6701,6728,6754,6781,6807,6833,6860,6886,6913,6939,6966,6992,7019,7045,7071,7098,7124,7151,7177,7204,7230,7256,7283,7309,7336,7362,7388,7415,7441,7467,7494,7520,7547,7573,7599,7626,7652,7678,7705,7731,7757,7783,7810,7836,7862,7889,7915,7941,7967,7993,8020,8046,8072,8098,8124,8150,8177,8203,8229,8255,8281,8307,8333,8359,8385,8411,8437,8463,8489,8515,8541,8567,8593,8619,8645,8671,8697,8722,8748,8774,8800,8826,8851,8877,8903,8928,8954,8980,9005,9031,9057,9082,9108,9133,9159,9184,9210,9235,9261,9286,9312,9337,9362,9388,9413,9438,9463,9489,9514,9539,9564,9589,9615,9640,9665,9690,9715,9740,9765,9790,9815,9839,9864,9889,9914,9939,9963,9988,10013,10037,10062,10087,10111,10136,10160,10185,10209,10234,10258,10282,10307,10331,10355,10380,10404,10428,10452,10476,10500,10524,10548,10572,10596,10620,10644,10668,10692,10716,10739,10763,10787,10810,10834,10857,10881,10904,10928,10951,10975,10998,11021,11045,11068,11091,11114,11137,11160,11183,11206,11229,11252,11275,11298,11321,11344,11366,11389,11412,11434,11457,11479,11502,11524,11547,11569,11591,11613,11636,11658,11680,11702,11724,11746,11768,11790,11812,11834,11855,11877,11899,11920,11942,11963,11985,12006,12028,12049,12070,12092,12113,12134,12155,12176,12197,12218,12239,12260,12281,12302,12322,12343,12364,12384,12405,12425,12446,12466,12486,12506,12527,12547,12567,12587,12607,12627,12647,12667,12686,12706,12726,12746,12765,12785,12804,12823,12843,12862,12881,12901,12920,12939,12958,12977,12996,13015,13033,13052,13071,13089,13108,13127,13145,13163,13182,13200,13218,13236,13255,13273,13291,13309,13326,13344,13362,13380,13397,13415,13432,13450,13467,13485,13502,13519,13536,13553,13570,13587,13604,13621,13638,13654,13671,13688,13704,13721,13737,13753,13770,13786,13802,13818,13834,13850,13866,13882,13898,13913,13929,13945,13960,13975,13991,14006,14021,14037,14052,14067,14082,14097,14111,14126,14141,14155,14170,14185,14199,14213,14228,14242,14256,14270,14284,14298,14312,14326,14340,14353,14367,14380,14394,14407,14421,14434,14447,14460,14473,14486,14499,14512,14525,14537,14550,14563,14575,14587,14600,14612,14624,14636,14648,14660,14672,14684,14696,14708,14719,14731,14742,14754,14765,14776,14787,14799,14810,14820,14831,14842,14853,14864,14874,14885,14895,14905,14916,14926,14936,14946,14956,14966,14976,14986,14995,15005,15015,15024,15033,15043,15052,15061,15070,15079,15088,15097,15106,15114,15123,15132,15140,15148,15157,15165,15173,15181,15189,15197,15205,15213,15220,15228,15236,15243,15250,15258,15265,15272,15279,15286,15293,15300,15307,15313,15320,15326,15333,15339,15346,15352,15358,15364,15370,15376,15382,15387,15393,15399,15404,15409,15415,15420,15425,15430,15435,15440,15445,15450,15455,15459,15464,15468,15473,15477,15481,15485,15489,15493,15497,15501,15505,15508,15512,15515,15519,15522,15525,15529,15532,15535,15538,15540,15543,15546,15548,15551,15553,15556,15558,15560,15562,15564,15566,15568,15570,15572,15573,15575,15576,15578,15579,15580,15581,15582,15583,15584,15585,15586,15586,15587,15588,15588,15588,15588,15589,15589,15589,15589,15588,15588,15588,15588,15587,15586,15586,15585,15584,15583,15582,15581,15580,15579,15578,15576,15575,15573,15572,15570,15568,15566,15564,15562,15560,15558,15556,15553,15551,15548,15546,15543,15540,15538,15535,15532,15529,15525,15522,15519,15515,15512,15508,15505,15501,15497,15493,15489,15485,15481,15477,15473,15468,15464,15459,15455,15450,15445,15440,15435,15430,15425,15420,15415,15409,15404,15399,15393,15387,15382,15376,15370,15364,15358,15352,15346,15339,15333,15326,15320,15313,15307,15300,15293,15286,15279,15272,15265,15258,15250,15243,15236,15228,15220,15213,15205,15197,15189,15181,15173,15165,15157,15148,15140,15132,15123,15114,15106,15097,15088,15079,15070,15061,15052,15043,15033,15024,15015,15005,14995,14986,14976,14966,14956,14946,14936,14926,14916,14905,14895,14885,14874,14864,14853,14842,14831,14820,14810,14799,14787,14776,14765,14754,14742,14731,14719,14708,14696,14684,14672,14660,14648,14636,14624,14612,14600,14587,14575,14563,14550,14537,14525,14512,14499,14486,14473,14460,14447,14434,14421,14407,14394,14380,14367,14353,14340,14326,14312,14298,14284,14270,14256,14242,14228,14213,14199,14185,14170,14155,14141,14126,14111,14097,14082,14067,14052,14037,14021,14006,13991,13975,13960,13945,13929,13913,13898,13882,13866,13850,13834,13818,13802,13786,13770,13753,13737,13721,13704,13688,13671,13654,13638,13621,13604,13587,13570,13553,13536,13519,13502,13485,13467,13450,13432,13415,13397,13380,13362,13344,13326,13309,13291,13273,13255,13236,13218,13200,13182,13163,13145,13127,13108,13089,13071,13052,13033,13015,12996,12977,12958,12939,12920,12901,12881,12862,12843,12823,12804,12785,12765,12746,12726,12706,12686,12667,12647,12627,12607,12587,12567,12547,12527,12506,12486,12466,12446,12425,12405,12384,12364,12343,12322,12302,12281,12260,12239,12218,12197,12176,12155,12134,12113,12092,12070,12049,12028,12006,11985,11963,11942,11920,11899,11877,11855,11834,11812,11790,11768,11746,11724,11702,11680,11658,11636,11613,11591,11569,11547,11524,11502,11479,11457,11434,11412,11389,11366,11344,11321,11298,11275,11252,11229,11206,11183,11160,11137,11114,11091,11068,11045,11021,10998,10975,10951,10928,10904,10881,10857,10834,10810,10787,10763,10739,10716,10692,10668,10644,10620,10596,10572,10548,10524,10500,10476,10452,10428,10404,10380,10355,10331,10307,10282,10258,10234,10209,10185,10160,10136,10111,10087,10062,10037,10013,9988,9963,9939,9914,9889,9864,9839,9815,9790,9765,9740,9715,9690,9665,9640,9615,9589,9564,9539,9514,9489,9463,9438,9413,9388,9362,9337,9312,9286,9261,9235,9210,9184,9159,9133,9108,9082,9057,9031,9005,8980,8954,8928,8903,8877,8851,8826,8800,8774,8748,8722,8697,8671,8645,8619,8593,8567,8541,8515,8489,8463,8437,8411,8385,8359,8333,8307,8281,8255,8229,8203,8177,8150,8124,8098,8072,8046,8020,7993,7967,7941,7915,7889,7862,7836,7810,7783,7757,7731,7705,7678,7652,7626,7599,7573,7547,7520,7494,7467,7441,7415,7388,7362,7336,7309,7283,7256,7230,7204,7177,7151,7124,7098,7071,7045,7019,6992,6966,6939,6913,6886,6860,6833,6807,6781,6754,6728,6701,6675,6648,6622,6596,6569,6543,6516,6490,6463,6437,6411,6384,6358,6331,6305,6279,6252,6226,6199,6173,6147,6120,6094,6068,6041,6015,5988,5962,5936,5910,5883,5857,5831,5804,5778,5752,5726,5699,5673,5647,5621,5594,5568,5542,5516,5490,5464,5437,5411,5385,5359,5333,5307,5281,5255,5229,5203,5177,5151,5125,5099,5073,5047,5021,4995,4969,4943,4917,4891,4865,4840,4814,4788,4762,4736,4711,4685,4659,4634,4608,4582,4557,4531,4505,4480,4454,4429,4403,4378,4352,4327,4301,4276,4251,4225,4200,4174,4149,4124,4099,4073,4048,4023,3998,3973,3947,3922,3897,3872,3847,3822,3797,3772,3747,3722,3697,3673,3648,3623,3598,3573,3549,3524,3499,3475,3450,3425,3401,3376,3352,3327,3303,3278,3254,3230,3205,3181,3157,3132,3108,3084,3060,3036,3012,2987,2963,2939,2915,2891,2868,2844,2820,2796,2772,2748,2725,2701,2677,2654,2630,2607,2583,2560,2536,2513,2489,2466,2443,2419,2396,2373,2350,2326,2303,2280,2257,2234,2211,2188,2165,2143,2120,2097,2074,2051,2029,2006,1984,1961,1938,1916,1893,1871,1849,1826,1804,1782,1760,1737,1715,1693,1671,1649,1627,1605,1583,1561,1540,1518,1496,1474,1453,1431,1410,1388,1367,1345,1324,1302,1281,1260,1239,1217,1196,1175,1154,1133,1112,1091,1070,1050,1029,1008,987,967,946,925,905,884,864,844,823,803,783,763,742,722,702,682,662,642,622,603,583,563,543,524,504,485,465,446,426,407,388,368,349,330,311,292,273,254,235,216,197,178,160,141,122,104,85,67,48,30,11,-6,-24,-42,-60,-78,-96,-114,-132,-150,-168,-186,-204,-221,-239,-256,-274,-291,-309,-326,-343,-361,-378,-395,-412,-429,-446,-463,-480,-497,-514,-530,-547,-564,-580,-597,-613,-630,-646,-662,-678,-695,-711,-727,-743,-759,-775,-791,-807,-822,-838,-854,-869,-885,-900,-916,-931,-946,-962,-977,-992,-1007,-1022,-1037,-1052,-1067,-1082,-1097,-1111,-1126,-1141,-1155,-1170,-1184,-1199,-1213,-1227,-1241,-1256,-1270,-1284,-1298,-1312,-1326,-1339,-1353,-1367,-1380,-1394,-1408,-1421,-1435,-1448,-1461,-1475,-1488,-1501,-1514,-1527,-1540,-1553,-1566,-1579,-1591,-1604,-1617,-1629,-1642,-1654,-1667,-1679,-1691,-1704,-1716,-1728,-1740,-1752,-1764,-1776,-1788,-1799,-1811,-1823,-1834,-1846,-1857,-1869,-1880,-1892,-1903,-1914,-1925,-1936,-1947,-1958,-1969,-1980,-1991,-2002,-2012,-2023,-2034,-2044,-2054,-2065,-2075,-2086,-2096,-2106,-2116,-2126,-2136,-2146,-2156,-2166,-2175,-2185,-2195,-2204,-2214,-2223,-2233,-2242,-2252,-2261,-2270,-2279,-2288,-2297,-2306,-2315,-2324,-2333,-2341,-2350,-2359,-2367,-2376,-2384,-2393,-2401,-2409,-2417,-2426,-2434,-2442,-2450,-2458,-2465,-2473,-2481,-2489,-2496,-2504,-2512,-2519,-2526,-2534,-2541,-2548,-2555,-2563,-2570,-2577,-2584,-2591,-2597,-2604,-2611,-2618,-2624,-2631,-2637,-2644,-2650,-2656,-2663,-2669,-2675,-2681,-2687,-2693,-2699,-2705,-2711,-2717,-2722,-2728,-2734,-2739,-2745,-2750,-2756,-2761,-2766,-2771,-2777,-2782,-2787,-2792,-2797,-2802,-2806,-2811,-2816,-2821,-2825,-2830,-2834,-2839,-2843,-2847,-2852,-2856,-2860,-2864,-2868,-2872,-2876,-2880,-2884,-2888,-2892,-2895,-2899,-2903,-2906,-2910,-2913,-2916,-2920,-2923,-2926,-2929,-2932,-2935,-2938,-2941,-2944,-2947,-2950,-2953,-2955,-2958,-2961,-2963,-2966,-2968,-2970,-2973,-2975,-2977,-2979,-2981,-2983,-2985,-2987,-2989,-2991,-2993,-2995,-2996,-2998,-3000,-3001,-3003,-3004,-3006,-3007,-3008,-3010,-3011,-3012,-3013,-3014,-3015,-3016,-3017,-3018,-3019,-3019,-3020,-3021,-3021,-3022,-3022,-3023,-3023,-3024,-3024,-3024,-3024,-3025,-3025,-3025,-3025,-3025,-3025,-3025,-3024,-3024,-3024,-3024,-3023,-3023,-3022,-3022,-3021,-3021,-3020,-3020,-3019,-3018,-3017,-3016,-3015,-3015,-3014,-3012,-3011,-3010,-3009,-3008,-3007,-3005,-3004,-3003,-3001,-3000,-2998,-2997,-2995,-2993,-2992,-2990,-2988,-2986,-2984,-2982,-2980,-2978,-2976,-2974,-2972,-2970,-2968,-2966,-2963,-2961,-2958,-2956,-2954,-2951,-2949,-2946,-2943,-2941,-2938,-2935,-2932,-2930,-2927,-2924,-2921,-2918,-2915,-2912,-2909,-2905,-2902,-2899,-2896,-2892,-2889,-2886,-2882,-2879,-2875,-2872,-2868,-2865,-2861,-2857,-2854,-2850,-2846,-2842,-2838,-2834,-2830,-2826,-2822,-2818,-2814,-2810,-2806,-2802,-2798,-2793,-2789,-2785,-2780,-2776,-2771,-2767,-2762,-2758,-2753,-2749,-2744,-2739,-2735,-2730,-2725,-2720,-2716,-2711,-2706,-2701,-2696,-2691,-2686,-2681,-2676,-2670,-2665,-2660,-2655,-2650,-2644,-2639,-2634,-2628,-2623,-2617,-2612,-2606,-2601,-2595,-2590,-2584,-2578,-2573,-2567,-2561,-2555,-2550,-2544,-2538,-2532,-2526,-2520,-2514,-2508,-2502,-2496,-2490,-2484,-2478,-2472,-2465,-2459,-2453,-2447,-2440,-2434,-2428,-2421,-2415,-2409,-2402,-2396,-2389,-2383,-2376,-2370,-2363,-2356,-2350,-2343,-2336,-2330,-2323,-2316,-2309,-2303,-2296,-2289,-2282,-2275,-2268,-2261,-2254,-2247,-2240,-2233,-2226,-2219,-2212,-2205,-2198,-2191,-2183,-2176,-2169,-2162,-2155,-2147,-2140,-2133,-2125,-2118,-2111,-2103,-2096,-2088,-2081,-2074,-2066,-2059,-2051,-2043,-2036,-2028,-2021,-2013,-2006,-1998,-1990,-1983,-1975,-1967,-1959,-1952,-1944,-1936,-1928,-1921,-1913,-1905,-1897,-1889,-1881,-1874,-1866,-1858,-1850,-1842,-1834,-1826,-1818,-1810,-1802,-1794,-1786,-1778,-1770,-1762,-1754,-1745,-1737,-1729,-1721,-1713,-1705,-1697,-1688,-1680,-1672,-1664,-1656,-1647,-1639,-1631,-1623,-1614,-1606,-1598,-1590,-1581,-1573,-1565,-1556,-1548,-1540,-1531,-1523,-1514,-1506,-1498,-1489,-1481,-1472,-1464,-1456,-1447,-1439,-1430,-1422,-1413,-1405,-1396,-1388,-1379,-1371,-1362,-1354,-1345,-1337,-1328,-1320,-1311,-1303,-1294,-1286,-1277,-1269,-1260,-1251,-1243,-1234,-1226,-1217,-1209,-1200,-1191,-1183,-1174,-1166,-1157,-1148,-1140,-1131,-1123,-1114,-1105,-1097,-1088,-1080,-1071,-1062,-1054,-1045,-1037,-1028,-1019,-1011,-1002,-994,-985,-976,-968,-959,-950,-942,-933,-925,-916,-907,-899,-890,-882,-873,-864,-856,-847,-839,-830,-822,-813,-804,-796,-787,-779,-770,-762,-753,-744,-736,-727,-719,-710,-702,-693,-685,-676,-668,-659,-651,-642,-634,-625,-617,-608,-600,-591,-583,-575,-566,-558,-549,-541,-532,-524,-516,-507,-499,-490,-482,-474,-465,-457,-449,-440,-432,-424,-415,-407,-399,-391,-382,-374,-366,-358,-349,-341,-333,-325,-317,-308,-300,-292,-284,-276,-268,-259,-251,-243,-235,-227,-219,-211,-203,-195,-187,-179,-171,-163,-155,-147,-139,-131,-123,-115,-107,-99,-92,-84,-76,-68,-60,-52,-45,-37,-29,-21,-14,-6,1,9,16,24,32,39,47,54,62,70,77,85,92,100,107,115,122,130,137,145,152,159,167,174,182,189,196,204,211,218,225,233,240,247,254,261,269,276,283,290,297,304,311,318,325,332,339,346,353,360,367,374,381,387,394,401,408,415,421,428,435,442,448,455,462,468,475,481,488,495,501,508,514,521,527,533,540,546,553,559,565,572,578,584,590,597,603,609,615,621,628,634,640,646,652,658,664,670,676,682,688,694,699,705,711,717,723,729,734,740,746,751,757,763,768,774,779,785,790,796,801,807,812,818,823,829,834,839,845,850,855,860,866,871,876,881,886,891,896,901,906,911,916,921,926,931,936,941,946,951,955,960,965,970,974,979,984,988,993,997,1002,1007,1011,1015,1020,1024,1029,1033,1038,1042,1046,1051,1055,1059,1063,1067,1072,1076,1080,1084,1088,1092,1096,1100,1104,1108,1112,1116,1120,1124,1127,1131,1135,1139,1143,1146,1150,1154,1157,1161,1164,1168,1172,1175,1178,1182,1185,1189,1192,1196,1199,1202,1205,1209,1212,1215,1218,1222,1225,1228,1231,1234,1237,1240,1243,1246,1249,1252,1255,1258,1260,1263,1266,1269,1272,1274,1277,1280,1282,1285,1287,1290,1293,1295,1298,1300,1302,1305,1307,1310,1312,1314,1317,1319,1321,1323,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1357,1359,1361,1363,1364,1366,1368,1369,1371,1372,1374,1375,1377,1378,1380,1381,1383,1384,1386,1387,1388,1389,1391,1392,1393,1394,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1408,1409,1410,1411,1412,1412,1413,1414,1414,1415,1416,1416,1417,1417,1418,1418,1419,1419,1420,1420,1421,1421,1421,1422,1422,1422,1422,1423,1423,1423,1423,1423,1423,1424,1424,1424,1424,1424,1424,1424,1424,1423,1423,1423,1423,1423,1423,1422,1422,1422,1422,1421,1421,1421,1420,1420,1419,1419,1418,1418,1417,1417,1416,1416,1415,1415,1414,1413,1413,1412,1411,1410,1410,1409,1408,1407,1406,1405,1405,1404,1403,1402,1401,1400,1399,1398,1397,1396,1395,1393,1392,1391,1390,1389,1388,1386,1385,1384,1382,1381,1380,1378,1377,1376,1374,1373,1371,1370,1368,1367,1365,1364,1362,1361,1359,1357,1356,1354,1352,1351,1349,1347,1346,1344,1342,1340,1338,1337,1335,1333,1331,1329,1327,1325,1323,1321,1319,1317,1315,1313,1311,1309,1307,1305,1302,1300,1298,1296,1294,1292,1289,1287,1285,1282,1280,1278,1275,1273,1271,1268,1266,1264,1261,1259,1256,1254,1251,1249,1246,1244,1241,1238,1236,1233,1231,1228,1225,1223,1220,1217,1215,1212,1209,1206,1204,1201,1198,1195,1192,1189,1187,1184,1181,1178,1175,1172,1169,1166,1163,1160,1157,1154,1151,1148,1145,1142,1139,1136,1133,1130,1127,1124,1120,1117,1114,1111,1108,1104,1101,1098,1095,1092,1088,1085,1082,1078,1075,1072,1068,1065,1062,1058,1055,1052,1048,1045,1041,1038,1034,1031,1028,1024,1021,1017,1014,1010,1007,1003,999,996,992,989,985,982,978,974,971,967,963,960,956,952,949,945,941,938,934,930,927,923,919,915,912,908,904,900,896,893,889,885,881,877,874,870,866,862,858,854,850,846,843,839,835,831,827,823,819,815,811,807,803,799,795,791,787,783,779,775,771,767,763,759,755,751,747,743,739,735,731,727,723,719,715,711,707,703,698,694,690,686,682,678,674,670,666,661,657,653,649,645,641,637,632,628,624,620,616,612,608,603,599,595,591,587,582,578,574,570,566,562,557,553,549,545,541,536,532,528,524,520,515,511,507,503,499,494,490,486,482,478,473,469,465,461,456,452,448,444,440,435,431,427,423,419,414,410,406,402,398,393,389,385,381,377,372,368,364,360,356,351,347,343,339,335,330,326,322,318,314,310,305,301,297,293,289,285,280,276,272,268,264,260,256,251,247,243,239,235,231,227,223,218,214,210,206,202,198,194,190,186,182,178,174,169,165,161,157,153,149,145,141,137,133,129,125,121,117,113,109,105,101,97,93,89,85,81,77,73,69,66,62,58,54,50,46,42,38,34,30,27,23,19,15,11,7,3,0,-3,-7,-11,-15,-18,-22,-26,-30,-34,-37,-41,-45,-49,-52,-56,-60,-63,-67,-71,-74,-78,-82,-86,-89,-93,-96,-100,-104,-107,-111,-115,-118,-122,-125,-129,-132,-136,-139,-143,-147,-150,-154,-157,-161,-164,-168,-171,-174,-178,-181,-185,-188,-192,-195,-198,-202,-205,-209,-212,-215,-219,-222,-225,-229,-232,-235,-238,-242,-245,-248,-251,-255,-258,-261,-264,-268,-271,-274,-277,-280,-283,-287,-290,-293,-296,-299,-302,-305,-308,-311,-314,-317,-320,-323,-326,-329,-332,-335,-338,-341,-344,-347,-350,-353,-356,-359,-362,-364,-367,-370,-373,-376,-379,-381,-384,-387,-390,-392,-395,-398,-401,-403,-406,-409,-411,-414,-417,-419,-422,-425,-427,-430,-432,-435,-438,-440,-443,-445,-448,-450,-453,-455,-458,-460,-463,-465,-468,-470,-472,-475,-477,-479,-482,-484,-486,-489,-491,-493,-496,-498,-500,-502,-505,-507,-509,-511,-514,-516,-518,-520,-522,-524,-526,-528,-531,-533,-535,-537,-539,-541,-543,-545,-547,-549,-551,-553,-555,-557,-559,-560,-562,-564,-566,-568,-570,-572,-573,-575,-577,-579,-581,-582,-584,-586,-588,-589,-591,-593,-594,-596,-598,-599,-601,-603,-604,-606,-607,-609,-610,-612,-613,-615,-616,-618,-619,-621,-622,-624,-625,-627,-628,-629,-631,-632,-633,-635,-636,-637,-639,-640,-641,-643,-644,-645,-646,-647,-649,-650,-651,-652,-653,-654,-656,-657,-658,-659,-660,-661,-662,-663,-664,-665,-666,-667,-668,-669,-670,-671,-672,-673,-674,-674,-675,-676,-677,-678,-679,-679,-680,-681,-682,-683,-683,-684,-685,-686,-686,-687,-688,-688,-689,-690,-690,-691,-691,-692,-693,-693,-694,-694,-695,-695,-696,-696,-697,-697,-698,-698,-699,-699,-699,-700,-700,-701,-701,-701,-702,-702,-702,-703,-703,-703,-703,-704,-704,-704,-704,-705,-705,-705,-705,-705,-705,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-706,-705,-705,-705,-705,-705,-705,-704,-704,-704,-704,-703,-703,-703,-703,-702,-702,-702,-701,-701,-701,-700,-700,-700,-699,-699,-698,-698,-698,-697,-697,-696,-696,-695,-695,-694,-694,-693,-693,-692,-692,-691,-691,-690,-689,-689,-688,-688,-687,-686,-686,-685,-684,-684,-683,-682,-682,-681,-680,-679,-679,-678,-677,-676,-676,-675,-674,-673,-672,-671,-671,-670,-669,-668,-667,-666,-665,-664,-664,-663,-662,-661,-660,-659,-658,-657,-656,-655,-654,-653,-652,-651,-650,-649,-648,-647,-646,-644,-643,-642,-641,-640,-639,-638,-637,-636,-634,-633,-632,-631,-630,-628,-627,-626,-625,-624,-622,-621,-620,-619,-617,-616,-615,-614,-612,-611,-610,-608,-607,-606,-604,-603,-602,-600,-599,-597,-596,-595,-593,-592,-590,-589,-588,-586,-585,-583,-582,-580,-579,-577,-576,-574,-573,-571,-570,-568,-567,-565,-564,-562,-561,-559,-558,-556,-555,-553,-551,-550,-548,-547,-545,-543,-542,-540,-539,-537,-535,-534,-532,-530,-529,-527,-525,-524,-522,-520,-519,-517,-515,-513,-512,-510,-508,-507,-505,-503,-501,-500,-498,-496,-494,-493,-491,-489,-487,-485,-484,-482,-480,-478,-476,-475,-473,-471,-469,-467,-465,-464,-462,-460,-458,-456,-454,-453,-451,-449,-447,-445,-443,-441,-439,-437,-436,-434,-432,-430,-428,-426,-424,-422,-420,-418,-416,-414,-413,-411,-409,-407,-405,-403,-401,-399,-397,-395,-393,-391,-389,-387,-385,-383,-381,-379,-377,-375,-373,-371,-369,-367,-365,-363,-361,-359,-357,-355,-353,-351,-349,-347,-345,-343,-341,-339,-337,-335,-333,-331,-329,-327,-325,-323,-321,-319,-317,-315,-313,-311,-309,-306,-304,-302,-300,-298,-296,-294,-292,-290,-288,-286,-284,-282,-280,-278,-276,-274,-272,-269,-267,-265,-263,-261,-259,-257,-255,-253,-251,-249,-247,-245,-243,-241,-238,-236,-234,-232,-230,-228,-226,-224,-222,-220,-218,-216,-214,-212,-210,-207,-205,-203,-201,-199,-197,-195,-193,-191,-189,-187,-185,-183,-181,-179,-177,-175,-173,-171,-168,-166,-164,-162,-160,-158,-156,-154,-152,-150,-148,-146,-144,-142,-140,-138,-136,-134,-132,-130,-128,-126,-124,-122,-120,-118,-116,-114,-112,-110,-108,-106,-104,-102,-100,-98,-96,-94,-92,-90,-88,-86,-84,-82,-80,-78,-76,-74,-72,-70,-68,-66,-64,-62,-60,-59,-57,-55,-53,-51,-49,-47,-45,-43,-41,-39,-37,-36,-34,-32,-30,-28,-26,-24,-22,-20,-19,-17,-15,-13,-11,-9,-7,-6,-4,-2,-0,1,3,4,6,8,10,12,14,15,17,19,21,23,24,26,28,30,31,33,35,37,39,40,42,44,46,47,49,51,52,54,56,58,59,61,63,64,66,68,69,71,73,74,76,78,79,81,83,84,86,88,89,91,92,94,96,97,99,100,102,104,105,107,108,110,111,113,115,116,118,119,121,122,124,125,127,128,130,131,133,134,136,137,139,140,142,143,144,146,147,149,150,152,153,154,156,157,159,160,161,163,164,166,167,168,170,171,172,174,175,176,178,179,180,182,183,184,185,187,188,189,190,192,193,194,195,197,198,199,200,202,203,204,205,206,208,209,210,211,212,213,215,216,217,218,219,220,221,222,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,257,258,259,260,261,262,263,264,264,265,266,267,268,269,269,270,271,272,273,273,274,275,276,276,277,278,279,279,280,281,282,282,283,284,284,285,286,286,287,288,288,289,290,290,291,292,292,293,293,294,295,295,296,296,297,297,298,299,299,300,300,301,301,302,302,303,303,304,304,305,305,306,306,307,307,307,308,308,309,309,310,310,310,311,311,312,312,312,313,313,313,314,314,314,315,315,315,316,316,316,317,317,317,317,318,318,318,319,319,319,319,319,320,320,320,320,321,321,321,321,321,321,322,322,322,322,322,322,323,323,323,323,323,323,323,323,323,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,324,323,323,323,323,323,323,323,323,323,322,322,322,322,322,322,322,321,321,321,321,321,321,320,320,320,320,320,319,319,319,319,318,318,318,318,317,317,317,317,316,316,316,316,315,315,315,314,314,314,313,313,313,312,312,312,311,311,311,310,310,310,309,309,308,308,308,307,307,306,306,306,305,305,304,304,304,303,303,302,302,301,301,300,300,299,299,299,298,298,297,297,296,296,295,295,294,294,293,292,292,291,291,290,290,289,289,288,288,287,286,286,285,285,284,284,283,282,282,281,281,280,279,279,278,278,277,276,276,275,275,274,273,273,272,271,271,270,269,269,268,267,267,266,265,265,264,263,263,262,261,261,260,259,258,258,257,256,256,255,254,253,253,252,251,251,250,249,248,248,247,246,245,245,244,243,242,242,241,240,239,239,238,237,236,235,235,234,233,232,231,231,230,229,228,228,227,226,225,224,223,223,222,221,220,219,219,218,217,216,215,214,214,213,212,211,210,209,209,208,207,206,205,204,203,203,202,201,200,199,198,197,197,196,195,194,193,192,191,191,190,189,188,187,186,185,184,184,183,182,181,180,179,178,177,176,176,175,174,173,172,171,170,169,168,167,167,166,165,164,163,162,161,160,159,158,158,157,156,155,154,153,152,151,150,149,148,148,147,146,145,144,143,142,141,140,139,138,137,137,136,135,134,133,132,131,130,129,128,127,126,126,125,124,123,122,121,120,119,118,117,116,115,115,114,113,112,111,110,109,108,107,106,105,105,104,103,102,101,100,99,98,97,96,95,94,94,93,92,91,90,89,88,87,86,85,85,84,83,82,81,80,79,78,77,76,76,75,74,73,72,71,70,69,68,68,67,66,65,64,63,62,61,60,60,59,58,57,56,55,54,53,53,52,51,50,49,48,47,47,46,45,44,43,42,41,41,40,39,38,37,36,36,35,34,33,32,31,30,30,29,28,27,26,26,25,24,23,22,21,21,20,19,18,17,17,16,15,14,13,13,12,11,10,9,9,8,7,6,5,5,4,3,2,2,1,0,-0,-1,-1,-2,-3,-4,-4,-5,-6,-7,-7,-8,-9,-10,-10,-11,-12,-13,-13,-14,-15,-16,-16,-17,-18,-18,-19,-20,-21,-21,-22,-23,-23,-24,-25,-25,-26,-27,-28,-28,-29,-30,-30,-31,-32,-32,-33,-34,-34,-35,-36,-36,-37,-38,-38,-39,-40,-40,-41,-42,-42,-43,-44,-44,-45,-45,-46,-47,-47,-48,-49,-49,-50,-50,-51,-52,-52,-53,-53,-54,-55,-55,-56,-56,-57,-58,-58,-59,-59,-60,-60,-61,-62,-62,-63,-63,-64,-64,-65,-65,-66,-67,-67,-68,-68,-69,-69,-70,-70,-71,-71,-72,-72,-73,-73,-74,-74,-75,-75,-76,-76,-77,-77,-78,-78,-79,-79,-80,-80,-81,-81,-82,-82,-83,-83,-83,-84,-84,-85,-85,-86,-86,-87,-87,-87,-88,-88,-89,-89,-90,-90,-90,-91,-91,-92,-92,-92,-93,-93,-94,-94,-94,-95,-95,-96,-96,-96,-97,-97,-97,-98,-98,-99,-99,-99,-100,-100,-100,-101,-101,-101,-102,-102,-102,-103,-103,-103,-104,-104,-104,-105,-105,-105,-105,-106,-106,-106,-107,-107,-107,-107,-108,-108,-108,-109,-109,-109,-109,-110,-110,-110,-110,-111,-111,-111,-111,-112,-112,-112,-112,-113,-113,-113,-113,-114,-114,-114,-114,-114,-115,-115,-115,-115,-115,-116,-116,-116,-116,-116,-117,-117,-117,-117,-117,-117,-118,-118,-118,-118,-118,-118,-119,-119,-119,-119,-119,-119,-119,-120,-120,-120,-120,-120,-120,-120,-120,-121,-121,-121,-121,-121,-121,-121,-121,-121,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-123,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-122,-121,-121,-121,-121,-121,-121,-121,-121,-121,-121,-120,-120,-120,-120,-120,-120,-120,-120,-120,-119,-119,-119,-119,-119,-119,-119,-118,-118,-118,-118,-118,-118,-118,-117,-117,-117,-117,-117,-117,-117,-116,-116,-116,-116,-116,-116,-115,-115,-115,-115,-115,-115,-114,-114,-114,-114,-114,-113,-113,-113,-113,-113,-112,-112,-112,-112,-112,-111,-111,-111,-111,-111,-110,-110,-110,-110,-110,-109,-109,-109,-109,-109,-108,-108,-108,-108,-107,-107,-107,-107,-106,-106,-106,-106,-106,-105,-105,-105,-105,-104,-104,-104,-104,-103,-103,-103,-103,-102,-102,-102,-102,-101,-101,-101,-101,-100,-100,-100,-100,-99,-99,-99,-98,-98,-98,-98,-97,-97,-97,-97,-96,-96,-96,-95,-95,-95,-95,-94,-94,-94,-93,-93,-93,-93,-92,-92,-92,-91,-91,-91,-91,-90,-90,-90,-89,-89,-89,-89,-88,-88,-88,-87,-87,-87,-86,-86,-86,-86,-85,-85,-85,-84,-84,-84,-83,-83,-83,-82,-82,-82,-81,-81,-81,-81,-80,-80,-80,-79,-79,-79,-78,-78,-78,-77,-77,-77,-76,-76,-76,-75,-75,-75,-74,-74,-74,-74,-73,-73,-73,-72,-72,-72,-71,-71,-71,-70,-70,-70,-69,-69,-69,-68,-68,-68,-67,-67,-67,-66,-66,-66,-65,-65,-65,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-61,-60,-60,-60,-59,-59,-59,-58,-58,-58,-57,-57,-57,-56,-56,-56,-55,-55,-55,-54,-54,-54,-53,-53,-53,-52,-52,-52,-51,-51,-51,-50,-50,-50,-49,-49,-49,-48,-48,-48,-47,-47,-47,-46,-46,-46,-45,-45,-45,-44,-44,-44,-43,-43,-43,-42,-42,-42,-41,-41,-41,-41,-40,-40,-40,-39,-39,-39,-38,-38,-38,-37,-37,-37,-36,-36,-36,-35,-35,-35,-34,-34,-34,-33,-33,-33,-32,-32,-32,-32,-31,-31,-31,-30,-30,-30,-29,-29,-29,-28,-28,-28,-27,-27,-27,-27,-26,-26,-26,-25,-25,-25,-24,-24,-24,-23,-23,-23,-23,-22,-22,-22,-21,-21,-21,-20,-20,-20,-20,-19,-19,-19,-18,-18,-18,-18,-17,-17,-17,-16,-16,-16,-16,-15,-15,-15,-14,-14,-14,-14,-13,-13,-13,-12,-12,-12,-12,-11,-11,-11,-11,-10,-10,-10,-9,-9,-9,-9,-8,-8,-8,-8,-7,-7,-7,-7,-6,-6,-6,-5,-5,-5,-5,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1,-1,-1,-0,-0,-0,-0,-0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,15,15,15,15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,19,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,26};
short coeff_3072_to_25[] = {21,21,21,20,20,20,20,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,11,11,11,11,11,11,11,10,10,10,10,10,10,10,9,9,9,9,9,9,8,8,8,8,8,8,8,7,7,7,7,7,7,6,6,6,6,6,6,5,5,5,5,5,4,4,4,4,4,4,3,3,3,3,3,3,2,2,2,2,2,1,1,1,1,1,0,0,0,0,0,-0,-0,-0,-0,-0,-0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-3,-3,-3,-3,-4,-4,-4,-4,-4,-5,-5,-5,-5,-5,-6,-6,-6,-6,-6,-7,-7,-7,-7,-8,-8,-8,-8,-8,-9,-9,-9,-9,-10,-10,-10,-10,-10,-11,-11,-11,-11,-12,-12,-12,-12,-13,-13,-13,-13,-13,-14,-14,-14,-14,-15,-15,-15,-15,-16,-16,-16,-16,-17,-17,-17,-17,-18,-18,-18,-18,-19,-19,-19,-19,-20,-20,-20,-20,-21,-21,-21,-21,-22,-22,-22,-22,-23,-23,-23,-23,-24,-24,-24,-24,-25,-25,-25,-25,-26,-26,-26,-26,-27,-27,-27,-27,-28,-28,-28,-28,-29,-29,-29,-29,-30,-30,-30,-30,-31,-31,-31,-32,-32,-32,-32,-33,-33,-33,-33,-34,-34,-34,-34,-35,-35,-35,-36,-36,-36,-36,-37,-37,-37,-37,-38,-38,-38,-38,-39,-39,-39,-40,-40,-40,-40,-41,-41,-41,-41,-42,-42,-42,-43,-43,-43,-43,-44,-44,-44,-44,-45,-45,-45,-46,-46,-46,-46,-47,-47,-47,-47,-48,-48,-48,-48,-49,-49,-49,-50,-50,-50,-50,-51,-51,-51,-51,-52,-52,-52,-53,-53,-53,-53,-54,-54,-54,-54,-55,-55,-55,-55,-56,-56,-56,-57,-57,-57,-57,-58,-58,-58,-58,-59,-59,-59,-59,-60,-60,-60,-61,-61,-61,-61,-62,-62,-62,-62,-63,-63,-63,-63,-64,-64,-64,-64,-65,-65,-65,-65,-66,-66,-66,-66,-67,-67,-67,-67,-68,-68,-68,-68,-69,-69,-69,-69,-70,-70,-70,-70,-71,-71,-71,-71,-72,-72,-72,-72,-73,-73,-73,-73,-74,-74,-74,-74,-75,-75,-75,-75,-76,-76,-76,-76,-76,-77,-77,-77,-77,-78,-78,-78,-78,-78,-79,-79,-79,-79,-80,-80,-80,-80,-80,-81,-81,-81,-81,-82,-82,-82,-82,-82,-83,-83,-83,-83,-83,-84,-84,-84,-84,-84,-85,-85,-85,-85,-85,-86,-86,-86,-86,-86,-87,-87,-87,-87,-87,-88,-88,-88,-88,-88,-88,-89,-89,-89,-89,-89,-89,-90,-90,-90,-90,-90,-90,-91,-91,-91,-91,-91,-91,-92,-92,-92,-92,-92,-92,-93,-93,-93,-93,-93,-93,-93,-94,-94,-94,-94,-94,-94,-94,-95,-95,-95,-95,-95,-95,-95,-95,-96,-96,-96,-96,-96,-96,-96,-96,-96,-97,-97,-97,-97,-97,-97,-97,-97,-97,-97,-98,-98,-98,-98,-98,-98,-98,-98,-98,-98,-98,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-98,-98,-98,-98,-98,-98,-98,-98,-98,-98,-97,-97,-97,-97,-97,-97,-97,-97,-97,-96,-96,-96,-96,-96,-96,-96,-95,-95,-95,-95,-95,-95,-95,-94,-94,-94,-94,-94,-94,-94,-93,-93,-93,-93,-93,-92,-92,-92,-92,-92,-92,-91,-91,-91,-91,-91,-90,-90,-90,-90,-90,-89,-89,-89,-89,-89,-88,-88,-88,-88,-87,-87,-87,-87,-86,-86,-86,-86,-85,-85,-85,-85,-84,-84,-84,-84,-83,-83,-83,-83,-82,-82,-82,-82,-81,-81,-81,-80,-80,-80,-79,-79,-79,-79,-78,-78,-78,-77,-77,-77,-76,-76,-76,-75,-75,-75,-74,-74,-74,-73,-73,-73,-72,-72,-72,-71,-71,-71,-70,-70,-70,-69,-69,-69,-68,-68,-67,-67,-67,-66,-66,-66,-65,-65,-64,-64,-64,-63,-63,-62,-62,-62,-61,-61,-60,-60,-60,-59,-59,-58,-58,-58,-57,-57,-56,-56,-55,-55,-54,-54,-54,-53,-53,-52,-52,-51,-51,-50,-50,-50,-49,-49,-48,-48,-47,-47,-46,-46,-45,-45,-44,-44,-43,-43,-42,-42,-41,-41,-40,-40,-39,-39,-38,-38,-37,-37,-36,-36,-35,-35,-34,-34,-33,-33,-32,-32,-31,-31,-30,-30,-29,-28,-28,-27,-27,-26,-26,-25,-25,-24,-23,-23,-22,-22,-21,-21,-20,-20,-19,-18,-18,-17,-17,-16,-15,-15,-14,-14,-13,-13,-12,-11,-11,-10,-10,-9,-8,-8,-7,-7,-6,-5,-5,-4,-3,-3,-2,-2,-1,-0,-0,0,1,1,2,2,3,4,4,5,6,6,7,8,8,9,9,10,11,11,12,13,13,14,15,15,16,17,17,18,19,19,20,21,21,22,23,23,24,25,25,26,27,27,28,29,29,30,31,32,32,33,34,34,35,36,36,37,38,39,39,40,41,41,42,43,43,44,45,46,46,47,48,48,49,50,51,51,52,53,53,54,55,56,56,57,58,58,59,60,61,61,62,63,64,64,65,66,67,67,68,69,69,70,71,72,72,73,74,75,75,76,77,78,78,79,80,80,81,82,83,83,84,85,86,86,87,88,89,89,90,91,92,92,93,94,95,95,96,97,98,98,99,100,101,101,102,103,104,104,105,106,107,107,108,109,110,110,111,112,113,113,114,115,116,116,117,118,118,119,120,121,121,122,123,124,124,125,126,127,127,128,129,130,130,131,132,133,133,134,135,135,136,137,138,138,139,140,141,141,142,143,143,144,145,146,146,147,148,149,149,150,151,151,152,153,154,154,155,156,156,157,158,159,159,160,161,161,162,163,163,164,165,166,166,167,168,168,169,170,170,171,172,172,173,174,174,175,176,176,177,178,178,179,180,180,181,182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,191,192,193,193,194,195,195,196,197,197,198,198,199,200,200,201,201,202,203,203,204,204,205,206,206,207,207,208,209,209,210,210,211,211,212,213,213,214,214,215,215,216,216,217,218,218,219,219,220,220,221,221,222,222,223,223,224,224,225,225,226,226,227,227,228,228,229,229,230,230,231,231,232,232,233,233,234,234,234,235,235,236,236,237,237,238,238,238,239,239,240,240,240,241,241,242,242,242,243,243,244,244,244,245,245,245,246,246,247,247,247,248,248,248,249,249,249,250,250,250,251,251,251,252,252,252,252,253,253,253,254,254,254,254,255,255,255,255,256,256,256,256,257,257,257,257,258,258,258,258,258,259,259,259,259,259,260,260,260,260,260,260,261,261,261,261,261,261,262,262,262,262,262,262,262,262,262,263,263,263,263,263,263,263,263,263,263,263,263,263,263,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,263,263,263,263,263,263,263,263,263,263,263,263,263,263,262,262,262,262,262,262,262,262,261,261,261,261,261,261,260,260,260,260,260,260,259,259,259,259,258,258,258,258,258,257,257,257,257,256,256,256,256,255,255,255,254,254,254,253,253,253,253,252,252,252,251,251,250,250,250,249,249,249,248,248,247,247,247,246,246,245,245,245,244,244,243,243,242,242,242,241,241,240,240,239,239,238,238,237,237,236,236,235,235,234,233,233,232,232,231,231,230,230,229,228,228,227,227,226,225,225,224,224,223,222,222,221,220,220,219,218,218,217,216,216,215,214,214,213,212,212,211,210,209,209,208,207,206,206,205,204,203,203,202,201,200,200,199,198,197,196,195,195,194,193,192,191,190,190,189,188,187,186,185,184,184,183,182,181,180,179,178,177,176,175,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,144,143,142,141,140,139,138,137,136,135,134,132,131,130,129,128,127,126,124,123,122,121,120,119,117,116,115,114,113,112,110,109,108,107,106,104,103,102,101,99,98,97,96,94,93,92,91,89,88,87,86,84,83,82,80,79,78,76,75,74,73,71,70,69,67,66,65,63,62,60,59,58,56,55,54,52,51,50,48,47,45,44,43,41,40,38,37,36,34,33,31,30,28,27,26,24,23,21,20,18,17,15,14,12,11,9,8,7,5,4,2,1,-0,-1,-3,-4,-6,-7,-9,-10,-12,-13,-15,-17,-18,-20,-21,-23,-24,-26,-27,-29,-30,-32,-33,-35,-37,-38,-40,-41,-43,-44,-46,-48,-49,-51,-52,-54,-55,-57,-59,-60,-62,-63,-65,-67,-68,-70,-71,-73,-75,-76,-78,-79,-81,-83,-84,-86,-88,-89,-91,-92,-94,-96,-97,-99,-101,-102,-104,-106,-107,-109,-111,-112,-114,-115,-117,-119,-120,-122,-124,-125,-127,-129,-130,-132,-134,-135,-137,-139,-140,-142,-144,-145,-147,-149,-150,-152,-154,-155,-157,-159,-160,-162,-164,-165,-167,-169,-170,-172,-174,-175,-177,-179,-181,-182,-184,-186,-187,-189,-191,-192,-194,-196,-197,-199,-201,-202,-204,-206,-207,-209,-211,-212,-214,-216,-217,-219,-221,-223,-224,-226,-228,-229,-231,-233,-234,-236,-238,-239,-241,-243,-244,-246,-248,-249,-251,-253,-254,-256,-258,-259,-261,-263,-264,-266,-268,-269,-271,-273,-274,-276,-277,-279,-281,-282,-284,-286,-287,-289,-291,-292,-294,-296,-297,-299,-300,-302,-304,-305,-307,-309,-310,-312,-313,-315,-317,-318,-320,-321,-323,-325,-326,-328,-329,-331,-332,-334,-336,-337,-339,-340,-342,-344,-345,-347,-348,-350,-351,-353,-354,-356,-357,-359,-361,-362,-364,-365,-367,-368,-370,-371,-373,-374,-376,-377,-379,-380,-382,-383,-385,-386,-388,-389,-391,-392,-393,-395,-396,-398,-399,-401,-402,-404,-405,-406,-408,-409,-411,-412,-414,-415,-416,-418,-419,-421,-422,-423,-425,-426,-427,-429,-430,-431,-433,-434,-436,-437,-438,-440,-441,-442,-443,-445,-446,-447,-449,-450,-451,-452,-454,-455,-456,-458,-459,-460,-461,-463,-464,-465,-466,-467,-469,-470,-471,-472,-473,-475,-476,-477,-478,-479,-480,-482,-483,-484,-485,-486,-487,-488,-489,-491,-492,-493,-494,-495,-496,-497,-498,-499,-500,-501,-502,-503,-504,-505,-506,-507,-508,-509,-510,-511,-512,-513,-514,-515,-516,-517,-518,-519,-520,-521,-522,-523,-523,-524,-525,-526,-527,-528,-529,-530,-530,-531,-532,-533,-534,-534,-535,-536,-537,-538,-538,-539,-540,-541,-541,-542,-543,-544,-544,-545,-546,-546,-547,-548,-548,-549,-550,-550,-551,-552,-552,-553,-553,-554,-555,-555,-556,-556,-557,-557,-558,-558,-559,-559,-560,-560,-561,-561,-562,-562,-563,-563,-564,-564,-565,-565,-565,-566,-566,-567,-567,-567,-568,-568,-568,-569,-569,-569,-570,-570,-570,-570,-571,-571,-571,-571,-572,-572,-572,-572,-573,-573,-573,-573,-573,-573,-574,-574,-574,-574,-574,-574,-574,-574,-574,-574,-575,-575,-575,-575,-575,-575,-575,-575,-575,-575,-575,-575,-574,-574,-574,-574,-574,-574,-574,-574,-574,-574,-573,-573,-573,-573,-573,-573,-572,-572,-572,-572,-571,-571,-571,-571,-570,-570,-570,-569,-569,-569,-568,-568,-568,-567,-567,-567,-566,-566,-565,-565,-564,-564,-564,-563,-563,-562,-562,-561,-561,-560,-559,-559,-558,-558,-557,-557,-556,-555,-555,-554,-554,-553,-552,-552,-551,-550,-549,-549,-548,-547,-547,-546,-545,-544,-544,-543,-542,-541,-540,-539,-539,-538,-537,-536,-535,-534,-533,-532,-532,-531,-530,-529,-528,-527,-526,-525,-524,-523,-522,-521,-520,-519,-518,-516,-515,-514,-513,-512,-511,-510,-509,-508,-506,-505,-504,-503,-502,-500,-499,-498,-497,-495,-494,-493,-492,-490,-489,-488,-486,-485,-484,-482,-481,-479,-478,-477,-475,-474,-472,-471,-470,-468,-467,-465,-464,-462,-461,-459,-458,-456,-454,-453,-451,-450,-448,-447,-445,-443,-442,-440,-438,-437,-435,-433,-432,-430,-428,-427,-425,-423,-421,-420,-418,-416,-414,-412,-411,-409,-407,-405,-403,-401,-400,-398,-396,-394,-392,-390,-388,-386,-384,-382,-380,-378,-376,-374,-372,-370,-368,-366,-364,-362,-360,-358,-356,-354,-352,-350,-348,-346,-343,-341,-339,-337,-335,-333,-330,-328,-326,-324,-322,-319,-317,-315,-313,-310,-308,-306,-303,-301,-299,-296,-294,-292,-289,-287,-285,-282,-280,-278,-275,-273,-270,-268,-265,-263,-261,-258,-256,-253,-251,-248,-246,-243,-241,-238,-236,-233,-231,-228,-225,-223,-220,-218,-215,-212,-210,-207,-205,-202,-199,-197,-194,-191,-189,-186,-183,-180,-178,-175,-172,-170,-167,-164,-161,-159,-156,-153,-150,-147,-145,-142,-139,-136,-133,-131,-128,-125,-122,-119,-116,-113,-111,-108,-105,-102,-99,-96,-93,-90,-87,-84,-81,-78,-75,-72,-69,-67,-64,-61,-58,-55,-52,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,25,28,31,34,37,40,44,47,50,53,56,60,63,66,69,72,76,79,82,85,89,92,95,98,102,105,108,111,115,118,121,125,128,131,135,138,141,144,148,151,154,158,161,164,168,171,174,178,181,184,188,191,194,198,201,205,208,211,215,218,221,225,228,232,235,238,242,245,248,252,255,259,262,265,269,272,276,279,282,286,289,293,296,300,303,306,310,313,317,320,323,327,330,334,337,341,344,347,351,354,358,361,365,368,371,375,378,382,385,389,392,395,399,402,406,409,413,416,419,423,426,430,433,436,440,443,447,450,454,457,460,464,467,471,474,477,481,484,488,491,494,498,501,504,508,511,515,518,521,525,528,531,535,538,542,545,548,552,555,558,562,565,568,572,575,578,582,585,588,592,595,598,601,605,608,611,615,618,621,624,628,631,634,637,641,644,647,650,654,657,660,663,666,670,673,676,679,682,686,689,692,695,698,701,704,708,711,714,717,720,723,726,729,733,736,739,742,745,748,751,754,757,760,763,766,769,772,775,778,781,784,787,790,793,796,799,802,805,807,810,813,816,819,822,825,828,830,833,836,839,842,845,847,850,853,856,858,861,864,867,869,872,875,878,880,883,886,888,891,893,896,899,901,904,907,909,912,914,917,919,922,924,927,929,932,934,937,939,942,944,947,949,951,954,956,959,961,963,966,968,970,973,975,977,979,982,984,986,988,991,993,995,997,999,1001,1003,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1045,1047,1049,1051,1053,1055,1056,1058,1060,1062,1063,1065,1067,1068,1070,1072,1073,1075,1077,1078,1080,1081,1083,1085,1086,1088,1089,1091,1092,1093,1095,1096,1098,1099,1101,1102,1103,1105,1106,1107,1109,1110,1111,1112,1114,1115,1116,1117,1118,1119,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1137,1138,1139,1140,1141,1141,1142,1143,1144,1144,1145,1146,1146,1147,1148,1148,1149,1149,1150,1151,1151,1152,1152,1153,1153,1153,1154,1154,1155,1155,1155,1156,1156,1156,1157,1157,1157,1157,1157,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1157,1157,1157,1157,1156,1156,1156,1155,1155,1155,1154,1154,1153,1153,1153,1152,1152,1151,1150,1150,1149,1149,1148,1147,1147,1146,1145,1145,1144,1143,1142,1142,1141,1140,1139,1138,1137,1137,1136,1135,1134,1133,1132,1131,1130,1129,1127,1126,1125,1124,1123,1122,1121,1119,1118,1117,1115,1114,1113,1112,1110,1109,1107,1106,1104,1103,1102,1100,1099,1097,1095,1094,1092,1091,1089,1087,1086,1084,1082,1080,1079,1077,1075,1073,1071,1070,1068,1066,1064,1062,1060,1058,1056,1054,1052,1050,1048,1046,1043,1041,1039,1037,1035,1032,1030,1028,1026,1023,1021,1019,1016,1014,1011,1009,1007,1004,1002,999,997,994,991,989,986,984,981,978,976,973,970,967,965,962,959,956,953,950,948,945,942,939,936,933,930,927,924,921,917,914,911,908,905,902,898,895,892,889,885,882,879,875,872,869,865,862,858,855,851,848,844,841,837,834,830,826,823,819,815,812,808,804,800,797,793,789,785,781,777,773,770,766,762,758,754,750,746,742,738,733,729,725,721,717,713,708,704,700,696,691,687,683,679,674,670,665,661,657,652,648,643,639,634,630,625,621,616,611,607,602,597,593,588,583,579,574,569,564,560,555,550,545,540,535,530,525,521,516,511,506,501,496,491,485,480,475,470,465,460,455,450,444,439,434,429,424,418,413,408,402,397,392,386,381,376,370,365,359,354,348,343,337,332,326,321,315,310,304,298,293,287,282,276,270,264,259,253,247,242,236,230,224,218,213,207,201,195,189,183,177,171,166,160,154,148,142,136,130,124,118,112,105,99,93,87,81,75,69,63,57,50,44,38,32,26,19,13,7,1,-5,-11,-17,-24,-30,-36,-43,-49,-55,-62,-68,-74,-81,-87,-94,-100,-107,-113,-120,-126,-132,-139,-145,-152,-159,-165,-172,-178,-185,-191,-198,-204,-211,-218,-224,-231,-238,-244,-251,-257,-264,-271,-278,-284,-291,-298,-304,-311,-318,-325,-331,-338,-345,-352,-358,-365,-372,-379,-385,-392,-399,-406,-413,-420,-426,-433,-440,-447,-454,-461,-467,-474,-481,-488,-495,-502,-509,-516,-523,-529,-536,-543,-550,-557,-564,-571,-578,-585,-592,-599,-606,-613,-620,-627,-634,-641,-648,-655,-661,-668,-675,-682,-689,-696,-703,-710,-717,-724,-731,-738,-745,-752,-759,-766,-773,-780,-787,-794,-801,-808,-815,-822,-829,-836,-843,-850,-857,-864,-871,-878,-885,-893,-900,-907,-914,-921,-928,-935,-941,-948,-955,-962,-969,-976,-983,-990,-997,-1004,-1011,-1018,-1025,-1032,-1039,-1046,-1053,-1060,-1067,-1074,-1081,-1088,-1095,-1102,-1109,-1116,-1122,-1129,-1136,-1143,-1150,-1157,-1164,-1171,-1178,-1184,-1191,-1198,-1205,-1212,-1219,-1226,-1232,-1239,-1246,-1253,-1260,-1266,-1273,-1280,-1287,-1293,-1300,-1307,-1314,-1320,-1327,-1334,-1341,-1347,-1354,-1361,-1367,-1374,-1381,-1387,-1394,-1401,-1407,-1414,-1420,-1427,-1434,-1440,-1447,-1453,-1460,-1466,-1473,-1479,-1486,-1492,-1499,-1505,-1512,-1518,-1525,-1531,-1537,-1544,-1550,-1557,-1563,-1569,-1576,-1582,-1588,-1595,-1601,-1607,-1613,-1620,-1626,-1632,-1638,-1644,-1651,-1657,-1663,-1669,-1675,-1681,-1687,-1693,-1699,-1706,-1712,-1718,-1724,-1730,-1736,-1741,-1747,-1753,-1759,-1765,-1771,-1777,-1783,-1788,-1794,-1800,-1806,-1812,-1817,-1823,-1829,-1834,-1840,-1846,-1851,-1857,-1863,-1868,-1874,-1879,-1885,-1890,-1896,-1901,-1907,-1912,-1918,-1923,-1928,-1934,-1939,-1944,-1950,-1955,-1960,-1965,-1970,-1976,-1981,-1986,-1991,-1996,-2001,-2006,-2011,-2016,-2021,-2026,-2031,-2036,-2041,-2046,-2051,-2056,-2060,-2065,-2070,-2075,-2080,-2084,-2089,-2094,-2098,-2103,-2107,-2112,-2116,-2121,-2125,-2130,-2134,-2139,-2143,-2147,-2152,-2156,-2160,-2165,-2169,-2173,-2177,-2181,-2186,-2190,-2194,-2198,-2202,-2206,-2210,-2214,-2218,-2222,-2225,-2229,-2233,-2237,-2241,-2244,-2248,-2252,-2255,-2259,-2263,-2266,-2270,-2273,-2277,-2280,-2283,-2287,-2290,-2294,-2297,-2300,-2303,-2307,-2310,-2313,-2316,-2319,-2322,-2325,-2328,-2331,-2334,-2337,-2340,-2343,-2346,-2348,-2351,-2354,-2357,-2359,-2362,-2364,-2367,-2369,-2372,-2374,-2377,-2379,-2382,-2384,-2386,-2389,-2391,-2393,-2395,-2397,-2399,-2402,-2404,-2406,-2408,-2409,-2411,-2413,-2415,-2417,-2419,-2420,-2422,-2424,-2425,-2427,-2429,-2430,-2432,-2433,-2434,-2436,-2437,-2438,-2440,-2441,-2442,-2443,-2445,-2446,-2447,-2448,-2449,-2450,-2451,-2451,-2452,-2453,-2454,-2455,-2455,-2456,-2457,-2457,-2458,-2458,-2459,-2459,-2460,-2460,-2460,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2460,-2460,-2460,-2459,-2459,-2459,-2458,-2458,-2457,-2456,-2456,-2455,-2454,-2454,-2453,-2452,-2451,-2450,-2449,-2448,-2447,-2446,-2445,-2444,-2442,-2441,-2440,-2438,-2437,-2436,-2434,-2433,-2431,-2429,-2428,-2426,-2424,-2423,-2421,-2419,-2417,-2415,-2413,-2411,-2409,-2407,-2405,-2403,-2401,-2398,-2396,-2394,-2391,-2389,-2386,-2384,-2381,-2379,-2376,-2373,-2370,-2368,-2365,-2362,-2359,-2356,-2353,-2350,-2347,-2344,-2341,-2337,-2334,-2331,-2328,-2324,-2321,-2317,-2314,-2310,-2306,-2303,-2299,-2295,-2292,-2288,-2284,-2280,-2276,-2272,-2268,-2264,-2260,-2255,-2251,-2247,-2242,-2238,-2234,-2229,-2225,-2220,-2215,-2211,-2206,-2201,-2197,-2192,-2187,-2182,-2177,-2172,-2167,-2162,-2157,-2151,-2146,-2141,-2135,-2130,-2125,-2119,-2114,-2108,-2102,-2097,-2091,-2085,-2080,-2074,-2068,-2062,-2056,-2050,-2044,-2038,-2031,-2025,-2019,-2013,-2006,-2000,-1993,-1987,-1980,-1974,-1967,-1961,-1954,-1947,-1940,-1933,-1926,-1919,-1912,-1905,-1898,-1891,-1884,-1877,-1869,-1862,-1855,-1847,-1840,-1832,-1825,-1817,-1809,-1802,-1794,-1786,-1778,-1770,-1762,-1754,-1746,-1738,-1730,-1722,-1714,-1705,-1697,-1689,-1680,-1672,-1663,-1655,-1646,-1638,-1629,-1620,-1611,-1602,-1594,-1585,-1576,-1567,-1558,-1548,-1539,-1530,-1521,-1511,-1502,-1493,-1483,-1474,-1464,-1455,-1445,-1435,-1426,-1416,-1406,-1396,-1386,-1376,-1366,-1356,-1346,-1336,-1326,-1316,-1305,-1295,-1285,-1274,-1264,-1253,-1243,-1232,-1221,-1211,-1200,-1189,-1178,-1167,-1156,-1145,-1134,-1123,-1112,-1101,-1090,-1079,-1067,-1056,-1045,-1033,-1022,-1010,-999,-987,-975,-964,-952,-940,-928,-916,-904,-892,-880,-868,-856,-844,-832,-820,-807,-795,-783,-770,-758,-745,-733,-720,-707,-695,-682,-669,-656,-643,-630,-618,-605,-591,-578,-565,-552,-539,-526,-512,-499,-486,-472,-459,-445,-431,-418,-404,-391,-377,-363,-349,-335,-321,-307,-293,-279,-265,-251,-237,-223,-209,-194,-180,-166,-151,-137,-122,-108,-93,-78,-64,-49,-34,-19,-5,9,24,39,54,69,84,99,115,130,145,160,176,191,206,222,237,253,268,284,300,315,331,347,363,378,394,410,426,442,458,474,490,506,523,539,555,571,588,604,620,637,653,670,686,703,720,736,753,770,787,803,820,837,854,871,888,905,922,939,956,973,991,1008,1025,1043,1060,1077,1095,1112,1130,1147,1165,1182,1200,1217,1235,1253,1271,1288,1306,1324,1342,1360,1378,1396,1414,1432,1450,1468,1486,1504,1523,1541,1559,1577,1596,1614,1632,1651,1669,1688,1706,1725,1743,1762,1781,1799,1818,1837,1856,1874,1893,1912,1931,1950,1969,1988,2007,2026,2045,2064,2083,2102,2121,2140,2159,2179,2198,2217,2237,2256,2275,2295,2314,2334,2353,2372,2392,2412,2431,2451,2470,2490,2510,2529,2549,2569,2589,2608,2628,2648,2668,2688,2708,2728,2748,2768,2788,2808,2828,2848,2868,2888,2908,2928,2948,2968,2989,3009,3029,3049,3070,3090,3110,3131,3151,3172,3192,3212,3233,3253,3274,3294,3315,3335,3356,3377,3397,3418,3438,3459,3480,3500,3521,3542,3563,3583,3604,3625,3646,3666,3687,3708,3729,3750,3771,3792,3813,3834,3854,3875,3896,3917,3938,3959,3980,4001,4023,4044,4065,4086,4107,4128,4149,4170,4191,4213,4234,4255,4276,4297,4319,4340,4361,4382,4404,4425,4446,4467,4489,4510,4531,4553,4574,4595,4617,4638,4659,4681,4702,4723,4745,4766,4788,4809,4831,4852,4873,4895,4916,4938,4959,4981,5002,5023,5045,5066,5088,5109,5131,5152,5174,5195,5217,5238,5260,5281,5303,5324,5346,5367,5389,5410,5432,5453,5475,5496,5518,5540,5561,5583,5604,5626,5647,5669,5690,5712,5733,5755,5776,5798,5819,5841,5862,5884,5905,5927,5948,5970,5991,6013,6034,6055,6077,6098,6120,6141,6163,6184,6206,6227,6248,6270,6291,6313,6334,6355,6377,6398,6420,6441,6462,6484,6505,6526,6548,6569,6590,6612,6633,6654,6675,6697,6718,6739,6760,6781,6803,6824,6845,6866,6887,6908,6930,6951,6972,6993,7014,7035,7056,7077,7098,7119,7140,7161,7182,7203,7224,7245,7266,7287,7308,7329,7349,7370,7391,7412,7433,7453,7474,7495,7516,7536,7557,7578,7598,7619,7640,7660,7681,7701,7722,7742,7763,7783,7804,7824,7845,7865,7885,7906,7926,7946,7967,7987,8007,8027,8048,8068,8088,8108,8128,8148,8168,8188,8209,8229,8248,8268,8288,8308,8328,8348,8368,8388,8407,8427,8447,8467,8486,8506,8526,8545,8565,8584,8604,8623,8643,8662,8682,8701,8720,8740,8759,8778,8797,8817,8836,8855,8874,8893,8912,8931,8950,8969,8988,9007,9026,9045,9063,9082,9101,9120,9138,9157,9176,9194,9213,9231,9250,9268,9287,9305,9323,9342,9360,9378,9396,9415,9433,9451,9469,9487,9505,9523,9541,9559,9577,9595,9612,9630,9648,9665,9683,9701,9718,9736,9753,9771,9788,9805,9823,9840,9857,9875,9892,9909,9926,9943,9960,9977,9994,10011,10028,10045,10061,10078,10095,10111,10128,10145,10161,10178,10194,10211,10227,10243,10260,10276,10292,10308,10324,10340,10356,10372,10388,10404,10420,10436,10451,10467,10483,10498,10514,10530,10545,10560,10576,10591,10607,10622,10637,10652,10667,10682,10697,10712,10727,10742,10757,10772,10786,10801,10816,10830,10845,10859,10874,10888,10903,10917,10931,10945,10960,10974,10988,11002,11016,11030,11043,11057,11071,11085,11098,11112,11126,11139,11152,11166,11179,11193,11206,11219,11232,11245,11258,11271,11284,11297,11310,11323,11335,11348,11361,11373,11386,11398,11411,11423,11435,11447,11460,11472,11484,11496,11508,11520,11532,11543,11555,11567,11578,11590,11601,11613,11624,11636,11647,11658,11669,11681,11692,11703,11714,11725,11735,11746,11757,11768,11778,11789,11799,11810,11820,11830,11841,11851,11861,11871,11881,11891,11901,11911,11921,11931,11940,11950,11959,11969,11978,11988,11997,12006,12016,12025,12034,12043,12052,12061,12070,12079,12087,12096,12105,12113,12122,12130,12138,12147,12155,12163,12171,12179,12187,12195,12203,12211,12219,12226,12234,12242,12249,12257,12264,12271,12279,12286,12293,12300,12307,12314,12321,12328,12334,12341,12348,12354,12361,12367,12374,12380,12386,12393,12399,12405,12411,12417,12423,12428,12434,12440,12445,12451,12457,12462,12467,12473,12478,12483,12488,12493,12498,12503,12508,12513,12518,12522,12527,12531,12536,12540,12545,12549,12553,12557,12561,12565,12569,12573,12577,12581,12584,12588,12592,12595,12598,12602,12605,12608,12611,12615,12618,12621,12624,12626,12629,12632,12634,12637,12640,12642,12644,12647,12649,12651,12653,12655,12657,12659,12661,12663,12665,12666,12668,12669,12671,12672,12673,12675,12676,12677,12678,12679,12680,12681,12682,12682,12683,12684,12684,12685,12685,12685,12686,12686,12686,12686,12686,12686,12686,12686,12685,12685,12685,12684,12684,12683,12682,12682,12681,12680,12679,12678,12677,12676,12675,12673,12672,12671,12669,12668,12666,12665,12663,12661,12659,12657,12655,12653,12651,12649,12647,12644,12642,12640,12637,12634,12632,12629,12626,12624,12621,12618,12615,12611,12608,12605,12602,12598,12595,12592,12588,12584,12581,12577,12573,12569,12565,12561,12557,12553,12549,12545,12540,12536,12531,12527,12522,12518,12513,12508,12503,12498,12493,12488,12483,12478,12473,12467,12462,12457,12451,12445,12440,12434,12428,12423,12417,12411,12405,12399,12393,12386,12380,12374,12367,12361,12354,12348,12341,12334,12328,12321,12314,12307,12300,12293,12286,12279,12271,12264,12257,12249,12242,12234,12226,12219,12211,12203,12195,12187,12179,12171,12163,12155,12147,12138,12130,12122,12113,12105,12096,12087,12079,12070,12061,12052,12043,12034,12025,12016,12006,11997,11988,11978,11969,11959,11950,11940,11931,11921,11911,11901,11891,11881,11871,11861,11851,11841,11830,11820,11810,11799,11789,11778,11768,11757,11746,11735,11725,11714,11703,11692,11681,11669,11658,11647,11636,11624,11613,11601,11590,11578,11567,11555,11543,11532,11520,11508,11496,11484,11472,11460,11447,11435,11423,11411,11398,11386,11373,11361,11348,11335,11323,11310,11297,11284,11271,11258,11245,11232,11219,11206,11193,11179,11166,11152,11139,11126,11112,11098,11085,11071,11057,11043,11030,11016,11002,10988,10974,10960,10945,10931,10917,10903,10888,10874,10859,10845,10830,10816,10801,10786,10772,10757,10742,10727,10712,10697,10682,10667,10652,10637,10622,10607,10591,10576,10560,10545,10530,10514,10498,10483,10467,10451,10436,10420,10404,10388,10372,10356,10340,10324,10308,10292,10276,10260,10243,10227,10211,10194,10178,10161,10145,10128,10111,10095,10078,10061,10045,10028,10011,9994,9977,9960,9943,9926,9909,9892,9875,9857,9840,9823,9805,9788,9771,9753,9736,9718,9701,9683,9665,9648,9630,9612,9595,9577,9559,9541,9523,9505,9487,9469,9451,9433,9415,9396,9378,9360,9342,9323,9305,9287,9268,9250,9231,9213,9194,9176,9157,9138,9120,9101,9082,9063,9045,9026,9007,8988,8969,8950,8931,8912,8893,8874,8855,8836,8817,8797,8778,8759,8740,8720,8701,8682,8662,8643,8623,8604,8584,8565,8545,8526,8506,8486,8467,8447,8427,8407,8388,8368,8348,8328,8308,8288,8268,8248,8229,8209,8188,8168,8148,8128,8108,8088,8068,8048,8027,8007,7987,7967,7946,7926,7906,7885,7865,7845,7824,7804,7783,7763,7742,7722,7701,7681,7660,7640,7619,7598,7578,7557,7536,7516,7495,7474,7453,7433,7412,7391,7370,7349,7329,7308,7287,7266,7245,7224,7203,7182,7161,7140,7119,7098,7077,7056,7035,7014,6993,6972,6951,6930,6908,6887,6866,6845,6824,6803,6781,6760,6739,6718,6697,6675,6654,6633,6612,6590,6569,6548,6526,6505,6484,6462,6441,6420,6398,6377,6355,6334,6313,6291,6270,6248,6227,6206,6184,6163,6141,6120,6098,6077,6055,6034,6013,5991,5970,5948,5927,5905,5884,5862,5841,5819,5798,5776,5755,5733,5712,5690,5669,5647,5626,5604,5583,5561,5540,5518,5496,5475,5453,5432,5410,5389,5367,5346,5324,5303,5281,5260,5238,5217,5195,5174,5152,5131,5109,5088,5066,5045,5023,5002,4981,4959,4938,4916,4895,4873,4852,4831,4809,4788,4766,4745,4723,4702,4681,4659,4638,4617,4595,4574,4553,4531,4510,4489,4467,4446,4425,4404,4382,4361,4340,4319,4297,4276,4255,4234,4213,4191,4170,4149,4128,4107,4086,4065,4044,4023,4001,3980,3959,3938,3917,3896,3875,3854,3834,3813,3792,3771,3750,3729,3708,3687,3666,3646,3625,3604,3583,3563,3542,3521,3500,3480,3459,3438,3418,3397,3377,3356,3335,3315,3294,3274,3253,3233,3212,3192,3172,3151,3131,3110,3090,3070,3049,3029,3009,2989,2968,2948,2928,2908,2888,2868,2848,2828,2808,2788,2768,2748,2728,2708,2688,2668,2648,2628,2608,2589,2569,2549,2529,2510,2490,2470,2451,2431,2412,2392,2372,2353,2334,2314,2295,2275,2256,2237,2217,2198,2179,2159,2140,2121,2102,2083,2064,2045,2026,2007,1988,1969,1950,1931,1912,1893,1874,1856,1837,1818,1799,1781,1762,1743,1725,1706,1688,1669,1651,1632,1614,1596,1577,1559,1541,1523,1504,1486,1468,1450,1432,1414,1396,1378,1360,1342,1324,1306,1288,1271,1253,1235,1217,1200,1182,1165,1147,1130,1112,1095,1077,1060,1043,1025,1008,991,973,956,939,922,905,888,871,854,837,820,803,787,770,753,736,720,703,686,670,653,637,620,604,588,571,555,539,523,506,490,474,458,442,426,410,394,378,363,347,331,315,300,284,268,253,237,222,206,191,176,160,145,130,115,99,84,69,54,39,24,9,-5,-19,-34,-49,-64,-78,-93,-108,-122,-137,-151,-166,-180,-194,-209,-223,-237,-251,-265,-279,-293,-307,-321,-335,-349,-363,-377,-391,-404,-418,-431,-445,-459,-472,-486,-499,-512,-526,-539,-552,-565,-578,-591,-605,-618,-630,-643,-656,-669,-682,-695,-707,-720,-733,-745,-758,-770,-783,-795,-807,-820,-832,-844,-856,-868,-880,-892,-904,-916,-928,-940,-952,-964,-975,-987,-999,-1010,-1022,-1033,-1045,-1056,-1067,-1079,-1090,-1101,-1112,-1123,-1134,-1145,-1156,-1167,-1178,-1189,-1200,-1211,-1221,-1232,-1243,-1253,-1264,-1274,-1285,-1295,-1305,-1316,-1326,-1336,-1346,-1356,-1366,-1376,-1386,-1396,-1406,-1416,-1426,-1435,-1445,-1455,-1464,-1474,-1483,-1493,-1502,-1511,-1521,-1530,-1539,-1548,-1558,-1567,-1576,-1585,-1594,-1602,-1611,-1620,-1629,-1638,-1646,-1655,-1663,-1672,-1680,-1689,-1697,-1705,-1714,-1722,-1730,-1738,-1746,-1754,-1762,-1770,-1778,-1786,-1794,-1802,-1809,-1817,-1825,-1832,-1840,-1847,-1855,-1862,-1869,-1877,-1884,-1891,-1898,-1905,-1912,-1919,-1926,-1933,-1940,-1947,-1954,-1961,-1967,-1974,-1980,-1987,-1993,-2000,-2006,-2013,-2019,-2025,-2031,-2038,-2044,-2050,-2056,-2062,-2068,-2074,-2080,-2085,-2091,-2097,-2102,-2108,-2114,-2119,-2125,-2130,-2135,-2141,-2146,-2151,-2157,-2162,-2167,-2172,-2177,-2182,-2187,-2192,-2197,-2201,-2206,-2211,-2215,-2220,-2225,-2229,-2234,-2238,-2242,-2247,-2251,-2255,-2260,-2264,-2268,-2272,-2276,-2280,-2284,-2288,-2292,-2295,-2299,-2303,-2306,-2310,-2314,-2317,-2321,-2324,-2328,-2331,-2334,-2337,-2341,-2344,-2347,-2350,-2353,-2356,-2359,-2362,-2365,-2368,-2370,-2373,-2376,-2379,-2381,-2384,-2386,-2389,-2391,-2394,-2396,-2398,-2401,-2403,-2405,-2407,-2409,-2411,-2413,-2415,-2417,-2419,-2421,-2423,-2424,-2426,-2428,-2429,-2431,-2433,-2434,-2436,-2437,-2438,-2440,-2441,-2442,-2444,-2445,-2446,-2447,-2448,-2449,-2450,-2451,-2452,-2453,-2454,-2454,-2455,-2456,-2456,-2457,-2458,-2458,-2459,-2459,-2459,-2460,-2460,-2460,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2461,-2460,-2460,-2460,-2459,-2459,-2458,-2458,-2457,-2457,-2456,-2455,-2455,-2454,-2453,-2452,-2451,-2451,-2450,-2449,-2448,-2447,-2446,-2445,-2443,-2442,-2441,-2440,-2438,-2437,-2436,-2434,-2433,-2432,-2430,-2429,-2427,-2425,-2424,-2422,-2420,-2419,-2417,-2415,-2413,-2411,-2409,-2408,-2406,-2404,-2402,-2399,-2397,-2395,-2393,-2391,-2389,-2386,-2384,-2382,-2379,-2377,-2374,-2372,-2369,-2367,-2364,-2362,-2359,-2357,-2354,-2351,-2348,-2346,-2343,-2340,-2337,-2334,-2331,-2328,-2325,-2322,-2319,-2316,-2313,-2310,-2307,-2303,-2300,-2297,-2294,-2290,-2287,-2283,-2280,-2277,-2273,-2270,-2266,-2263,-2259,-2255,-2252,-2248,-2244,-2241,-2237,-2233,-2229,-2225,-2222,-2218,-2214,-2210,-2206,-2202,-2198,-2194,-2190,-2186,-2181,-2177,-2173,-2169,-2165,-2160,-2156,-2152,-2147,-2143,-2139,-2134,-2130,-2125,-2121,-2116,-2112,-2107,-2103,-2098,-2094,-2089,-2084,-2080,-2075,-2070,-2065,-2060,-2056,-2051,-2046,-2041,-2036,-2031,-2026,-2021,-2016,-2011,-2006,-2001,-1996,-1991,-1986,-1981,-1976,-1970,-1965,-1960,-1955,-1950,-1944,-1939,-1934,-1928,-1923,-1918,-1912,-1907,-1901,-1896,-1890,-1885,-1879,-1874,-1868,-1863,-1857,-1851,-1846,-1840,-1834,-1829,-1823,-1817,-1812,-1806,-1800,-1794,-1788,-1783,-1777,-1771,-1765,-1759,-1753,-1747,-1741,-1736,-1730,-1724,-1718,-1712,-1706,-1699,-1693,-1687,-1681,-1675,-1669,-1663,-1657,-1651,-1644,-1638,-1632,-1626,-1620,-1613,-1607,-1601,-1595,-1588,-1582,-1576,-1569,-1563,-1557,-1550,-1544,-1537,-1531,-1525,-1518,-1512,-1505,-1499,-1492,-1486,-1479,-1473,-1466,-1460,-1453,-1447,-1440,-1434,-1427,-1420,-1414,-1407,-1401,-1394,-1387,-1381,-1374,-1367,-1361,-1354,-1347,-1341,-1334,-1327,-1320,-1314,-1307,-1300,-1293,-1287,-1280,-1273,-1266,-1260,-1253,-1246,-1239,-1232,-1226,-1219,-1212,-1205,-1198,-1191,-1184,-1178,-1171,-1164,-1157,-1150,-1143,-1136,-1129,-1122,-1116,-1109,-1102,-1095,-1088,-1081,-1074,-1067,-1060,-1053,-1046,-1039,-1032,-1025,-1018,-1011,-1004,-997,-990,-983,-976,-969,-962,-955,-948,-941,-935,-928,-921,-914,-907,-900,-893,-885,-878,-871,-864,-857,-850,-843,-836,-829,-822,-815,-808,-801,-794,-787,-780,-773,-766,-759,-752,-745,-738,-731,-724,-717,-710,-703,-696,-689,-682,-675,-668,-661,-655,-648,-641,-634,-627,-620,-613,-606,-599,-592,-585,-578,-571,-564,-557,-550,-543,-536,-529,-523,-516,-509,-502,-495,-488,-481,-474,-467,-461,-454,-447,-440,-433,-426,-420,-413,-406,-399,-392,-385,-379,-372,-365,-358,-352,-345,-338,-331,-325,-318,-311,-304,-298,-291,-284,-278,-271,-264,-257,-251,-244,-238,-231,-224,-218,-211,-204,-198,-191,-185,-178,-172,-165,-159,-152,-145,-139,-132,-126,-120,-113,-107,-100,-94,-87,-81,-74,-68,-62,-55,-49,-43,-36,-30,-24,-17,-11,-5,1,7,13,19,26,32,38,44,50,57,63,69,75,81,87,93,99,105,112,118,124,130,136,142,148,154,160,166,171,177,183,189,195,201,207,213,218,224,230,236,242,247,253,259,264,270,276,282,287,293,298,304,310,315,321,326,332,337,343,348,354,359,365,370,376,381,386,392,397,402,408,413,418,424,429,434,439,444,450,455,460,465,470,475,480,485,491,496,501,506,511,516,521,525,530,535,540,545,550,555,560,564,569,574,579,583,588,593,597,602,607,611,616,621,625,630,634,639,643,648,652,657,661,665,670,674,679,683,687,691,696,700,704,708,713,717,721,725,729,733,738,742,746,750,754,758,762,766,770,773,777,781,785,789,793,797,800,804,808,812,815,819,823,826,830,834,837,841,844,848,851,855,858,862,865,869,872,875,879,882,885,889,892,895,898,902,905,908,911,914,917,921,924,927,930,933,936,939,942,945,948,950,953,956,959,962,965,967,970,973,976,978,981,984,986,989,991,994,997,999,1002,1004,1007,1009,1011,1014,1016,1019,1021,1023,1026,1028,1030,1032,1035,1037,1039,1041,1043,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1071,1073,1075,1077,1079,1080,1082,1084,1086,1087,1089,1091,1092,1094,1095,1097,1099,1100,1102,1103,1104,1106,1107,1109,1110,1112,1113,1114,1115,1117,1118,1119,1121,1122,1123,1124,1125,1126,1127,1129,1130,1131,1132,1133,1134,1135,1136,1137,1137,1138,1139,1140,1141,1142,1142,1143,1144,1145,1145,1146,1147,1147,1148,1149,1149,1150,1150,1151,1152,1152,1153,1153,1153,1154,1154,1155,1155,1155,1156,1156,1156,1157,1157,1157,1157,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1158,1157,1157,1157,1157,1157,1156,1156,1156,1155,1155,1155,1154,1154,1153,1153,1153,1152,1152,1151,1151,1150,1149,1149,1148,1148,1147,1146,1146,1145,1144,1144,1143,1142,1141,1141,1140,1139,1138,1137,1137,1136,1135,1134,1133,1132,1131,1130,1129,1128,1127,1126,1125,1124,1123,1122,1121,1119,1118,1117,1116,1115,1114,1112,1111,1110,1109,1107,1106,1105,1103,1102,1101,1099,1098,1096,1095,1093,1092,1091,1089,1088,1086,1085,1083,1081,1080,1078,1077,1075,1073,1072,1070,1068,1067,1065,1063,1062,1060,1058,1056,1055,1053,1051,1049,1047,1045,1044,1042,1040,1038,1036,1034,1032,1030,1028,1026,1024,1022,1020,1018,1016,1014,1012,1010,1008,1006,1003,1001,999,997,995,993,991,988,986,984,982,979,977,975,973,970,968,966,963,961,959,956,954,951,949,947,944,942,939,937,934,932,929,927,924,922,919,917,914,912,909,907,904,901,899,896,893,891,888,886,883,880,878,875,872,869,867,864,861,858,856,853,850,847,845,842,839,836,833,830,828,825,822,819,816,813,810,807,805,802,799,796,793,790,787,784,781,778,775,772,769,766,763,760,757,754,751,748,745,742,739,736,733,729,726,723,720,717,714,711,708,704,701,698,695,692,689,686,682,679,676,673,670,666,663,660,657,654,650,647,644,641,637,634,631,628,624,621,618,615,611,608,605,601,598,595,592,588,585,582,578,575,572,568,565,562,558,555,552,548,545,542,538,535,531,528,525,521,518,515,511,508,504,501,498,494,491,488,484,481,477,474,471,467,464,460,457,454,450,447,443,440,436,433,430,426,423,419,416,413,409,406,402,399,395,392,389,385,382,378,375,371,368,365,361,358,354,351,347,344,341,337,334,330,327,323,320,317,313,310,306,303,300,296,293,289,286,282,279,276,272,269,265,262,259,255,252,248,245,242,238,235,232,228,225,221,218,215,211,208,205,201,198,194,191,188,184,181,178,174,171,168,164,161,158,154,151,148,144,141,138,135,131,128,125,121,118,115,111,108,105,102,98,95,92,89,85,82,79,76,72,69,66,63,60,56,53,50,47,44,40,37,34,31,28,25,21,18,15,12,9,6,3,0,-3,-6,-9,-12,-15,-18,-21,-24,-27,-30,-33,-36,-39,-42,-45,-48,-52,-55,-58,-61,-64,-67,-69,-72,-75,-78,-81,-84,-87,-90,-93,-96,-99,-102,-105,-108,-111,-113,-116,-119,-122,-125,-128,-131,-133,-136,-139,-142,-145,-147,-150,-153,-156,-159,-161,-164,-167,-170,-172,-175,-178,-180,-183,-186,-189,-191,-194,-197,-199,-202,-205,-207,-210,-212,-215,-218,-220,-223,-225,-228,-231,-233,-236,-238,-241,-243,-246,-248,-251,-253,-256,-258,-261,-263,-265,-268,-270,-273,-275,-278,-280,-282,-285,-287,-289,-292,-294,-296,-299,-301,-303,-306,-308,-310,-313,-315,-317,-319,-322,-324,-326,-328,-330,-333,-335,-337,-339,-341,-343,-346,-348,-350,-352,-354,-356,-358,-360,-362,-364,-366,-368,-370,-372,-374,-376,-378,-380,-382,-384,-386,-388,-390,-392,-394,-396,-398,-400,-401,-403,-405,-407,-409,-411,-412,-414,-416,-418,-420,-421,-423,-425,-427,-428,-430,-432,-433,-435,-437,-438,-440,-442,-443,-445,-447,-448,-450,-451,-453,-454,-456,-458,-459,-461,-462,-464,-465,-467,-468,-470,-471,-472,-474,-475,-477,-478,-479,-481,-482,-484,-485,-486,-488,-489,-490,-492,-493,-494,-495,-497,-498,-499,-500,-502,-503,-504,-505,-506,-508,-509,-510,-511,-512,-513,-514,-515,-516,-518,-519,-520,-521,-522,-523,-524,-525,-526,-527,-528,-529,-530,-531,-532,-532,-533,-534,-535,-536,-537,-538,-539,-539,-540,-541,-542,-543,-544,-544,-545,-546,-547,-547,-548,-549,-549,-550,-551,-552,-552,-553,-554,-554,-555,-555,-556,-557,-557,-558,-558,-559,-559,-560,-561,-561,-562,-562,-563,-563,-564,-564,-564,-565,-565,-566,-566,-567,-567,-567,-568,-568,-568,-569,-569,-569,-570,-570,-570,-571,-571,-571,-571,-572,-572,-572,-572,-573,-573,-573,-573,-573,-573,-574,-574,-574,-574,-574,-574,-574,-574,-574,-574,-575,-575,-575,-575,-575,-575,-575,-575,-575,-575,-575,-575,-574,-574,-574,-574,-574,-574,-574,-574,-574,-574,-573,-573,-573,-573,-573,-573,-572,-572,-572,-572,-571,-571,-571,-571,-570,-570,-570,-570,-569,-569,-569,-568,-568,-568,-567,-567,-567,-566,-566,-565,-565,-565,-564,-564,-563,-563,-562,-562,-561,-561,-560,-560,-559,-559,-558,-558,-557,-557,-556,-556,-555,-555,-554,-553,-553,-552,-552,-551,-550,-550,-549,-548,-548,-547,-546,-546,-545,-544,-544,-543,-542,-541,-541,-540,-539,-538,-538,-537,-536,-535,-534,-534,-533,-532,-531,-530,-530,-529,-528,-527,-526,-525,-524,-523,-523,-522,-521,-520,-519,-518,-517,-516,-515,-514,-513,-512,-511,-510,-509,-508,-507,-506,-505,-504,-503,-502,-501,-500,-499,-498,-497,-496,-495,-494,-493,-492,-491,-489,-488,-487,-486,-485,-484,-483,-482,-480,-479,-478,-477,-476,-475,-473,-472,-471,-470,-469,-467,-466,-465,-464,-463,-461,-460,-459,-458,-456,-455,-454,-452,-451,-450,-449,-447,-446,-445,-443,-442,-441,-440,-438,-437,-436,-434,-433,-431,-430,-429,-427,-426,-425,-423,-422,-421,-419,-418,-416,-415,-414,-412,-411,-409,-408,-406,-405,-404,-402,-401,-399,-398,-396,-395,-393,-392,-391,-389,-388,-386,-385,-383,-382,-380,-379,-377,-376,-374,-373,-371,-370,-368,-367,-365,-364,-362,-361,-359,-357,-356,-354,-353,-351,-350,-348,-347,-345,-344,-342,-340,-339,-337,-336,-334,-332,-331,-329,-328,-326,-325,-323,-321,-320,-318,-317,-315,-313,-312,-310,-309,-307,-305,-304,-302,-300,-299,-297,-296,-294,-292,-291,-289,-287,-286,-284,-282,-281,-279,-277,-276,-274,-273,-271,-269,-268,-266,-264,-263,-261,-259,-258,-256,-254,-253,-251,-249,-248,-246,-244,-243,-241,-239,-238,-236,-234,-233,-231,-229,-228,-226,-224,-223,-221,-219,-217,-216,-214,-212,-211,-209,-207,-206,-204,-202,-201,-199,-197,-196,-194,-192,-191,-189,-187,-186,-184,-182,-181,-179,-177,-175,-174,-172,-170,-169,-167,-165,-164,-162,-160,-159,-157,-155,-154,-152,-150,-149,-147,-145,-144,-142,-140,-139,-137,-135,-134,-132,-130,-129,-127,-125,-124,-122,-120,-119,-117,-115,-114,-112,-111,-109,-107,-106,-104,-102,-101,-99,-97,-96,-94,-92,-91,-89,-88,-86,-84,-83,-81,-79,-78,-76,-75,-73,-71,-70,-68,-67,-65,-63,-62,-60,-59,-57,-55,-54,-52,-51,-49,-48,-46,-44,-43,-41,-40,-38,-37,-35,-33,-32,-30,-29,-27,-26,-24,-23,-21,-20,-18,-17,-15,-13,-12,-10,-9,-7,-6,-4,-3,-1,-0,1,2,4,5,7,8,9,11,12,14,15,17,18,20,21,23,24,26,27,28,30,31,33,34,36,37,38,40,41,43,44,45,47,48,50,51,52,54,55,56,58,59,60,62,63,65,66,67,69,70,71,73,74,75,76,78,79,80,82,83,84,86,87,88,89,91,92,93,94,96,97,98,99,101,102,103,104,106,107,108,109,110,112,113,114,115,116,117,119,120,121,122,123,124,126,127,128,129,130,131,132,134,135,136,137,138,139,140,141,142,143,144,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,175,176,177,178,179,180,181,182,183,184,184,185,186,187,188,189,190,190,191,192,193,194,195,195,196,197,198,199,200,200,201,202,203,203,204,205,206,206,207,208,209,209,210,211,212,212,213,214,214,215,216,216,217,218,218,219,220,220,221,222,222,223,224,224,225,225,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239,240,240,241,241,242,242,242,243,243,244,244,245,245,245,246,246,247,247,247,248,248,249,249,249,250,250,250,251,251,252,252,252,253,253,253,253,254,254,254,255,255,255,256,256,256,256,257,257,257,257,258,258,258,258,258,259,259,259,259,260,260,260,260,260,260,261,261,261,261,261,261,262,262,262,262,262,262,262,262,263,263,263,263,263,263,263,263,263,263,263,263,263,263,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,263,263,263,263,263,263,263,263,263,263,263,263,263,263,262,262,262,262,262,262,262,262,262,261,261,261,261,261,261,260,260,260,260,260,260,259,259,259,259,259,258,258,258,258,258,257,257,257,257,256,256,256,256,255,255,255,255,254,254,254,254,253,253,253,252,252,252,252,251,251,251,250,250,250,249,249,249,248,248,248,247,247,247,246,246,245,245,245,244,244,244,243,243,242,242,242,241,241,240,240,240,239,239,238,238,238,237,237,236,236,235,235,234,234,234,233,233,232,232,231,231,230,230,229,229,228,228,227,227,226,226,225,225,224,224,223,223,222,222,221,221,220,220,219,219,218,218,217,216,216,215,215,214,214,213,213,212,211,211,210,210,209,209,208,207,207,206,206,205,204,204,203,203,202,201,201,200,200,199,198,198,197,197,196,195,195,194,193,193,192,191,191,190,190,189,188,188,187,186,186,185,184,184,183,182,182,181,180,180,179,178,178,177,176,176,175,174,174,173,172,172,171,170,170,169,168,168,167,166,166,165,164,163,163,162,161,161,160,159,159,158,157,156,156,155,154,154,153,152,151,151,150,149,149,148,147,146,146,145,144,143,143,142,141,141,140,139,138,138,137,136,135,135,134,133,133,132,131,130,130,129,128,127,127,126,125,124,124,123,122,121,121,120,119,118,118,117,116,116,115,114,113,113,112,111,110,110,109,108,107,107,106,105,104,104,103,102,101,101,100,99,98,98,97,96,95,95,94,93,92,92,91,90,89,89,88,87,86,86,85,84,83,83,82,81,80,80,79,78,78,77,76,75,75,74,73,72,72,71,70,69,69,68,67,67,66,65,64,64,63,62,61,61,60,59,58,58,57,56,56,55,54,53,53,52,51,51,50,49,48,48,47,46,46,45,44,43,43,42,41,41,40,39,39,38,37,36,36,35,34,34,33,32,32,31,30,29,29,28,27,27,26,25,25,24,23,23,22,21,21,20,19,19,18,17,17,16,15,15,14,13,13,12,11,11,10,9,9,8,8,7,6,6,5,4,4,3,2,2,1,1,0,-0,-0,-1,-2,-2,-3,-3,-4,-5,-5,-6,-7,-7,-8,-8,-9,-10,-10,-11,-11,-12,-13,-13,-14,-14,-15,-15,-16,-17,-17,-18,-18,-19,-20,-20,-21,-21,-22,-22,-23,-23,-24,-25,-25,-26,-26,-27,-27,-28,-28,-29,-30,-30,-31,-31,-32,-32,-33,-33,-34,-34,-35,-35,-36,-36,-37,-37,-38,-38,-39,-39,-40,-40,-41,-41,-42,-42,-43,-43,-44,-44,-45,-45,-46,-46,-47,-47,-48,-48,-49,-49,-50,-50,-50,-51,-51,-52,-52,-53,-53,-54,-54,-54,-55,-55,-56,-56,-57,-57,-58,-58,-58,-59,-59,-60,-60,-60,-61,-61,-62,-62,-62,-63,-63,-64,-64,-64,-65,-65,-66,-66,-66,-67,-67,-67,-68,-68,-69,-69,-69,-70,-70,-70,-71,-71,-71,-72,-72,-72,-73,-73,-73,-74,-74,-74,-75,-75,-75,-76,-76,-76,-77,-77,-77,-78,-78,-78,-79,-79,-79,-79,-80,-80,-80,-81,-81,-81,-82,-82,-82,-82,-83,-83,-83,-83,-84,-84,-84,-84,-85,-85,-85,-85,-86,-86,-86,-86,-87,-87,-87,-87,-88,-88,-88,-88,-89,-89,-89,-89,-89,-90,-90,-90,-90,-90,-91,-91,-91,-91,-91,-92,-92,-92,-92,-92,-92,-93,-93,-93,-93,-93,-94,-94,-94,-94,-94,-94,-94,-95,-95,-95,-95,-95,-95,-95,-96,-96,-96,-96,-96,-96,-96,-97,-97,-97,-97,-97,-97,-97,-97,-97,-98,-98,-98,-98,-98,-98,-98,-98,-98,-98,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-99,-98,-98,-98,-98,-98,-98,-98,-98,-98,-98,-98,-97,-97,-97,-97,-97,-97,-97,-97,-97,-97,-96,-96,-96,-96,-96,-96,-96,-96,-96,-95,-95,-95,-95,-95,-95,-95,-95,-94,-94,-94,-94,-94,-94,-94,-93,-93,-93,-93,-93,-93,-93,-92,-92,-92,-92,-92,-92,-91,-91,-91,-91,-91,-91,-90,-90,-90,-90,-90,-90,-89,-89,-89,-89,-89,-89,-88,-88,-88,-88,-88,-88,-87,-87,-87,-87,-87,-86,-86,-86,-86,-86,-85,-85,-85,-85,-85,-84,-84,-84,-84,-84,-83,-83,-83,-83,-83,-82,-82,-82,-82,-82,-81,-81,-81,-81,-80,-80,-80,-80,-80,-79,-79,-79,-79,-78,-78,-78,-78,-78,-77,-77,-77,-77,-76,-76,-76,-76,-76,-75,-75,-75,-75,-74,-74,-74,-74,-73,-73,-73,-73,-72,-72,-72,-72,-71,-71,-71,-71,-70,-70,-70,-70,-69,-69,-69,-69,-68,-68,-68,-68,-67,-67,-67,-67,-66,-66,-66,-66,-65,-65,-65,-65,-64,-64,-64,-64,-63,-63,-63,-63,-62,-62,-62,-62,-61,-61,-61,-61,-60,-60,-60,-59,-59,-59,-59,-58,-58,-58,-58,-57,-57,-57,-57,-56,-56,-56,-55,-55,-55,-55,-54,-54,-54,-54,-53,-53,-53,-53,-52,-52,-52,-51,-51,-51,-51,-50,-50,-50,-50,-49,-49,-49,-48,-48,-48,-48,-47,-47,-47,-47,-46,-46,-46,-46,-45,-45,-45,-44,-44,-44,-44,-43,-43,-43,-43,-42,-42,-42,-41,-41,-41,-41,-40,-40,-40,-40,-39,-39,-39,-38,-38,-38,-38,-37,-37,-37,-37,-36,-36,-36,-36,-35,-35,-35,-34,-34,-34,-34,-33,-33,-33,-33,-32,-32,-32,-32,-31,-31,-31,-30,-30,-30,-30,-29,-29,-29,-29,-28,-28,-28,-28,-27,-27,-27,-27,-26,-26,-26,-26,-25,-25,-25,-25,-24,-24,-24,-24,-23,-23,-23,-23,-22,-22,-22,-22,-21,-21,-21,-21,-20,-20,-20,-20,-19,-19,-19,-19,-18,-18,-18,-18,-17,-17,-17,-17,-16,-16,-16,-16,-15,-15,-15,-15,-14,-14,-14,-14,-13,-13,-13,-13,-13,-12,-12,-12,-12,-11,-11,-11,-11,-10,-10,-10,-10,-10,-9,-9,-9,-9,-8,-8,-8,-8,-8,-7,-7,-7,-7,-6,-6,-6,-6,-6,-5,-5,-5,-5,-5,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-0,-0,-0,-0,-0,-0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21};
#include <stdarg.h>
#define SAMPLES_PER_FRM 76800
#define SAMPLES_PER_SLOT 3840
#define HW_offset 32
#define N_slot_offset 4
#define T_start 3840*20*100
void format_printf(int flag,const char * fmt, ...)
{
if(flag)
{
va_list args;
va_start(args,fmt);
vprintf(fmt,args);
va_end(args);
}
}
#include <stdarg.h>
#define SAMPLES_PER_FRM 76800
#define SAMPLES_PER_FRM_USRP 62500
#define SAMPLES_PER_SLOT 3840
#define SAMPLES_PER_SLOT_USRP 6250
#define HW_offset 32
#define N_slot_offset 4
#define T_start 3840*20*100
void format_printf(int flag,const char * fmt, ...)
{
if(flag)
{
va_list args;
va_start(args,fmt);
vprintf(fmt,args);
va_end(args);
}
}
/*******************************************************************************
Eurecom OpenAirInterface
Copyright(c) 1999 - 2011 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file lte-softmodem.c
* \brief main program to control HW and scheduling
* \author R. Knopp, F. Kaltenberger
* \date 2012
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr
* \note
* \warning
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#define __USE_GNU
//#define _GNU_SOURCE
#include <sched.h>
#include <signal.h>
#include <execinfo.h>
#include <getopt.h>
//#include <windows.h>
#include <errno.h>
#include "rt_wrapper.h"
#ifdef EMOS
#include <gps.h>
#endif
#include "PHY/types.h"
#include "PHY/defs.h"
#include "openair0_lib.h"
#include "PHY/vars.h"
#include "MAC_INTERFACE/vars.h"
#include "SCHED/vars.h"
#include "LAYER2/MAC/vars.h"
#include "../../SIMU/USER/init_lte.h"
#ifdef EMOS
#include "SCHED/phy_procedures_emos.h"
#endif
#ifdef OPENAIR2
#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/vars.h"
#ifndef CELLULAR
#include "RRC/LITE/vars.h"
#endif
#include "PHY_INTERFACE/vars.h"
#endif
#ifdef SMBV
#include "PHY/TOOLS/smbv.h"
unsigned short config_frames[4] = {2,9,11,13};
#endif
#include "UTIL/LOG/log_extern.h"
#include "UTIL/OTG/otg.h"
#include "UTIL/OTG/otg_vars.h"
#include "UTIL/MATH/oml.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#ifdef XFORMS
#include "PHY/TOOLS/lte_phy_scope.h"
#include "stats.h"
#include "../../ARCH/USRP/USERSPACE/LIB/def.h"
#include "TOOLS/thread_ipc.c"
#include <time.h>
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE
FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX];
FD_lte_phy_scope_enb *form_enb[NUMBER_OF_UE_MAX];
FD_stats_form *form_stats=NULL;
char title[255];
unsigned char scope_enb_num_ue = 1;
#endif //XFORMS
#define FRAME_PERIOD 100000000ULL
#define DAQ_PERIOD 66667ULL
//#define rt_printk printf
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
#ifdef RTAI //by super
static SEM *mutex;
//static CND *cond;
static int thread0;
static int thread1;
static int thread_recv;
//static int sync_thread;
#else
pthread_t thread0;
pthread_t thread1;
pthread_t thread_recv;
pthread_attr_t attr_dlsch_threads;
struct sched_param sched_param_dlsch;
#endif
pthread_t thread2;
pthread_t thread3;
pthread_t tid_eNB;
pthread_t tid_recv;
pthread_t thread_tx_error;
pthread_attr_t attr;
pthread_mutex_t mutex_eNB;
pthread_cond_t cond_eNB;
int ret;
// ------------------------------------
// functions and variables for USRP
// ------------------------------------
extern int oai_tx_buff[SAMPLES_PER_FRM];
extern int oai_rx_buff[SAMPLES_PER_FRM];
extern void UHD_init(void);
extern void UHD_init_display(void);
extern void Init_send(void);
extern void Init_recv(void);
extern void set_freq(int freq_offset);
extern void send_data(int hw_slot_offset);
extern void recv_data(int hw_slot_offset);
extern void send_end();
extern void tx_errorcode_handler(void);
int tx_offset = 0;
int hw_slot_offset = 0;
extern volatile unsigned long long tx_timestamp,rx_timestamp,clock_usrp;
extern volatile int flag_recv,flag_clock;
extern volatile int recv_ready;
extern volatile int w_pos_usrp_rcv; // value range [0:76800-1]
extern volatile int w_slot_usrp_rcv, r_slot_usrp_send; // slot index for USRP thread. value range [0:19]
extern volatile int r_slot_idx, t_slot_idx; // slot index for eNB thread. value range [0;19]
extern volatile int send_slot_missed;
double time_diff1,time_diff2,time_diff3,time_diff4;
struct timespec time_1, time_2,time_3,time_4,time_5;
// USRP debug output control
extern int g_usrp_debug;
//add for program run limit times
int N_slot_cycle;
// -----------------------------------
// Ctrl+c control
// -----------------------------------
int oai_exit = 0;
void sig_int_handler(void);
int card = 0;
exmimo_config_t *p_exmimo_config;
exmimo_id_t *p_exmimo_id;
volatile unsigned int *DAQ_MBOX;
//int time_offset[4] = {-138,-138,-138,-138};
//int time_offset[4] = {-145,-145,-145,-145};
int time_offset[4] = {0,0,0,0};
int fs4_test=0;
char UE_flag;
u8 eNB_id=0,UE_id=0;
u32 carrier_freq[4]= {1907600000,1907600000,1907600000,1907600000};
struct timing_info_t {
//unsigned int frame, hw_slot, last_slot, next_slot;
RTIME time_min, time_max, time_avg, time_last, time_now;
//unsigned int mbox0, mbox1, mbox2, mbox_target;
unsigned int n_samples;
} timing_info;
extern s16* sync_corr_ue0;
extern s16 prach_ifft[4][1024*2];
runmode_t mode;
int rx_input_level_dBm;
#ifdef XFORMS
extern int otg_enabled;
#else
int otg_enabled;
#endif
int number_of_cards = 1;
int mbox_bounds[20] = {8,16,24,30,38,46,54,60,68,76,84,90,98,106,114,120,128,136,144, 0}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers
int init_dlsch_threads(void);
void cleanup_dlsch_threads(void);
s32 init_rx_pdsch_thread(void);
void cleanup_rx_pdsch_thread(void);
int init_ulsch_threads(void);
void cleanup_ulsch_threads(void);
LTE_DL_FRAME_PARMS *frame_parms;
void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier);
void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier);
void test_config(int card, int ant, unsigned int rf_mode, int UE_flag);
unsigned int build_rflocal(txi, txq, rxi, rxq)
{
return (txi + (txq<<6) + (rxi<<12) + (rxq<<18));
}
unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe)
{
return (dcoff_i_rxfe + (dcoff_q_rxfe<<8));
}
void signal_handler(int sig)
{
void *array[10];
size_t size;
if (sig==SIGSEGV) {
// get void*'s for all entries on the stack
size = backtrace(array, 10);
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, 2);
exit(-1);
}
else {
oai_exit=1;
}
}
void exit_fun(const char* s)
{
void *array[10];
size_t size;
printf("Exiting: %s\n",s);
oai_exit=1;
//rt_sleep_ns(FRAME_PERIOD);
//exit (-1);
}
int dummy_tx_buffer[3840*4] __attribute__((aligned(16)));
void sig_int_handler(void)
{
oai_exit = 1;
}
// -----------------------------------
// USRP tx underflow test
// -----------------------------------
void *tx_error_handler(void *ptr)
{
(void)ptr;
while (!oai_exit)
{
tx_errorcode_handler();
}
pthread_exit(NULL);
}
// -----------------------------------
// USRP send and receive thread
// -----------------------------------
void *recv_all(void *ptr)
{
(void)ptr;
bind_thread2kernel(1);
int i=0;
// continuous receiving
while (!oai_exit)
{
// receive one slot-len
recv_data(hw_slot_offset);
// send one slot
send_data(hw_slot_offset);
i++; if(i==N_slot_cycle) oai_exit=1;//control run N_slot_cycle slot and exit
}
send_end();
printf("[rcv thread] Received oai_exit signal. Ends. send slot missed: %d\n",send_slot_missed);
printf("hw_slot_offset = %d\n",hw_slot_offset);//test hw_slot_offset value
pthread_exit(NULL);
}
/* This is the main eNB thread. It gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */
static void *eNB_thread(void *arg)
//void eNB_thread(void)
{
printf("Start eNB Server...\n\n");
bind_thread2kernel(2);
#ifdef RTAI
RT_TASK *task;
#endif
int slot=0,last_slot, next_slot,frame=0;
unsigned int aa,slot_offset, slot_offset_F;
int diff = 0;
int i;
int num_slot_missed = 0;
#ifdef RTAI
task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF);
LOG_D(HW,"Started eNB thread (id %p)\n",task);
//if(task==NULL) printf("RT Task creation failed\n"); else printf("Task success!\n");
#endif
mlockall(MCL_CURRENT | MCL_FUTURE);
#ifdef HARD_RT
rt_make_hard_real_time();
#endif
// initialize reading postition
r_slot_idx = 0;
t_slot_idx = 0;
frame = 0;
while (!oai_exit)
{
format_printf(g_usrp_debug,"[eNB ] r_eNB: %d w_usrp: %d num_slot_missed: %d diff: %d\n",r_slot_idx,w_slot_usrp_rcv, num_slot_missed,diff);
// Update 'diff'. Handle the frame wrap-arround
if ((w_slot_usrp_rcv<4)&&(r_slot_idx>=16)){
diff = r_slot_idx - (w_slot_usrp_rcv + 20) ;
}
else if((w_slot_usrp_rcv>=16)&&(r_slot_idx<4)){
diff = (r_slot_idx + 20) - w_slot_usrp_rcv;
}
else{
diff = r_slot_idx - w_slot_usrp_rcv;
}
// Reading is too slow. It's already late.
if(diff < -4)
{
r_slot_idx++;
num_slot_missed += abs(diff + 4);
if(r_slot_idx==20){
r_slot_idx = 0;
frame++;
}
continue;
}
// Wait for writing
while((diff > 0)&& (!oai_exit))
{
usleep(500);
// Update 'diff'. Handle the frame wrap-arround
if ((w_slot_usrp_rcv<4)&&(r_slot_idx>=16)){
diff = r_slot_idx - (w_slot_usrp_rcv + 20) ;
}
else if((w_slot_usrp_rcv>=16)&&(r_slot_idx<4)){
diff = (r_slot_idx + 20) - w_slot_usrp_rcv;
}
else{
diff = r_slot_idx - w_slot_usrp_rcv;
}
}
// The slot is ready
last_slot = r_slot_idx;
next_slot = (r_slot_idx + N_slot_offset)%LTE_SLOTS_PER_FRAME;
format_printf(g_usrp_debug, "[eNB ] r_eNB: %d w_usrp: %d last_slot: %d next_slot: %d diff: %d\n\n",r_slot_idx,w_slot_usrp_rcv,last_slot, next_slot,diff);
//---------------------------
// eNB procedure
//---------------------------
PHY_vars_eNB_g[0]->frame = frame;
//if (frame>5)
{
if (fs4_test==0)
// -- PHY procedure --
{
//phy_procedures_eNB_lte(last_slot, next_slot, PHY_vars_eNB_g[0], 0);//for OAI version berfore 4160
phy_procedures_eNB_lte(last_slot, next_slot, PHY_vars_eNB_g[0], 0,0);
#ifndef IFFT_FPGA
slot_offset_F = (next_slot)*
(PHY_vars_eNB_g[0]->lte_frame_parms.ofdm_symbol_size)*
((PHY_vars_eNB_g[0]->lte_frame_parms.Ncp==1) ? 6 : 7);//0for normal 7,1 for extened 6
slot_offset = (next_slot)*
(PHY_vars_eNB_g[0]->lte_frame_parms.samples_per_tti>>1);
if ((subframe_select(&PHY_vars_eNB_g[0]->lte_frame_parms,next_slot>>1)==SF_DL)||
((subframe_select(&PHY_vars_eNB_g[0]->lte_frame_parms,next_slot>>1)==SF_S)&&((next_slot&1)==0)))
{
for (aa=0; aa<PHY_vars_eNB_g[0]->lte_frame_parms.nb_antennas_tx; aa++)
{
if (PHY_vars_eNB_g[0]->lte_frame_parms.Ncp == 1)
{
PHY_ofdm_mod(&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdataF[0][aa][slot_offset_F],
#ifdef BIT8_TX
&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][slot_offset>>1],
#else
dummy_tx_buffer,//&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][slot_offset],
#endif
PHY_vars_eNB_g[0]->lte_frame_parms.log2_symbol_size,
6,
PHY_vars_eNB_g[0]->lte_frame_parms.nb_prefix_samples,
PHY_vars_eNB_g[0]->lte_frame_parms.twiddle_ifft,
PHY_vars_eNB_g[0]->lte_frame_parms.rev,
CYCLIC_PREFIX);
}
else
{
normal_prefix_mod(&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdataF[0][aa][slot_offset_F],
#ifdef BIT8_TX
&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][slot_offset>>1],
#else
dummy_tx_buffer,//&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][slot_offset],
#endif
7,
&(PHY_vars_eNB_g[0]->lte_frame_parms));
}
//else
//{
// normal_prefix_mod(&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdataF[0] [aa][slot_offset_F],
// &PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa ][slot_offset>>1],
// 7,
// &(PHY_vars_eNB_g[0]->lte_frame_parms));
//}
#ifdef EXMIMO
for (i=0; i<PHY_vars_eNB_g[0]->lte_frame_parms.samples_per_tti/2; i++)
{
tx_offset = (int)slot_offset+time_offset[aa]+i;
if (tx_offset<0)
tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*PHY_vars_eNB_g[0]->lte_frame_parms.samples_per_tti;
if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*PHY_vars_eNB_g[0]->lte_frame_parms.samples_per_tti))
tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*PHY_vars_eNB_g[0]->lte_frame_parms.samples_per_tti;
((short*)&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][tx_offset])[0]=
((short*)dummy_tx_buffer)[2*i]<<4;
((short*)&PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][tx_offset])[1]=
((short*)dummy_tx_buffer)[2*i+1]<<4;
//printf("txdata = %d ",PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa][tx_offset]);
}
#endif //EXMIMO
}
}
}// end of PHY procedure
#endif //IFFT_FPGA
}// end of frame>5
// update slot index
t_slot_idx = next_slot; // this slot is ready to send
r_slot_idx++;
if(r_slot_idx==20)
{
r_slot_idx = 0;
frame++;
}
}// end of while
format_printf(1,"\n[eNB thread] Received oai_exit signal. Ends. Ran %d frames. num_slot_missed: %d\n",frame, num_slot_missed);
#ifdef HARD_RT
rt_make_soft_real_time();
#endif
// clean task
#ifdef RTAI
rt_task_delete(task);
#endif
rt_printk("Task deleted. returning\n");
return 0;
}
/* This is the main UE thread. Initially it is doing a periodic get_frame. One synchronized it gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */
static void *UE_thread(void *arg)
{
printf("Start UE Client...\n\n");
bind_thread2kernel(2);
#ifdef RTAI
RT_TASK *task;
#endif
int slot=0,last_slot, next_slot,frame=0;
unsigned int aa,slot_offset, slot_offset_F;
int diff = 0;
int i;
int num_slot_missed = 0;
static int is_synchronized = 0;
static int received_slots = 0;
static int slot0 = 0;
static int first_run=1;
#ifdef RTAI
task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF);
LOG_D(HW,"Started UE thread (id %p)\n",task);
//if(task==NULL) printf("RT Task creation failed\n"); else printf("Task success!\n");
#endif
mlockall(MCL_CURRENT | MCL_FUTURE);
#ifdef HARD_RT
rt_make_hard_real_time();
#endif
// initialize reading postition
r_slot_idx = 0;
t_slot_idx = 0;
frame = 0;
openair_daq_vars.freq_offset = 0; //-7500;
set_freq(openair_daq_vars.freq_offset);
if (mode == rx_calib_ue) {
openair_daq_vars.freq_offset = -7500;
set_freq(openair_daq_vars.freq_offset);
}
usleep(10000*(7.68/6.25));//wait frame data fill in buff
//test synchronized or not
char test_synchronize = 1;
while (!oai_exit)
{
if (is_synchronized)
{
//test is synchronized or not
if(test_synchronize) {printf("Found cell ,UE synchronized! hw_slot_offset = %d\n",hw_slot_offset); test_synchronize = 0;}
format_printf(g_usrp_debug,"[UE ] r_ue: %d w_usrp: %d num_slot_missed: %d diff: %d\n",r_slot_idx,w_slot_usrp_rcv, num_slot_missed,diff);
// Update 'diff'. Handle the frame wrap-arround
if ((w_slot_usrp_rcv<4)&&(r_slot_idx>=16)){
diff = r_slot_idx - (w_slot_usrp_rcv + 20) ;
}
else if((w_slot_usrp_rcv>=16)&&(r_slot_idx<4)){
diff = (r_slot_idx + 20) - w_slot_usrp_rcv;
}
else{
diff = r_slot_idx - w_slot_usrp_rcv;
}
// Reading is too slow. It's already late.
if(diff < -4)
{
r_slot_idx++;
num_slot_missed += abs(diff + 4);
if(r_slot_idx==20){
r_slot_idx = 0;
frame++;
}
continue;
}
// Wait for writing
while((diff > 0)&& (!oai_exit))
{
usleep(500);
// Update 'diff'. Handle the frame wrap-arround
if ((w_slot_usrp_rcv<4)&&(r_slot_idx>=16)){
diff = r_slot_idx - (w_slot_usrp_rcv + 20) ;
}
else if((w_slot_usrp_rcv>=16)&&(r_slot_idx<4)){
diff = (r_slot_idx + 20) - w_slot_usrp_rcv;
}
else{
diff = r_slot_idx - w_slot_usrp_rcv;
}
}
// The slot is ready
last_slot = r_slot_idx;
next_slot = (r_slot_idx + N_slot_offset)%LTE_SLOTS_PER_FRAME;
format_printf(g_usrp_debug, "[UE ] r_ue: %d w_usrp: %d last_slot: %d next_slot: %d diff: %d\n\n",r_slot_idx,w_slot_usrp_rcv,last_slot, next_slot,diff);
PHY_vars_UE_g[0]->frame = frame;
//phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[0], 0, 0,mode);//for OAI version after 4160
phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[0], 0, 0,mode,0);
// update slot index
t_slot_idx = next_slot; // this slot is ready to send
r_slot_idx++;
if(r_slot_idx==20)
{
r_slot_idx = 0;
frame++;
}
}
else // we are not yet synchronized
{
hw_slot_offset = 0;
slot = 0;
if (initial_sync(PHY_vars_UE_g[0],mode)==0) {
if (mode == rx_calib_ue) {
oai_exit=1;
}
else {
is_synchronized = 1;
hw_slot_offset = PHY_vars_UE_g[0]->rx_offset;
//hw_slot_offset = (PHY_vars_UE_g[0]->rx_offset<<1) / PHY_vars_UE_g[0]->lte_frame_parms.samples_per_tti;
LOG_D(HW,"Got synch: hw_slot_offset %d\n",hw_slot_offset);
}
}
else {
if (openair_daq_vars.freq_offset >= 0) {
openair_daq_vars.freq_offset += 100;
openair_daq_vars.freq_offset *= -1;
}
else {
openair_daq_vars.freq_offset *= -1;
}
if (abs(openair_daq_vars.freq_offset) > 7500) {
LOG_I(PHY,"[initial_sync] No cell synchronization found, abondoning\n");
mac_xface->macphy_exit("");
oai_exit = 1;
}
else {
LOG_I(PHY,"[initial_sync] trying carrier off %d Hz\n",openair_daq_vars.freq_offset);
set_freq(openair_daq_vars.freq_offset);
}
}
}
}
LOG_D(HW,"UE_thread: finished, ran %d times.\n",frame);
format_printf(1,"\n[UE thread] Received oai_exit signal. Ends. Ran %d frames. num_slot_missed: %d\n",frame, num_slot_missed);
#ifdef HARD_RT
rt_make_soft_real_time();
#endif
// clean task
#ifdef RTAI
rt_task_delete(task);
#endif
LOG_D(HW,"Task deleted. returning\n");
return 0;
}
int main(int argc, char **argv)
{
#ifdef RTAI
RT_TASK *task;
#endif
int i,j,aa;
void *status;
/*
u32 rf_mode_max[4] = {55759,55759,55759,55759};
u32 rf_mode_med[4] = {39375,39375,39375,39375};
u32 rf_mode_byp[4] = {22991,22991,22991,22991};
*/
u32 my_rf_mode = RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX;
u32 my_rf_mode2 = RXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX;
u32 rf_mode[4] = {my_rf_mode,my_rf_mode2,0,0};
u32 rf_local[4] = {8255000,8255000,8255000,8255000}; // UE zepto
//{8254617, 8254617, 8254617, 8254617}; //eNB khalifa
//{8255067,8254810,8257340,8257340}; // eNB PETRONAS
u32 rf_vcocal[4] = {910,910,910,910};
u32 rf_vcocal_850[4] = {2015, 2015, 2015, 2015};
u32 rf_rxdc[4] = {32896,32896,32896,32896};
u32 rxgain[4] = {20,20,20,20};
u32 txgain[4] = {25,25,25,25};
u16 Nid_cell = 0;
u8 cooperation_flag=0, transmission_mode=1, abstraction_flag=0;
u8 beta_ACK=0,beta_RI=0,beta_CQI=2;
int c;
char do_forms=0;
unsigned int fd;
unsigned int tcxo = 114;
int amp;
u8 prach_fmt;
int N_ZC;
char rxg_fname[100];
char txg_fname[100];
char rflo_fname[100];
char rfdc_fname[100];
FILE *rxg_fd=NULL;
FILE *txg_fd=NULL;
FILE *rflo_fd=NULL;
FILE *rfdc_fd=NULL;
unsigned int rxg_max[4]={133,133,133,133}, rxg_med[4]={127,127,127,127}, rxg_byp[4]={120,120,120,120};
int tx_max_power=0;
char line[1000];
int l;
int ret, ant;
int error_code;
const struct option long_options[] = {
{"calib-ue-rx", required_argument, NULL, 256},
{"calib-ue-rx-med", required_argument, NULL, 257},
{"calib-ue-rx-byp", required_argument, NULL, 258},
{"debug-ue-prach", no_argument, NULL, 259},
{"no-L2-connect", no_argument, NULL, 260},
{NULL, 0, NULL, 0}};
mode = normal_txrx;
while ((c = getopt_long (argc, argv, "C:ST:UdF:V:Dn:",long_options,NULL)) != -1)
{
switch (c)
{
case 'D':
printf("Enable debug output. \n\n");
g_usrp_debug = 1;
break;
case 'V':
ouput_vcd = 1;
break;
case 'd':
do_forms=1;
break;
case 'U':
UE_flag = 1;
break;
case 'C':
carrier_freq[0] = atoi(optarg);
carrier_freq[1] = atoi(optarg);
carrier_freq[2] = atoi(optarg);
carrier_freq[3] = atoi(optarg);
break;
case 'S':
fs4_test=1;
break;
case 'T':
tcxo=atoi(optarg);
break;
case 'n':
N_slot_cycle=atoi(optarg);
break;
case 'F':
sprintf(rxg_fname,"%srxg.lime",optarg);
rxg_fd = fopen(rxg_fname,"r");
if (rxg_fd) {
printf("Loading RX Gain parameters from %s\n",rxg_fname);
l=0;
while (fgets(line, sizeof(line), rxg_fd)) {
if ((strlen(line)==0) || (*line == '#')) continue; //ignore empty or comment lines
else {
if (l==0) sscanf(line,"%d %d %d %d",&rxg_max[0],&rxg_max[1],&rxg_max[2],&rxg_max[3]);
if (l==1) sscanf(line,"%d %d %d %d",&rxg_med[0],&rxg_med[1],&rxg_med[2],&rxg_med[3]);
if (l==2) sscanf(line,"%d %d %d %d",&rxg_byp[0],&rxg_byp[1],&rxg_byp[2],&rxg_byp[3]);
l++;
}
}
}
else
printf("%s not found, running with defaults\n",rxg_fname);
sprintf(txg_fname,"%stxg.lime",optarg);
txg_fd = fopen(txg_fname,"r");
if (txg_fd) {
printf("Loading TX Gain parameters from %s\n",txg_fname);
l=0;
while (fgets(line, sizeof(line), txg_fd)) {
if ((strlen(line)==0) || (*line == '#')) {
continue; //ignore empty or comment lines
}
else {
if (l==0) sscanf(line,"%d %d %d %d",&txgain[0],&txgain[1],&txgain[2],&txgain[3]);
if (l==1) sscanf(line,"%d",&tx_max_power);
l++;
}
}
}
else
printf("%s not found, running with defaults\n",txg_fname);
sprintf(rflo_fname,"%srflo.lime",optarg);
rflo_fd = fopen(rflo_fname,"r");
if (rflo_fd) {
printf("Loading RF LO parameters from %s\n",rflo_fname);
fscanf(rflo_fd,"%d %d %d %d",&rf_local[0],&rf_local[1],&rf_local[2],&rf_local[3]);
}
else
printf("%s not found, running with defaults\n",rflo_fname);
sprintf(rfdc_fname,"%srfdc.lime",optarg);
rfdc_fd = fopen(rfdc_fname,"r");
if (rfdc_fd) {
printf("Loading RF DC parameters from %s\n",rfdc_fname);
fscanf(rfdc_fd,"%d %d %d %d",&rf_rxdc[0],&rf_rxdc[1],&rf_rxdc[2],&rf_rxdc[3]);
}
else
printf("%s not found, running with defaults\n",rfdc_fname);
break;
case 256:
mode = rx_calib_ue;
rx_input_level_dBm = atoi(optarg);
printf("Running with UE calibration on (LNA max), input level %d dBm\n",rx_input_level_dBm);
break;
case 257:
mode = rx_calib_ue_med;
rx_input_level_dBm = atoi(optarg);
printf("Running with UE calibration on (LNA med), input level %d dBm\n",rx_input_level_dBm);
break;
case 258:
mode = rx_calib_ue_byp;
rx_input_level_dBm = atoi(optarg);
printf("Running with UE calibration on (LNA byp), input level %d dBm\n",rx_input_level_dBm);
break;
case 259:
mode = debug_prach;
break;
case 260:
mode = no_L2_connect;
break;
default:
break;
}
}
if (UE_flag==1)
printf("configuring for UE\n");
else
printf("configuring for eNB\n");
//randominit (0);
set_taus_seed (0);
// initialize the log (see log.h for details)
logInit();
if (ouput_vcd) {
if (UE_flag==1)
vcd_signal_dumper_init("/tmp/openair_dump_UE.vcd");
else
vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd");
}
#ifdef NAS_NETLINK
netlink_init();
#endif
// to make a graceful exit when ctrl-c is pressed
//signal(SIGSEGV, signal_handler);
//signal(SIGINT, signal_handler);
#ifndef RTAI
check_clock();
#endif
// init the parameters
frame_parms = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS));
frame_parms->N_RB_DL = 25;
frame_parms->N_RB_UL = 25;
frame_parms->Ncp = 0;
frame_parms->Ncp_UL = 0;
frame_parms->Nid_cell = Nid_cell;
frame_parms->nushift = 0;
frame_parms->nb_antennas_tx_eNB = 1; //initial value overwritten by initial sync later
// frame_parms->nb_antennas_tx = (UE_flag==0) ? 1 : 1;
// frame_parms->nb_antennas_rx = (UE_flag==0) ? 1 : 1;
frame_parms->nb_antennas_tx = 1;
frame_parms->nb_antennas_rx = 1;
frame_parms->mode1_flag = (transmission_mode == 1) ? 1 : 0;
frame_parms->frame_type = 1;
frame_parms->tdd_config = 3;
frame_parms->tdd_config_S = 0;
frame_parms->phich_config_common.phich_resource = oneSixth;
frame_parms->phich_config_common.phich_duration = normal;
// UL RS Config
frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 0;//n_DMRS1 set to 0
frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0;
frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0;
frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0;
//print [PHY] ... message
init_ul_hopping(frame_parms);
//print [PHY][I][INIT]... message
init_frame_parms(frame_parms,1);
phy_init_top(frame_parms);
phy_init_lte_top(frame_parms);
//init prach for openair1 test
frame_parms->prach_config_common.rootSequenceIndex=22;
frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1;
frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0;
frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag=0;
frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0;
prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex,
frame_parms->frame_type);
N_ZC = (prach_fmt <4)?839:139;
if (UE_flag==1) {
#ifdef OPENAIR2
g_log->log_component[PHY].level = LOG_INFO;
#else
g_log->log_component[PHY].level = LOG_INFO;
#endif
g_log->log_component[PHY].flag = LOG_HIGH;
g_log->log_component[MAC].level = LOG_INFO;
g_log->log_component[MAC].flag = LOG_HIGH;
g_log->log_component[RLC].level = LOG_INFO;
g_log->log_component[RLC].flag = LOG_HIGH;
g_log->log_component[PDCP].level = LOG_INFO;
g_log->log_component[PDCP].flag = LOG_HIGH;
g_log->log_component[OTG].level = LOG_INFO;
g_log->log_component[OTG].flag = LOG_HIGH;
g_log->log_component[RRC].level = LOG_INFO;
g_log->log_component[RRC].flag = LOG_HIGH;
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE*));
//print [PHY][I][init_lte_eNB]... messages
PHY_vars_UE_g[0] = init_lte_UE(frame_parms, UE_id,abstraction_flag,transmission_mode);
#ifndef OPENAIR2
for (i=0;i<NUMBER_OF_eNB_MAX;i++) {
PHY_vars_UE_g[0]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK;
PHY_vars_UE_g[0]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI;
PHY_vars_UE_g[0]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI;
PHY_vars_UE_g[0]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = UE_id;
PHY_vars_UE_g[0]->scheduling_request_config[i].sr_ConfigIndex = 7+(UE_id%3);
PHY_vars_UE_g[0]->scheduling_request_config[i].dsr_TransMax = sr_n4;
}
#endif
compute_prach_seq(&PHY_vars_UE_g[0]->lte_frame_parms.prach_config_common,
PHY_vars_UE_g[0]->lte_frame_parms.frame_type,
PHY_vars_UE_g[0]->X_u);
PHY_vars_UE_g[0]->lte_ue_pdcch_vars[0]->crnti = 0x1234;
#ifndef OPENAIR2
PHY_vars_UE_g[0]->lte_ue_pdcch_vars[0]->crnti = 0x1235;
#endif
NB_UE_INST=1;
NB_INST=1;
openair_daq_vars.manual_timing_advance = 0;
//openair_daq_vars.timing_advance = TIMING_ADVANCE_HW;
openair_daq_vars.rx_gain_mode = DAQ_AGC_OFF;
openair_daq_vars.auto_freq_correction = 0;
openair_daq_vars.use_ia_receiver = 1;
// if AGC is off, the following values will be used
// for (i=0;i<4;i++)
// rxgain[i] = 20;
rxgain[0] = 20;
rxgain[1] = 20;
rxgain[2] = 20;
rxgain[3] = 20;
for (i=0;i<4;i++) {
PHY_vars_UE_g[0]->rx_gain_max[i] = rxg_max[i];
PHY_vars_UE_g[0]->rx_gain_med[i] = rxg_med[i];
PHY_vars_UE_g[0]->rx_gain_byp[i] = rxg_byp[i];
}
if ((mode == normal_txrx) || (mode == rx_calib_ue) || (mode == no_L2_connect) || (mode == debug_prach)) {
for (i=0; i<4; i++) {
PHY_vars_UE_g[0]->rx_gain_mode[i] = max_gain;
// frame_parms->rfmode[i] = rf_mode_max[i];
rf_mode[i] = (rf_mode[i] & (~LNAGAINMASK)) | LNAMax;
}
PHY_vars_UE_g[0]->rx_total_gain_dB = PHY_vars_UE_g[0]->rx_gain_max[0] + rxgain[0] - 30; //-30 because it was calibrated with a 30dB gain
}
else if ((mode == rx_calib_ue_med)) {
for (i=0; i<4; i++) {
PHY_vars_UE_g[0]->rx_gain_mode[i] = med_gain;
// frame_parms->rfmode[i] = rf_mode_med[i];
rf_mode[i] = (rf_mode[i] & (~LNAGAINMASK)) | LNAMed;
}
PHY_vars_UE_g[0]->rx_total_gain_dB = PHY_vars_UE_g[0]->rx_gain_med[0] + rxgain[0] - 30; //-30 because it was calibrated with a 30dB gain;
}
else if ((mode == rx_calib_ue_byp)) {
for (i=0; i<4; i++) {
PHY_vars_UE_g[0]->rx_gain_mode[i] = byp_gain;
// frame_parms->rfmode[i] = rf_mode_byp[i];
rf_mode[i] = (rf_mode[i] & (~LNAGAINMASK)) | LNAByp;
}
PHY_vars_UE_g[0]->rx_total_gain_dB = PHY_vars_UE_g[0]->rx_gain_byp[0] + rxgain[0] - 30; //-30 because it was calibrated with a 30dB gain;
}
PHY_vars_UE_g[0]->tx_power_max_dBm = tx_max_power;
printf("tx_max_power = %d -> amp %d\n",tx_max_power,get_tx_amp(tx_max_power,tx_max_power));
}
else { //this is eNB
#ifdef OPENAIR2
g_log->log_component[PHY].level = LOG_INFO;
#else
g_log->log_component[PHY].level = LOG_INFO;
#endif
g_log->log_component[PHY].flag = LOG_HIGH;
g_log->log_component[MAC].level = LOG_INFO;
g_log->log_component[MAC].flag = LOG_HIGH;
g_log->log_component[RLC].level = LOG_INFO;
g_log->log_component[RLC].flag = LOG_HIGH;
g_log->log_component[PDCP].level = LOG_INFO;
g_log->log_component[PDCP].flag = LOG_HIGH;
g_log->log_component[OTG].level = LOG_INFO;
g_log->log_component[OTG].flag = LOG_HIGH;
g_log->log_component[RRC].level = LOG_INFO;
g_log->log_component[RRC].flag = LOG_HIGH;
PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB*));
PHY_vars_eNB_g[0] = init_lte_eNB(frame_parms,eNB_id,Nid_cell,cooperation_flag,transmission_mode,abstraction_flag);
#ifndef OPENAIR2
for (i=0;i<NUMBER_OF_UE_MAX;i++) {
PHY_vars_eNB_g[0]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK;
PHY_vars_eNB_g[0]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI;
PHY_vars_eNB_g[0]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI;
PHY_vars_eNB_g[0]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i;
PHY_vars_eNB_g[0]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3);
PHY_vars_eNB_g[0]->scheduling_request_config[i].dsr_TransMax = sr_n4;
}
#endif
compute_prach_seq(&PHY_vars_eNB_g[0]->lte_frame_parms.prach_config_common,
PHY_vars_eNB_g[0]->lte_frame_parms.frame_type,
PHY_vars_eNB_g[0]->X_u);
NB_eNB_INST=1;
NB_INST=1;
openair_daq_vars.ue_dl_rb_alloc=0x1fff;
openair_daq_vars.target_ue_dl_mcs=20;
openair_daq_vars.ue_ul_nb_rb=6;
openair_daq_vars.target_ue_ul_mcs=9;
// if AGC is off, the following values will be used
// for (i=0;i<4;i++)
// rxgain[i]=30;
rxgain[0] = 20;
rxgain[1] = 20;
rxgain[2] = 20;
rxgain[3] = 20;
// set eNB to max gain
PHY_vars_eNB_g[0]->rx_total_gain_eNB_dB = rxg_max[0] + rxgain[0] - 30; //was measured at rxgain=30;
for (i=0; i<4; i++) {
// frame_parms->rfmode[i] = rf_mode_max[i];
rf_mode[i] = (rf_mode[i] & (~LNAGAINMASK)) | LNAMax;
}
}
dump_frame_parms(frame_parms);
mac_xface = malloc(sizeof(MAC_xface));
#ifdef OPENAIR2
int eMBMS_active=0;
//print [MAC][I]... messages
//l2_init(frame_parms,eMBMS_active);
l2_init(frame_parms,eMBMS_active,
0); // cba_group_active
if (UE_flag == 1)
mac_xface->dl_phy_sync_success (0, 0, 0, 1);
else
mac_xface->mrbch_phy_sync_failure (0, 0, 0);
#endif
mac_xface->macphy_exit = &exit_fun;
#ifdef OPENAIR2
//if (otg_enabled) {
init_all_otg(0);
g_otg->seed = 0;
init_seeds(g_otg->seed);
g_otg->num_nodes = 2;
for (i=0; i<g_otg->num_nodes; i++){
for (j=0; j<g_otg->num_nodes; j++){
g_otg->application_idx[i][j] = 1;
//g_otg->packet_gen_type=SUBSTRACT_STRING;
g_otg->aggregation_level[i][j][0]=1;
g_otg->application_type[i][j][0] = BCBR; //MCBR, BCBR
}
}
init_predef_traffic();
//USRP INIT
UHD_init();
UHD_init_display();
Init_send();
Init_recv();
printf("USRP init DONE...\n");
// }
#endif
// connect the TX/RX buffers
if (UE_flag==1) {
setup_ue_buffers(PHY_vars_UE_g[0],frame_parms,0);
printf("Setting UE buffer to all-RX\n");
}
else {
setup_eNB_buffers(PHY_vars_eNB_g[0],frame_parms,0);
if (fs4_test==0)
{
printf("Setting eNB buffer to all-RX\n");
}
else {
printf("Setting eNB buffer to fs/4 test signal\n");
for (j=0; j<PHY_vars_eNB_g[0]->lte_frame_parms.samples_per_tti*10; j+=4)
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++)
{
amp = 0x8000;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+1] = 0;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+3] = amp-1;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+5] = 0;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+7] = amp;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j] = amp-1;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+2] = 0;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+4] = amp;
((short*)PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][aa])[2*j+6] = 0;
}
}
}
//rt_sleep_ns(10*FRAME_PERIOD);//delay one second
#ifndef RTAI
pthread_attr_init (&attr_dlsch_threads);
pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE);
//attr_dlsch_threads.priority = 1;
sched_param_dlsch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY;
pthread_attr_setschedparam (&attr_dlsch_threads, &sched_param_dlsch);
pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO);
#endif
// start the main thread
if (UE_flag == 1) {
#ifdef RTAI
thread1 = rt_thread_create(UE_thread, NULL, 100000000);
thread_recv = rt_thread_create(recv_all, NULL, 100000000);
#else
error_code = pthread_create(&thread1, &attr_dlsch_threads, UE_thread, NULL);
if (error_code!= 0) {
LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code);
return(error_code);
}
else {
LOG_D(HW,"[lte-softmodem.c] Allocate UE_thread successful\n");
}
pthread_create(&thread_recv, NULL, recv_all, NULL);
#endif
#ifdef DLSCH_THREAD//defined
init_rx_pdsch_thread();
//rt_sleep_ns(FRAME_PERIOD/10);
init_dlsch_threads();
#endif
}
else {
#ifdef RTAI
thread0 = rt_thread_create(eNB_thread, NULL, 100000000);
thread_recv = rt_thread_create(recv_all, NULL, 100000000);
#else
error_code = pthread_create(&thread0, &attr_dlsch_threads, eNB_thread, NULL);
if (error_code!= 0) {
LOG_D(HW,"[lte-softmodem.c] Could not allocate eNB_thread, error %d\n",error_code);
return(error_code);
}
else {
LOG_D(HW,"[lte-softmodem.c] Allocate eNB_thread successful\n");
}
pthread_create(&thread_recv, NULL, recv_all, NULL);
#endif
#ifdef ULSCH_THREAD//not defined
init_ulsch_threads();
#endif
}
pthread_create(&thread_tx_error, NULL, tx_error_handler, NULL);
// wait for end of program
usleep(500);
printf("TYPE <CTRL-C> TO TERMINATE\n");
signal(SIGINT, &sig_int_handler);
getchar();
oai_exit=1;
// cleanup
pthread_join(thread_tx_error,&status);
if (UE_flag == 1) {
#ifdef RTAI
rt_thread_join(thread1);
rt_thread_join(thread_recv);
#else
pthread_join(thread1,&status);
pthread_join(thread_recv,&status);
#endif
#ifdef DLSCH_THREAD
printf("waiting for DLSCH_THREAD thread\n");
cleanup_dlsch_threads();
cleanup_rx_pdsch_thread();
#endif
}
else {
#ifdef RTAI
rt_thread_join(thread0);
rt_thread_join(thread_recv);
#else
pthread_join(thread0,&status);
pthread_join(thread_recv,&status);
#endif
#ifdef ULSCH_THREAD
printf("waiting for ULSCH_THREAD thread\n");
cleanup_ulsch_threads();
#endif
}
logClean();
printf("Program Done!\n");
return 0;
}
void test_config(int card, int ant, unsigned int rf_mode, int UE_flag)
{
p_exmimo_config->framing.eNB_flag = !UE_flag;
p_exmimo_config->framing.tdd_config = 0;
p_exmimo_config->framing.resampling_factor = 2;
p_exmimo_config->rf.rf_freq_rx[ant] = 1907600000;
p_exmimo_config->rf.rf_freq_tx[ant] = 1907600000;;
p_exmimo_config->rf.rx_gain[ant][0] = 20;
p_exmimo_config->rf.tx_gain[ant][0] = 10;
p_exmimo_config->rf.rf_mode[ant] = rf_mode;
p_exmimo_config->rf.rf_local[ant] = build_rflocal(20,25,26,04);
p_exmimo_config->rf.rf_rxdc[ant] = build_rfdc(128, 128);
p_exmimo_config->rf.rf_vcocal[ant] = (0xE<<6) + 0xE;
}
void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier) {
int i;
if (phy_vars_ue) {
if ((frame_parms->nb_antennas_rx>1) && (carrier>0)) {
printf("RX antennas > 1 and carrier > 0 not possible\n");
exit(-1);
}
if ((frame_parms->nb_antennas_tx>1) && (carrier>0)) {
printf("TX antennas > 1 and carrier > 0 not possible\n");
exit(-1);
}
// replace RX signal buffers with mmaped HW versions
for (i=0;i<frame_parms->nb_antennas_rx;i++) {
free(phy_vars_ue->lte_ue_common_vars.rxdata[i]);
phy_vars_ue->lte_ue_common_vars.rxdata[i] = (s32*) oai_rx_buff;
printf("rxdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.rxdata[i]);
}
for (i=0;i<frame_parms->nb_antennas_tx;i++) {
free(phy_vars_ue->lte_ue_common_vars.txdata[i]);
phy_vars_ue->lte_ue_common_vars.txdata[i] = (s32*) oai_tx_buff;
printf("txdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.txdata[i]);
}
}
}
void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier) {
int i;
if (phy_vars_eNB) {
if ((frame_parms->nb_antennas_rx>1) && (carrier>0)) {
printf("RX antennas > 1 and carrier > 0 not possible\n");
exit(-1);
}
if ((frame_parms->nb_antennas_tx>1) && (carrier>0)) {
printf("TX antennas > 1 and carrier > 0 not possible\n");
exit(-1);
}
// replace RX signal buffers with mmaped HW versions
for (i=0;i<frame_parms->nb_antennas_rx;i++) {
free(phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i]);
phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i] = (s32 *) oai_rx_buff;
printf("rxdata[%d] @ %p\n",i,phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i]);
/* for (j=0;j<16;j++) {
printf("rxbuffer %d: %x\n",j,phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i][j]);
phy_vars_eNB->lte_eNB_common_vars.rxdata[0][i][j] = 16-j;
}*/
}
for (i=0;i<frame_parms->nb_antennas_tx;i++) {
free(phy_vars_eNB->lte_eNB_common_vars.txdata[0][i]);
phy_vars_eNB->lte_eNB_common_vars.txdata[0][i] = (s32 *) oai_tx_buff;
printf("txdata[%d] @ %p\n",i,phy_vars_eNB->lte_eNB_common_vars.txdata[0][i]);
/* for (j=0;j<16;j++) {
printf("txbuffer %d: %x\n",j,phy_vars_eNB->lte_eNB_common_vars.txdata[0][i][j]);
phy_vars_eNB->lte_eNB_common_vars.txdata[0][i][j] = 16-j;
}*/
}
}
}
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/format.hpp>
#include <iostream>
#include <complex>
#include <fstream>
#include <cmath>
#include "def.h"
using namespace std;
using std::ofstream;
using std::ifstream;
// --------------------------------
// contant variables
// --------------------------------
#define PI 3.1415926535898
#define SAM_RATE 6.25e6 // 6.25e6 = 100e6/16
#define DL_FREQ 880e6
#define UL_FREQ 835e6
// --------------------------------
// variables for USRP configuration
// --------------------------------
uhd::usrp::multi_usrp::sptr tx_usrp;
uhd::usrp::multi_usrp::sptr rx_usrp;
//create a send streamer and a receive streamer
uhd::stream_args_t stream_args_short("sc16");//complex short
uhd::stream_args_t stream_args_float("fc32");//complex float
uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream;
uhd::tx_metadata_t tx_md;
uhd::rx_metadata_t rx_md;
//setup variables and allocate buffer
uhd::async_metadata_t async_md;
double tx_timeout;
double rx_timeout;
double rx_freq;
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
// --------------------------------
// variables for OAI buffers
// --------------------------------
int oai_tx_buff[SAMPLES_PER_FRM];
int oai_rx_buff[SAMPLES_PER_FRM];
int oai_rx_buff_temp[SAMPLES_PER_FRM];
volatile unsigned long long tx_timestamp,rx_timestamp,clock_usrp,tmp_clock;
volatile int w_pos_usrp_rcv = 0; // value range [0:76800-1]
volatile int r_pos_usrp_send = 0; // value range [0:76800-1]
volatile int w_slot_usrp_rcv, r_slot_usrp_send; // slot index for USRP thread. value range [0:19]
volatile int r_slot_idx, t_slot_idx; // slot index for eNB thread. value range [0;19]
volatile int send_slot_missed = 0;
// --------------------------------
// Debug and output control
// --------------------------------
int g_usrp_debug=0;
int num_underflows=0;
int num_overflows=0;
int num_seq_errors=0;
extern "C"
{
void UHD_init(void);
void UHD_init_display(void);
void Init_send(void);
void Init_recv(void);
void send_data(int hw_frm_head_pos);
void recv_data(int hw_frm_head_pos);
void send_end(void);
void set_freq(int freq_offset);
char UE_flag;
void tx_errorcode_handler(void);
void sig_int_handler(void);
}
// --------------------------------
// USRP initial
// --------------------------------
void UHD_init(void)
{
uhd::set_thread_priority_safe();
std::string args = "send_frame_size=3840,recv_frame_size=3840";
uhd::device_addrs_t device_addr = uhd::device::find(args);
if (device_addr.size() == 0 )
{
std::cerr<<"No USRP Device Found"<<std::endl;
exit(1);
}
else
std::cout<<"USRP Device Found"<<std::endl<<device_addr[0].to_pp_string()<<std::endl;
tx_usrp = uhd::usrp::multi_usrp::make(args);
rx_usrp = uhd::usrp::multi_usrp::make(args);
tx_stream = tx_usrp->get_tx_stream(stream_args_short);
rx_stream = rx_usrp->get_rx_stream(stream_args_short);
//Lock mboard clocks
tx_usrp->set_clock_source("internal");
rx_usrp->set_clock_source("internal");
tx_usrp->set_tx_rate(SAM_RATE);
if(UE_flag)
tx_usrp->set_tx_freq(UL_FREQ);
else
tx_usrp->set_tx_freq(DL_FREQ);
tx_usrp->set_tx_gain(0);
tx_usrp->set_tx_bandwidth(25e6);
tx_usrp->set_tx_antenna("TX/RX");
rx_usrp->set_rx_rate(SAM_RATE);
if(UE_flag)
{
rx_usrp->set_rx_freq(DL_FREQ);
rx_freq = DL_FREQ;
}
else
{
rx_usrp->set_rx_freq(UL_FREQ);
rx_freq = UL_FREQ;
}
rx_usrp->set_rx_gain(0);
rx_usrp->set_rx_bandwidth(25e6);
rx_usrp->set_rx_antenna("RX2");
std::cout <<std::endl<< boost::format("Setting device timestamp to 0...") << std::endl;
tx_usrp->set_time_now(uhd::time_spec_t(0.0));
rx_usrp->set_time_now(uhd::time_spec_t(0.0));
}
// --------------------------------
// USRP information display
// --------------------------------
void UHD_init_display(void)
{
std::cout << std::endl<<boost::format("Actual TX sample rate: %fMSps...") % (tx_usrp->get_tx_rate()/1e6) << std::endl;
std::cout << boost::format("Actual RX sample rate: %fMSps...") % (rx_usrp->get_rx_rate()/1e6) << std::endl;
std::cout << boost::format("Actual TX frequency: %fGHz...") % (tx_usrp->get_tx_freq()/1e9) << std::endl;
std::cout << boost::format("Actual RX frequency: %fGHz...") % (rx_usrp->get_rx_freq()/1e9) << std::endl;
std::cout << boost::format("Actual TX gain: %f...") % (tx_usrp->get_tx_gain()) << std::endl;
std::cout << boost::format("Actual RX gain: %f...") % (rx_usrp->get_rx_gain()) << std::endl;
std::cout << boost::format("Actual TX bandwidth: %fM...") % (tx_usrp->get_tx_bandwidth()/1e6) << std::endl;
std::cout << boost::format("Actual RX bandwidth: %fM...") % (rx_usrp->get_rx_bandwidth()/1e6) << std::endl;
std::cout << boost::format("Actual TX antenna: %s...") % (tx_usrp->get_tx_antenna()) << std::endl;
std::cout << boost::format("Actual RX antenna: %s...") % (rx_usrp->get_rx_antenna()) << std::endl;
std::cout << boost::format("Device TX timestamp: %f...") % (tx_usrp->get_time_now().get_real_secs()) << std::endl;
std::cout << boost::format("Device RX timestamp: %f...") % (rx_usrp->get_time_now().get_real_secs()) << std::endl << std::endl;
}
// -----------------------
//send init
// -----------------------
void Init_send(void)
{
//reset send buffer
memset(oai_tx_buff , 0 , sizeof(oai_tx_buff));
// the first slot sent shoud be the 0+N_slot_offset.
r_slot_usrp_send = N_slot_offset;
//send constantly
tx_md.start_of_burst = false;
tx_md.end_of_burst = false;
tx_md.has_time_spec = true; // set the transmission start time
tx_timestamp = T_start + r_slot_usrp_send * SAMPLES_PER_SLOT;
tx_md.time_spec = uhd::time_spec_t::from_ticks(tx_timestamp,SAM_RATE);
tx_timeout = tx_timestamp/SAM_RATE + 0.1;
}
// -----------------------
//receive init
// -----------------------
void Init_recv(void)
{
//reset receive buffer
memset(oai_rx_buff , 0 , sizeof(oai_rx_buff));
// initialize the rx stream
stream_cmd.stream_now = false;//When true, the device will begin streaming ASAP. When false, the device will begin streaming at a time specified by time_spec.
stream_cmd.num_samps = 0;
rx_timestamp = T_start + HW_offset;//Device timestamp and time of send sample
stream_cmd.time_spec = uhd::time_spec_t::from_ticks(rx_timestamp,SAM_RATE);
rx_usrp->issue_stream_cmd(stream_cmd);
//the first call to recv() will block this many seconds before receiving
rx_timeout = rx_timestamp/SAM_RATE + 0.1; //timeout (delay before receive + padding)
// the first clock number = rx_timestamp
clock_usrp = rx_timestamp;
w_pos_usrp_rcv = 0;
w_slot_usrp_rcv = 19;
}
// -----------------------
// send function
// -----------------------
void send_data(int hw_frm_head_pos)
{
int diff;
// Handle the frame wrap-arround
if ((r_slot_usrp_send<4)&&(t_slot_idx>=16)){
diff = t_slot_idx - (r_slot_usrp_send + 20) ;
}
else if((r_slot_usrp_send>=16)&&(t_slot_idx<4)){
diff = (t_slot_idx + 20) - r_slot_usrp_send;
}
else{
diff = t_slot_idx - r_slot_usrp_send;
}
format_printf(g_usrp_debug, "[send] diff: %d\n",diff);
if (diff<0){} // data is not ready for sending
else if (diff>1) // sending is late
{
format_printf(g_usrp_debug, "Sending is late\n");
r_slot_usrp_send = t_slot_idx;
// count the missed sending slots
send_slot_missed += (diff - 1);
}
else // diff = 0,1 Send the data, one or two slots
{
for (int ii=0;ii<diff+1;ii++)
{
format_printf(g_usrp_debug,"[send] r_usrp: %d t_slot: %d w_usrp: %d w_pos_usrp_rcv: %d\n", r_slot_usrp_send,t_slot_idx,w_slot_usrp_rcv, w_pos_usrp_rcv);
format_printf(g_usrp_debug,"[send] clock_usrp: %llu tx_timestamp: %llu\n", clock_usrp, tx_timestamp);
// sending
size_t num_tx_samps;
r_pos_usrp_send = (t_slot_idx * SAMPLES_PER_SLOT + hw_frm_head_pos) % SAMPLES_PER_FRM;
if((r_pos_usrp_send + SAMPLES_PER_SLOT) <= SAMPLES_PER_FRM)
{
num_tx_samps = tx_stream->send((& oai_tx_buff[r_pos_usrp_send]),SAMPLES_PER_SLOT, tx_md, tx_timeout);
}
else
{
int tmp_len = SAMPLES_PER_FRM - r_pos_usrp_send;
num_tx_samps = tx_stream->send((& oai_tx_buff[r_pos_usrp_send]),tmp_len, tx_md, tx_timeout);
num_tx_samps = tx_stream->send((& oai_tx_buff[0]),SAMPLES_PER_SLOT - tmp_len, tx_md, tx_timeout);
}
tx_md.has_time_spec = false;
tx_timeout = 0.1;
r_slot_usrp_send++;
if(r_slot_usrp_send==20) r_slot_usrp_send=0;
}
}
}
// --------------------------------
// handle TX error codes
// --------------------------------
void tx_errorcode_handler(void){
if (not tx_stream->recv_async_msg(async_md)) {}
else{
switch(async_md.event_code){
case uhd::async_metadata_t::EVENT_CODE_BURST_ACK:
return;
case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW:
format_printf(g_usrp_debug,"[send] USRP TX UNDERFLOW!\n");
num_underflows++;
break;
case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET:
format_printf(g_usrp_debug,"[send] USRP TX UNDERFLOW IN_PACKET!\n");
break;
case uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR:
case uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST:
num_seq_errors++;
break;
default:
//std::cerr << "Event code: " << async_md.event_code << std::endl;
//std::cerr << "Unexpected event on async recv, continuing..." << std::endl;
break;
}
}
}
// -----------------------
// send end of burst
// -----------------------
void send_end()
{
//send a mini EOB packet
tx_md.end_of_burst = true;
tx_stream->send("", 0, tx_md);
tx_md.end_of_burst = false;
format_printf(1,"num_underflows: %d num_overflows: %d num_seq_errors: %d\n",num_underflows,num_overflows,num_seq_errors);
}
// -----------------------
// receive function
// -----------------------
void recv_data(int hw_frm_head_pos)
{
size_t num_rx_samps;
//volatile unsigned long long tmp_clock;
num_rx_samps = rx_stream->recv((&oai_rx_buff_temp[0]), SAMPLES_PER_SLOT,rx_md,rx_timeout);
//after the first receiving, reset the timeout value
rx_timeout = 0.1;
tmp_clock = rx_md.time_spec.to_ticks(SAM_RATE);
// Update writing position
w_pos_usrp_rcv = (w_pos_usrp_rcv + (int)(tmp_clock - clock_usrp))%SAMPLES_PER_FRM;
// Copy data into the PHY layer buffer
if((w_pos_usrp_rcv+num_rx_samps) <= SAMPLES_PER_FRM){
memcpy(& oai_rx_buff[w_pos_usrp_rcv],& oai_rx_buff_temp[0],num_rx_samps*sizeof(int));
}
else{
int tmp_len = SAMPLES_PER_FRM - w_pos_usrp_rcv;
memcpy(& oai_rx_buff[w_pos_usrp_rcv],& oai_rx_buff_temp[0],tmp_len*sizeof(int));
memcpy(& oai_rx_buff[0],& oai_rx_buff_temp[tmp_len],(num_rx_samps-tmp_len)*sizeof(int));
}
w_slot_usrp_rcv = (w_pos_usrp_rcv - hw_frm_head_pos + num_rx_samps - SAMPLES_PER_SLOT)%SAMPLES_PER_FRM / SAMPLES_PER_SLOT;
// update clock
clock_usrp = tmp_clock;
// show log
format_printf(g_usrp_debug,"[recv] w_pos: %d num_rx_samps=%d clock_usrp=%llu w_usrp: %d\n",w_pos_usrp_rcv,num_rx_samps,clock_usrp,w_slot_usrp_rcv);
//handle the error code
switch(rx_md.error_code){
case uhd::rx_metadata_t::ERROR_CODE_NONE:
break;
case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
format_printf(g_usrp_debug,"[recv] USRP RX OVERFLOW!\n");
num_overflows++;
break;
case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
format_printf(g_usrp_debug, "[recv] USRP RX TIMEOUT!\n");
break;
default:
format_printf(g_usrp_debug, "[recv] Unexpected error on RX, Error code: 0x%x\n",rx_md.error_code);
break;
}
}
// -----------------------
// set RX frequency in UE
// -----------------------
void set_freq(int freq_offset)
{
rx_usrp->set_rx_freq(rx_freq + freq_offset);
}
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/format.hpp>
#include <iostream>
#include <complex>
#include <fstream>
#include <cmath>
#include "def.h"
// --------------------------------
// headers for polyphaseResample
// --------------------------------
#include "polyphaseResample.h"
#include "coeff_3072_to_25.h"
#include "coeff_25_to_3072.h"
using namespace std;
using std::ofstream;
using std::ifstream;
// --------------------------------
// contant variables
// --------------------------------
#define PI 3.1415926535898
#define SAM_RATE 6.25e6 // 6.25e6 = 100e6/16
#define DL_FREQ 880e6
#define UL_FREQ 835e6
// --------------------------------
// variables for polyphaseResample
// --------------------------------
const int OUTRATE = 625;
const int INRATE = 768;
int *g_branch_table;
int *g_offset_table;
short Rx_history[625*2];
short Tx_history[768*2];
// --------------------------------
// variables for USRP configuration
// --------------------------------
uhd::usrp::multi_usrp::sptr tx_usrp;
uhd::usrp::multi_usrp::sptr rx_usrp;
//create a send streamer and a receive streamer
uhd::stream_args_t stream_args_short("sc16");//complex short
uhd::stream_args_t stream_args_float("fc32");//complex float
uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream;
uhd::tx_metadata_t tx_md;
uhd::rx_metadata_t rx_md;
//setup variables and allocate buffer
uhd::async_metadata_t async_md;
double tx_timeout;
double rx_timeout;
double rx_freq;
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
// --------------------------------
// variables for OAI buffers
// --------------------------------
int oai_tx_buff[SAMPLES_PER_FRM];
int oai_rx_buff[SAMPLES_PER_FRM];
int oai_rx_buff_temp[SAMPLES_PER_FRM_USRP];
int oai_tx_buff_temp[SAMPLES_PER_FRM_USRP];
volatile unsigned long long tx_timestamp,rx_timestamp,clock_usrp,tmp_clock;
volatile int w_pos_usrp_rcv = 0; // value range [0:76800-1]
volatile int r_pos_usrp_send = 0; // value range [0:76800-1]
volatile int w_slot_usrp_rcv, r_slot_usrp_send; // slot index for USRP thread. value range [0:19]
volatile int r_slot_idx, t_slot_idx; // slot index for eNB thread. value range [0;19]
volatile int send_slot_missed = 0;
// --------------------------------
// Debug and output control
// --------------------------------
int g_usrp_debug=0;
int num_underflows=0;
int num_overflows=0;
int num_seq_errors=0;
extern "C"
{
void UHD_init(void);
void UHD_init_display(void);
void Init_send(void);
void Init_recv(void);
void send_data(int hw_slot_offset);
void recv_data(int hw_slot_offset);
void send_end(void);
void set_freq(int freq_offset);
char UE_flag;
void tx_errorcode_handler(void);
void sig_int_handler(void);
}
void Rx_resample(void);
void Tx_resample(void);
// --------------------------------
// USRP initial
// --------------------------------
void UHD_init(void)
{
uhd::set_thread_priority_safe();
std::string args = "send_frame_size=3840,recv_frame_size=3840";
uhd::device_addrs_t device_addr = uhd::device::find(args);
if (device_addr.size() == 0 )
{
std::cerr<<"No USRP Device Found"<<std::endl;
exit(1);
}
else
std::cout<<"USRP Device Found"<<std::endl<<device_addr[0].to_pp_string()<<std::endl;
tx_usrp = uhd::usrp::multi_usrp::make(args);
rx_usrp = uhd::usrp::multi_usrp::make(args);
tx_stream = tx_usrp->get_tx_stream(stream_args_short);
rx_stream = rx_usrp->get_rx_stream(stream_args_short);
//Lock mboard clocks
tx_usrp->set_clock_source("internal");
rx_usrp->set_clock_source("internal");
tx_usrp->set_tx_rate(SAM_RATE);
if(UE_flag)
tx_usrp->set_tx_freq(UL_FREQ);
else
tx_usrp->set_tx_freq(DL_FREQ);
tx_usrp->set_tx_gain(0);
tx_usrp->set_tx_bandwidth(25e6);
tx_usrp->set_tx_antenna("TX/RX");
rx_usrp->set_rx_rate(SAM_RATE);
if(UE_flag)
{
rx_usrp->set_rx_freq(DL_FREQ);
rx_freq = DL_FREQ;
}
else
{
rx_usrp->set_rx_freq(UL_FREQ);
rx_freq = UL_FREQ;
}
rx_usrp->set_rx_gain(0);
rx_usrp->set_rx_bandwidth(25e6);
rx_usrp->set_rx_antenna("RX2");
std::cout <<std::endl<< boost::format("Setting device timestamp to 0...") << std::endl;
tx_usrp->set_time_now(uhd::time_spec_t(0.0));
rx_usrp->set_time_now(uhd::time_spec_t(0.0));
}
// --------------------------------
// USRP information display
// --------------------------------
void UHD_init_display(void)
{
std::cout << std::endl<<boost::format("Actual TX sample rate: %fMSps...") % (tx_usrp->get_tx_rate()/1e6) << std::endl;
std::cout << boost::format("Actual RX sample rate: %fMSps...") % (rx_usrp->get_rx_rate()/1e6) << std::endl;
std::cout << boost::format("Actual TX frequency: %fGHz...") % (tx_usrp->get_tx_freq()/1e9) << std::endl;
std::cout << boost::format("Actual RX frequency: %fGHz...") % (rx_usrp->get_rx_freq()/1e9) << std::endl;
std::cout << boost::format("Actual TX gain: %f...") % (tx_usrp->get_tx_gain()) << std::endl;
std::cout << boost::format("Actual RX gain: %f...") % (rx_usrp->get_rx_gain()) << std::endl;
std::cout << boost::format("Actual TX bandwidth: %fM...") % (tx_usrp->get_tx_bandwidth()/1e6) << std::endl;
std::cout << boost::format("Actual RX bandwidth: %fM...") % (rx_usrp->get_rx_bandwidth()/1e6) << std::endl;
std::cout << boost::format("Actual TX antenna: %s...") % (tx_usrp->get_tx_antenna()) << std::endl;
std::cout << boost::format("Actual RX antenna: %s...") % (rx_usrp->get_rx_antenna()) << std::endl;
std::cout << boost::format("Device TX timestamp: %f...") % (tx_usrp->get_time_now().get_real_secs()) << std::endl;
std::cout << boost::format("Device RX timestamp: %f...") % (rx_usrp->get_time_now().get_real_secs()) << std::endl << std::endl;
}
// -----------------------
//send init
// -----------------------
void Init_send(void)
{
//reset send buffer
memset(oai_tx_buff , 0 , sizeof(oai_tx_buff));
//reset Tx_history
memset(Tx_history, 0, sizeof(Tx_history));
// the first slot sent shoud be the 0+N_slot_offset.
r_slot_usrp_send = N_slot_offset;
//send constantly
tx_md.start_of_burst = false;
tx_md.end_of_burst = false;
tx_md.has_time_spec = true;
tx_timestamp = T_start + r_slot_usrp_send * SAMPLES_PER_SLOT;
tx_md.time_spec = uhd::time_spec_t::from_ticks(tx_timestamp,SAM_RATE);
tx_timeout = tx_timestamp/SAM_RATE + 0.1;
}
// -----------------------
//receive init
// -----------------------
void Init_recv(void)
{
//reset receive buffer
memset(oai_rx_buff , 0 , sizeof(oai_rx_buff));
//reset Rx_history
memset(Rx_history, 0, sizeof(Rx_history));
// initialize the rx stream
stream_cmd.stream_now = false;//When true, the device will begin streaming ASAP. When false, the device will begin streaming at a time specified by time_spec.
stream_cmd.num_samps = 0;
rx_timestamp = T_start + HW_offset;//Device timestamp and time of send sample
stream_cmd.time_spec = uhd::time_spec_t::from_ticks(rx_timestamp,SAM_RATE);
rx_usrp->issue_stream_cmd(stream_cmd);
//the first call to recv() will block this many seconds before receiving
rx_timeout = rx_timestamp/SAM_RATE + 0.1; //timeout (delay before receive + padding)
// the first clock number = rx_timestamp
clock_usrp = rx_timestamp;
w_pos_usrp_rcv = 0;
w_slot_usrp_rcv = 19;
}
// -----------------------
// send function
// -----------------------
void send_data(int hw_slot_offset)
{
int diff;
// Handle the frame wrap-arround
if ((r_slot_usrp_send<4)&&(t_slot_idx>=16)){
diff = t_slot_idx - (r_slot_usrp_send + 20) ;
}
else if((r_slot_usrp_send>=16)&&(t_slot_idx<4)){
diff = (t_slot_idx + 20) - r_slot_usrp_send;
}
else{
diff = t_slot_idx - r_slot_usrp_send;
}
format_printf(g_usrp_debug, "[send] diff: %d\n",diff);
if (diff<0){}
else if (diff>1)
{
format_printf(g_usrp_debug, "Sending is late\n");
r_slot_usrp_send = t_slot_idx;
// count the missed sending slots
send_slot_missed += (diff - 1);
}
else // diff = 0,1
{
for (int ii=0;ii<diff+1;ii++)
{
format_printf(g_usrp_debug,"[send] r_usrp: %d t_slot: %d w_usrp: %d w_pos_usrp_rcv: %d\n", r_slot_usrp_send,t_slot_idx,w_slot_usrp_rcv, w_pos_usrp_rcv);
format_printf(g_usrp_debug,"[send] clock_usrp: %llu tx_timestamp: %llu\n", clock_usrp, tx_timestamp);
Tx_resample();
// sending
size_t num_tx_samps;
r_pos_usrp_send = (t_slot_idx * SAMPLES_PER_SLOT + hw_slot_offset) % SAMPLES_PER_FRM;
if((r_pos_usrp_send + SAMPLES_PER_SLOT) <= SAMPLES_PER_FRM)
{
memcpy((& oai_tx_buff_temp[0]) , (& oai_tx_buff[r_pos_usrp_send]) , SAMPLES_PER_SLOT*4 );
//num_tx_samps = tx_stream->send((& oai_tx_buff[r_pos_usrp_send]), SAMPLES_PER_SLOT_USRP, tx_md, tx_timeout);
}
else
{
int tmp_len = SAMPLES_PER_FRM - r_pos_usrp_send;
//num_tx_samps = tx_stream->send((& oai_tx_buff[r_pos_usrp_send]), tmp_len, tx_md, tx_timeout);
memcpy((& oai_tx_buff_temp[0]) , (& oai_tx_buff[r_pos_usrp_send]) , tmp_len*4 );
//num_tx_samps = tx_stream->send((& oai_tx_buff[0]),SAMPLES_PER_SLOT_USRP - tmp_len, tx_md, tx_timeout);
memcpy((& oai_tx_buff_temp[tmp_len]) , (& oai_tx_buff[0]) , (SAMPLES_PER_SLOT - tmp_len)*4 );
}
num_tx_samps = tx_stream->send((& oai_tx_buff_temp[0]), SAMPLES_PER_SLOT_USRP, tx_md, tx_timeout);
//without timestamp
tx_md.has_time_spec = false;
tx_timeout = 0.1;
r_slot_usrp_send++;
if(r_slot_usrp_send==20) r_slot_usrp_send=0;
}
}
}
// --------------------------------
// handle TX error codes
// --------------------------------
void tx_errorcode_handler(void){
if (not tx_stream->recv_async_msg(async_md)) {}
else{
switch(async_md.event_code){
case uhd::async_metadata_t::EVENT_CODE_BURST_ACK:
return;
case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW:
format_printf(g_usrp_debug,"[send] USRP TX UNDERFLOW!\n");
num_underflows++;
break;
case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET:
format_printf(g_usrp_debug,"[send] USRP TX UNDERFLOW IN_PACKET!\n");
break;
case uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR:
case uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST:
num_seq_errors++;
break;
default:
//std::cerr << "Event code: " << async_md.event_code << std::endl;
//std::cerr << "Unexpected event on async recv, continuing..." << std::endl;
break;
}
}
}
// -----------------------
// send end of burst
// -----------------------
void send_end()
{
//send a mini EOB packet
tx_md.end_of_burst = true;
tx_stream->send("", 0, tx_md);
tx_md.end_of_burst = false;
format_printf(1,"num_underflows: %d num_overflows: %d num_seq_errors: %d\n",num_underflows,num_overflows,num_seq_errors);
}
// -----------------------
// receive function
// -----------------------
void recv_data(int hw_slot_offset)
{
size_t num_rx_samps;
//volatile unsigned long long tmp_clock;
num_rx_samps = rx_stream->recv((&oai_rx_buff_temp[0]), SAMPLES_PER_SLOT_USRP,rx_md,rx_timeout);
Rx_resample();
//after the first receiving, reset the timeout value
rx_timeout = 0.1;
tmp_clock = rx_md.time_spec.to_ticks(SAM_RATE);
// Update writing position
w_pos_usrp_rcv = (w_pos_usrp_rcv + (int)(tmp_clock - clock_usrp))%SAMPLES_PER_FRM;
// Copy data into the PHY layer buffer
if((w_pos_usrp_rcv+num_rx_samps) <= SAMPLES_PER_FRM){
memcpy(& oai_rx_buff[w_pos_usrp_rcv],& oai_rx_buff_temp[0],num_rx_samps*sizeof(int));
}
else{
int tmp_len = SAMPLES_PER_FRM - w_pos_usrp_rcv;
memcpy(& oai_rx_buff[w_pos_usrp_rcv],& oai_rx_buff_temp[0],tmp_len*sizeof(int));
memcpy(& oai_rx_buff[0],& oai_rx_buff_temp[tmp_len],(num_rx_samps-tmp_len)*sizeof(int));
}
w_slot_usrp_rcv = (w_pos_usrp_rcv - hw_slot_offset + num_rx_samps - SAMPLES_PER_SLOT)%SAMPLES_PER_FRM / SAMPLES_PER_SLOT;
// update clock
clock_usrp = tmp_clock;
// show log
format_printf(g_usrp_debug,"[recv] w_pos: %d num_rx_samps=%d clock_usrp=%llu w_usrp: %d\n",w_pos_usrp_rcv,num_rx_samps,clock_usrp,w_slot_usrp_rcv);
//handle the error code
switch(rx_md.error_code){
case uhd::rx_metadata_t::ERROR_CODE_NONE:
break;
case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
format_printf(g_usrp_debug,"[recv] USRP RX OVERFLOW!\n");
num_overflows++;
break;
case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
format_printf(g_usrp_debug, "[recv] USRP RX TIMEOUT!\n");
break;
default:
format_printf(g_usrp_debug, "[recv] Unexpected error on RX, Error code: 0x%x\n",rx_md.error_code);
break;
}
}
// -----------------------
// set RX frequency in UE
// -----------------------
void set_freq(int freq_offset)
{
rx_usrp->set_rx_freq(rx_freq + freq_offset);
}
// -----------------------
// Rx_resample
// -----------------------
void Rx_resample(void)
{
short Rx_data_in[6250+625*2];
short Rx_data_out[7680+768*2];
memset(Rx_data_in, 0, sizeof(Rx_data_in));
memset(Rx_data_out, 0, sizeof(Rx_data_out));
memcpy(Rx_data_in, Rx_history, 625*4);
memcpy(Rx_data_in+625*2, & oai_rx_buff_temp[0], 3125*4);
polyphaseResample(Rx_data_in, sizeof(Rx_data_in) / sizeof(short) / 2 ,Rx_data_out , sizeof(Rx_data_out) / sizeof(short) / 2 , coeff_25_to_3072, sizeof(coeff_25_to_3072) / sizeof(short), INRATE, OUTRATE, 13, g_branch_table, g_offset_table);
memcpy(& oai_rx_buff_temp[0], Rx_data_out+768*2, 3840*4);
memcpy(Rx_history, Rx_data_in+6250-625*2, 625*4);
}
// -----------------------
// Tx_resample
// -----------------------
void Tx_resample(void)
{
short Tx_data_out[6250+625*2];
short Tx_data_in[7680+768*2];
memset(Tx_data_in, 0, sizeof(Tx_data_in));
memset(Tx_data_out, 0, sizeof(Tx_data_out));
memcpy(Tx_data_in, Tx_history, 768*4);
memcpy(Tx_data_in+768*2, & oai_tx_buff_temp[0], 3840*4);
polyphaseResample(Tx_data_in, sizeof(Tx_data_in) / sizeof(short) / 2 ,Tx_data_out , sizeof(Tx_data_out) / sizeof(short) / 2 , coeff_3072_to_25, sizeof(coeff_3072_to_25) / sizeof(short) , OUTRATE, INRATE, 11, g_branch_table, g_offset_table);
memcpy((& oai_tx_buff_temp[0]) , Tx_data_out+625*2, 3125*4);
memcpy(Tx_history, Tx_data_in+7680-768*2, 768*4);
}
#include "polyphaseResample.h"
#include <iostream>
#include <stdio.h>
using namespace std;
// table_len should be decied by the length of the filter output
// but a default value of 50000 is adequate for our app
void buildPolyphaseCache(const int P, const int Q, int *&branch_table, int *&offset_table, const int table_len) {
branch_table = new int[table_len];
offset_table = new int[table_len];
for (int i = 0; i < table_len; ++i) {
branch_table[i] = (i * Q) % P;
offset_table[i] = (i * Q - branch_table[i]) / P;
}
}
void polyphaseResample(short *in_data, unsigned int in_sample_count,
short *out_data, unsigned int out_sample_count,
short *filter_coeff, unsigned int filter_len,
const int P, const int Q, const unsigned int fix_shift,
int *branch_table, int *offset_table) {
buildPolyphaseCache( P, Q, branch_table, offset_table, 50000);
// calculate the sample count of output
out_sample_count = (int)(in_sample_count * (float)P / (float)Q);
short *output_ptr = out_data;
unsigned int output_ix = 0;
short const *input_end = in_data + in_sample_count * 2;
short const *output_end = out_data + out_sample_count * 2;
short const *filter_end = filter_coeff + filter_len;
while (output_ptr < output_end)
{
int output_branch = branch_table[output_ix];
int input_offset = offset_table[output_ix];
short *input_ptr = in_data + 2 * input_offset;
short *filter_ptr = filter_coeff + output_branch;
while (input_ptr >= input_end) {
input_ptr -= 2;
filter_ptr += P;
}
int sum_real = 0, sum_imag = 0;
while ((input_ptr >= in_data) && (filter_ptr < filter_end)) {
sum_real += (int)(*input_ptr) * (int)(*filter_ptr);
sum_imag += (int)(*(input_ptr + 1)) * (int)(*filter_ptr);
input_ptr -= 2;
filter_ptr += P;
}
*output_ptr = (short)(sum_real >> fix_shift);
*(output_ptr + 1) = (short)(sum_imag >> fix_shift);
output_ptr += 2;
output_ix++;
}
}
#ifndef _POLYPHASERESAMPLE_H_
#include <cmath>
//#include "coeff_3072_to_25.h"
void buildPolyphaseCache(const int P, const int Q, int *&branch_table, int *&offset_table, const int filter_len = 50000);
/**
* @brief polyphase resampler
* @param in_data input data, layout as [real,imag,real,imag...]
* @param in_sample_count count of input samples, i.e. a complex
* cosisting of two short int counts as one
* @param out_data output data, layout same as in_data
* @param out_sample_count sample count of result, as return
* @param filter_coeff filter with only real coeffcients
* @param filter_len count of coeffcients
* @param P order of upper sampling
* @param Q order of down sampling
**/
void polyphaseResample(short *in_data, unsigned int in_sample_count,
short *out_data, unsigned int out_sample_count,
short *filter_coeff, unsigned int filter_len,
const int P, const int Q, const unsigned int fix_shift,
int *branch_table, int *offset_table);
#endif
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment