fault
fault copied to clipboard
List Index Out Of Range Error Message Not Helpful
The file https://github.com/David-Durst/aetherling/blob/f765d8f6aabc5790dcc981dca3a43e58aaa9f871/aetherling/examples/ae_circuit28334-312.py produces the following error message:
File "/home/david/dev/magma/magma/array.py", line 247, in value
return ts[0].name.array
IndexError: list index out of range
I think I'm wiring up the circuit incorrectly. However, the error message doesn't tell me where that is.
The full trace is:
Traceback (most recent call last):
File "/home/david/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/helpers/pydev/pydevd.py", line 2060, in <module>
main()
File "/home/david/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/helpers/pydev/pydevd.py", line 2054, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/david/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/helpers/pydev/pydevd.py", line 1405, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/david/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/helpers/pydev/pydevd.py", line 1412, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/david/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/192.6262.63/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/david/dev/aetherling/aetherling/examples/ae_circuit28334-312.py", line 66, in <module>
fault_helpers.compile_and_run(tester)
File "/home/david/dev/aetherling/aetherling/helpers/fault_helpers.py", line 87, in compile_and_run
}, directory="vBuild/", flags=["-Wno-fatal"])
File "/home/david/dev/fault/fault/tester.py", line 302, in compile_and_run
self._compile_and_run(target=target, **kwargs)
File "/home/david/dev/fault/fault/tester.py", line 286, in _compile_and_run
self._compile(target, **kwargs)
File "/home/david/dev/fault/fault/tester.py", line 249, in _compile
self.targets[target] = self.make_target(target, **kwargs)
File "/home/david/dev/fault/fault/tester.py", line 96, in make_target
return VerilatorTarget(self._circuit, **kwargs)
File "/home/david/dev/fault/fault/verilator_target.py", line 111, in __init__
include_verilog_libraries, magma_output, magma_opts)
File "/home/david/dev/fault/fault/verilog_target.py", line 47, in __init__
**self.magma_opts)
File "/home/david/dev/magma/magma/compile.py", line 114, in compile
uniquification_pass(main, uniquification_mode)
File "/home/david/dev/magma/magma/uniquification.py", line 102, in uniquification_pass
pass_.run()
File "/home/david/dev/magma/magma/uniquification.py", line 79, in run
super(UniquificationPass, self).run()
File "/home/david/dev/magma/magma/passes/passes.py", line 58, in run
self._run(self.main)
File "/home/david/dev/magma/magma/uniquification.py", line 70, in _run
self._run( instancedefinition )
File "/home/david/dev/magma/magma/uniquification.py", line 70, in _run
self._run( instancedefinition )
File "/home/david/dev/magma/magma/uniquification.py", line 70, in _run
self._run( instancedefinition )
[Previous line repeated 2 more times]
File "/home/david/dev/magma/magma/uniquification.py", line 76, in _run
self(definition)
File "/home/david/dev/magma/magma/uniquification.py", line 47, in __call__
key = _hash(definition)
File "/home/david/dev/magma/magma/uniquification.py", line 33, in _hash
hash_struct = _make_hash_struct(definition)
File "/home/david/dev/magma/magma/uniquification.py", line 26, in _make_hash_struct
repr_ = repr(definition)
File "/home/david/dev/magma/magma/circuit.py", line 135, in __repr__
s += repr( cls.interface )
File "/home/david/dev/magma/magma/interface.py", line 60, in __repr__
output = input.value()
File "/home/david/dev/magma/magma/array.py", line 247, in value
return ts[0].name.array
IndexError: list index out of range
The file https://github.com/David-Durst/aetherling/blob/96fceabd202df7e6846495e152327b0e07c9c76f/aetherling/examples/ae_circuit11324-288.py is a better example of the error. I'm fairly certain this file has no type errors as I've improved my Aetherling type checker.
Additionally, i've isolated the error: https://github.com/David-Durst/aetherling/blob/96fceabd202df7e6846495e152327b0e07c9c76f/tests/test_space_time/test_downsample.py#L8-L22 produces the same error
test_downsample.py::test_down_s FAILED [100%]/home/david/dev/coreir/src/passes/transform/rungenerators.cpp:10 In Run Generators
/home/david/dev/coreir/src/passes/transform/rungenerators.cpp:26 Done running generators
/home/david/dev/coreir/src/passes/transform/rungenerators.cpp:10 In Run Generators
/home/david/dev/coreir/src/passes/transform/rungenerators.cpp:26 Done running generators
tests/test_space_time/test_downsample.py:7 (test_down_s)
def test_down_s():
num_out = 1
test_val = 3
elem_t = ST_Int()
down = DefineDown_S(1, 0, ST_Int(), has_valid=True)
tester = fault.Tester(down, down.CLK)
tester.circuit.valid_up = 1
tester.circuit.I[0] = test_val
tester.eval()
for i in range(num_out):
tester.circuit.O[i].expect(test_val)
tester.circuit.valid_down.expect(1)
> compile_and_run(tester)
test_downsample.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../aetherling/helpers/fault_helpers.py:87: in compile_and_run
}, directory="vBuild/", flags=["-Wno-fatal"])
../../../fault/fault/tester.py:302: in compile_and_run
self._compile_and_run(target=target, **kwargs)
../../../fault/fault/tester.py:286: in _compile_and_run
self._compile(target, **kwargs)
../../../fault/fault/tester.py:249: in _compile
self.targets[target] = self.make_target(target, **kwargs)
../../../fault/fault/tester.py:96: in make_target
return VerilatorTarget(self._circuit, **kwargs)
../../../fault/fault/verilator_target.py:111: in __init__
include_verilog_libraries, magma_output, magma_opts)
../../../fault/fault/verilog_target.py:47: in __init__
**self.magma_opts)
../../../magma/magma/compile.py:114: in compile
uniquification_pass(main, uniquification_mode)
../../../magma/magma/uniquification.py:102: in uniquification_pass
pass_.run()
../../../magma/magma/uniquification.py:79: in run
super(UniquificationPass, self).run()
../../../magma/magma/passes/passes.py:58: in run
self._run(self.main)
../../../magma/magma/uniquification.py:70: in _run
self._run( instancedefinition )
../../../magma/magma/uniquification.py:70: in _run
self._run( instancedefinition )
../../../magma/magma/uniquification.py:76: in _run
self(definition)
../../../magma/magma/uniquification.py:47: in __call__
key = _hash(definition)
../../../magma/magma/uniquification.py:33: in _hash
hash_struct = _make_hash_struct(definition)
../../../magma/magma/uniquification.py:26: in _make_hash_struct
repr_ = repr(definition)
../../../magma/magma/circuit.py:135: in __repr__
s += repr( cls.interface )
../../../magma/magma/interface.py:60: in __repr__
output = input.value()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = dehydrate_tArray_0_Array_8_Bit__.out
def value(self):
ts = [t.value() for t in self.ts]
for t in ts:
if t is None:
return None
if self.iswhole(ts):
> return ts[0].name.array
E IndexError: list index out of range
../../../magma/magma/array.py:247: IndexError
Assertion failed
Assertion failed
Assertion failed
Assertion failed
The error was occurring due to an invalid magma type. I was creating a Term for a magma type of "Array[0, Array[8, Bit]]". The calls to magma would succeed until I tried to compile the circuit to verilog. Please see https://github.com/David-Durst/aetherling/blob/f5320a674260dd361a5637f1970ae57d1b2ba79b/tests/test_term.py#L6-L13 for a simple test that shows this issue. Note, you will need to remove line 12 for the test to actually run. I've added that line so that my tests can pass.
@leonardt , can magma or fault print a better error message in this case?