Skip to content

Commit

Permalink
Extend concat to support bitvector
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Jun 11, 2019
1 parent c8c3aee commit a7c45c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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 type(t) == 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
2 changes: 1 addition & 1 deletion magma/syntax/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def visit_Call(self, node):
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}_{outputs}",
return ast.Tuple([ast.Name(f"self_{attr}_{output}",
ast.Load()) for output in outputs],
ast.Load())
return node
Expand Down

0 comments on commit a7c45c7

Please sign in to comment.