Skip to content

Commit

Permalink
Merge 1a1d361 into c2f9eed
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshegarty committed Oct 15, 2019
2 parents c2f9eed + 1a1d361 commit a818e1e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
4 changes: 2 additions & 2 deletions magma/backend/coreir_.py
Expand Up @@ -4,7 +4,7 @@
from ..bit import VCC, GND, BitType, BitIn, BitOut, MakeBit, BitKind
from ..array import ArrayKind, ArrayType, Array
from ..tuple import TupleKind, TupleType, Tuple
from ..clock import wiredefaultclock, wireclock, ClockType, Clock, ResetType, ClockKind, EnableKind, ResetKind, AsyncResetType, AsyncResetKind
from ..clock import wiredefaultclock, wireclock, ClockType, Clock, ResetType, ClockKind, EnableKind, ResetKind, AsyncResetType, AsyncResetKind, ResetNKind, AsyncResetNKind
from ..bitutils import seq2int
from ..backend.verilog import find
from ..logging import error
Expand Down Expand Up @@ -113,7 +113,7 @@ def check_type(port, errorMessage=""):
elif isinstance(port, TupleKind):
for (k, t) in zip(port.Ks, port.Ts):
check_type(t, errorMessage.format("Tuple({}:{})".format(k, "{}")))
elif isinstance(port, (BitKind, ClockKind, EnableKind, ResetKind, AsyncResetKind)):
elif isinstance(port, (BitKind, ClockKind, EnableKind, ResetKind, AsyncResetKind, ResetNKind, AsyncResetNKind)):
return
else:
raise CoreIRBackendError(errorMessage.format(str(port)))
Expand Down
59 changes: 58 additions & 1 deletion magma/clock.py
Expand Up @@ -9,9 +9,15 @@
__all__ += ['ResetKind', 'ResetType']
__all__ += ['Reset', 'ResetIn', 'ResetOut']

__all__ += ['ResetNKind', 'ResetNType']
__all__ += ['ResetN', 'ResetNIn', 'ResetNOut']

__all__ += ['AsyncResetKind', 'AsyncResetType']
__all__ += ['AsyncReset', 'AsyncResetIn', 'AsyncResetOut']

__all__ += ['AsyncResetNKind', 'AsyncResetNType']
__all__ += ['AsyncResetN', 'AsyncResetNIn', 'AsyncResetNOut']

__all__ += ['EnableKind', 'EnableType']
__all__ += ['Enable', 'EnableIn', 'EnableOut']

Expand Down Expand Up @@ -45,7 +51,7 @@ class ClockType(_BitType):
ClockIn = ClockKind('Clock', (ClockType,), dict(direction=INPUT))
ClockOut = ClockKind('Clock', (ClockType,), dict(direction=OUTPUT))


# synchronous reset, active high (i.e. reset when signal is 1)
class ResetKind(_BitKind):
def __str__(cls):
if cls.isinput(): return 'In(Reset)'
Expand All @@ -70,6 +76,32 @@ class ResetType(_BitType):
ResetIn = ResetKind('Reset', (ResetType,), dict(direction=INPUT))
ResetOut = ResetKind('Reset', (ResetType,), dict(direction=OUTPUT))

# synchronous reset, active low (i.e. reset when signal is 0)
class ResetNKind(_BitKind):
def __str__(cls):
if cls.isinput(): return 'In(ResetN)'
if cls.isoutput(): return 'Out(ResetN)'
return 'ResetN'

def qualify(cls, direction):
if direction is None: return ResetN
elif direction == INPUT: return ResetNIn
elif direction == OUTPUT: return ResetNOut
return cls

def flip(cls):
if cls.isoriented(INPUT): return ResetNOut
elif cls.isoriented(OUTPUT): return ResetNIn
return cls

class ResetNType(_BitType):
pass

ResetN = ResetNKind('ResetN', (ResetNType,), {})
ResetNIn = ResetNKind('ResetN', (ResetNType,), dict(direction=INPUT))
ResetNOut = ResetNKind('ResetN', (ResetNType,), dict(direction=OUTPUT))

# asynchronous reset, active high (i.e. reset when signal is 1)
class AsyncResetKind(_BitKind):
def __str__(cls):
if cls.isinput(): return 'In(AsyncReset)'
Expand All @@ -94,6 +126,31 @@ class AsyncResetType(_BitType):
AsyncResetIn = AsyncResetKind('AsyncReset', (AsyncResetType,), dict(direction=INPUT))
AsyncResetOut = AsyncResetKind('AsyncReset', (AsyncResetType,), dict(direction=OUTPUT))

# asynchronous reset, active low (i.e. reset when signal is 0)
class AsyncResetNKind(_BitKind):
def __str__(cls):
if cls.isinput(): return 'In(AsyncResetN)'
if cls.isoutput(): return 'Out(AsyncResetN)'
return 'AsyncResetN'

def qualify(cls, direction):
if direction is None: return AsyncResetN
elif direction == INPUT: return AsyncResetNIn
elif direction == OUTPUT: return AsyncResetNOut
return cls

def flip(cls):
if cls.isoriented(INPUT): return AsyncResetNOut
elif cls.isoriented(OUTPUT): return AsyncResetNIn
return cls

class AsyncResetNType(_BitType):
pass

AsyncResetN = AsyncResetNKind('AsyncResetN', (AsyncResetNType,), {})
AsyncResetNIn = AsyncResetNKind('AsyncResetN', (AsyncResetNType,), dict(direction=INPUT))
AsyncResetNOut = AsyncResetNKind('AsyncResetN', (AsyncResetNType,), dict(direction=OUTPUT))

# Preset
# Clear

Expand Down

0 comments on commit a818e1e

Please sign in to comment.