Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/migen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dd0f3311cd4d
Choose a base ref
...
head repository: m-labs/migen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2f522bdd9f3f
Choose a head ref
  • 4 commits
  • 11 files changed
  • 1 contributor

Commits on Mar 15, 2013

  1. sim: remove PureSimulable (superseded by Module)

    Sebastien Bourdeauducq committed Mar 15, 2013
    Copy the full SHA
    51bec34 View commit details
  2. fhdl/specials: fix rename_clock_domain declarations

    Sebastien Bourdeauducq committed Mar 15, 2013
    Copy the full SHA
    7b49fd9 View commit details
  3. genlib/cdc/MultiReg: remove idomain

    Sebastien Bourdeauducq committed Mar 15, 2013
    Copy the full SHA
    e2d156e View commit details
  4. genlib/cdc/MultiReg: implement rename_clock_domain + get_clock_domains

    Sebastien Bourdeauducq committed Mar 15, 2013
    Copy the full SHA
    2f522bd View commit details
Showing with 32 additions and 32 deletions.
  1. +1 −1 examples/basic/psync.py
  2. +1 −1 examples/basic/simple_gpio.py
  3. +3 −2 examples/sim/fir.py
  4. +2 −2 migen/actorlib/sim.py
  5. +2 −2 migen/bus/csr.py
  6. +2 −2 migen/bus/memory.py
  7. +5 −4 migen/bus/wishbone.py
  8. +3 −3 migen/fhdl/specials.py
  9. +2 −2 migen/flow/hooks.py
  10. +11 −6 migen/genlib/cdc.py
  11. +0 −7 migen/sim/generic.py
2 changes: 1 addition & 1 deletion examples/basic/psync.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ def get_fragment(self):
class XilinxMultiReg:
@staticmethod
def lower(dr):
return XilinxMultiRegImpl(dr.i, dr.idomain, dr.o, dr.odomain, dr.n)
return XilinxMultiRegImpl(dr.i, dr.o, dr.odomain, dr.n)

ps = PulseSynchronizer("from", "to")
v = verilog.convert(ps, {ps.i, ps.o}, special_overrides={MultiReg: XilinxMultiReg})
2 changes: 1 addition & 1 deletion examples/basic/simple_gpio.py
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ def __init__(self, ninputs=32, noutputs=32):
###

