Changeset 3623


Ignore:
Timestamp:
Mar 25, 2013, 11:36:14 PM (21 months ago)
Author:
wmb
Message:

OLPC XO-4 - improved the reliability of the audio test:
a) Instead of the real random number generator, use a LFSR-based PRNG,

with a polynomial that happens to give a good spectrum for acoustic
testing with OLPC speakers. In addition to working around a unit-
dependent problem with the MMP3's hardware RNG, this also speeds up
the test because the LFSR is faster than the hardware RNG.

b) Store 16-bit "random" values in the audio buffer instead of using

32-bit random numbers and hoping that the top and bottom halves
are uncorrelated. This seems to give better decorrelation of left
and right signals.

c) Hard-reset the audio subsystem by powering off/on the audio island

between the acoustic and loopback tests, thus making the loopback
test more repeatable.

Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/olpc/build-fw.fth

    r3585 r3623  
    741741 
    742742fload ${BP}/cpu/arm/saverom.fth  \ Save the dictionary for standalone startup 
     743 
     744fload ${BP}/forth/lib/lfsr.fth 
     7450 value lfsr-state 
     746: init-audio-noise  ( -- ) 
     747   random-long to lfsr-state 
     748   \ Use a polynomial with a 32-bit period 
     749   lfsr-polynomials d# 32 na+ @ to lfsr-poly 
     750; 
     751: audio-noise  ( -- n )  lfsr-state lfsr-step dup to lfsr-state  ; 
    743752 
    744753fload ${BP}/dev/hdaudio/noiseburst.fth  \ audio-test support package 
  • cpu/arm/olpc/sound.fth

    r3532 r3623  
    183183   false 
    184184; 
     185\ This is a grotesque workaround for a hardware problem.  The audio 
     186\ subsystem (SSPA + ADMA) works reasonably reliably right after the 
     187\ audio island is powered on, but subsequent tries tend to get 
     188\ confused about which channel is which, and possibly about the 
     189\ initial SSPA FIFO contents.  Resetting between test phases makes 
     190\ the test work more reliably.  Attempts to get help from the vendor, 
     191\ over a long period of time, were unsuccessful. 
     192: reset-audio  ( -- )  audio-clock-off  d# 50 ms audio-clock-on drop  ; 
    185193 
    186194: reset-rx  ( -- )  h# 8000.0002 h# 0c sspa!  ; 
  • cpu/x86/pc/olpc/via/fw.bth

    r3618 r3623  
    480480 
    481481fload ${BP}/cpu/x86/pc/olpc/via/padlock.fth   \ Via security engine 
     482alias init-audio-noise noop 
     483alias audio-noise random-long 
    482484fload ${BP}/dev/hdaudio/noiseburst.fth  \ audio-test support package 
    483485 
  • dev/hdaudio/noiseburst.fth

    r3424 r3623  
    621621 
    622622: prepare-signal  ( -- out-adr, len in-adr,len ) 
     623   init-audio-noise 
     624   \ Doing the noise 16 bits at a time does a better job 
     625   \ of decorrelating the channels compared to storing 
     626   \ a 32-bit "random" number 
    623627[ifdef] debug-analyzer? 
    624628   debug-analyzer?  if 
    625629      pb /pb  d# 1000  d# 48000 make-2tones 
    626630   else 
    627       pb /pb bounds  do  random-long  i l!  /l +loop 
     631      pb /pb bounds  do  audio-noise  i w!  /w +loop 
    628632   then 
    629633[else] 
    630    pb /pb bounds  do  random-long  i l!  /l +loop 
     634   pb /pb bounds  do  audio-noise  i w!  /w +loop 
    631635[then] 
    632636   pb      /pb -stereo-wmean 
  • dev/hdaudio/test.fth

    r3450 r3623  
    228228   analysis-parameters " set-analysis-parameters" $call-analyzer 
    229229   acoustic-test 
     230   [ifdef] reset-audio reset-audio [then] 
    230231   loopback-test 
    231232; 
  • forth/lib/lfsr.fth

    r2377 r3623  
    22purpose: Linear feedback shift register code and related memory tests 
    33 
    4 0 value lfsr-state 
    5  
    640 value lfsr-poly 
    7 : lfsr-step  ( state -- state' ) 
    8    dup 2/  swap 1 and  if  lfsr-poly xor  then 
    9 ;    
    105 
    116[ifdef] arm-assembler 
     
    1813   then 
    1914c; 
    20 code lfsr-fill ( adr seed polynomial -- adr' ) 
    21    \ tos:polynomial 
    22    ldmia  sp!,{r0,r1}   \ r0:seed r1:adr 
    23    mov  r2,r0           \ r2:lfsr 
    24    begin 
    25       str   r2,[r1],#4 
    26       movs  r2,r2,lsr #1 
    27       eorcs r2,r2,tos 
    28       cmp   r2,r0 
    29    = until 
    30    mov tos,r1 
    31 c; 
    32 code random-fill  ( adr len data index polynomial -- ) 
    33    ldmia sp!,{r1,r2,r3,r4}  \ tos:poly r1:index r2:data r3:len r4:adr 
    34  
    35    movs  r3,r3,lsr #2    \ Convert to longword count 
    36    nxteq 
    37  
    38    sub   r0,r3,#1         \ r0:remaining count 
    39     
    40    \ r3:address-lfsr r4:data-lfsr r5:data-poly 
    41    set r5,#0x80200003  \ 32-bit polynomial 
    42  
    43    begin 
    44       \ Compute new data value with an LFSR step 
    45       movs  r2,r2,lsr #1 
    46       eorcs r2,r2,r5 
    47  
    48       \ Compute new address index, discarding values >= len 
    49       begin 
    50          movs  r1,r1,lsr #1 
    51          eorcs r1,r1,tos 
    52          cmp   r1,r3 
    53       u< until 
    54  
    55       \ Write the "random" value to the "random" address (adr[index]) 
    56       str  r2,[r4,r1,lsl #2] 
    57  
    58       decs  r0,#1 
    59    0= until    
    60  
    61    pop tos,sp 
    62 c; 
    63 code random-check  ( adr len data index remain polynomial -- false | adr len data index remain true ) 
    64    ldmia sp!,{r0,r1,r2,r3,r4}  \ tos:poly r0:remain  r1:index r2:data r3:len r4:adr 
    65  
    66    cmp     r0,#0 
    67    moveq   tos,#0  \ Return false 
    68    nxteq 
    69  
    70    mov   r7,r3,lsr #2    \ Convert to longword count 
    71  
    72    set r5,#0x80200003  \ 32-bit polynomial 
    73  
    74    begin 
    75       \ Compute new data value with an LFSR step 
    76       movs  r2,r2,lsr #1 
    77       eorcs r2,r2,r5 
    78  
    79       \ Compute new address index, discarding values >= len 
    80       begin 
    81          movs  r1,r1,lsr #1 
    82          eorcs r1,r1,tos 
    83          cmp   r1,r7 
    84       u< until 
    85  
    86       \ Read the value at the "random" address (adr[index]) 
    87       ldr  r6,[r4,r1,lsl #2] 
    88  
    89       \ Compare it to the calculated value 
    90       cmp  r6,r2 
    91  
    92       decne   r0,#1 
    93       stmnedb sp!,{r0,r1,r2,r3,r4}  \ Push results 
    94       mvnne   tos,#0    \ True on top of stack 
    95       nxtne 
    96  
    97       decs  r0,#1 
    98    0= until    
    99  
    100    mov tos,#0 
    101 c; 
    102 [then] 
    103150 [if]  \ This is for testing the period of various polynomials 
    10416code lfsr-period  ( polynomial -- period ) 
     
    12840c; 
    12941[then] 
     42[ifndef] lfsr-step 
     43: lfsr-step  ( state -- state' ) 
     44   dup 2/  swap 1 and  if  lfsr-poly xor  then 
     45;    
     46[then] 
    13047 
    131480 [if] 
     
    14764\ The values come from the Wikipedia article for Linear Feedback Shift Register and from 
    14865\ http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf 
    149 create polynomials \ #bits   period 
     66create lfsr-polynomials 
     67                   \ #bits   period 
    15068h#        0 ,      \     0        0 
    15169h#        1 ,      \     1        1 
     
    182100h# 80200003 ,      \    32 ffffffff 
    183101 
    184 : round-up-log2  ( n -- log2 ) 
    185    dup log2              ( n log2 ) 
    186    tuck  1 swap lshift   ( log2 n 2^log2 ) 
    187    > -                   ( log2' ) 
    188 ; 
    189  
    190 defer .lfsr-mem-error 
    191 : (.lfsr-mem-error)  ( adr len data index remain -- adr len data index remain ) 
    192    push-hex 
    193    ." Error at address "  4 pick  2 pick la+  dup 8 u.r  ( adr len data index remain err-adr ) 
    194    ."  - expected " 3 pick 8 u.r  ( adr len data index remain err-adr ) 
    195    ."  got " l@ 8 u.r cr 
    196    pop-base 
    197 ; 
    198 ' (.lfsr-mem-error) to .lfsr-mem-error 
    199 : random-test  ( adr len -- ) 
    200    dup /l <=  if  2drop exit  then ( adr len #bits ) 
    201    dup /l / round-up-log2          ( adr len #bits ) 
    202    polynomials swap la+ l@         ( adr len polynomial ) 
    203  
    204    3dup 1 1 rot random-fill        ( adr len polynomial ) 
    205  
    206    >r                              ( adr len  r: polynomial ) 
    207    1 1  third /l / 1-              ( adr len data index remain  r: polynomial ) 
    208    begin                           ( adr len data index remain  r: polynomial ) 
    209       r@ random-check              ( false | adr len data index remain true  r: polynomial ) 
    210    while                           ( adr len data index remain  r: polynomial ) 
    211       .lfsr-mem-error              ( adr len data index remain  r: polynomial ) 
    212    repeat                          ( r: polynomial ) 
    213    r> drop 
    214 ; 
    215  
    216102\ LICENSE_BEGIN 
    217103\ Copyright (c) 2010 FirmWorks 
Note: See TracChangeset for help on using the changeset viewer.