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: d139f340b33c
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: 247454ef2fbe
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 2, 2019

  1. hdl.ast: don't crash on Mux(<bool>, ...).

    Fixes #240.
    whitequark committed Oct 2, 2019
    Copy the full SHA
    247454e View commit details
Showing with 6 additions and 1 deletion.
  1. +2 −1 nmigen/hdl/ast.py
  2. +4 −0 nmigen/test/test_hdl_ast.py
3 changes: 2 additions & 1 deletion nmigen/hdl/ast.py
Original file line number Diff line number Diff line change
@@ -526,8 +526,9 @@ def Mux(sel, val1, val0):
Value, out
Output ``Value``. If ``sel`` is asserted, the Mux returns ``val1``, else ``val0``.
"""
sel = Value.wrap(sel)
if len(sel) != 1:
sel = Value.wrap(sel).bool()
sel = sel.bool()
return Operator("m", [sel, val1, val0])


4 changes: 4 additions & 0 deletions nmigen/test/test_hdl_ast.py
Original file line number Diff line number Diff line change
@@ -292,6 +292,10 @@ def test_mux_wide(self):
v = Mux(s, Const(0, (4, False)), Const(0, (6, False)))
self.assertEqual(repr(v), "(m (b (const 3'd4)) (const 4'd0) (const 6'd0))")

def test_mux_bool(self):
v = Mux(True, Const(0), Const(0))
self.assertEqual(repr(v), "(m (const 1'd1)) (const 1'd0) (const 1'd0))")

def test_bool(self):
v = Const(0).bool()
self.assertEqual(repr(v), "(b (const 1'd0))")