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/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 79a371025542
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 537d91851dc8
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 4, 2019

  1. Copy the full SHA
    38917e4 View commit details
  2. Copy the full SHA
    537d918 View commit details
Showing with 15 additions and 9 deletions.
  1. +2 −0 nmigen/compat/fhdl/module.py
  2. +13 −9 nmigen/compat/fhdl/specials.py
2 changes: 2 additions & 0 deletions nmigen/compat/fhdl/module.py
Original file line number Diff line number Diff line change
@@ -95,6 +95,8 @@ def __iadd__(self, other):


class CompatModule(ir.Elaboratable):
_Elaboratable__silence = True

# Actually returns nmigen.fhdl.Module, not a Fragment.
def get_fragment(self):
assert not self.get_fragment_called
22 changes: 13 additions & 9 deletions nmigen/compat/fhdl/specials.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
from ...hdl.ir import Fragment, Instance
from ...hdl.dsl import Module
from .module import Module as CompatModule
from ...lib.io import Pin


__all__ = ["TSTriple", "Instance", "Memory", "READ_FIRST", "WRITE_FIRST", "NO_CHANGE"]
@@ -32,22 +33,25 @@ def get_tristate(self, io):
class Tristate(Elaboratable):
def __init__(self, target, o, oe, i=None):
self.target = target
self.triple = TSTriple()
self.triple.o = o
self.triple.oe = oe
if i is not None:
self.triple.i = i
self.o = o
self.oe = oe
self.i = i if i is not None else None

def elaborate(self, platform):
if hasattr(platform, "get_input_output"):
return platform.get_input_output(self.triple, self.target, extras={})
pin = Pin(len(self.target), dir="oe" if self.i is None else "io")
pin.o = self.o
pin.oe = self.oe
if self.i is not None:
pin.i = self.i
return platform.get_input_output(pin, self.target, extras={})

m = Module()
m.d.comb += self.triple.i.eq(self.target)
m.d.comb += self.i.eq(self.target)
m.submodules += Instance("$tribuf",
p_WIDTH=len(self.target),
i_EN=self.triple.oe,
i_A=self.triple.o,
i_EN=self.oe,
i_A=self.o,
o_Y=self.target,
)