Skip to content

Commit

Permalink
elsewhere: do not create interface in default param
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Dec 6, 2012
1 parent 62187aa commit 280a87e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions migen/bus/csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class Interconnect(SimpleInterconnect):
pass

class Initiator(PureSimulable):
def __init__(self, generator, bus=Interface()):
def __init__(self, generator, bus=None):
self.generator = generator
if bus is None:
bus = Interface()
self.bus = bus
self.transaction = None
self.done = False
Expand Down Expand Up @@ -50,7 +52,7 @@ def _compute_page_bits(nwords):
return 0

class SRAM:
def __init__(self, mem_or_size, address, bus=Interface()):
def __init__(self, mem_or_size, address, bus=None):
if isinstance(mem_or_size, Memory):
assert(mem_or_size.width <= data_width)
self.mem = mem_or_size
Expand All @@ -62,6 +64,8 @@ def __init__(self, mem_or_size, address, bus=Interface()):
self._page = RegisterField("page", page_bits)
else:
self._page = None
if bus is None:
bus = Interface()
self.bus = bus

def get_registers(self):
Expand Down
12 changes: 9 additions & 3 deletions migen/bus/wishbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ def do_simulation(self, s):
self.handler(transaction)

class Initiator(PureSimulable):
def __init__(self, generator, bus=Interface()):
def __init__(self, generator, bus=None):
self.generator = generator
if bus is None:
bus = Interface()
self.bus = bus
self.transaction_start = 0
self.transaction = None
Expand Down Expand Up @@ -178,7 +180,9 @@ def can_ack(self, bus):
return True

class Target(PureSimulable):
def __init__(self, model, bus=Interface()):
def __init__(self, model, bus=None):
if bus is None:
bus = Interface()
self.bus = bus
self.model = model

Expand All @@ -195,12 +199,14 @@ def do_simulation(self, s):
bus.ack = 0

class SRAM:
def __init__(self, mem_or_size, bus=Interface()):
def __init__(self, mem_or_size, bus=None):
if isinstance(mem_or_size, Memory):
assert(mem_or_size.width <= 32)
self.mem = mem_or_size
else:
self.mem = Memory(32, mem_or_size//4)
if bus is None:
bus = Interface()
self.bus = bus

def get_fragment(self):
Expand Down

0 comments on commit 280a87e

Please sign in to comment.