hdl.ast: simplify Mux implementation.

This commit is contained in:
whitequark 2021-10-02 14:18:02 +00:00
parent 65499d5c45
commit e88d283ed3
4 changed files with 9 additions and 4 deletions

View file

@ -562,6 +562,8 @@ class _RHSValueCompiler(_ValueCompiler):
def on_Operator_mux(self, value):
sel, val1, val0 = value.operands
if len(sel) != 1:
sel = sel.bool()
val1_bits, val1_sign = val1.shape()
val0_bits, val0_sign = val0.shape()
res_bits, res_sign = value.shape()

View file

@ -735,9 +735,6 @@ def Mux(sel, val1, val0):
Value, out
Output ``Value``. If ``sel`` is asserted, the Mux returns ``val1``, else ``val0``.
"""
sel = Value.cast(sel)
if len(sel) != 1:
sel = sel.bool()
return Operator("m", [sel, val1, val0])