Hi Monks, I am writing a perl program to parse a verilog file for case statements. Once this is done, I am checking that all cases have been covered(we don't allow falling into default in our hardware design). But, the way I think is very C like(forgive me), and the code below can take a very long time to execute for large values of current_size, since the for loops are nested. Please help me reduce the execution time of this code.
for $j (0..((2**$current_size) - 1)) { $found = 0; @final_values = split(/[\s|\t]+/, $current_case); foreach $statement (@final_values) { if (bintodec($statement) == $j) {$found = 1;} } if (!$found){$missed_one = 1;} }
current_size is the number of bits, and current_case is a space separated string containing all of the case values in binary format. Thanks in advance for your help!

In reply to Comparison effeciency by flounder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.