Parsing VHDL with python, where to start.

Henrique Dante de Almeida hdante at gmail.com
Tue Jul 29 22:23:49 EDT 2008


On Jul 28, 6:49 pm, Svenn Are Bjerkem <svenn.bjer... at googlemail.com>
wrote:
> Hi again,
>
> when I get far enough to parse the VHDL (which is not currently the
> fact, but I have to look at the work coming up downstream) I will have
> to put it into an internal data structure and then write some classes
> to handle the MVC between whatever data I have and the PyQt4 widget
> that is going to show the block diagram. I own the book "Rapig GUI
> Programming with Python and Qt" by Mark Summerfield and try to read up
> on the PyQt way of doing things as I try to make a plan for my
> application. I have been looking for possible data structures with
> google just to find out that most of the ideas are stored in
> proceedings or to conferences or ieee papers not generally available
> to me. Is anybody experienced with designing data structures willing
> to share some ideas with me? Since I am using the open-source version
> of PyQt4, any information will eventually be available to public (if
> the app pass the planning stage) if that makes helping out any
> easier: :-) There is already an app called Qucs that is running in
> Qt-3 and being ported to Qt-4 that is written in C++, but I don't know
> how wise it is to just reverse-engineering C++ classes and translate
> them into python classes.
>
> --
> Svenn

 Don't mix the parsing code with Qt. They're independent. Qt should be
used mostly for the model and the view. The controller should be
completelly decoupled from the model and the view. If you need to wrap
the controller in some Qt object, first write the controller without
Qt, then wrap it in the Qt object. Considering that you need a full
parser for VHDL, my option would be to take the VHDL grammar:

 http://tams-www.informatik.uni-hamburg.de/vhdl/tools/grammar/vhdl93-bnf.html

 and port it to a LR(1) or LALR parser that emits python code. See:

 http://en.wikipedia.org/wiki/Comparison_of_parser_generators

 Then, add action code to the grammar that you wrote, so that it
builds a tree representing the parsed file.



More information about the Python-list mailing list