/***************************** compare.lib *****************************/ component { in opd1, opd2 } compareBit { out less, equal, greater } begin path notOpd1, notOpd2; { in opd1 } not( 1 ) { out notOpd1 }; { in opd2 } not( 1 ) { out notOpd2 }; { in notOpd1 opd2 } and( 2 ) { out less }; { in opd1 opd2 } xor( 2 ).not( 1 ) { out equal }; { in notOpd2 opd1 } and( 2 ) { out greater }; end component { in opd1[ n ], opd2[ n ] } compare( n ) { out less, equal, greater } begin if n == 1 then { in opd1[ 0 ], opd2[ 0 ] } compareBit { out less, equal, greater }; else path lessLow, equalLow, greaterLow; path lessHigh, equalHigh, greaterHigh; path less1, greater1; { in opd1[ n / 2 @ 0 ], opd2[ n / 2 @ 0 ] } compare( n / 2 ) { out lessLow, equalLow, greaterLow }; { in opd1[ n - n / 2 @ n / 2 ], opd2[ n - n / 2 @ n / 2 ] } compare( n - n / 2 ) { out lessHigh, equalHigh, greaterHigh }; { in equalHigh lessLow } and( 2 ) { out less1 }; { in equalHigh greaterLow } and( 2 ) { out greater1 }; { in lessHigh less1 } or( 2 ) { out less }; { in equalHigh equalLow } and( 2 ) { out equal }; { in greaterHigh greater1 } or( 2 ) { out greater }; end end