home *** CD-ROM | disk | FTP | other *** search
- /* Digital Logic, by an idea of Toffoli, in CAMRexx by THOR */
-
-
- MakeAlgorithm:
- if plane=0 then
- PLANEALGORITHM margolus hvphases
- if plane=1 then
- PLANEALGORITHM echo center1
- return
-
- MakePlane:
- if plane=0 then; do /* calculate "electrons" */
- wires=center_+cw_+ccw_+opp_ /* # of wires in plane 1 */
-
- if center_ then; do /* Wire present here ? */
- select
- when wires=0 then
- SETPLANE off /* remove electron */
- when wires=1 then; do
- new=opp | cw | ccw /* Origin nearby ? */
- SETPLANE new /* move electron to this wire */
- end
- when wires=2 then; do
- /* fetch incoming signal */
- if opp_ then signal=opp
- if cw_ then signal=cw
- if ccw_ then signal=ccw
- if cw_ | ccw_ then
- signal=signal^opp
- SETPLANE signal
- end
- when wires=3 then; do
- i=1 /* read incoming signals */
- if opp_ then; do
- signal.i=opp
- i=i+1
- end
- if cw_ then; do
- signal.i=cw
- i=i+1
- end
- if ccw_ then; do
- signal.i=ccw
- i=i+1
- end
- /* get logic control... */
- if opp_=0 then
- control=opp
- if cw_=0 then
- control=cw
- if ccw_=0 then
- control=ccw
-
- if control then
- new=signal.1 & signal.2
- else
- new=signal.1 | signal.2
- SETPLANE new
- end
- when wires=4 then
- SETPLANE opp /* crossing */
- end
- end; else
- SETPLANE center /* preserve switches */
- end
- return
-
-