gpio_in_s = Signal(ninputs)
self.specials += MultiReg(self.gpio_in, "ext", gpio_in_s, "sys")
self.specials += MultiReg(self.gpio_in, gpio_in_s, "sys")
self.comb += [
r_i.field.w.eq(gpio_in_s),
self.gpio_out.eq(r_o.field.r)
5 changes: 3 additions & 2 deletions examples/sim/fir.py
Original file line number Diff line number Diff line change
@@ -6,10 +6,11 @@
import matplotlib.pyplot as plt

from migen.fhdl.structure import *
from migen.fhdl.module import Module
from migen.fhdl import verilog
from migen.genlib.misc import optree
from migen.fhdl import autofragment
from migen.sim.generic import Simulator, PureSimulable
from migen.sim.generic import Simulator

# A synthesizable FIR filter.
class FIR:
@@ -36,7 +37,7 @@ def get_fragment(self):

# A test bench for our FIR filter.
# Generates a sine wave at the input and records the output.
class TB(PureSimulable):
class TB(Module):
def __init__(self, fir, frequency):
self.fir = fir
self.frequency = frequency
4 changes: 2 additions & 2 deletions migen/actorlib/sim.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from migen.fhdl.structure import *
from migen.fhdl.module import Module
from migen.flow.actor import *
from migen.flow.transactions import *
from migen.sim.generic import PureSimulable

# Generators yield None or a tuple of Tokens.
# Tokens for Sink endpoints are pulled and the "value" field filled in.
# Tokens for Source endpoints are pushed according to their "value" field.
#
# NB: the possibility to push several tokens at once is important to interact
# with actors that only accept a group of tokens when all of them are available.
class TokenExchanger(PureSimulable):
class TokenExchanger(Module):
def __init__(self, generator, actor):
self.generator = generator
self.actor = actor
4 changes: 2 additions & 2 deletions migen/bus/csr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from migen.fhdl.structure import *
from migen.fhdl.specials import Memory
from migen.fhdl.module import Module
from migen.bus.simple import *
from migen.bus.transactions import *
from migen.sim.generic import PureSimulable
from migen.bank.description import RegisterField
from migen.genlib.misc import chooser

@@ -19,7 +19,7 @@ def __init__(self):
class Interconnect(SimpleInterconnect):
pass

class Initiator(PureSimulable):
class Initiator(Module):
def __init__(self, generator, bus=None):
self.generator = generator
if bus is None:
4 changes: 2 additions & 2 deletions migen/bus/memory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from migen.fhdl.module import Module
from migen.bus.transactions import *
from migen.sim.generic import PureSimulable

def _byte_mask(orig, dat_w, sel):
r = 0
@@ -15,7 +15,7 @@ def _byte_mask(orig, dat_w, sel):
shift += 8
return r

class Initiator(PureSimulable):
class Initiator(Module):
def __init__(self, generator, mem):
self.generator = generator
self.mem = mem
9 changes: 5 additions & 4 deletions migen/bus/wishbone.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from migen.fhdl.structure import *
from migen.fhdl.specials import Memory
from migen.fhdl.module import Module
from migen.genlib import roundrobin
from migen.genlib.misc import optree
from migen.bus.simple import *
from migen.bus.transactions import *
from migen.sim.generic import Proxy, PureSimulable
from migen.sim.generic import Proxy

_desc = Description(
(M_TO_S, "adr", 30),
@@ -116,7 +117,7 @@ def __init__(self, masters, slaves, register=False):
def get_fragment(self):
return self._arbiter.get_fragment() + self._decoder.get_fragment()

class Tap(PureSimulable):
class Tap(Module):
def __init__(self, bus, handler=print):
self.bus = bus
self.handler = handler
@@ -133,7 +134,7 @@ def do_simulation(self, s):
s.rd(self.bus.dat_r))
self.handler(transaction)

class Initiator(PureSimulable):
class Initiator(Module):
def __init__(self, generator, bus=None):
self.generator = generator
if bus is None:
@@ -180,7 +181,7 @@ def write(self, address, data, sel):
def can_ack(self, bus):
return True

class Target(PureSimulable):
class Target(Module):
def __init__(self, model, bus=None):
if bus is None:
bus = Interface()
6 changes: 3 additions & 3 deletions migen/fhdl/specials.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
from migen.fhdl.verilog import _printexpr as verilog_printexpr

class Special(HUID):
def rename_clock_domain(self):
def rename_clock_domain(self, old, new):
pass

def get_clock_domains(self):
@@ -94,7 +94,7 @@ def get_io(self, name):
if isinstance(item, Instance._IO) and item.name == name:
return item.expr

def rename_clock_domain(self):
def rename_clock_domain(self, old, new):
for cr in filter(lambda x: isinstance(x, Instance._CR), self.items):
if cr.domain == old:
cr.domain = new
@@ -214,7 +214,7 @@ def get_port(self, write_capable=False, async_read=False,
self.ports.append(mp)
return mp

def rename_clock_domain(self):
def rename_clock_domain(self, old, new):
for port in self.ports:
if port.clock_domain == old:
port.clock_domain = new
4 changes: 2 additions & 2 deletions migen/flow/hooks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from migen.fhdl.structure import *
from migen.fhdl.module import Module
from migen.flow.actor import *
from migen.sim.generic import PureSimulable

class EndpointSimHook(PureSimulable):
class EndpointSimHook(Module):
def __init__(self, endpoint):
self.endpoint = endpoint

17 changes: 11 additions & 6 deletions migen/genlib/cdc.py
Original file line number Diff line number Diff line change
@@ -3,9 +3,8 @@
from migen.fhdl.tools import value_bits_sign, list_signals

class MultiRegImpl:
def __init__(self, i, idomain, o, odomain, n):
def __init__(self, i, o, odomain, n):
self.i = i
self.idomain = idomain
self.o = o
self.odomain = odomain

@@ -24,14 +23,20 @@ def get_fragment(self):
return Fragment(comb, {self.odomain: o_sync})

class MultiReg(Special):
def __init__(self, i, idomain, o, odomain, n=2):
def __init__(self, i, o, odomain, n=2):
Special.__init__(self)
self.i = i
self.idomain = idomain
self.o = o
self.odomain = odomain
self.n = n

def rename_clock_domain(self, old, new):
if self.odomain == old:
self.odomain = new

def get_clock_domains(self):
return {self.odomain}

def list_ios(self, ins, outs, inouts):
r = set()
if ins:
@@ -42,7 +47,7 @@ def list_ios(self, ins, outs, inouts):

@staticmethod
def lower(dr):
return MultiRegImpl(dr.i, dr.idomain, dr.o, dr.odomain, dr.n)
return MultiRegImpl(dr.i, dr.o, dr.odomain, dr.n)

class PulseSynchronizer:
def __init__(self, idomain, odomain):
@@ -66,4 +71,4 @@ def get_fragment(self):
]
return Fragment(comb,
{self.idomain: sync_i, self.odomain: sync_o},
specials={MultiReg(toggle_i, self.idomain, toggle_o, self.odomain)})
specials={MultiReg(toggle_i, toggle_o, self.odomain)})
7 changes: 0 additions & 7 deletions migen/sim/generic.py
Original file line number Diff line number Diff line change
@@ -203,10 +203,3 @@ def __setattr__(self, name, value):
item = getattr(self._obj, name)
assert(isinstance(item, Signal))
self._sim.wr(item, value)

class PureSimulable:
def do_simulation(self, s):
raise NotImplementedError("Need to overload do_simulation")

def get_fragment(self):
return Fragment(sim=[self.do_simulation])