Re: [myhdl-list] always_comb exception
Brought to you by:
jandecaluwe
From: Norbo <Nor...@gm...> - 2013-10-09 21:11:03
|
Am 09.10.2013, 20:16 Uhr, schrieb Per Karlsson <bas...@gm...>: > 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 > > > On Wed, Oct 9, 2013 at 7:48 PM, Steve Vejcik > <ste...@ea...>wrote: > >> Hi Folks - I'm just wetting my feet with myhdl and have run into a >> problem >> running the simple latch example from the wiki. I'm running python 2.7 >> with >> myhdl v0.8. If anyone can offer some insight I'd appreciate it. Here's a >> variant of the problem: >> >> 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 "/usr/local/lib/python2.7/dist-packages/myhdl/_always_comb.py", >> line >> 64, in always_comb >> c = _AlwaysComb(func, symdict) >> File "/usr/local/lib/python2.7/dist-packages/myhdl/_always_comb.py", >> line >> 185, in __init__ >> s = inspect.getsource(func) >> File "/usr/lib/python2.7/inspect.py", line 701, in getsource >> lines, lnum = getsourcelines(object) >> File "/usr/lib/python2.7/inspect.py", line 690, in getsourcelines >> lines, lnum = findsource(object) >> File "/usr/lib/python2.7/inspect.py", line 538, in findsource >> raise IOError('could not get source code') >> IOError: could not get source code >> >> Steve Yes,a file is needed, you could also write it into a file for the interpreter, then it should definitly work. for example like this: from myhdl import * source_text="""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)""" source_file=open("sourcetext.txt","w") source_file.write(source_text) source_file.close() dd=compile(source_text,"sourcetext.txt","exec") exec(dd) greetings Norbo |