Skip to content

Commit

Permalink
Merge 340836f into 7655fb6
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Jun 12, 2019
2 parents 7655fb6 + 340836f commit 5163854
Show file tree
Hide file tree
Showing 6 changed files with 1,381 additions and 4 deletions.
2 changes: 1 addition & 1 deletion magma/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, *largs, **kwargs):
for t in largs:
if isinstance(t, IntegerTypes):
t = VCC if t else GND
assert type(t) == self.T, (type(t), self.T)
assert isinstance(type(t), type(self.T)), (type(t), self.T)
self.ts.append(t)
elif len(largs) == 1 and isinstance(largs[0], int):
self.ts = []
Expand Down
8 changes: 7 additions & 1 deletion magma/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .tuple import TupleType, tuple_ as tuple_imported, TupleKind, namedtuple
from .bitutils import int2seq
import magma as m
import hwtypes

__all__ = ['bit']
__all__ += ['clock', 'reset', 'enable', 'asyncreset']
Expand Down Expand Up @@ -180,7 +181,12 @@ def bfloat(value, n=None):


def concat(*arrays):
ts = [t for a in arrays for t in a.ts] # flatten
ts = []
for a in arrays:
if isinstance(a, hwtypes.BitVector):
ts.extend(a.bits())
else:
ts.extend(a.ts)
return array(ts)


Expand Down
9 changes: 7 additions & 2 deletions magma/syntax/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ def visit_Call(self, node):
self.calls_seen.extend(ret)
func = astor.to_source(node.func).rstrip()
outputs = self.initial_value_map[attr][3].interface.outputs()
assert len(outputs) == 1, f"Expected one output: {outputs}"
return ast.Name(f"self_{attr}_{outputs[0]}", ast.Load())
if len(outputs) == 1:
return ast.Name(f"self_{attr}_{outputs[0]}", ast.Load())
else:
assert outputs, "Expected module with at least one output"
return ast.Tuple([ast.Name(f"self_{attr}_{output}",
ast.Load()) for output in outputs],
ast.Load())
return node

def visit_If(self, node):
Expand Down

0 comments on commit 5163854

Please sign in to comment.