TriStateBuffer constructor

TriStateBuffer(
  1. Logic in_, {
  2. required Logic enable,
  3. String name = 'tristate',
})

Creates a tri-state buffer which drives out with in_ if enable is high, otherwise leaves it floating z.

Implementation

TriStateBuffer(Logic in_, {required Logic enable, super.name = 'tristate'})
    : _outDriver = Logic(name: 'outDriver', width: in_.width) {
  _inName = Naming.unpreferredName(in_.name);
  _outName = Naming.unpreferredName('${name}_${in_.name}');
  _enableName = Naming.unpreferredName('enable_${enable.name}');

  addInput(_inName, in_, width: in_.width);
  addInput(_enableName, enable);

  out = LogicNet(width: in_.width);
  addInOut(_outName, out, width: in_.width) <= _outDriver;

  _setup();
}