Skip to content

Commit

Permalink
Get rid of check_context_is_default check
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajsekhar Setaluri committed Dec 6, 2019
1 parent df23e27 commit bec7984
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
15 changes: 6 additions & 9 deletions magma/backend/coreir_.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ def __init__(self):


class CoreIRBackend:
def __init__(self, context=None, check_context_is_default=True):
# TODO(rsetaluri): prove this logic.
def __init__(self, context=None):
singleton = CoreIRContextSingleton().get_instance()
if context is None:
context = singleton
elif check_context_is_default and context != singleton:
logger.warn("Creating CoreIRBackend with non-singleton CoreIR "
"context. If you're sure you want to do this, set "
"check_context_is_default when initializing the "
"CoreIRBackend.")
if context is not singleton:
logger.warning("Creating CoreIRBackend with non-singleton CoreIR "
"context.")
self.modules = _context_to_modules.setdefault(context, {})
self.context = context
self.libs = keydefaultdict(self.context.get_lib)
Expand Down Expand Up @@ -120,9 +117,9 @@ def __call__(self, definition):
self.wrap_if_arst(port, definition)


def compile(main, file_name=None, context=None, check_context_is_default=True):
def compile(main, file_name=None, context=None):
InsertWrapCasts(main).run()
backend = CoreIRBackend(context, check_context_is_default)
backend = CoreIRBackend(context)
backend.compile(main)
if file_name is not None:
return backend.modules[main.coreir_name].save_to_file(file_name)
Expand Down
5 changes: 1 addition & 4 deletions magma/simulator/coreir_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,9 @@ def __init__(self, circuit, clock, coreir_filename=None, context=None,

if context is None:
self.ctx = GetMagmaContext()
check_context_is_default = True
else:
self.ctx = context
check_context_is_default = False
coreir_.compile(circuit, coreir_filename, context=self.ctx,
check_context_is_default=check_context_is_default)
coreir_.compile(circuit, coreir_filename, context=self.ctx)

# Initialize interpreter, get handle back to interpreter state
self.ctx.get_lib("commonlib")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_coreir/test_coreir.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def definition(cls):

def test_nested_clocks():
c = coreir.Context()
cirb = CoreIRBackend(c, check_context_is_default=False)
cirb = CoreIRBackend(c)
args = ['clocks', In(Array[2, Clock])]

inner_test_circuit = DefineCircuit('inner_test_nested_clocks', *args)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simulator/test_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def simulator_nested(simple):
testValInt = 80
testValBits = int2seq(testValInt)
c = coreir.Context()
cirb = CoreIRBackend(c, check_context_is_default=False)
cirb = CoreIRBackend(c)
scope = Scope()
inDims = [4, 3, width]
toNest = Array[inDims[1], Array[inDims[2], Bit]]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simulator/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_simulator_tuple():
width = 8
testValInt = 80
c = coreir.Context()
cirb = CoreIRBackend(c, check_context_is_default=False)
cirb = CoreIRBackend(c)
scope = Scope()
inDims = [2, width]
tupleEl = Array[inDims[1], Bit]
Expand Down

0 comments on commit bec7984

Please sign in to comment.