Hi
A long time ago (five months according to the list archive, sorry for
the delay) I ask about a way to get the conversion output to a string
object. So I wrote a patch to add file objects and StringIO support as
output to both converters.
With this patch, you can add an attribute called "fileobject", which
can be any object with the following restrictions:
* Must have a "write()" method like a file object
* Must have a "closed" bool attribute (also like a file object)
* If "fileobject" is a string, the converter create a new cStringIO
object (and the string contents is lost).
Ideally you can use an existing file object (and must not be closed),
or a StringIO object.
So you can do something like:
toVHDL.fileobject = StringIO()
toVHDL(myTopGenerator, mysig1, mysig2, reset, clock)
print(toVHDL.fileobject.getvalue())
And the VHDL output will be printed to the console. This works for VHDL
and Verilog converters.
There is another issue that I think could be a problem but I don't have
a smart way to solve it: you *must* provide a fresh object before
calling toVHDL (or toVerilog), otherwise the converter just append the
output code to previous conversions. Maybe doing
toVHDL.fileobject.truncate(0)
before using it inside the function, but that breaks the initial
assumption to accept any object with only "write" y "closed"
attributes. Any suggestions?
Best wishes
--
Oscar Díaz
Huella de clave = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964
gpg --keyserver subkeys.pgp.net --recv-keys 90E99964
Recomiendo usar OpenDocument Format
para uso e intercambio de documentos
http://www.spreadopendocument.org/
|