#Logic Gates Routines $t=0; $a=0; LAB: { if($gate[$t] eq "INV") { $mystring= @raw_data[$a]; OUTER: while($mystring =~ m/(\d+)/g) { print "\r\n"; push (@new, $1); } print "\r\n"; print @new; print " rerwerwe \r\n"; $inp=$new[0]; $out=$new[1]; print "\r\n"; print $net[$out-1]; print "\r\n"; print "$out \r\n"; if ($net[$inp-1] eq "1") { @net[$out-1]=0; $gate[$t]=0; $t++; print "fef"; last LAB; } elsif ($net[$inp-1] eq "0") { $net[$out-1]=1; $gate[$t]=0; $t++; last LAB; } else { $t++; last LAB; } } if($gate[$t] eq "BUF") { $mystring= @raw_data[$a]; OUTER: while($mystring =~ m/(\d+)/g) { print "\r\n"; push (@new, $1); } print @new; print "\r\n"; $inp=$new[0]; $out=$new[1]; if ($net[$inp-1] eq "1") { $net[$out-1]=1; $gate[$t]=0; $t++; last LAB; } elsif ($net[$inp-1] eq "0") { $net[$out-1]=0; $gate[$t]=0; $t++; last LAB; } else { $t++; last LAB; } } if($gate[$t] eq "AND") { $mystring= @raw_data[$a]; OUTER: while($mystring =~ m/(\d+)/g) { print "\r\n"; push (@new, $1); } print @new; print "\r\n"; $inp1=$new[0]; $inp2=$new[1]; $out=$new[2]; print $net[$inp1-1]; $new=$net[$inp1-1]; $new1=$net[$inp2-1]; $new2=$net[$out-1]; print "\r\n"; print $net[$inp2-1]; print "\r\n"; if($new == 1) { if($new1 ==1) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; print "fesf"; last LAB; } elsif($new1 ==0) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; print "g"; last LAB; } } if(($new) or ($new1) == 0) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } else { print "fersf"; } } if($gate[$t] eq "NAND") { $mystring= @raw_data[$a]; OUTER: while($mystring =~ m/(\d+)/g) { print "\r\n"; push (@new, $1); } print @new; print "\r\n"; $inp1=$new[0]; $inp2=$new[1]; $out=$new[2]; print $net[$inp1-1]; $new=$net[$inp1-1]; $new1=$net[$inp2-1]; $new2=$net[$out-1]; print "\r\n"; print $net[$inp2-1]; print "\r\n"; if($new == 1) { if($new1 ==1) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; print "fesf"; last LAB; } elsif($new1 ==0) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; print "g"; last LAB; } } if(($new) or ($new1) == 0) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } else { $t++; last LAB; } } if($gate[$t] eq "OR") { $mystring= @raw_data[$a]; OUTER: while($mystring =~ m/(\d+)/g) { print "\r\n"; push (@new, $1); } print @new; print "\r\n"; $inp1=$new[0]; $inp2=$new[1]; $out=$new[2]; print $net[$inp1-1]; $new=$net[$inp1-1]; $new1=$net[$inp2-1]; $new2=$net[$out-1]; print "\r\n"; print $net[$inp2-1]; print "\r\n"; if(($new)== 1) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } elsif(($new1)== 1) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } elsif(($new) == 0) { if(($new1) == 0) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } elsif(($new1) == 1) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } } else { $t++; last LAB; } } if($gate[$t] eq "NOR") { $mystring= @raw_data[$a]; OUTER: while($mystring =~ m/(\d+)/g) { print "\r\n"; push (@new, $1); } print @new; print "\r\n"; $inp1=$new[0]; $inp2=$new[1]; $out=$new[2]; print $net[$inp1-1]; $new=$net[$inp1-1]; $new1=$net[$inp2-1]; $new2=$net[$out-1]; print "\r\n"; print $net[$inp2-1]; print "\r\n"; if(($new)== 1) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } elsif(($new1)== 1) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } elsif(($new) == 0) { if(($new1) == 0) { $net[$out-1]=1; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } elsif(($new1) == 1) { $net[$out-1]=0; print $net[$out-1]; $gate[$t]=0; $t++; last LAB; } } else { $t++; last LAB; } } } print "@net \r\n"; print "@gate \r\n"; exit 0;