From 64b125a8cf93e2ba3834e5708deaf08bf826507f Mon Sep 17 00:00:00 2001 From: Jan Decaluwe Date: Wed, 4 Jul 2012 14:02:02 +0200 Subject: [PATCH] Support for toVHDL.library --HG-- branch : 0.8-dev --- myhdl/conversion/_toVHDL.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/myhdl/conversion/_toVHDL.py b/myhdl/conversion/_toVHDL.py index b80a35cb..744cd321 100644 --- a/myhdl/conversion/_toVHDL.py +++ b/myhdl/conversion/_toVHDL.py @@ -92,7 +92,8 @@ class _ToVHDLConvertor(object): __slots__ = ("name", "component_declarations", "header", - "no_myhdl_header" + "no_myhdl_header", + "library" ) def __init__(self): @@ -100,6 +101,7 @@ class _ToVHDLConvertor(object): self.component_declarations = None self.header = '' self.no_myhdl_header = False + self.library = "work" def __call__(self, func, *args, **kwargs): global _converting @@ -148,6 +150,7 @@ class _ToVHDLConvertor(object): doc = _makeDoc(inspect.getdoc(func)) needPck = len(_enumTypeSet) > 0 + lib = self.library if pfile: _writeFileHeader(pfile, ppath) @@ -157,7 +160,7 @@ class _ToVHDLConvertor(object): _writeFileHeader(vfile, vpath) if needPck: _writeCustomPackage(vfile, intf) - _writeModuleHeader(vfile, intf, needPck, doc) + _writeModuleHeader(vfile, intf, needPck, lib, doc) _writeFuncDecls(vfile) _writeSigDecls(vfile, intf, siglist, memlist) _writeCompDecls(vfile, compDecls) @@ -219,16 +222,18 @@ def _writeCustomPackage(f, intf): print >> f -def _writeModuleHeader(f, intf, needPck, doc): +def _writeModuleHeader(f, intf, needPck, lib, doc): print >> f, "library IEEE;" print >> f, "use IEEE.std_logic_1164.all;" print >> f, "use IEEE.numeric_std.all;" print >> f, "use std.textio.all;" print >> f - print >> f, "use work.pck_myhdl_%s.all;" % _version + if lib != "work": + print >> f, "library %s;" % lib + print >> f, "use %s.pck_myhdl_%s.all;" % (lib, _version) print >> f if needPck: - print >> f, "use work.pck_%s.all;" % intf.name + print >> f, "use %s.pck_%s.all;" % (lib, intf.name) print >> f print >> f, "entity %s is" % intf.name if intf.argnames: