Implemented tristate_logic function. Changed tri-state buffer to a function that returns a Gate instance.