# version = 1.02 of atchange-computer 2001 Oct 29 # this is an atchange script, see: # http://www.lecb.ncifcrf.gov/~toms/atchange.html # Dr. Thomas D. Schneider # National Cancer Institute # Laboratory of Experimental and Computational Biology # Frederick, Maryland 21702-1201 # toms@ncifcrf.gov # permanent email: toms@alum.mit.edu # http://www.lecb.ncifcrf.gov/~toms/ # purpose: Demonstrate that atchange, with shell script if # can simulate boolean logic circuits. # There are 5 boolean variables, a, b, c, d and e. # There are three nodes, node1, node2 and node 3 # node1 is programed as c = a+b (OR function) # node2 is programed as d = a*b (AND function) # node3 is programed as e = ~d (NAND function) # touch reset to set up the booleans and nodes reset echo 0 > a echo 0 > b echo 0 > c echo 0 > d echo 0 > e echo 0 > node1 echo 0 > node2 echo 0 > node3 echo 'result node' > result echo 'listing node' > listing a if (`cat a` == 1) then echo a is 1 else echo a is 0 endif touch node1 touch node2 b if (`cat b` == 1) then echo b is 1 else echo b is 0 endif touch node1 touch node2 c if (`cat c` == 1) then echo c is 1 else echo c is 0 endif touch result d if (`cat d` == 1) then echo d is 1 else echo d is 0 endif touch node3 touch result e if (`cat e` == 1) then echo e is 1 else echo e is 0 endif touch result node1 if ((`cat a` == 1)||((`cat b`) == 1)) then echo '1' > c else echo '0' > c endif node2 if ((`cat a` == 1)&&((`cat b`) == 1)) then echo '1' > d else echo '0' > d endif node3 if (`cat d` == 0) then # pause to allow settling sleep 2 echo '1' > e else # pause to allow settling sleep 2 echo '0' > e endif result printf "|---------|\n" > listing printf "| a = %s --|\n" `cat a` >> listing printf "| b = %s --|\n" `cat b` >> listing printf "| c = %s --| a+b \n" `cat c` >> listing printf "| d = %s --| a*b \n" `cat d` >> listing printf "| e = %s --| ~d \n" `cat e` >> listing printf "|---------|\n" >> listing cat listing