Hello monks. I am currently stuck with my code.
Shown above is a snippet of my program. After I'm done with pushing the values into array @CCO_value_1, I want to find the max value between those three values. However, I want to display the max value as well as the wire name that holds the value. Is it possible?for $gate (@gates) { if (grep { $gate->{gate_level} eq '1' } @gates) { push @level_1_output, $gate->{output}->{wire_name}; %hash1 = ( $gate->{input_1}->{wire_name} => { CC0 => 1, CC1 => 1} + ); %hash2 = ( $gate->{input_2}->{wire_name} => { CC0 => 1, CC1 => 1} + ); %hash3 = ( $gate->{output}->{wire_name} => { CC0 => 0, CC1 => 0} +); print "CC0[", $gate->{input_1}->{wire_name},"]= ", $hash1{$gate-> +{input_1}->{wire_name}}{CC0}, "\n"; print "CC1[", $gate->{input_1}->{wire_name},"]= ", $hash1{$gate-> +{input_1}->{wire_name}}{CC1}, "\n\n"; print "CC0[", $gate->{input_2}->{wire_name},"]= ", $hash2{$gate-> +{input_2}->{wire_name}}{CC0}, "\n"; print "CC1[", $gate->{input_2}->{wire_name},"]= ", $hash2{$gate-> +{input_2}->{wire_name}}{CC1}, "\n\n"; if (grep { $gate->{gate_type} eq 'nand' } @gates) { $hash3{$gate->{output}->{wire_name}}{CC0} = $hash1{$gate->{inpu +t_1}->{wire_name}}{CC1} + $hash2{$gate->{input_2}->{wire_name}}{CC1} ++ 1; $hash3{$gate->{output}->{wire_name}}{CC1} = min($hash1{$gate->{ +input_1}->{wire_name}}{CC0} , $hash2{$gate->{input_2}->{wire_name}}{C +C0}) + 1; } print "CC0[", $gate->{output}->{wire_name},"]= ", $hash3{$gate->{ +output}->{wire_name}}{CC0}, "\n"; print "CC1[", $gate->{output}->{wire_name},"]= ", $hash3{$gate->{ +output}->{wire_name}}{CC1}, "\n\n"; $level_2_inputCC0 = $hash3{$gate->{output}->{wire_name}}{CC0}; $level_2_inputCC1 = $hash3{$gate->{output}->{wire_name}}{CC1}; push @CC0_value_1, $hash1{$gate->{input_1}->{wire_name}}{CC0}, $h +ash2{$gate->{input_2}->{wire_name}}{CC0}, $hash3{$gate->{output}->{wi +re_name}}{CC0}; push @CC1_value_1, $hash3{$gate->{output}->{wire_name}}{CC1}; $max_CC0_1 = max @CC0_value_1; print "$max_CC0_1\n"; } }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |