Closed phanrahan closed 4 years ago
Hmm, can you do $ pip show magma-lang coreir fault hwtypes
to see what versions of the various packages you're running? I have
Name: magma-lang
Version: 2.0.68
...
---
Name: coreir
Version: 2.0.87
...
---
Name: fault
Version: 3.0.24
...
---
Name: hwtypes
Version: 1.4.2
...
Also, it looks like you're using a local installation of coreir (based on /Users/hanrahan/git/coreir/src/ir/context.cpp). One sanity check would be to uninstall this version (remove it from your path or use make uninstall in your build directory), install the latest pycoreir package (pip install --upgrade coreir), then re-run the test. If this works, that would suggest a problem with your local build that we can investigate
Hmm. I have the development versions checked out. They don't work?
% pip show magma-lang coreir fault hwtypes
Name: magma-lang
Version: 2.0.68
Summary: An embedded DSL for constructing hardware circuits
Home-page: https://github.com/phanrahan/magma
Author: None
Author-email: None
License: MIT
Location: /Users/hanrahan/miniconda3/lib/python3.7/site-packages
Requires: hwtypes, numpy, coreir, ast-tools, six, kratos, graphviz, mako, staticfg, astor, pyverilog, colorlog, dataclasses
Required-by: gemstone, canal, fault, mantle
---
Name: coreir
Version: 2.0.87
Summary: Python bindings for CoreIR
Home-page: https://github.com/leonardt/pycoreir
Author: Leonard Truong
Author-email: lenny@cs.stanford.edu
License: BSD License
Location: /Users/hanrahan/git/pycoreir
Requires: hwtypes
Required-by: magma-lang, metamapper, CoSA, fault
---
Name: fault
Version: 3.0.23
Summary: A Python package for testing hardware (part of the magma ecosystem)
Home-page: https://github.com/leonardt/fault
Author: Leonard Truong
Author-email: lenny@cs.stanford.edu
License: BSD License
Location: /Users/hanrahan/git/fault
Requires: astor, coreir, cosa, z3-solver, hwtypes, magma-lang, pyyaml, scipy, numpy, DeCiDa
Required-by: gemstone, mantle
---
Name: hwtypes
Version: 1.4.2
Summary: Python implementations of fixed size hardware types (Bit, BitVector, UInt, SInt, ...) based on the SMT-LIB2 semantics
Home-page: https://github.com/leonardt/hwtypes
Author: Leonard Truong
Author-email: lenny@cs.stanford.edu
License: UNKNOWN
Location: /Users/hanrahan/miniconda3/lib/python3.7/site-packages
Requires: gmpy2, pysmt, z3-solver
Required-by: magma-lang, gemstone, canal, CoSA, coreir, fault
The development versions should work, but I wanted to just verify that they are being used. Can you try using the release version of the pycoreir package? Perhaps there's some problem with your local installation.
Also, can you try doing /usr/local/bin/coreir --version
to see which version you have installed? (You may need to change the path to where you have it installed if it's in a different location). The current master branch should be installing v0.1.40
When I install coreir from pycoreir it goes into my anaconda directory. Is that ok?
It reports v0.1.40
yes that's okay, does the issue persist with the pycoreir only setup?
Also maybe a which -a coreir
, my suspicion is there is an old version of coreir lying around somewhere in your PATH or DYLD_LIBRARY_PATH
% which -a coreir
/Users/hanrahan/miniconda3/bin/coreir
A little further:
=================================== FAILURES ===================================
____________________________ test_sequential2_reset ____________________________
def test_sequential2_reset():
> @m.sequential2(reset_type=m.AsyncReset, has_enable=True)
class Test2:
tests/test_syntax/test_sequential2.py:372:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
magma/syntax/sequential2.py:327: in seq_inner
file_name=file_name)(cls.__init__)
../ast_tools/ast_tools/passes/util.py:208: in __call__
return self.exec(etree, stree, env)
../ast_tools/ast_tools/passes/util.py:218: in exec
return exec_def_in_file(etree, env, self.path, self.file_name, stree)
../ast_tools/ast_tools/common.py:40: in exec_def_in_file
return exec_in_file(tree, st, path, file_name, serialized_tree)[tree.name]
../ast_tools/ast_tools/common.py:58: in exec_in_file
source = astor.to_source(tree)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:52: in to_source
generator.visit(node)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:320: in visit_FunctionDef
self.body(node.body)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:218: in body
self.write(*statements)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:278: in visit_Assign
self.visit(node.value)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:514: in visit_Call
self.visit(node.func)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:524: in visit_Call
write(write_comma, arg, '=' if arg else '**', keyword.value)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
node = <_ast.Constant object at 0x7fd9de825ad0>
def abort_visit(node): # XXX: self?
msg = 'No defined handler for node of type %s'
> raise AttributeError(msg % node.__class__.__name__)
E AttributeError: No defined handler for node of type Constant
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:137: AttributeError
__________________________________ test_jtag ___________________________________
def test_jtag():
TEST_LOGIC_RESET = m.bits(15, 4)
RUN_TEST_IDLE = m.bits(12, 4)
SELECT_DR_SCAN = m.bits(7, 4)
CAPTURE_DR = m.bits(6, 4)
SHIFT_DR = m.bits(2, 4)
EXIT1_DR = m.bits(1, 4)
PAUSE_DR = m.bits(3, 4)
EXIT2_DR = m.bits(0, 4)
UPDATE_DR = m.bits(5, 4)
SELECT_IR_SCAN = m.bits(4, 4)
CAPTURE_IR = m.bits(14, 4)
SHIFT_IR = m.bits(10, 4)
EXIT1_IR = m.bits(9, 4)
PAUSE_IR = m.bits(11, 4)
EXIT2_IR = m.bits(8, 4)
UPDATE_IR = m.bits(13, 4)
> @m.coroutine(manual_encoding=True, reset_type=m.AsyncReset)
class JTAG:
tests/test_syntax/test_coroutine/test_jtag.py:33:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
magma/syntax/coroutine.py:312: in inner
)(cls)
magma/syntax/sequential2.py:327: in seq_inner
file_name=file_name)(cls.__init__)
../ast_tools/ast_tools/passes/util.py:208: in __call__
return self.exec(etree, stree, env)
../ast_tools/ast_tools/passes/util.py:218: in exec
return exec_def_in_file(etree, env, self.path, self.file_name, stree)
../ast_tools/ast_tools/common.py:40: in exec_def_in_file
return exec_in_file(tree, st, path, file_name, serialized_tree)[tree.name]
../ast_tools/ast_tools/common.py:58: in exec_in_file
source = astor.to_source(tree)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:52: in to_source
generator.visit(node)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:320: in visit_FunctionDef
self.body(node.body)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:218: in body
self.write(*statements)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:278: in visit_Assign
self.visit(node.value)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:514: in visit_Call
self.visit(node.func)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:524: in visit_Call
write(write_comma, arg, '=' if arg else '**', keyword.value)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
node = <_ast.Constant object at 0x7fd9deb20e90>
def abort_visit(node): # XXX: self?
msg = 'No defined handler for node of type %s'
> raise AttributeError(msg % node.__class__.__name__)
E AttributeError: No defined handler for node of type Constant
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:137: AttributeError
__________________________________ test_sdram __________________________________
def test_sdram():
CLK_FREQUENCY = 133 # Mhz
REFRESH_TIME = 32 # ms (how often we need to refresh)
REFRESH_COUNT = 8192 # cycles (how many refreshes required per refresh time)
# clk / refresh = clk / sec
# , sec / refbatch
# , ref / refbatch
CYCLES_BETWEEN_REFRESH = \
(CLK_FREQUENCY * 1_000 * REFRESH_TIME) // REFRESH_COUNT
# IDLE = "5'b00000"
IDLE = m.bits(0, 5)
# INIT_NOP1 = "5'b01000"
# INIT_PRE1 = "5'b01001"
# INIT_NOP1_1 = "5'b00101"
# INIT_REF1 = "5'b01010"
# INIT_NOP2 = "5'b01011"
# INIT_REF2 = "5'b01100"
# INIT_NOP3 = "5'b01101"
# INIT_LOAD = "5'b01110"
# INIT_NOP4 = "5'b01111"
# REF_PRE = "5'b00001"
# REF_NOP1 = "5'b00010"
# REF_REF = "5'b00011"
# REF_NOP2 = "5'b00100"
# READ_ACT = "5'b10000"
# READ_NOP1 = "5'b10001"
# READ_CAS = "5'b10010"
# READ_NOP2 = "5'b10011"
# READ_READ = "5'b10100"
# WRIT_ACT = "5'b11000"
# WRIT_NOP1 = "5'b11001"
# WRIT_CAS = "5'b11010"
# WRIT_NOP2 = "5'b11011"
INIT_NOP1 = m.bits(0b01000, 5)
INIT_PRE1 = m.bits(0b01001, 5)
INIT_NOP1_1 = m.bits(0b00101, 5)
INIT_REF1 = m.bits(0b01010, 5)
INIT_NOP2 = m.bits(0b01011, 5)
INIT_REF2 = m.bits(0b01100, 5)
INIT_NOP3 = m.bits(0b01101, 5)
INIT_LOAD = m.bits(0b01110, 5)
INIT_NOP4 = m.bits(0b01111, 5)
REF_PRE = m.bits(0b00001, 5)
REF_NOP1 = m.bits(0b00010, 5)
REF_REF = m.bits(0b00011, 5)
REF_NOP2 = m.bits(0b00100, 5)
READ_ACT = m.bits(0b10000, 5)
READ_NOP1 = m.bits(0b10001, 5)
READ_CAS = m.bits(0b10010, 5)
READ_NOP2 = m.bits(0b10011, 5)
READ_READ = m.bits(0b10100, 5)
WRIT_ACT = m.bits(0b11000, 5)
WRIT_NOP1 = m.bits(0b11001, 5)
WRIT_CAS = m.bits(0b11010, 5)
WRIT_NOP2 = m.bits(0b11011, 5)
# CMD_PALL = "8'b10010001"
# CMD_REF = "8'b10001000"
# CMD_NOP = "8'b10111000"
# CMD_MRS = "8'b1000000x"
# CMD_BACT = "8'b10011xxx"
# CMD_READ = "8'b10101xx1"
# CMD_WRIT = "8'b10100xx1"
CMD_PALL = m.bits(0b10010001, 8)
CMD_REF = m.bits(0b10001000, 8)
CMD_NOP = m.bits(0b10111000, 8)
CMD_MRS = m.bits(0b10000000, 8)
CMD_BACT = m.bits(0b10011000, 8)
CMD_READ = m.bits(0b10101001, 8)
CMD_WRIT = m.bits(0b10100001, 8)
> @m.coroutine(manual_encoding=True, reset_type=m.AsyncResetN)
class SDRAMController:
tests/test_syntax/test_coroutine/test_sdram.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
magma/syntax/coroutine.py:312: in inner
)(cls)
magma/syntax/sequential2.py:327: in seq_inner
file_name=file_name)(cls.__init__)
../ast_tools/ast_tools/passes/util.py:208: in __call__
return self.exec(etree, stree, env)
../ast_tools/ast_tools/passes/util.py:218: in exec
return exec_def_in_file(etree, env, self.path, self.file_name, stree)
../ast_tools/ast_tools/common.py:40: in exec_def_in_file
return exec_in_file(tree, st, path, file_name, serialized_tree)[tree.name]
../ast_tools/ast_tools/common.py:58: in exec_in_file
source = astor.to_source(tree)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:52: in to_source
generator.visit(node)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:320: in visit_FunctionDef
self.body(node.body)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:218: in body
self.write(*statements)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:278: in visit_Assign
self.visit(node.value)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:514: in visit_Call
self.visit(node.func)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:524: in visit_Call
write(write_comma, arg, '=' if arg else '**', keyword.value)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
node = <_ast.Constant object at 0x7fd9dee80590>
def abort_visit(node): # XXX: self?
msg = 'No defined handler for node of type %s'
> raise AttributeError(msg % node.__class__.__name__)
E AttributeError: No defined handler for node of type Constant
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:137: AttributeError
__________________________________ test_uart ___________________________________
def test_uart():
> @m.coroutine(reset_type=m.AsyncReset)
class UART:
tests/test_syntax/test_coroutine/test_uart.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
magma/syntax/coroutine.py:312: in inner
)(cls)
magma/syntax/sequential2.py:327: in seq_inner
file_name=file_name)(cls.__init__)
../ast_tools/ast_tools/passes/util.py:208: in __call__
return self.exec(etree, stree, env)
../ast_tools/ast_tools/passes/util.py:218: in exec
return exec_def_in_file(etree, env, self.path, self.file_name, stree)
../ast_tools/ast_tools/common.py:40: in exec_def_in_file
return exec_in_file(tree, st, path, file_name, serialized_tree)[tree.name]
../ast_tools/ast_tools/common.py:58: in exec_in_file
source = astor.to_source(tree)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:52: in to_source
generator.visit(node)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:320: in visit_FunctionDef
self.body(node.body)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:218: in body
self.write(*statements)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:278: in visit_Assign
self.visit(node.value)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:514: in visit_Call
self.visit(node.func)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:524: in visit_Call
write(write_comma, arg, '=' if arg else '**', keyword.value)
../../miniconda3/lib/python3.7/site-packages/astor/code_gen.py:168: in write
visit(item)
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:143: in visit
return visitor(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
node = <_ast.Constant object at 0x7fd9dede0e50>
def abort_visit(node): # XXX: self?
msg = 'No defined handler for node of type %s'
> raise AttributeError(msg % node.__class__.__name__)
E AttributeError: No defined handler for node of type Constant
../../miniconda3/lib/python3.7/site-packages/astor/node_util.py:137: AttributeError
=========================== short test summary info ============================
FAILED tests/test_syntax/test_sequential2.py::test_sequential2_reset - Attrib...
FAILED tests/test_syntax/test_coroutine/test_jtag.py::test_jtag - AttributeEr...
FAILED tests/test_syntax/test_coroutine/test_sdram.py::test_sdram - Attribute...
FAILED tests/test_syntax/test_coroutine/test_uart.py::test_uart - AttributeEr...
============= 4 failed, 611 passed, 6 skipped in 371.16s (0:06:11) =============
%
Can you try pip install --upgrade astor
? It looks like support for Constant was added in a recent version (see https://github.com/berkerpeksag/astor/commit/641390339bea88f13bcdd0abaa576e078191a86c)
Yeah. That did it. The tests pass now.
Any ideas what is causing this error? I updated coreir.