Skip to content

Commit

Permalink
Merge e6e2cc6 into 0f1d554
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Dec 13, 2019
2 parents 0f1d554 + e6e2cc6 commit 61f047c
Show file tree
Hide file tree
Showing 152 changed files with 3,834 additions and 2,029 deletions.
33 changes: 33 additions & 0 deletions docs/magma_2_migration_guide.md
@@ -0,0 +1,33 @@
# Migrating to magma 2

* Operator definitions (e.g. `+`, `-`, ...) have moved from mantle to magma.
This should not cause any user facing code changes, but the names of
generated circuits may be different. It also means that coreir primitives
will always be used to implement the operators (before, it would dispatch to
the current mantle target). Support for other mantle targets will be added
later as implementations of the coreir primitives.
* Rename `<..>Type` to `<...>`. No more type constructors (e.g. `ArrayType`
becomes `Array`). Parametrized types are constructed using the bracket
syntax (e.g. `Array[5, Bit]`)
* `isinstance(..., <...>Kind)` -> `issubclass(..., <...>)`. Concrete
parameterized types are subclasses of the abstract type) (e.g. `isinstance(T,
BitsKind)` becomes `issubclass(T, Bits)`
* `_Bit` -> `Digital`. Renamed parent type of Bit, Clock, Reset, ...
* `Tuple(...)` -> `Product.from_fields("anon", dict(...))`. Tuple now refers to
a heterogenous type indexed by position (e.g. x[0], x[1], ...), while Product
is used for the key/value version (e.g. x.a, x.y, ...). Magma previously
used Tuple to represent both versions. This change is in line with the
`hwtypes` `Tuple` and `Product` types (as well as Python's `tuple` vs
`namedtuple`). `"anon"` is the name of the type (before all magma tuples
were "anonymous"). We are considering an interface for declaring
anonymous Products so the user does not have to supply a name.
* `<Tuple>.Ks` -> `<Tuple>.keys()` and `<Tuple>.Ts` -> `<Tuple>.types()` these
attributes were refactored to methods to be more clear/consistent with the
hwtypes tuple.
* `isinput`, `isinout`, `isoutput` renamed to `is_input`, `is_inout`,
`is_output` for clarity


See these PRs for examples of these changes
* Mantle: https://github.com/phanrahan/mantle/pull/165
* Fault: https://github.com/leonardt/fault/pull/187
16 changes: 4 additions & 12 deletions magma/__init__.py
Expand Up @@ -30,12 +30,12 @@ def wrapper(*args, **kwargs):

# types
from .t import *

from .bit import *

from .array import *
from .bits import *
# Define default operators that raise exceptions, rename so it doesn't muck
# with `from magma import *` code that also uses operator
import magma.operators
from .bfloat import BFloat
from .tuple import *
from .clock import *
from .conversions import *
Expand Down Expand Up @@ -74,15 +74,7 @@ def set_mantle_target(t):

from .uniquification import UniquificationPass

from .product import Product


from hwtypes.bit_vector_abc import TypeFamily


BitVector = Bits
UIntVector = UInt
SIntVector = SInt
_Family_ = TypeFamily(Bit, BitVector, UIntVector, SIntVector)
def get_family():
return _Family_
_Family_ = TypeFamily(Bit, Bits, UInt, SInt)

0 comments on commit 61f047c

Please sign in to comment.