ravimartha has asked for the wisdom of the Perl Monks concerning the following question:

Dear Sir, I am trying to convert some combinational verilog files in to some expressions. for example: a,b are the inputs. sum,carry are the outputs.
################################# always @ (a or b ) begin case({a,b}) 2'b00 : begin sum = 1'b0; carry = 1'b0; end 2'b01 : begin sum = 1'b1; carry = 1'b0; end 2'b10 : begin sum = 1'b1; carry = 1'b0; end 2'b11 : begin sum = 1'b0; carry = 1'b1; end endcase end ##################################
for this how can i convert the above block to
sum = (a(~b))&((~a)b) carry = a&b
using perl. are there any packages to solve this problem

Replies are listed 'Best First'.
Re: Coverting Case statements of verilog to equations.
by toolic (Bishop) on Apr 02, 2012 at 17:07 UTC
    You can use Verilog-Perl to parse the Verilog source code (as I mentioned in a previous post), but I think you need to do the rest yourself.
Re: Coverting Case statements of verilog to equations.
by jandrew (Chaplain) on Apr 02, 2012 at 18:54 UTC

    There is an RPN calculator example in Dominus's++ book Higher order perl chapter 2 section 2 that may be useful to you once you have parsed the file. It's not a module but you probably don't need one just to do math.

Re: Coverting Case statements of verilog to equations.
by roboticus (Chancellor) on Apr 02, 2012 at 23:33 UTC

    ravimartha:

    I think I'd process it into a set of Karnaugh maps (one per output variable). From there, it's relatively straightforward to create expressions. Your biggest problem might be parsing the verilog.

    Update: Repaired link.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.