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: b43495aab16e
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: eb921fb95798
Choose a head ref
  • 4 commits
  • 52 files changed
  • 1 contributor

Commits on Sep 12, 2015

  1. Copy the full SHA
    3367284 View commit details
  2. Copy the full SHA
    1bdb9be View commit details
  3. genlib: cleanup CRG

    sbourdeauducq committed Sep 12, 2015
    1
    Copy the full SHA
    9667d61 View commit details
  4. Copy the full SHA
    eb921fb View commit details
Showing with 137 additions and 143 deletions.
  1. +1 −1 README.md
  2. +1 −1 doc/fhdl.rst
  3. +3 −2 examples/basic/arrays.py
  4. +4 −5 examples/basic/fsm.py
  5. +1 −2 examples/basic/graycounter.py
  6. +1 −2 examples/basic/instance.py
  7. +4 −3 examples/basic/local_cd.py
  8. +5 −3 examples/basic/memory.py
  9. +1 −1 examples/basic/namer.py
  10. +6 −4 examples/basic/psync.py
  11. +7 −5 examples/basic/record.py
  12. +4 −2 examples/basic/reslice.py
  13. +4 −3 examples/basic/tristate.py
  14. +4 −3 examples/basic/two_dividers.py
  15. +1 −2 examples/sim/basic1.py
  16. +1 −2 examples/sim/basic2.py
  17. +4 −4 examples/sim/fir.py
  18. +1 −2 examples/sim/memory.py
  19. +10 −0 migen/__init__.py
  20. +2 −1 migen/build/altera/common.py
  21. +1 −2 migen/build/generic_platform.py
  22. +4 −4 migen/build/lattice/common.py
  23. +2 −6 migen/build/sim/verilator.py
  24. +3 −1 migen/build/xilinx/common.py
  25. +0 −1 migen/build/xilinx/ise.py
  26. +0 −2 migen/build/xilinx/vivado.py
  27. +3 −0 migen/fhdl/bitcontainer.py
  28. +6 −12 migen/fhdl/decorators.py
  29. +2 −3 migen/fhdl/edif.py
  30. +3 −0 migen/fhdl/module.py
  31. +1 −1 migen/fhdl/simplify.py
  32. +6 −1 migen/fhdl/specials.py
  33. +0 −7 migen/fhdl/std.py
  34. +3 −3 migen/genlib/cdc.py
  35. +3 −2 migen/genlib/coding.py
  36. +2 −1 migen/genlib/divider.py
  37. +3 −1 migen/genlib/fifo.py
  38. +5 −2 migen/genlib/fsm.py
  39. +5 −5 migen/genlib/io.py
  40. +2 −27 migen/genlib/misc.py
  41. +1 −1 migen/genlib/record.py
  42. +1 −2 migen/genlib/resetsync.py
  43. +3 −1 migen/genlib/roundrobin.py
  44. +2 −1 migen/genlib/sort.py
  45. +4 −1 migen/sim.py
  46. +1 −2 migen/test/support.py
  47. +1 −1 migen/test/test_coding.py
  48. +1 −1 migen/test/test_fifo.py
  49. +1 −1 migen/test/test_signed.py
  50. +1 −1 migen/test/test_size.py
  51. +1 −1 migen/test/test_sort.py
  52. +1 −1 migen/test/test_syntax.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ http://m-labs.hk/gateware.html
#### Quick intro

