Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: verilog perl usage

by mahurshi (Initiate)
on Mar 14, 2009 at 05:43 UTC ( #750574=note: print w/ replies, xml ) Need Help??


in reply to Re: verilog perl usage
in thread verilog perl usage

Excellent example. Could you also show an example of how to identify the ports of the module, what blocks are instantiated in it, what ports those blocks have, and what they're connected to.. If you could show me one or two examples, or perhaps, point me to a website with such examples, that would be great. I am currently parsing files manually but would love to switch to using Verilog::Perl if it makes things simpler. My goal is to be able to access ports of the module, identify all the instantiations of other blocks in a module, find out what ports are present in those instantations for each block, and what wires they are connected to. I am currently stuck with parsing the files manually and building hash tables to get this info but would love to switch to this package and get rid of my buggy parsing subroutines.


Comment on Re^2: verilog perl usage
Re^3: verilog perl usage (Verilog::Netlist)
by toolic (Chancellor) on Mar 15, 2009 at 01:31 UTC
    would love to switch to this package and get rid of my buggy parsing subroutines.
    You are a wise monk, indeed. I have also come to realize that parsing Verilog is not a trivial matter. Every time I get the urge to do so, I take a step back and ask myself these questions:
    1. Can any of the tools for which my $company pays millions of dollars per annum already do what I need?
    2. Are there any free tools available out on the 'net which can do what I need?

    If the answer to the above is "no", then I turn to Perl.

    would love to switch to using Verilog::Perl if it makes things simpler
    Since I have not used these tools, I can not comment on their capabilities or limitations. However, according to the documentation, they seem quite useful. I think it is well worth a try.
    point me to a website with such examples
    I have done some searching, but I have not found any examples. I encourage you to give it a try, and report back here if you discover anything. CPAN modules usually have an "examples" directory in the install area. Have you looked there?
    Could you also show an example of how to identify the ports of the module, what blocks are instantiated in it, what ports those blocks have, and what they're connected to
    Sure. This is my first program using Verilog::Netlist (see also Re^3: verilog-perl vhier usage). I merely adapted the EXAMPLE given in the POD on CPAN. My Verilog example code is extremely simple. I can not guarantee it will work for whatever code you have. But, give it a try.

    May I ask what you plan to do with the parsed output?

      Thanks a lot again for your second example. This is really along the lines of what I am expecting out of the parser. What I want to do (eventually) with the parsing really depends on how much I am able to do with it :-). At the very minimum, I would like to identify the instantiations, port names, widths, connections, etc to do various kinds of post processing. Coming back to the piece of code you posted: I was able to get it to work by commenting out the exit_if_error() part. I have to admit first that I still need to spend some time to learn what each of these function calls really mean. Here is the example code I tried to test it with:
      cat top.v module top (a, b, c, d); input a; input b; output c; output d; inverter i_inverter (.in_a(a), .out_c(c)); buffer i_buffer (.in_b(b), .out_d(d)); endmodule
      Granted, this is not much, but this is enough for a starter like me :-) What I didn't give the script were the module definitions of "inverter" and "buffer" modules. I still expected it to at least write out the instantiation names and their port connections. I agree with the error messages below from the scripts output, but I don't understand why doesn't show the instantiation names. Why doesn't it associate the pin names (in_*, out_*) to the instantiation names? Does it absolutely require module references for that?
      %Error: top.v:10: Cannot find buffer %Error: top.v:9: Cannot find inverter %Error: top.v:10: Module reference not found: buffer %Error: top.v:9: Module reference not found: inverter Exiting due to errors Module names in netlist: top ModuleName=top HierInstName=top PortDir=input PortName=a PortDir=input PortName=b PortDir=output PortName=c PortDir=output PortName=d PinName=in_b NetName=b PinName=out_d NetName=d PinName=in_a NetName=a PinName=out_c NetName=c
      Thanks again for your help
        Does it absolutely require module references for that?
        I do not know. You now have as much working experience as I do with Verilog-Perl. It seems reasonable that Verilog::Netlist would require you to provide the sub-module definitions (just as all simulators do). OTOH, I can understand why you might want them to be treated like black boxes. All I can offer is this generic advice:
        1. Read (and re-read) the POD.
        2. Try experimenting with more methods and options.
        3. Start studying the Perl source code. Perhaps the functionality you desire is buried in there. If not, maybe it becomes obvious to you how to alter the source code to do what you want.
        4. Try browsing (or asking a question on) the CPAN Verilog Discussion forum: http://www.cpanforum.com/dist/Verilog-Perl.
        5. As a last resort, try contacting the author. There must be some reason CPAN authors provide an email address :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://750574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-12-25 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls