Re: [myhdl-list] always_comb exception
Brought to you by:
jandecaluwe
From: David H. <da...@ad...> - 2013-10-09 19:29:57
|
This fails with both "ipython" and plain "python" (in interactive mode) on Mac OS X 10.8.5 using prerelease MyHDL 0.8.1 from the repo. I pasted this text: from myhdl import * def Mux(z, a, b, sel): @always_comb def muxLogic(): if sel == 1: z.next = a else: z.next = b return muxLogic z, a, b, sel = [Signal(0) for i in range(4)] mux_1 = Mux(z,a,b,sel) And got this dump from ipython: subspace(ttys002):~> ipython Leopard libedit detected. Python 2.7.2 (default, Oct 11 2012, 20:14:37) Type "copyright", "credits" or "license" for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: from myhdl import * In [2]: def Mux(z, a, b, sel): ...: @always_comb ...: def muxLogic(): ...: if sel == 1: ...: z.next = a ...: else: ...: z.next = b ...: return muxLogic ...: In [3]: z, a, b, sel = [Signal(0) for i in range(4)] In [4]: mux_1 = Mux(z,a,b,sel) --------------------------------------------------------------------------- IOError Traceback (most recent call last) /Users/dholl/<ipython console> in <module>() /Users/dholl/<ipython console> in Mux(z, a, b, sel) /Users/dholl/Library/Python/2.7/lib/python/site-packages/myhdl/_always_comb.pyc in always_comb(func) 62 except NameError: 63 raise NameError(n) ---> 64 c = _AlwaysComb(func, symdict) 65 return c 66 /Users/dholl/Library/Python/2.7/lib/python/site-packages/myhdl/_always_comb.pyc in __init__(self, func, symdict) 193 self.func = func 194 self.symdict = symdict --> 195 s = inspect.getsource(func) 196 s = _dedent(s) 197 tree = ast.parse(s) /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py in getsource(object) 697 or code object. The source code is returned as a single string. An 698 IOError is raised if the source code cannot be retrieved.""" --> 699 lines, lnum = getsourcelines(object) 700 return string.join(lines, '') 701 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py in getsourcelines(object) 686 original source file the first line of code was found. An IOError is 687 raised if the source code cannot be retrieved.""" --> 688 lines, lnum = findsource(object) 689 690 if ismodule(object): return lines, 0 /Users/dholl/Library/Python/2.7/lib/python/site-packages/IPython/ultraTB.pyc in findsource(object) 143 lines = linecache.getlines(file, globals_dict) 144 if not lines: --> 145 raise IOError('could not get source code') 146 147 if ismodule(object): IOError: could not get source code In [5]: For completeness, the dump form python is: Last login: Wed Oct 9 15:24:05 on ttys002 subspace(ttys003):~> python Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from myhdl import * >>> def Mux(z, a, b, sel): ... @always_comb ... def muxLogic(): ... if sel == 1: ... z.next = a ... else: ... z.next = b ... return muxLogic ... >>> z, a, b, sel = [Signal(0) for i in range(4)] >>> mux_1 = Mux(z,a,b,sel) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in Mux File "/Users/dholl/Library/Python/2.7/lib/python/site-packages/myhdl/_always_comb.py", line 64, in always_comb c = _AlwaysComb(func, symdict) File "/Users/dholl/Library/Python/2.7/lib/python/site-packages/myhdl/_always_comb.py", line 195, in __init__ s = inspect.getsource(func) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 699, in getsource lines, lnum = getsourcelines(object) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 688, in getsourcelines lines, lnum = findsource(object) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 529, in findsource raise IOError('source code not available') IOError: source code not available >>> On Wed, Oct 9, 2013 at 2:44 PM, Christopher Felton <chr...@gm...>wrote: > On 10/9/2013 1:16 PM, Per Karlsson wrote: > > I suspect you are running from the interpreter. > > That won't work, because MyHDL uses inspection. > > Every piece of MyHDL code has to be written to an actual file somewhere > (or > > at least that's how I understand it). > > > > Cheers > > Per > > > > Don't know about the base Python interpreter-shell > but from the ipython console it works fine. > > In [2]: from myhdl import * > ...: def Mux(z, a, b, sel): > ...: @always_comb > ...: def muxLogic(): > ...: if sel == 1: > ...: z.next = a > ...: else: > ...: z.next = b > ...: return muxLogic > ...: z, a, b, sel = [Signal(0) for i in range(4)] > ...: mux_1 = Mux(z,a,b,sel) > ...: > > I can never type it all correct to use the base-shell > for multiline input, e.g. function definitions :) > > Regards, > Chris > > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |