CIC decimation output is strange (Output word length and negative fractional length)

11 views (last 30 days)
I'm implementing fixed point CIC decimation filter with following requirements --
  • Decimation factor: 20
  • Number of CIC stages: 4
  • Input and output bit width of the CIC: Signed 12-bit
Based on the above requirement, I created a CIC filter
cicDecimOut = dsp.CICDecimator(DecimationFactor=20,...
NumSections=4,...
FixedPointDataType="Specify word lengths",...
SectionWordLengths=12,...
OutputWordLength=12);
As an input, 12-bit signed data generated as follow.
x = randi([-2048 2047], 100000, 1);
in = fi(x,1,12);
Now the singned 12-bit input data plug-in to the CIC decimation filter.
out = cicDecimOut(in)
out =
0 -327155712 -479723520 146014208 -237502464 132120576 365428736 162529280 197394432 55574528 136052736 -407896064 30932992 -214958080 -67633152 -473956352 -123994112 -124256256 344719360 267649024 519831552 -233570304 -363069440 -427032576 -56360960 122159104 517996544 238288896 -14942208 230686720 30932992 56098816 305659904 -315621376 -211288064 333971456 -534511616 41156608 510394368 174587904 429654016 -288882688 -154402816 -22544384 160694272 509870080 -427556864 373817344 -137101312 -108527616 -83623936 -241172480 -299368448 115081216 -339214336 416284672 -231997440 335282176 -324272128 425721856 505937920 -284688384 -369623040 380895232 347865088 -451674112 -428867584 238813184 -148897792 -110100480 240386048 -415498240 292552704 70516736 43253760 -3670016 367525888 -361758720 -152305664 449576960 -157286400 -92798976 -308543488 -187170816 -341835776 18087936 476839936 -138674176 40370176 536346624 -65011712 380370944 73662464 -401342464 200278016 -216006656 -506200064 -11010048 139722752 -78643200 -112984064 424148992 114556928 428081152 -249298944 399769600 160956416 162529280 -470548480 -74448896 -12845056 -375390208 460324864 475791360 486801408 -398458880 -339476480 -329515008 308543488 391643136 -152829952 222298112 -536084480 -146800640 479723520 -278659072 201588736 391643136 -323223552 -168296448 374079488 -7077888 -504365056 393740288 -281280512 -424935424 20971520 -497811456 32768000 -157024256 -262930432 390594560 -235929600 -174063616 -312475648 -186384384 210239488 506200064 526909440 286523392 526909440 271056896 419692544 143130624 361758720 530841600 235405312 371720192 -296222720 535560192 -279707648 -219414528 474742784 -514326528 193724416 -472907776 -101449728 -338690048 -485490688 445906944 -510394368 -362283008 216793088 204472320 -132120576 115605504 516947968 -513540096 105119744 -30932992 -325320704 137887744 -221773824 -189267968 139198464 -374341632 -47185920 217579520 122421248 138149888 -398983168 -409206784 96468992 452984832 418643968 409468928 -67108864 -114556928 -31981568 518782976 271581184 92798976 283115520 385613824 -236978176 229638144 74186752 -327680000 -69468160 340787200 535560192 -430440448 219676672 -111149056 -208928768 213123072 470024192 169607168 139460608 450101248 497287168 271056896 320602112 -217055232 500432896 -47972352 -113246208 531103744 -472121344 -509607936 513802240 -480772096 531365888 287834112 467664896 -169082880 148897792 -398196736 369623040 -299630592 255066112 -193986560 -254279680 -268435456 460587008 459800576 -280756224 157024256 -70254592 386400256 150994944 -27525120 -180092928 536608768 259784704 -143392768 510394368 254541824 -500170752 407896064 -403963904 -349175808 -173539328 421527552 177209344 -396623872 -367001600 217055232 -120324096 -94633984 -7864320 -441450496 483393536 -521404416 479199232 -136577024 44302336 492306432 304087040 81002496 -346816512 106168320 -260046848 -477364224 525336576 161480704 98304000 -60293120 -99876864 167772160 501481472 -234881024 -5242880 -281542656 351010816 -273154048 532152320 269221888 -459014144 530055168 -472121344 -34603008 -150732800 139722752 270008320 400293888 85196800 35389440 326631424 -440401920 500170752 51642368 192937984 -225181696 492306432 -510656512 -219938816 -480509952 -353370112 148635648 -8650752 -81264640 237764608 -480772096 47448064 -366477312 478412800 -22020096 -349700096 290193408 483131392 236191744 274989056 12845056 523239424 -3932160 -316407808 -92012544 -124518400 -68943872 391643136 -189530112 341049344 264241152 -178520064 -299368448 -370409472 279183360 -326107136 10485760 -520617984 490995712 520093696 310902784 -12582912 -262144000 88604672 166461440 33030144 169345024 -74973184 143917056 -374603776 -431226880 43253760 -304611328 -214433792 -312999936 -467664896 469499904 -60817408 -381943808 445120512 16777216 440401920 -121372672 -85458944 -245366784 -107741184 -438304768 -199753728 -161742848 -247201792 -371982336 -313524224 -301465600 -335544320 -58458112 445120512 347602944 -219152384 68419584 -285474816 -515375104 -284426240 332922880 -49020928 87031808 -427556864 -375128064 -50069504 22544384 227278848 -233570304 -405536768 -459014144 -48234496 -391118848 -15466496 262668288 228065280 244318208 397672448 -243007488 252182528 190840832 139460608 -241958912 -2359296 -199229440 523763712 -378011648 -464781312 -407109632 -217579520 66060288 -369885184 -309067776 -215220224 357826560 -368312320 -213123072 -242483200 439877632 -409993216 -470286336 506200064 -185597952 -485228544 437780480 440139776 263716864 -370933760 178782208 371982336 2359296 462159872 369098752 176685056 38010880 212336640 -302514176 -7077888 25427968 236716032 -364642304 484704256 380108800 -61341696 76808192 -265814016 -358612992 505937920 -469499904 -359923712 423362560 -393740288 432275456 -272367616 -388497408 -528220160 -529268736 -480509952 -149159936 125829120 -11010048 284426240 -424148992 19398656 487587840 427556864 165412864 290455552 29884416 454557696 358088704 -386400256 320077824 -331874304 299368448 50855936 264241152 64749568 -528220160 -436731904 -396361728 192151552 439615488 406847488 267124736 246939648 109051904 188481536 40894464 94371840 -130547712 516423680 225443840 -475529216 90439680 7340032 -235405312 -8388608 503054336 -340787200 -339214336 -88342528 -343670784 320864256 -298319872 123994112 148897792 -437256192 35913728 27000832 219414528 -94633984 101974016 396361728 56098816 14680064 -194510848 398983168 -240648192 231211008 -419954688 -496238592 -76283904 420216832 -82837504 284164096 516947968 -202637312 51118080 -443547648 -131858432 454033408 -341573632 224395264 -174063616 490471424 -377487360 -305922048 -33816576 -111149056 -111935488 240386048 153092096 4456448 516947968 -255328256 396623872 57671680 306970624 370147328 -254017536 -109838336 -117178368 -281280512 -244318208 -6553600 -194510848 155713536 40632320 131072000 -304873472 524550144 85983232 109576192 -138412032 -406585344 32768000 104071168 -521928704 186646528 476577792 294649856 -381419520 -344457216 -41418752 200802304 -464781312 216006656 235405312 -117440512 255590400 -21757952 445382656 -487849984 -36962304 248512512 -498597888 -486801408 375652352 -447217664 -159907840 -475267072 -198180864 235143168 -535035904 260571136 256901120 435683328 519045120 -4194304 516423680 -166199296 -480509952 -104595456 -284950528 404488192 -147849216 319291392 139984896 495190016 -138412032 -301465600 -136577024 -22806528 -361758720 525074432 445120512 215482368 -225181696 164888576 -81788928 244842496 -317456384 368312320 11796480 -363593728 448004096 268435456 -520355840 -256114688 -306446336 -189005824 -191102976 -5505024 -225443840 -491782144 84934656 -481034240 -309067776 -522452992 -524288 -55050240 -290979840 -295436288 -483393536 88604672 353370112 -332136448 46399488 -56360960 -508559360 9699328 -374603776 464257024 -16777216 -228851712 -471334912 240910336 43515904 64487424 -452984832 -257425408 357826560 -233570304 240910336 -336330752 95682560 190578688 243793920 308019200 309854208 24379392 -218365952 -526123008 53215232 -336330752 399769600 498073600 234881024 -340262912 432537600 427032576 488112128 83623936 -106692608 -399245312 -265027584 47185920 -18087936 328204288 177995776 513015808 526909440 372244480 -360448000 336068608 -54525952 216268800 469762048 -177733632 -279445504 51642368 470286336 -441450496 68419584 488636416 -342097920 -246415360 -407109632 209453056 -246939648 279183360 -433324032 525336576 489422848 -377487360 -458489856 -104857600 189267968 162529280 -109051904 -168820736 -420478976 -76808192 101974016 -160169984 484966400 -347340800 -28049408 141557760 172490752 124256256 -501743616 484966400 -172490752 161218560 -285736960 -53215232 -312999936 401342464 -106430464 72876032 344719360 -452984832 -376438784 -221511680 389545984 -320864256 498073600 532152320 505413632 362020864 386662400 -478674944 -533200896 470810624 -416546816 -124780544 -127401984 -203685888 -338690048 184025088 225443840 -182976512 513802240 -427556864 529268736 -259260416 195559424 -34603008 -304349184 351010816 76546048 65273856 -46661632 -518258688 -386400256 189267968 460062720 -8126464 187170816 320602112 -428343296 515375104 -207355904 468451328 -363331584 -52166656 -86245376 -112721920 427556864 -344719360 114556928 -159383552 -358612992 -423624704 -237502464 -432013312 37486592 13893632 -200015872 379060224 213909504 -133693440 127139840 246939648 224919552 -425721856 40108032 390332416 -237764608 229900288 -324009984 228327424 -388759552 236191744 -76283904 314310656 202637312 289669120 -122683392 -168558592 -17039360 -6553600 353894400 473432064 298844160 471859200 396886016 -1572864 -510394368 202375168 100401152 296484864 -520617984 -166723584 -390070272 476315648 287834112 133955584 207093760 -56623104 -312999936 264241152 353632256 -421789696 23330816 300941312 -156762112 -247726080 -158597120 -32768000 83099648 253755392 -509083648 -141295616 438566912 -38010880 137887744 -445644800 -76546048 7340032 374341632 276561920 -303038464 -279445504 -269746176 293601280 444858368 -137363456 -122945536 -1310720 149159936 -503578624 96731136 181927936 76283904 -277610496 356253696 -484442112 101449728 -429391872 371458048 383778816 -135266304 -368836608 -295698432 90963968 490471424 309854208 -59244544 166723584 41418752 -92274688 487063552 -314048512 273154048 -222560256 175636480 382730240 -428081152 519045120 211288064 340262912 -428343296 -327680000 535822336 386138112 -479723520 159383552 110362624 73924608 -508821504 -381157376 456916992 475004928 141819904 -517210112 311951360 -52690944 -18874368 -93323264 136839168 436994048 -220725248 447741952 211550208 -1835008 201326592 79167488 -527171584 -273940480 135004160 -117702656 -263716864 355467264 150470656 -428605440 503840768 310378496 384040960 243531776 -337641472 -476315648 275513344 -37224448 153092096 -536870912 386924544 -110624768 -60555264 230424576 94371840 338427904 250609664 -499646464 365690880 -265814016 276824064 148373504 466878464 499122176 27000832 101449728 -64749568 -519307264 231211008 -312475648 -478674944 265814016 392167424 -106430464 165150720 224395264 -483917824 484442112 -303562752 -498073600 -106168320 239337472 -251658240 102236160 -244580352 -139984896 342884352 187957248 16515072 -374865920 -322437120 -275513344 440401920 -523763712 185597952 391905280 187170816 -143392768 -461635584 -170393600 286261248 -461111296 467664896 515637248 460849152 382468096 449839104 400031744 229113856 520880128 258736128 395575296 483655680 -326893568 175374336 451936256 -49807360 173277184 128712704 377225216 173539328 133169152 -356777984 133955584 386400256 113246208 222035968 -533987328 260571136 385351680 455344128 409206784 -266338304 495976448 -206831616 -132644864 -142606336 213123072 239861760 418906112 -480247808 -502530048 207355904 288358400 -49020928 395051008 -309329920 468975616 119799808 400293888 307757056 -451936256 111149056 -307494912 108527616 265814016 36962304 -127401984 246153216 -488898560 33816576 -378535936 110886912 -101711872 -127401984 54263808 -220200960 -50069504 -487325696 -363855872 136052736 28573696 369623040 289406976 -52690944 96993280 -164626432 371982336 -283377664 432013312 -8912896 88342528 -307494912 -449576960 242221056 384565248 -328204288 210239488 231997440 -133169152 -234618880 -176685056 -190578688 -291504128 83623936 514588672 -87556096 341049344 -186646528 524288000 228065280 128974848 -110886912 37224448 -504627200 103809024 482869248 -435421184 417857536 -391118848 -8912896 180092928 -198967296 -386924544 -222035968 188481536 508559360 139722752 -49807360 177733632 3932160 -403963904 220725248 -58195968 -536608768 -2883584 219414528 -126353408 -392429568 -488112128 -105119744 -514326528 -123469824 465567744 394264576 -139460608 277086208 -258473984 493879296 176160768 498597888 -86507520 120586240 -421265408 82313216 215744512 -477888512 99352576 -15466496 390856704 511705088 2097152 -243269632 -11534336 44302336 -110362624 -279969792 -343408640 -427032576 -174063616 93847552 -122421248 -165675008 -331612160 -337379328 -196608000 195559424 -112984064 150732800 -151257088 185860096 -246677504 256901120 -135266304 -260833280 -468189184 -394002432 78381056 189005824 336592896 143392768 -52428800 467402752 530055168 139198464 -500432896 171704320 147062784 489422848 -142868480 -67633152 -66060288 200802304 -88866816 -35389440 262144 113508352 344457216 373030912 -183500800 -117702656 331350016 53215232 159645696 59244544 252444672 335544320 -338165760 -104333312 97255424 -13631488 -248512512 371720192 -193724416 431489024 -386138112 -279707648 -155189248 -83099648 -17825792 -281018368 266600448 -273678336 279183360 -276561920 478412800 -12582912 218628096 61341696 -350224384 60817408 40632320 433848320 -26738688 389283840 285999104 342360064 -503840768 -26214400 -292028416 463470592 -531365888 40108032 184549376 -140771328 101449728 136577024 -487325696 -290979840 -262144000 -162791424 476577792 -389808128 -216530944 -257163264 104857600 282853376 139984896 -379584512 531628032 -317194240 -283115520 -525598720 -294912000 -373555200 220725248 110886912 -153354240 -213385216 -260571136 466878464 -306970624 -390332416 -331087872 -268959744 176160768 -209715200 -178257920 233570304 -517472256 -180879360 341049344 -155975680 512753664 -245891072 329777152 457441280 -338165760 195559424 -366739456 -494927872 -16515072 45613056 -254279680 361234432 1572864 132120576 -227016704 -239337472 212860928 -124780544 458752000 340787200 -427032576 -150208512 -351535104 -50593792 89391104 -94371840 -29097984 -106430464 43515904 -80478208 -440664064 -26214400 327680000 532414464 187432960 33554432 367788032 -194510848 265551872 -183238656 75759616 -153092096 -370147328 212336640 502267904 466878464 355729408 -95682560 240386048 -342097920 524812288 147062784 106692608 26476544 -30932992 -142344192 458489856 353107968 -369098752 -451674112 251658240 -473432064 320077824 452722688 -333971456 -423624704 526385152 518520832 400556032 -158859264 -342884352 22282240 306970624 282329088 -245366784 -143392768 381157376 -430178304 455344128 432013312 -27525120 -243007488 385875968 -289406976 -525074432 -174063616 -414187520 407371776 201064448 -300154880 -284688384 42729472 -172228608 305659904 -185597952 419954688 -317980672 -481558528 517734400 -127139840 -51380224 -501481472 -132907008 -19660800 -301203456 471597056 336068608 219938816 71303168 282853376 257949696 283377664 -385351680 384565248 139722752 -417333248 165150720 -164364288 65011712 15728640 195821568 -497549312 452198400 461635584 -114556928 43778048 -376963072 -503840768 392953856 282853376 -481034240 -527171584 -475791360 282066944 -138936320 153878528 -54788096 435945472 -503316480 57933824 -428867584 204996608 326893568 90701824 461897728 468713472 278921216 321912832 51118080 -520880128 -507510784 -391380992 -43253760 -125304832 40632320 -328204288 473956352 -492568576 384040960 -229900288 -160169984 173801472 185335808 18350080 -386662400 303038464 -310902784 168296448 384827392 -321388544 325058560 5242880 421789696 -457441280 96731136 50331648 -348651520 -462946304 30408704 70516736 326369280 -268173312 228589568 -7340032 242483200 519831552 -314310656 -231997440 -502005760 -107216896 -4456448 -462422016 6815744 -442761216 -406061056 -228589568 -374865920 244318208 -146014208 -96468992 486539264 -249823232 269221888 -335544320 533987328 -526909440 441450496 -342097920 -255852544 -53215232 453771264 284688384 -18612224 179568640 388759552 301727744 508821504 -360185856 -281018368 445906944 -375652352 319553536 445644800 286523392 176685056 156237824 370933760 -410779648 112197632 441188352 30670848 -235667456 -364380160 317980672 -80216064 -339214336 142082048 317194240 -65011712 -133693440 59768832 519831552 67633152 -493617152 -107479040 493092864 486014976 145489920 272891904 70778880 -498335744 390594560 131858432 -95158272 415236096 56360960 63176704 -107479040 -24903680 493355008 381419520 32505856 344457216 375914496 -215744512 464519168 -437518336 -378535936 282591232 -4980736 112197632 110624768 110362624 -495452160 414449664 277348352 -35127296 250871808 519045120 -129499136 -198180864 -392167424 -84672512 -50069504 42467328 -413401088 -218628096 101187584 362807296 508559360 430964736 171966464 -217055232 -370409472 490209280 8126464 221773824 -412352512 -281542656 126091264 378273792 -54525952 455344128 -403701760 -255852544 -352059392 -495976448 -46923776 -261881856 512491520 -98828288 243007488 -230162432 304873472 520093696 346030080 -397410304 530317312 415236096 151519232 -486014976 339476480 418643968 102760448 446431232 399245312 -12845056 -399769600 -150208512 378535936 -119537664 -23592960 357826560 92012544 170655744 70778880 -343408640 -236191744 83361792 2621440 -476839936 -401080320 481558528 18350080 -487325696 172228608 256638976 137625600 108003328 177733632 -518520832 -440401920 133431296 -322174976 -87293952 -146276352 331874304 307757056 478150656 -297795584 194772992 173539328 -258211840 -148897792 -465043456 -220725248 -310378496 136577024 -17039360 494141440 -334495744 497287168 462946304 -425197568 -42991616 213909504 301727744 327155712 496238592 116129792 -127401984 -438304768 -17563648 -308805632 -225968128 441974784 70254592 216268800 -280494080 103546880 198180864 -287834112 386138112 -105644032 373030912 -83886080 -215744512 -136577024 -75759616 268959744 393740288 487063552 -251396096 -220200960 247201792 80216064 -3670016 150208512 -461111296 402391040 266076160 -437256192 -204210176 -493355008 271319040 231211008 510656512 534511616 -240910336 379322368 -516685824 -47972352 73662464 -449839104 -330825728 -28835840 -108003328 114556928 -424411136 471597056 -44040192 -526647296 28049408 -325058560 -51904512 -438042624 -9699328 220987392 -148373504 15204352 493879296 33554432 271843328 89653248 274726912 120586240 -141033472 -137625600 174850048 -524288000 -194248704 148635648 416546816 304087040 -381157376 150732800 369885184 -298844160 426246144 -237240320 219152384 183762944 534773760 -126353408 137363456 273678336 -265814016 -233046016 -226230272 520617984 61341696 -379322368 -164888576 -215220224 279969792 392691712 -147587072 -139198464 477102080 326107136 131858432 489684992 153092096 -202899456 419168256 260308992 367001600 200278016 -206831616 -294912000 -439091200 -377487360 -214695936 -115605504 293601280 420478976 139460608 428343296 -8912896 122421248 -398721024 -116129792 414187520 -404488192 114819072 27000832 212074496 523763712 362807296 -109838336 -331612160 -77856768 -15728640 139460608 -205783040 258473984 -482607104 124780544 509083648 -35913728 475791360 -46137344 403963904 261619712 509345792 -88866816 -171442176 -195821568 -302514176 -120324096 511967232 -523763712 -234356736 -498860032 362020864 -374079488 -481034240 -231735296 -454295552 -403963904 -88866816 -59506688 -142082048 450101248 -421789696 467927040 247463936 175374336 458752000 -392953856 -499122176 -305922048 80216064 -205258752 160694272 -473956352 -383516672 -475529216 467664896 -308543488 -102498304 263454720 489422848 -424148992 -342622208 234618880 -418381824 420741120 -331874304 354418688 120324096 -527433728 165675008 -498073600 274726912 -487587840 338427904 33292288 162791424 444858368 -510656512 446955520 148373504 355467264 -250085376 -390594560 45613056 453771264 -181403648 -475004928 -2883584 -154402816 86245376 -168820736 359923712 -41156608 516423680 -99876864 -370671616 24903680 -445644800 -390856704 494927872 452198400 57671680 151781376 -152567808 444071936 482082816 -92798976 535298048 -193200128 -39845888 186646528 457965568 -250347520 -314048512 -230424576 -316669952 51118080 -322961408 158859264 -344981504 -401604608 525860864 488898560 -418381824 -440401920 -320602112 230686720 234618880 -378273792 -242745344 225443840 -208142336 -160432128 491257856 132382720 -243531776 -465043456 -420741120 -212074496 -329515008 -469237760 1572864 -297009152 512491520 286785536 178257920 -260571136 23330816 100139008 -533987328 52428800 266862592 -505675776 -521142272 -76546048 -388235264 517996544 287834112 82837504 509345792 -277610496 -106430464 -343670784 -237240320 67108864 449576960 354156544 86245376 491520000 -297009152 154140672 -489684992 -259784704 23068672 391905280 217841664 -16252928 -388497408 9961472 -511705088 -343146496 384303104 533987328 1048576 452460544 -352583680 -439091200 341311488 469499904 113770496 -281280512 142344192 62914560 67371008 -80216064 463732736 -403439616 -278134784 -475791360 -51904512 183500800 -316932096 -395575296 -500695040 8126464 116916224 -342097920 133169152 -18087936 -521928704 180092928 -187957248 492568576 182976512 193986560 -413401088 -247463936 492830720 -136839168 465043456 521404416 69468160 -123731968 276824064 172228608 -228851712 336592896 84672512 146014208 -477102080 -473694208 -222560256 -464519168 214695936 429654016 285212672 -182452224 -257163264 -32768000 143130624 -469499904 213123072 457441280 189267968 117702656 -146276352 54263808 17825792 126353408 43515904 -112984064 476053504 275513344 434110464 46137344 -296222720 -126091264 303562752 385613824 28049408 27525120 -76808192 302252032 -375128064 -28049408 -352583680 74186752 -320077824 -492306432 23068672 223084544 -345767936 -294649856 148897792 -33292288 -142868480 -172752896 -486277120 -24379392 -246939648 322961408 -435683328 -519307264 -176947200 251920384 328990720 30146560 156237824 -507772928 305659904 492568576 -527695872 -486539264 510656512 275513344 253493248 -209190912 320339968 -93847552 26214400 263716864 114556928 293601280 -56098816 501743616 -434634752 -280231936 14942208 -116916224 327155712 -307494912 390070272 347340800 -192413696 422838272 -434372608 39583744 408158208 -111411200 18612224 -146014208 -382468096 -90701824 328728576 270270464 -19136512 505413632 -291241984 -271581184 -299892736 -410779648 294387712 -410779648 391118848 364642304 -72351744 -173801472 413138944 -53739520 -488112128 -314834944 47972352 -38797312 296747008 -99614720 -17039360 -191889408 -512491520 277610496 -506986496 -4980736 391118848 -228327424 460062720 452722688 -480772096 43778048 -306970624 250871808 227803136 442761216 416808960 238026752 150994944 -66322432 166985728 -504627200 -207355904 10223616 359661568 19398656 -497025024 126353408 295174144 189530112 -526385152 174850048 262668288 336330752 356253696 432013312 -61079552 453771264 -228851712 -226230272 488636416 127139840 176947200 505151488 62914560 -64487424 -11796480 309854208 108789760 449052672 -277610496 -402915328 514850816 233832448 -172752896 390594560 280231936 -495976448 144179200 366739456 157548544 -276299776 -62390272 308019200 -449052672 -114294784 -224395264 76021760 443285504 -134742016 510394368 -58982400 -427819008 62390272 -472645632 222560256 311689216 433586176 519569408 162267136 80216064 530055168 -258211840 -174325760 531890176 271319040 -110100480 233046016 -211550208 60030976 -204734464 209715200 179830784 -39583744 -146276352 -228327424 331350016 -195035136 303562752 -139198464 158859264 360185856 498073600 -46661632 -372768768 -104595456 -53739520 421003264 -283639808 -44302336 91226112 -159645696 518520832 318242816 533200896 355729408 269484032 309854208 428867584 147062784 -234356736 13631488 -138412032 276037632 177471488 154927104 -468451328 -45613056 -385351680 529006592 178257920 -284950528 -98304000 -105644032 384303104 -142082048 340262912 -195559424 495714304 -327680000 -453771264 189792256 -339476480 -311427072 445644800 -283901952 -176422912 -297533440 89653248 390856704 -1572864 -438566912 -219414528 127926272 156237824 123731968 160169984 114032640 -243269632 -238813184 138674176 -65011712 259522560 -438042624 84934656 -70778880 102236160 -448528384 490209280 -465829888 177733632 -430964736 -153354240 -8388608 118226944 -288620544 370671616 358350848 -290193408 67371008 -521928704 -348913664 395837440 390594560 120848384 530579456 -496762880 -478412800 -182714368 -405798912 18350080 12845056 -42729472 392167424 137887744 94896128 281018368 -45613056 -58982400 440926208 358875136 353632256 -355467264 31981568 69468160 35127296 -175636480 -492568576 -29360128 -534773760 164626432 -518258688 -63963136 -433848320 347078656 308281344 160956416 492044288 -8650752 -48234496 -309854208 164364288 264503296 374079488 -471334912 452984832 -16515072 335544320 480509952 112984064 236978176 17039360 -224657408 -166461440 -164364288 434372608 -508559360 -146276352 -51118080 -33816576 -216268800 160694272 127664128 97779712 -397934592 -230948864 -84672512 -378273792 386662400 -184025088 127401984 -4456448 -463470592 -496500736 41943040 436994048 -95158272 -459538432 111935488 -247463936 -53477376 -137101312 -164888576 354156544 -110624768 -509870080 528220160 -22282240 -269746176 137101312 487849984 -204472320 -56360960 112459776 -527695872 -512229376 -397934592 343932928 138149888 301989888 -321912832 504889344 472907776 182714368 -103809024 -6291456 376176640 -396361728 -303562752 162791424 328204288 143654912 -65798144 208142336 -183762944 176160768 -291241984 -491257856 397148160 -133955584 -98304000 -447741952 491782144 146800640 -39321600 -289144832 -157286400 -484966400 -287571968 -252706816 -244056064 -413663232 233570304 -263454720 108265472 -302252032 -367263744 -298844160 271843328 -270794752 -87031808 83623936 232783872 -62652416 359137280 67371008 43515904 -485752832 38797312 32768000 192413696 301203456 -508035072 -193724416 -194510848 502005760 494403584 -83623936 -184025088 29097984 -124518400 141819904 395575296 91488256 117964800 287309824 -362807296 341311488 515375104 -84410368 122683392 157286400 -385089536 254017536 477364224 -182976512 -312737792 -169345024 -433586176 213385216 363069440 -405274624 -455081984 -446169088 280231936 456130560 5767168 -172752896 445120512 -96731136 -51380224 -364904448 -87818240 -338165760 308805632 -387973120 83361792 -196870144 384565248 -68419584 466092032 -409206784 29622272 164626432 -142082048 70254592 325582848 -107216896 302252032 132907008 178257920 299106304 -145489920 -9437184 -82313216 322699264 -212598784 424935424 37486592 -10223616 47710208 318767104 -218890240 -445382656 134742016 -278396928 360710144 -171704320 450625536 -488898560 -437256192 16777216 -387448832 -187695104 -475529216 -310640640 -375390208 113770496 184025088 -126091264 469499904 128188416 390856704 -163053568 69730304 -458227712 35389440 -360448000 -470548480 530579456 86507520 -521928704 -207880192 -174325760 -123469824 430702592 458489856 327155712 362020864 -221511680 -304087040 -285212672 352321536 413925376 -298319872 -472121344 209977344 133169152 -328728576 85983232 -382205952 -525336576 271843328 -1048576 -55050240 340787200 525860864 206569472 -142868480 -10223616 262930432 481820672 -203685888 -379322368 317718528 298319872 -301465600 335020032 270008320 -423362560 40894464 311951360 477102080 -485228544 42729472 81526784 204734464 -283115520 306446336 -460849152 457703424 -373030912 -371720192 -216793088 136577024 -340262912 -6553600 -358612992 160432128 216268800 -472907776 89653248 -214695936 398458880 -499908608 500695040 58458112 282329088 -464519168 -340262912 23330816 259784704 -343408640 196345856 -283115520 414973952 -104333312 429916160 1572864 -382468096 -170917888 499646464 94371840 -488898560 199229440 -289144832 -221773824 262406144 187957248 -80478208 -112197632 -207618048 405274624 170917888 396623872 513015808 64225280 443023360 -335020032 131596288 224919552 471334912 -356515840 -185597952 -9699328 164102144 296484864 312999936 49283072 532152320 -82837504 526909440 -385875968 412614656 -409731072 197918720 -533725184 139460608 -171442176 363593728 277872640 157286400 371982336 -412352512 488112128 495714304 -502530048 268697600 -249561088 251133952 189792256 -166985728 -257949696 -267649024 128974848 499908608 250347520 -132120576 -277086208 -270794752 -336068608 -346030080 -2359296 347340800 326107136 -374603776 302776320 -414711808 -163577856 -139198464 -51904512 34078720 -48758784 50331648 74186752 374603776 322437120 153616384 365690880 -87031808 402391040 174587904 -478412800 -185335808 -233308160 7864320 -512229376 365428736 479461376 -51118080 110100480 235143168 122945536 57409536 148111360 -308543488 -25427968 -378011648 386138112 391380992 137363456 346554368 161218560 104333312 -112721920 -483655680 506200064 -329252864 -56098816 -290193408 -402653184 488636416 -19136512 -10485760 121634816 -250347520 -270270464 476315648 -307757056 170917888 -351797248 -94371840 3407872 -125042688 446955520 184811520 184287232 94109696 361234432 -320602112 219938816 34078720 -477102080 370671616 190316544 -302776320 433061888 382992384 -518520832 -12582912 -268959744 -168034304 -140771328 137363456 428867584 -162267136 359137280 209977344 -129499136 101974016 -39845888 -463208448 306708480 -278921216 -464257024 380633088 -126353408 -14417920 131334144 -502792192 -444071936 -347602944 26214400 -442236928 337641472 -103022592 443547648 511967232 327942144 -41156608 34603008 531890176 94371840 -531103744 -41943040 507510784 -313786368 -252182528 -287834112 -418119680 -512491520 149159936 399507456 -235143168 -264503296 -310902784 -329777152 457179136 -115343360 40894464 262144 -110362624 -354942976 267386880 4718592 -40894464 231473152 377749504 -29622272 -524288 -40632320 286785536 434896896 -250871808 458489856 234094592 -76283904 -25427968 -433586176 375128064 262668288 185073664 -246677504 299892736 191627264 -105119744 418906112 -414711808 371982336 322699264 -525336576 -344981504 20185088 157810688 210763776 -489160704 401080320 -231997440 -510656512 457703424 -244318208 -85983232 474742784 -34340864 335020032 -165412864 226230272 287309824 273154048 -316669952 197918720 450363392 -199753728 254017536 -311427072 -332398592 -424148992 500957184 -220725248 -305135616 -351272960 483131392 268959744 -115343360 -76546048 -146276352 531628032 165412864 105381888 497287168 185335808 532414464 333447168 -154927104 -408944640 -122945536 -57409536 477888512 -430702592 190054400 -293863424 35913728 -126091264 -198967296 -399769600 512753664 376438784 -11796480 -192413696 235667456 464781312 331350016 -381157376 -503840768 -289669120 30932992 181665792 254803968 -529268736 206569472 66060288 23592960 -93323264 489422848 -331612160 464519168 487325696 -71827456 -501481472 -170393600 49545216 -425984000 -314048512 30670848 -89653248 -108003328 189792256 -419168256 -76021760 223346688 348651520 -396623872 -127926272 153616384 389021696 -59244544 339738624 282853376 436731904 520617984 -211812352 514064384 155975680 256638976 -486801408 506986496 -422051840 -88342528 -185073664 102760448 345505792 381943808 -77070336 -275251200 416022528 -460324864 -516423680 -428081152 423886848 244318208 -210763776 294912000 -246677504 335020032 303824896 463732736 519045120 -351272960 32505856 -499908608 -12845056 -42205184 -180355072 -82837504 -147062784 -472907776 293339136 103546880 -151257088 -519045120 -174587904 -389545984 305135616 391905280 -52953088 275513344 -506200064 -325844992 -466878464 -397934592 -465829888 -308805632 -386138112 -155713536 -69730304 -283377664 -477364224 186646528 -150208512 99614720 -50855936 -429391872 223346688 -60555264 352845824 147324928 56885248 -523501568 137363456 219152384 -44302336 494403584 284688384 -100139008 48234496 416284672 492830720 340262912 117178368 -313524224 374603776 -465305600 138674176 384565248 96993280 468975616 424411136 -61079552 312737792 -487063552 88866816 -247988224 87293952 433586176 77332480 -160956416 -401342464 402653184 -292290560 31719424 22282240 -123469824 73662464 -56098816 172752896 -18612224 414711808 528482304 -293076992 105906176 -317718528 -190316544 176685056 514326528 169345024 -42991616 -525336576 459538432 242483200 -477888512 64749568 -169082880 173801472 177471488 -33030144 -429916160 -303824896 265814016 -451674112 -140509184 522190848 441450496 -299368448 -47185920 413663232 -63176704 397934592 -304611328 -138674176 -336855040 -395837440 -150208512 -11534336 -508559360 -149946368 -276299776 -433586176 6291456 -49807360 -454295552 -282329088 318242816 -252706816 -530579456 -34340864 258736128 325320704 -119537664 -443809792 -52166656 -17301504 -514588672 60817408 -516161536 238288896 266338304 327417856 -52953088 -176160768 177209344 95944704 143917056 -360448000 -474480640 356253696 375652352 195821568 -383778816 -425984000 -133169152 222560256 290455552 315883520 -85721088 -249298944 -475791360 -463994880 -294387712 180879360 449314816 50593792 142868480 416022528 -205520896 86769664 303038464 261357568 249561088 -520880128 430964736 -279445504 313786368 397672448 495714304 -386138112 457441280 253755392 72876032 -111149056 23330816 -448266240 454557696 180879360 359923712 -525598720 -409993216 139722752 786432 -367788032 -369360896 154140672 -320602112 -308805632 -265814016 -299368448 461373440 -1835008 -31719424 -24641536 504889344 -513540096 440664064 -127401984 392691712 90963968 364380160 -257425408 -81002496 124518400 125304832 -425197568 137101312 336330752 300941312 -63176704 525074432 94371840 -504365056 426508288 -66322432 -420216832 -276561920 43778048 -526909440 483655680 -198180864 384040960 48496640 433061888 -213123072 99876864 450625536 -52690944 -69468160 -232259584 -10485760 -276299776 -60030976 -8126464 -364118016 -316669952 -518782976 -99352576 450101248 428343296 333709312 -234618880 -489160704 -178520064 203948032 -415760384 -418643968 -45613056 127139840 -97255424 -471597056 124256256 -346554368 178257920 163840000 -120324096 108527616 303038464 240123904 294387712 -472645632 420478976 -413925376 78381056 503054336 -205258752 -330039296 324009984 -352059392 -487063552 223084544 -166985728 393216000 165675008 165412864 -456392704 239075328 -304611328 -269746176 330301440 -268959744 132382720 -465305600 -256901120 -129761280 -11796480 155189248 -132644864 500432896 268173312 -229638144 -183500800 315621376 401604608 -174587904 96993280 -72613888 -142606336 374865920 -163315712 -31981568 -201588736 -22806528 -358875136 313524224 -7602176 -398721024 -425459712 365428736 409206784 153354240 -174325760 -123994112 189792256 198180864 1572864 182714368 170655744 144179200 478150656 -219152384 527958016 -262406144 112197632 -333447168 -255066112 231735296 -279707648 312737792 115867648 -317980672 440139776 -18350080 317980672 -384303104 489684992 -432799744 506724352 484704256 269746176 437256192 -470286336 -476053504 -46399488 -307232768 -349962240 514326528 -368574464 457441280 -93847552 186908672 250609664 355991552 -45350912 -380895232 -220725248 7340032 139460608 300679168 -467664896 278396928 136577024 -46661632 86245376 -221249536 289669120 197394432 -281804800 -246415360 -251396096 -216268800 81264640 350224384 -34340864 -119799808 402915328 178520064 -521666560 7077888 237240320 26738688 522977280 -51642368 -87031808 194248704 -220200960 -167510016 -354156544 296484864 -460849152 57933824 -341311488 78118912 -373817344 54525952 348389376 239075328 -198443008 373030912 73662464 456916992 -470548480 -372506624 275251200 -267649024 -218890240 -506986496 352321536 -404488192 185860096 -185597952 -189792256 -184025088 -411303936 -202113024 172490752 438304768 81264640 187432960 423362560 -166985728 455081984 477102080 453246976 436207616 38273024 226492416 482869248 415498240 240648192 429916160 121110528 -25165824 45088768 43253760 -19136512 -405798912 -498335744 -148635648 470810624 -71041024 -514850816 -172490752 -535560192 -304611328 10223616 104071168 437780480 529530880 92012544 220200960 394264576 -240648192 533463040 -482869248 -393740288 -455081984 37224448 58195968 -375652352 -392691712 12582912 72089600 227803136 -156237824 268697600 217317376 -361496576 51904512 -88866816 -244318208 67108864 -508559360 473694208 -129761280 418906112 518258688 -120848384 -60030976 74973184 480509952 -63963136 322961408 -284164096 -221511680 -518520832 -395051008 -408944640 96993280 -183238656 252444672 443809792 -7602176 -180355072 73400320 -38797312 -349175808 169869312 371458048 29622272 -357826560 -139198464 154664960 -280494080 -287047680 314310656 255852544 387710976 -337641472 -324796416 460062720 -460849152 126877696 95158272 -23855104 68943872 -366215168 209453056 387973120 -66322432 -13107200 370147328 241696768 -525336576 48496640 -28311552 230162432 -116129792 -329252864 -344195072 503054336 -440139776 365953024 355991552 -501743616 108265472 358088704 -509870080 374603776 -271581184 394002432 -277348352 -32768000 -81788928 -92274688 345243648 442499072 -485752832 208666624 -386138112 -128450560 -336592896 -388497408 208404480 323485696 -347602944 470286336 54788096 -536084480 184549376 149946368 476839936 362545152 535560192 446431232 -190316544 331087872 110100480 400556032 -282329088 -442499072 -44564480 -46661632 -218628096 -258998272 127401984 168034304 234094592 399507456 -443023360 318504960 170393600 114556928 76808192 108527616 386662400 -52166656 7077888 -119799808 206569472 -170393600 -73924608 306970624 464781312 -427819008 438042624 90701824 363593728 236453888 319291392 -516685824 145489920 -4194304 -170917888 -44302336 -172490752 -259260416 363331584 -29884416 -307757056 245628928 -165150720 502005760 -430440448 -38535168 520355840 -163315712 -518782976 147849216 -117702656 -8650752 -24379392 -430702592 260571136 -213647360 -62914560 -481034240 135266304 -439877632 -106692608 -380633088 -465829888 196608000 -124518400 267124736 -164626432 -29884416 -198967296 -41943040 -526909440 -138412032 315883520 -358088704 202899456 27525120 -153616384 66060288 128188416 -322437120 217841664 6291456 -424148992 126877696 326369280 216006656 -321126400 -521928704 63176704 -454295552 183500800 -384565248 -126353408 -460324864 -149946368 -105119744 4980736 266862592 -399245312 103284736 -55836672 -503578624 -341835776 19660800 60817408 -472383488 -65798144 -420478976 -51904512 203423744 -71565312 335806464 55574528 169607168 -219676672 321126400 -137887744 -150208512 41943040 -32768000 155451392 -158597120 -413663232 31981568 202375168 -103546880 -77332480 -451411968 -478150656 491520000 488112128 -204734464 -314048512 -241958912 314572800 -390594560 267649024 460324864 -388235264 -471597056 76808192 -264503296 368574464 -212598784 424411136 4980736 -156762112 225181696 241696768 -404750336 252968960 143917056 -80478208 -476053504 263716864 386400256 106692608 -409993216 -194772992 -360185856 398721024 335544320 786432 -522715136 -130547712 68419584 -224657408 -169082880 481296384 89391104 -272105472 227803136 -171966464 -37486592 -206307328 163840000 509345792 286785536 163577856 -22806528 -329777152 135004160 -125304832 490471424 240910336 276037632 -477364224 -375914496 440401920 378011648 29360128 -130023424 123731968 -372506624 379584512 -521666560 441712640 70778880 -108265472 -86507520 -417071104 -468451328 346292224 -402391040 -90177536 27262976 30146560 -164888576 129761280 458227712 -458489856 -233832448 256376832 506986496 -206569472 -406585344 -54788096 385613824 -184287232 375914496 -515375104 -330563584 354156544 429916160 -450625536 527958016 141033472 -274989056 -270794752 -71041024 -277872640 -157286400 298319872 31457280 -255590400 140509184 446955520 114032640 514326528 -452460544 -216006656 419692544 38797312 -247463936 -488374272 -7340032 -310116352 -176160768 -237764608 -274464768 104857600 501219328 499646464 482344960 473956352 166199296 -48496640 502792192 203423744 -527171584 -330563584 454033408 325320704 186384384 128188416 -341311488 -400031744 -249561088 161742848 -471072768 192937984 -237502464 -490733568 465043456 141557760 -266076160 -304087040 51642368 -190316544 -20185088 487063552 -361234432 -107741184 -503054336 191102976 290193408 -119013376 -224657408 523763712 58982400 260046848 90439680 44564480 517996544 -310378496 -365428736 386662400 501743616 465305600 465829888 -110886912 226230272 397934592 448266240 113770496 -110362624 -359399424 -322437120 -142606336 -128188416 -411041792 378798080 433848320 -277610496 89391104 -360710144 195559424 331874304 -255328256 -158334976 75235328 148897792 437780480 148635648 -374865920 40370176 72351744 -161480704 -277610496 465567744 201064448 -121372672 -401866752 501743616 -183762944 -122159104 336592896 487849984 435421184 159907840 -142344192 -518782976 -137363456 -111673344 -4718592 -69992448 5242880 -193462272 459800576 396099584 276299776 329515008 135790592 211550208 -318242816 -501481472 -236191744 412614656 309592064 347078656 200278016 498597888 499908608 15990784 214171648 147849216 506986496 -306708480 -236978176 -294387712 101711872 -118751232 193986560 423886848 -91226112 141557760 -57409536 -344719360 293863424 -260046848 332136448 217317376 62390272 -159645696 -57933824 -56098816 192413696 -266600448 -488374272 320602112 383254528 -223870976 135266304 110362624 444596224 230162432 342622208 -79167488 136052736 -480772096 309854208 -7602176 257949696 329515008 -406847488 -246415360 203161600 -414187520 396099584 -389545984 229638144 233046016 505413632 -180355072 258211840 495452160 178782208 344719360 37486592 -397148160 523501568 -434896896 -406585344 -464781312 -82313216 -128188416 61865984 381943808 178257920 -202113024 132382720 -520617984 -292028416 355729408 -147324928 265027584 -111673344 -257163264 17825792 172490752 247726080 -33554432 446693376 227803136 -481558528 141557760 -104595456 -394002432 267911168 131334144 -219938816 432275456 465305600 116391936 -235929600 76546048 116391936 -104857600 267911168 388759552 -86245376 434110464 -76808192 206307328 341573632 57933824 93061120 -144441344 67371008 294649856 357564416 -331874304 341311488 361496576 65011712 432537600 463470592 -450625536 -389283840 -426508288 -101974016 -476577792 -429129728 389545984 505151488 114556928 -434110464 -275775488 -207880192 116391936 -72351744 -317980672 164626432 218103808 259522560 266338304 -186908672 170655744 -174587904 -115605504 91750400 -364380160 287047680 89915392 153354240 344457216 33030144 490733568 -315359232 -485228544 57147392 448004096 -341573632 -248774656 -274464768 109051904 -154664960 -155713536 -207880192 -432799744 -316669952 207880192 -85983232 -229376000 -166985728 225968128 505675776 -157548544 -229113856 -459538432 67108864 230424576 364380160 -143130624 340787200 -123469824 496500736 424673280 -214433792 -159907840 468451328 -427032576 -461373440 -513540096 -262406144 -455868416 461373440 -9699328 252968960 209453056 -422838272 -75497472 -386138112 -327680000 97517568 -488636416 317980672 -502530048 74448896 -356777984 -36438016 31195136 -280231936 -500432896 127926272 -96731136 -26738688 446431232 124780544 -186908672 498860032 -226230272 363593728 -397934592 464519168 397672448 -53215232 -171180032 -515375104 -49807360 -286261248 396623872 -389545984 48496640 -209977344 45088768 482869248 455868416 99614720 -472121344 204734464 -507772928 -125304832 476839936 -7340032 108265472 526909440 -191627264 216268800 -304087040 -343146496 -319815680 135004160 -142868480 41156608 323223552 -171442176 413401088 -519045120 132382720 -4194304 -23068672 489160704 30670848 304349184 416546816 -377225216 -454819840 138412032 352059392 -271056896 -464519168 195559424 55050240 515375104 120586240 -372768768 -172752896 -379846656 -467927040 300154880 56360960 133169152 -41418752 3407872 -69206016 -78643200 405274624 -1048576 -73662464 -121634816 418906112 331612160 -233832448 224395264 483393536 318504960 29360128 508297216 -365166592 -334495744 248774656 381419520 445906944 439353344 108789760 532938752 98304000 -430702592 -494665728 94633984 216006656 -32768000 -172752896 216793088 410779648 473956352 124518400 -308543488 -24903680 508297216 -310378496 494927872 -458752000 146800640 -411828224 -440926208 119013376 -163577856 -216268800 -306446336 492044288 109838336 -170393600 -304873472 -120324096 425459712 130023424 -352583680 -279969792 338165760 -531628032 411828224 312737792 -16515072 -372244480 512753664 -85983232 314048512 -164102144 -534249472 53739520 329777152 -388497408 318504960 469762048 214958080 -385613824 -473956352 -205520896 -343408640 275251200 -326631424 141819904 -46661632 -417333248 -306184192 -267911168 94109696 186908672 231473152 -67108864 -95158272 11534336 186908672 -79429632 -189267968 -500695040 -136052736 61603840 -362283008 329777152 429391872 182714368 294387712 -270532608 334495744 -232783872 -127664128 -498335744 -405798912 -408420352 -279707648 94109696 -65798144 35913728 149946368 -138936320 268435456 407371776 -432275456 77332480 -20185088 -179568640 442761216 -505413632 527171584 445644800 32768000 -205258752 456130560 270008320 341573632 272367616 -58195968 395313152 -242483200 -92012544 -144965632 103022592 -323223552 -315883520 478412800 292552704 197656576 312999936 -135266304 -26476544 -529793024 23068672 16777216 72613888 195559424 194248704 -46661632 -338427904 481296384 -367001600 -290979840 -282853376 101187584 -449576960 -18874368 449314816 -76808192 -468713472 159907840 -330563584 -482344960 -317194240 -325320704 97517568 -44826624 -249298944 -292028416 -449314816 379060224 -407109632 403701760 -350224384 -73662464 -160694272 -87556096 321126400 128188416 -413138944 -286785536 198967296 -168820736 293863424 -523239424 369098752 -271056896 -189792256 37224448 -481034240 266076160 -349700096 -49020928 -284164096 -274202624 -269221888 -420741120 -505675776 -434896896 502530048 -293601280 -162529280 -342884352 -228851712 -391905280 -76808192 128712704 -94633984 320602112 -96993280 -335806464 115343360 343408640 -478937088 -122683392 -118489088 -304873472 -435945472 405012480 -213385216 101974016 -433586176 130285568 357564416 -126877696 239075328 229900288 -80478208 -208404480 395575296 246677504 304349184 -338952192 446693376 -78643200 -150208512 465567744 -163840000 355467264 338165760 66060288 -94633984 -115605504 -484179968 -44564480 263716864 523239424 -85196800 -378535936 -287309824 500170752 -38535168 289669120 -385875968 -454295552 -140247040 276299776 504102912 -292028416 -284164096 494141440 -444858368 289144832 -158597120 467140608 -511967232 437518336 472383488 338427904 -429129728 193724416 -131596288 -120324096 305659904 -106692608 296222720 -322174976 -464781312 -484704256 -159645696 503054336 111411200 292028416 249298944 -22282240 109838336 -464257024 -277610496 -194510848 348651520 -529530880 230686720 -475529216 -155713536 227016704 241434624 487325696 480247808 68419584 420216832 -531103744 292814848 -113770496 324272128 445120512 -125566976 -190840832 -456392704 -245366784 -182714368 -338165760 177471488 -479461376 -212860928 60555264 199491584 36700160 379060224 333447168 -319553536 184025088 503840768 444596224 394788864 -147587072 -38273024 527433728 -456130560 -300154880 58720256 -301203456 97255424 430702592 293863424 222035968 68419584 -247201792 492568576 -295698432 150208512 183500800 -355467264 -386138112 504102912 -115605504 403177472 -461635584 -2359296 480772096 -432013312 -62390272 110362624 95420416 -115343360 402391040 -345243648 -299106304 517734400 107479040 44302336 -472645632 8650752 78381056 -78905344 -135004160 295174144 426246144 -250871808 -110624768 142344192 393740288 -343932928 -395575296 -316145664 407109632 32505856 -94371840 -488374272 34865152 -4980736 -440664064 481296384 -472645632 167247872 85983232 -34340864 -247726080 -252182528 304349184 230162432 -430178304 489947136 -455606272 -512753664 247726080 -406847488 -437256192 221249536 262144000 364380160 444334080
However, checking the out shows the following at the end,
Two questions I have --
  1. I was expecting signed 12-bit output as I set the OutputWordLength=12. However, out is much larger than 12-bit range. Why this happened. Not sure I was missing something. How could I fix this?
  2. FractionLength is a negative value (-18). Can this be 0 as I wanted to see signed 12-bit? How could I compare this out with the values from the real RTL implementation?

Accepted Answer

Andy Bartlett
Andy Bartlett on 11 Dec 2023
Edited: Andy Bartlett on 12 Dec 2023
In the documentation for CIC Decimator, take a look at the algorithm section.
In that section, take a look at Gain Correction and Output Data Type subsections.
Those sections explain that the block will amplify the input signal by an effective gain value Gain.
In your example, the Gain is as follows.
R_decimation_factor = 20;
M_differential_delay = 1;
N_number_of_sections = 4;
Gain = (R_decimation_factor * M_differential_delay)^N_number_of_sections
Gain = 160000
A fixed-point representation of that gain would use 18 bits.
GainFi = fi( Gain, 0, ceil(log2(Gain)), 0)
GainFi =
160000 DataTypeMode: Fixed-point: binary point scaling Signedness: Unsigned WordLength: 18 FractionLength: 0
So given your 12 bit integer valued input, a full precision output would be 30 bits.
inExample = upperbound(numerictype(1,12,0));
yFullPrecisionExample = inExample * GainFi
yFullPrecisionExample =
327520000 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 30 FractionLength: 0
You've requested that the output be only 12 bits. So the block must throw away 18 bits from the 30 bits that the full precision output would have. The block is design to throw those bits away from the least significant end which reduces precision, but avoids overflows.
nty = numerictype(1,12,-18 );
yExample = removefimath( fi( yFullPrecisionExample, nty, 'RoundingMethod','Floor') )
yExample =
327417856 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 12 FractionLength: -18
For this specific example, dropping the least significant 18 bits
% Type Real World Notation: Integer Mantissa
% Value and Pow2 Exponent
% numerictype(1,30,0) 327520000 = 010011100001011000111100000000 * 2^0
% numerictype(1,12,-18) 327417856 = 010011100001 * 2^18
Dropping the least significant 18 bits produces a relatively modest error for this specific example.
absoluteError = abs( double( yExample ) - double( yFullPrecisionExample ) )
absoluteError = 102144
relativeErr = absoluteError / double( yFullPrecisionExample )
relativeErr = 3.1187e-04
errorInParts = ceil(1/relativeErr)
errorInParts = 3207
The output is accurate to 1 part in 3207, which is in the vicinity of what would be expected for a signed 12 bits fixed point type if well scaled.
Compare using Stored Integer Value and/or Real-World Value
Fixed-point signals always have two values.
For binary-point types as being discussed here, the Fixed-Point Scaling Equation is
V = Q * 2^-FractionLength
where
V is the Real-World Value (RWV) in units prefered by the human engineers
Q is the Stored-Integer (SI) value
When modeling, it is usally far easier to work with Real-World Values (RWV). Fixed-Point Designer works with the real-world values by default. Designer automatically manages all the book keeping related to scaling and storage data types.
The actual embedded implementation produced by Coders will efficiently operate on the stored integers (SI) to produce the high level math desired by the engineers.
When using generic tools on the embedded device such as target debuggers, signals will typically be shown using the stored integer values.
When values for a signal being tested or examined are provided in both real-world value form and stored-integer value form, naturally, it is necessary convert in either direction, SI to RWV or RWV to SI.
Convert RWV to SI
Given a fixed-point fi object produce it's stored integer value.
si_approach_1 = yExample.storedInteger
si_approach_1 = int16 1249
si_approach_2 = yExample.storedIntegerToDouble
si_approach_2 = 1249
si_approach_3 = stripscaling(yExample)
si_approach_3 =
1249 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 12 FractionLength: 0
Notice that si_approach_3 is a fi object with trivial scaling (FractionLength == 0). With trivial scaling, RWV == SI.
Convert SI to RWV
Given a stored integer value and knowledge of the scaling to be applied, it is straightforward to produce a scaled fixed-point fi object or a double holding the real-world value.
RWV in double
si_from_target = int16(1518)
si_from_target = int16 1518
rwv1_in_double = double(si_from_target) * yExample.Slope % Note: Slope = 2^-FractionLength
rwv1_in_double = 397934592
Apply scaling knowledge to a raw SI to create a fixed-point fi object.
Reinterpcast is the key tool to use to apply the scaling information, but preserve the stored integer value.
si_in_raw_fi = fi( si_from_target, 1, 12, 0 )
si_in_raw_fi =
1518 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 12 FractionLength: 0
nty = numerictype( yExample )
nty = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 12 FractionLength: -18
rwv2_in_fi = reinterpretcast( si_in_raw_fi, nty)
rwv2_in_fi =
397934592 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 12 FractionLength: -18
check_si_still_same = rwv2_in_fi.storedIntegerToDouble
check_si_still_same = 1518
  3 Comments
Jay
Jay on 11 Dec 2023
Edited: Jay on 11 Dec 2023
One minor question is the Gain in your code. In MATLAB document, the Gain term is given by (R x M)^N, e.g., the product of R and M, while it was written by (R + M)^N in your example, e.g., the sum of R and M. I assume this is a typo while it doesn't change the number of bits to represent a fixed-point number?
R_decimation_factor = 20;
M_differential_delay = 1;
N_number_of_sections = 4;
Gain = (R_decimation_factor + M_differential_delay)^N_number_of_sections
Gain = 194481
Andy Bartlett
Andy Bartlett on 12 Dec 2023
Hi Jay,
Good catch. You are correct. The formula should be multiply and not add. I updated the answer. Numbers are a bit different, but the overall message of needing to drop 18 LS bits from the ideal 30 bits to get down to 12 is the same.

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!