```python
from migen.fhdl.std import *
from migen import *
from migen.build.platforms import m1
plat = m1.Platform()
led = plat.request("user_led")
2 changes: 1 addition & 1 deletion doc/fhdl.rst
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ FHDL differs from MyHDL [myhdl]_ in fundamental ways. MyHDL follows the event-dr

.. [myhdl] http://www.myhdl.org
FHDL is made of several elements, which are briefly explained below. They all can be imported from the ``migen.fhdl.std`` module.
FHDL is made of several elements, which are briefly explained below. They all can be imported directly from the ``migen`` module.

Expressions
***********
5 changes: 3 additions & 2 deletions examples/basic/arrays.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog


@@ -24,4 +24,5 @@ def __init__(self):
outa = Array(Signal() for a in range(dy))
self.specials += Instance("test", o_O=outa[y], i_I=ina[x])

print(verilog.convert(Example()))
if __name__ == "__main__":
print(verilog.convert(Example()))
9 changes: 4 additions & 5 deletions examples/basic/fsm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog
from migen.genlib.fsm import FSM, NextState, NextValue


class Example(Module):
def __init__(self):
@@ -26,5 +24,6 @@ def __init__(self):
self.bl = myfsm.before_leaving("FOO")
self.al = myfsm.after_leaving("FOO")

example = Example()
print(verilog.convert(example, {example.s, example.counter, example.be, example.ae, example.bl, example.al}))
if __name__ == "__main__":
example = Example()
print(verilog.convert(example, {example.s, example.counter, example.be, example.ae, example.bl, example.al}))
3 changes: 1 addition & 2 deletions examples/basic/graycounter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from random import Random

from migen.fhdl.std import *
from migen import *
from migen.genlib.cdc import GrayCounter
from migen.sim import Simulator


def tb(dut):
3 changes: 1 addition & 2 deletions examples/basic/instance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import subprocess

from migen.fhdl.std import *
from migen.fhdl.specials import Instance
from migen import *
from migen.fhdl.verilog import convert


7 changes: 4 additions & 3 deletions examples/basic/local_cd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog
from migen.genlib.divider import Divider

@@ -14,5 +14,6 @@ def __init__(self):
self.submodules.foo = CDM()
self.submodules.bar = CDM()

mm = MultiMod()
print(verilog.convert(mm, {mm.foo.cd_sys.clk, mm.bar.cd_sys.clk}))
if __name__ == "__main__":
mm = MultiMod()
print(verilog.convert(mm, {mm.foo.cd_sys.clk, mm.bar.cd_sys.clk}))
8 changes: 5 additions & 3 deletions examples/basic/memory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog


@@ -11,5 +11,7 @@ def __init__(self):
self.ios = {p1.adr, p1.dat_r, p1.we, p1.dat_w,
p2.adr, p2.dat_r, p2.re}

example = Example()
print(verilog.convert(example, example.ios))

if __name__ == "__main__":
example = Example()
print(verilog.convert(example, example.ios))
2 changes: 1 addition & 1 deletion examples/basic/namer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog

from functools import reduce
10 changes: 6 additions & 4 deletions examples/basic/psync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl.specials import SynthesisDirective
from migen.fhdl import verilog
from migen.genlib.cdc import *
@@ -16,6 +16,8 @@ class XilinxMultiReg:
def lower(dr):
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})
print(v)

if __name__ == "__main__":
ps = PulseSynchronizer("from", "to")
v = verilog.convert(ps, {ps.i, ps.o}, special_overrides={MultiReg: XilinxMultiReg})
print(v)
12 changes: 7 additions & 5 deletions examples/basic/record.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog
from migen.genlib.record import *


L = [
("position", [
@@ -19,6 +19,8 @@ def __init__(self):
slave = Record(L)
self.comb += master.connect(slave)

print(verilog.convert(Test()))
print(layout_len(L))
print(layout_partial(L, "position/x", "color"))

if __name__ == "__main__":
print(verilog.convert(Test()))
print(layout_len(L))
print(layout_partial(L, "position/x", "color"))
6 changes: 4 additions & 2 deletions examples/basic/reslice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog


@@ -14,4 +14,6 @@ def __init__(self):
self.comb += s3.eq(0)
self.comb += d.eq(Cat(d[::-1], Cat(s1[:1], s3[-4:])[:3]))

print(verilog.convert(Example()))

if __name__ == "__main__":
print(verilog.convert(Example()))
7 changes: 4 additions & 3 deletions examples/basic/tristate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog


@@ -8,5 +8,6 @@ def __init__(self, n=6):
self.t = TSTriple(n)
self.specials += self.t.get_tristate(self.pad)

e = Example()
print(verilog.convert(e, ios={e.pad, e.t.o, e.t.oe, e.t.i}))
if __name__ == "__main__":
e = Example()
print(verilog.convert(e, ios={e.pad, e.t.o, e.t.oe, e.t.i}))
7 changes: 4 additions & 3 deletions examples/basic/two_dividers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog
from migen.genlib import divider

@@ -14,5 +14,6 @@ def __init__(self, width):
d1.ready_o, d1.quotient_o, d1.remainder_o, d1.start_i, d1.dividend_i, d1.divisor_i,
d2.ready_o, d2.quotient_o, d2.remainder_o, d2.start_i, d2.dividend_i, d2.divisor_i}

example = Example(16)
print(verilog.convert(example, example.ios | {example.ce, example.reset}))
if __name__ == "__main__":
example = Example(16)
print(verilog.convert(example, example.ios | {example.ce, example.reset}))
3 changes: 1 addition & 2 deletions examples/sim/basic1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from migen.fhdl.std import *
from migen.sim import Simulator
from migen import *


# Our simple counter, which increments at every cycle.
3 changes: 1 addition & 2 deletions examples/sim/basic2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from migen.fhdl.std import *
from migen.sim import Simulator
from migen import *


# A slightly more elaborate counter.
8 changes: 4 additions & 4 deletions examples/sim/fir.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from functools import reduce
from operator import add

from math import cos, pi
from scipy import signal
import matplotlib.pyplot as plt

from migen.fhdl.std import *
from migen import *
from migen.fhdl import verilog
from migen.sim import Simulator

from functools import reduce
from operator import add

# A synthesizable FIR filter.
class FIR(Module):
3 changes: 1 addition & 2 deletions examples/sim/memory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from migen.fhdl.std import *
from migen.sim.generic import run_simulation
from migen import *


class Mem(Module):
10 changes: 10 additions & 0 deletions migen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from migen.fhdl.structure import *
from migen.fhdl.module import *
from migen.fhdl.specials import *
from migen.fhdl.bitcontainer import *
from migen.fhdl.decorators import *

from migen.sim import *

from migen.genlib.record import *
from migen.genlib.fsm import *
3 changes: 2 additions & 1 deletion migen/build/altera/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from migen.fhdl.std import Instance, Module
from migen.fhdl.module import Module
from migen.fhdl.specials import Instance
from migen.genlib.io import DifferentialInput, DifferentialOutput


3 changes: 1 addition & 2 deletions migen/build/generic_platform.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import sys

from migen.fhdl.std import Signal
from migen.fhdl.structure import Signal
from migen.genlib.record import Record
from migen.genlib.io import CRG
from migen.fhdl import verilog, edif
from migen.util.misc import autotype

from migen.build import tools


8 changes: 4 additions & 4 deletions migen/build/lattice/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from migen.fhdl.std import *
from migen.fhdl.module import Module
from migen.fhdl.specials import Instance
from migen.genlib.io import *

from migen.genlib.resetsync import AsyncResetSynchronizer


@@ -36,6 +36,6 @@ def lower(dr):
return LatticeDDROutputImpl(dr.i1, dr.i2, dr.o, dr.clk)

lattice_special_overrides = {
AsyncResetSynchronizer: LatticeAsyncResetSynchronizer,
DDROutput: LatticeDDROutput
AsyncResetSynchronizer: LatticeAsyncResetSynchronizer,
DDROutput: LatticeDDROutput
}
8 changes: 2 additions & 6 deletions migen/build/sim/verilator.py
Original file line number Diff line number Diff line change
@@ -4,18 +4,14 @@
import os
import subprocess

from migen.fhdl.std import *
from migen.fhdl.structure import _Fragment

from migen.build import tools
from migen.build.generic_platform import *
from migen.build.sim import common


def _build_tb(platform, vns, serial, template):

def io_name(ressource, subsignal=None):
res = platform.lookup_request(ressource)
def io_name(resource, subsignal=None):
res = platform.lookup_request(resource)
if subsignal is not None:
res = getattr(res, subsignal)
return vns.get_name(res)
4 changes: 3 additions & 1 deletion migen/build/xilinx/common.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,9 @@
import sys
from distutils.version import StrictVersion

from migen.fhdl.std import *
from migen.fhdl.structure import *
from migen.fhdl.specials import Instance
from migen.fhdl.module import Module
from migen.fhdl.specials import SynthesisDirective
from migen.genlib.cdc import *
from migen.genlib.resetsync import AsyncResetSynchronizer
1 change: 0 additions & 1 deletion migen/build/xilinx/ise.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
import subprocess
import sys

from migen.fhdl.std import *
from migen.fhdl.structure import _Fragment
from migen.build.generic_platform import *
from migen.build import tools
2 changes: 0 additions & 2 deletions migen/build/xilinx/vivado.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,7 @@
import subprocess
import sys

from migen.fhdl.std import *
from migen.fhdl.structure import _Fragment

from migen.build.generic_platform import *
from migen.build import tools
from migen.build.xilinx import common
3 changes: 3 additions & 0 deletions migen/fhdl/bitcontainer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from migen.fhdl import structure as f


__all__ = ["log2_int", "bits_for", "flen", "fiter", "fslice", "freversed"]


def log2_int(n, need_pow2=True):
l = 1
r = 0
18 changes: 6 additions & 12 deletions migen/fhdl/decorators.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import warnings

from migen.fhdl.structure import *
from migen.fhdl.module import Module
from migen.fhdl.tools import insert_reset, rename_clock_domain


__all__ = ["DecorateModule",
"InsertCE", "InsertReset", "RenameClockDomains",
"CEInserter", "ResetInserter", "ClockDomainsRenamer",
"ModuleTransformer"]


class ModuleTransformer:
# overload this in derived classes
def transform_instance(self, i):
@@ -47,16 +51,6 @@ def __call__(self, victim):
else:
return self.wrap_class(victim)

@classmethod
def adhoc(cls, i, *args, **kwargs):
warnings.warn("deprecated, use the plain transformer", DeprecationWarning, 2)
return cls(*args, **kwargs)(i)


def DecorateModule(transformer, *args, **kwargs):
warnings.warn("deprecated, use the plain transformer", DeprecationWarning, 2)
return transformer.__self__(*args, **kwargs)


class ControlInserter(ModuleTransformer):
control_name = None # override this
5 changes: 2 additions & 3 deletions migen/fhdl/edif.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from collections import OrderedDict
from collections import namedtuple
from collections import OrderedDict, namedtuple

from migen.fhdl.std import *
from migen.fhdl.structure import *
from migen.fhdl.namer import build_namespace
from migen.fhdl.tools import list_special_ios
from migen.fhdl.structure import _Fragment
3 changes: 3 additions & 0 deletions migen/fhdl/module.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@
from migen.fhdl.tools import rename_clock_domain


__all__ = ["Module", "FinalizeError"]


class FinalizeError(Exception):
pass

2 changes: 1 addition & 1 deletion migen/fhdl/simplify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from migen.fhdl.std import *
from migen.fhdl.structure import *
from migen.fhdl.specials import _MemoryPort
from migen.fhdl.decorators import ModuleTransformer
from migen.util.misc import gcd_multiple
Loading