[myhdl-list] supported operators for Signal class
Brought to you by:
jandecaluwe
From: David S. <dst...@kc...> - 2016-04-11 17:52:09
|
I'm trying some tests converting python code to MyHDL code that generates real hardware. As a hardware designer, I know some of these tests are going to be foolish first steps to make, but I also know that less experienced designers might make these same mistakes. Here's a simplified code block x, y = [Signal(intbv(1)[64:]) for i in range(2)] @always_seq(clk.posedge, reset) def test_divide(): y.next = y / x return test_divide and here's the error message I get: y.next = y / x TypeError: unsupported operand type(s) for /: '_Signal' and '_Signal' Which leads to the question, what operand types ARE supported for Signals? This feels like an obvious question, but I can't seem to find an answer anywhere in the documentation. When I change the code to be y.next = y ** x I was surprised to get a different error message: File "/home/dstanford/.local/lib/python2.7/site-packages/myhdl/conversion/_toVHDL.py", line 171, in __call__ _annotateTypes(genlist) File "/home/dstanford/.local/lib/python2.7/site-packages/myhdl/conversion/_toVHDL.py", line 2288, in _annotateTypes v.visit(tree) File "/usr/lib/python2.7/ast.py", line 241, in visit return visitor(node) File "/usr/lib/python2.7/ast.py", line 249, in generic_visit self.visit(item) File "/usr/lib/python2.7/ast.py", line 241, in visit return visitor(node) File "/home/dstanford/.local/lib/python2.7/site-packages/myhdl/conversion/_toVHDL.py", line 2029, in visit_FunctionDef self.visit(stmt) File "/usr/lib/python2.7/ast.py", line 241, in visit return visitor(node) File "/usr/lib/python2.7/ast.py", line 251, in generic_visit self.visit(value) File "/usr/lib/python2.7/ast.py", line 241, in visit return visitor(node) File "/home/dstanford/.local/lib/python2.7/site-packages/myhdl/conversion/_toVHDL.py", line 2137, in visit_BinOp self.inferBinOpType(node) File "/home/dstanford/.local/lib/python2.7/site-packages/myhdl/conversion/_toVHDL.py", line 2175, in inferBinOpType raise AssertionError("unexpected op %s" % op) AssertionError: unexpected op <_ast.Pow object at 0x7fa74b0e3350> And finally going through a list of basic python operators I tried out y.next = y // x which works, and makes sense though I didn't even know it was an option until I was trying this test out. Am I searching poorly looking for a list of operators that works between signals, or does such a table not exist? Should it? Thanks, Dave Stanford This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature. For additional important disclaimers and disclosures regarding KCG’s products and services, please click on the following link: http://www.kcg.com/legal/global-disclosures |