Re: [myhdl-list] not supported, extra positional arguments
Brought to you by:
jandecaluwe
|
From: Jan D. <ja...@ja...> - 2009-03-04 22:46:58
|
Neal Becker wrote:
> BTW, all I'm trying to do here is declare a signed number the same size as
> the one passed in. Is there an easier way?
The convertor doesn't support the *args and *kwargs syntax for extra
arguments.
I would clarify the code by calculating constants once in advance:
def sat (....)
min_x, max_x = min_signed(len(x)), max_signed(len(x))
min_out, max_out = ...
@always_comb
....
Jan
>
> This is OK:
> def sat_rnd (x, bits, outbits, output):
> @always_comb
> def sat_rnd_logic():
> y1 = intbv (int (x >> (bits-1)), min_signed (len (x)), max_signed
> (len (x)))
> y2 = intbv (int (y1 + 1), min_signed (len (x)), max_signed (len
> (x)))
> y3 = intbv (int (y2 >> 1), min_signed (len (x)), max_signed (len
> (x)))
> if (y3 > max_signed (outbits)):
> output.next = max_signed (outbits)
> elif (y3 < min_signed (outbits)):
> output.next = min_signed (outbits)
> else:
> output.next = y3
>
> return sat_rnd_logic
>
> But this is not:
>
> def sat_rnd (x, bits, outbits, output):
> @always_comb
> def sat_rnd_logic():
> y1 = intbv (int (x >> (bits-1)), *extrema_signed (len (x)))
> y2 = intbv (int (y1 + 1), *extrema_signed (len (x)))
> y3 = intbv (int (y2 >> 1), *extrema_signed (len (x)))
> if (y3 > max_signed (outbits)):
> output.next = max_signed (outbits)
> elif (y3 < min_signed (outbits)):
> output.next = min_signed (outbits)
> else:
> output.next = y3
>
> return sat_rnd_logic
>
> python test3.py
> Traceback (most recent call last):
> File "test3.py", line 174, in <module>
> verilog()
> File "test3.py", line 161, in verilog
> toVerilog (Decimator, clock, en, x, log2_n, count, result, reset)
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_toVerilog.py",
> line 115, in __call__
> genlist = _analyzeGens(arglist, h.absnames)
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_analyze.py", line
> 155, in _analyzeGens
> compiler.walk(ast, v)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 106, in walk
> walker.preorder(tree, visitor)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 63, in preorder
> self.dispatch(tree, *args) # XXX *args make sense?
> File "/usr/lib64/python2.5/compiler/visitor.py", line 57, in dispatch
> return meth(node, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 40, in default
> self.dispatch(child, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 57, in dispatch
> return meth(node, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 40, in default
> self.dispatch(child, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 57, in dispatch
> return meth(node, *args)
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_analyze.py", line
> 261, in visitFunction
> self.visitChildNodes(node, *args)
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_misc.py", line
> 137, in visitChildNodes
> self.visit(n, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 57, in dispatch
> return meth(node, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 40, in default
> self.dispatch(child, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 57, in dispatch
> return meth(node, *args)
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_analyze.py", line
> 240, in visitAssign
> self.visit(node.expr, *args)
> File "/usr/lib64/python2.5/compiler/visitor.py", line 57, in dispatch
> return meth(node, *args)
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_analyze.py", line
> 244, in visitCallFunc
> self.raiseError(node, _error.NotSupported, "extra positional arguments")
> File "/usr/lib/python2.5/site-packages/myhdl/conversion/_misc.py", line
> 128, in raiseError
> raise ConversionError(kind, msg, info)
>
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Python as a hardware description language:
http://www.myhdl.org
|