Mux constructor
Constructs a multiplexer which passes d0
or d1
to out depending
on if control
is 0 or 1, respectively.
Implementation
Mux(Logic control, Logic d1, Logic d0, {super.name = 'mux'}) {
if (control.width != 1) {
throw PortWidthMismatchException(control, 1);
}
if (d0.width != d1.width) {
throw PortWidthMismatchException.equalWidth(d0, d1);
}
_controlName = Naming.unpreferredName('control_${control.name}');
_d0Name = Naming.unpreferredName('d0_${d0.name}');
_d1Name = Naming.unpreferredName('d1_${d1.name}');
_outName = Naming.unpreferredName('out');
addInput(_controlName, control);
addInput(_d0Name, d0, width: d0.width);
addInput(_d1Name, d1, width: d1.width);
addOutput(_outName, width: d0.width);
_setup();
}