inverter


comment
========================================

	Probability Inverter

	po = 1-pi
	pige hi if pi >= .5
	pilt hi if pi < .5

             ATtiny45
              --v--
    rst pb5 -|     |- vcc
     pi pb3 -|     |- pb2 sck  pige
     po pb4 -|     |- pb1 miso pilt
        gnd -|     |- pb0 mosi scope
              ----- 
               1MHz    

========================================

( po = 1-pi )
: invert byin byout MOV COM ;

( pige hi if pi >= .5
  pilt hi if pi < .5 )
: out-hi { pb2 hi! pb1 lo! } ;
: out-lo { pb2 lo! pb1 hi! } ;
: out out-hi out-lo 128 temp byin CP >=? if-else ;

( scope )
: scope pb0 hi! lo! ;

( main loop )
: wait 60 msec delay ;
: loop { invert out scope wait } repeat ;

( factor out setup )
: on dup setup-ddrb swap dup setup-bynase swap merge merge ; 

1 mhz clock
loop on reset

 

Last edited November 24, 2017
Return to WelcomeVisitors