473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: Parsing VHDL with python, where to start.

On Jul 23, 1:03 pm, christopher.saun...@durham.ac.uk (c d saunter)
wrote:
How much of VHDL are you looking to parse? Are you just looking at files
intended for synthesis, or at simulation/testbench files as well?
As a start I want to parse VHDL which is going to be synthesised, and
I am limiting myself to the entities and the structural component
placement. I will drop the processes and the concurrent assignments
even if that will mask important information. It is a design viewer
tool, not a design tool that I am writing. Xilinx ISE do give me the
opportunity to browse my synthesised netlist, but there is simply too
much information.

Later the app can be extended with more functionality, depends on my
success with the initial problems that I have.
If I started again I'd use pyparsing:http://pyparsing.wikispaces.com/

Looks like someone is already there in part:http://pyparsing.wikispaces.com/mess...ew/home/103973
I also got a pointer to SimpleParse and now try to translate the parts
of the VHDL BNF that I need into a definition that SimpleParse can
understand. But looking at the BNF it is clear that VHDL is no easy
language to parse, just as it is no easy language to do structural
design in.

--
Svenn
Jul 24 '08 #1
5 3970
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
Jul 28 '08 #2
Svenn Are Bjerkem schrieb:
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.
For me it is not very clear what you intend to do. After years of
parsing parts of VHDL from time to time the rapid parsing way for me is
using regular expressions instead of one of the parser frame works
because of following reasons:

- It is hard for me to understand those frameworks
- They are very slow
- It is too much work for me to bring them up to work in a sensible way
- Compared with regular expression matching they usually need a lot of
extra work.

Regular expressions work very well once the validation of the VHDL code
was done by one of the commercial compilers.

Once you can rely on the code that it is valid VHDL
- Parse it with a regular expression for simple VHDL structures or
- Extract a structure first and analyse that with a set of regular
expressions

The result can be stored into a combination of lists and dictionaries,
dependend on the problem.

For processing with other tools the results could be stored into XML
structures.

PyQt as a widget framework is not useful until here, but of course you
could display your results in arbitrary graphical ways with PyQt, if you
rally need to. You should know, printing out an ASCII or XML
representation is so much more easy and quicker to code so I always
prefer that. There are even editors/visualizers ready to display XML...

Best regards

Wolfgang
Jul 29 '08 #3
On Jul 29, 5:14 pm, Wolfgang Grafen <wolfgang.gra...@ericsson.com>
wrote:
For me it is not very clear what you intend to do. After years of
parsing parts of VHDL from time to time the rapid parsing way for me is
using regular expressions instead of one of the parser frame works
because of following reasons:

- It is hard for me to understand those frameworks
- They are very slow
- It is too much work for me to bring them up to work in a sensible way
- Compared with regular expression matching they usually need a lot of
extra work.
I agree with frameworks being difficult to understand and that is why
I also have been using regular expressions in tcl to parse spice
netlists before. Now I want to parse spice, vhdl and also maybe
verilog. I think I will end up with regular expressions unless I get a
grip on SimpleParse.

The rationale for the whole project has been to finally be able to
view spice and specially vhdl code for projects I work on. This has
been something I have wanted to have for years, without having the
ressources to complete it. There are commercial tools available, but I
was looking for something more open/free that could be maintained
independently of what tools I have at work.
PyQt as a widget framework is not useful until here, but of course you
could display your results in arbitrary graphical ways with PyQt, if you
rally need to. You should know, printing out an ASCII or XML
representation is so much more easy and quicker to code so I always
prefer that. There are even editors/visualizers ready to display XML...
PyQt4 doesn't help me parse my sources, but it helps me visualise
them. I did something in tcl/tk to get hierarchical spice netlists
into a tree structure, but extending that app was too much hassle.
PyQt4 offers a lot of functionality once the threshold of learning it
has been passed. It also installs nicely on windows and most linux
distributions offer it ready to install. And I like Qt.

--
Svenn
Jul 29 '08 #4
On Jul 28, 6:49*pm, Svenn Are Bjerkem <svenn.bjer...@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-hambu...hdl93-bnf.html

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

http://en.wikipedia.org/wiki/Compari...ser_generators

Then, add action code to the grammar that you wrote, so that it
builds a tree representing the parsed file.
Jul 30 '08 #5
On Jul 29, 11:23*pm, Henrique Dante de Almeida <hda...@gmail.com>
wrote:
On Jul 28, 6:49*pm, Svenn Are Bjerkem <svenn.bjer...@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-hambu...ammar/vhdl93-b....

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

*http://en.wikipedia.org/wiki/Compari...ser_generators

*Then, add action code to the grammar that you wrote, so that it
builds a tree representing the parsed file.
I think SableCC seems to be the best choice:

http://www.mare.ee/indrek/sablecc/
Jul 30 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kylotan | last post by:
I have a text file where the fields are delimited in various different ways. For example, strings are terminated with a tilde, numbers are terminated with whitespace, and some identifiers are...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
14
by: Viktor Rosenfeld | last post by:
Hi, I need to create a parser for a Python project, and I'd like to use process kinda like lex/yacc. I've looked at various parsing packages online, but didn't find anything useful for me: -...
3
by: Willem Ligtenberg | last post by:
I decided to use SAX to parse my xml file. But the parser crashes on: File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError raise exception...
0
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
31
by: David Cramer | last post by:
If you had an application that you were about to begin development on which you wanted to be cross platform (at least Mac and Windows), would you suggest using c++ and Python? I'm asking because...
2
by: Felipe De Bene | last post by:
I'm having problems parsing an HTML file with the following syntax : <TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'> <TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH> <TH...
2
by: =?ISO-8859-1?Q?Andr=E9?= | last post by:
Hi everyone, I would like to implement a parser for a mini-language and would appreciate some pointers. The type of text I would like to parse is an extension of: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.