Interface ByteSignalSource

All Superinterfaces:
AbstractSignalSource, ByteSupplier, CompilableDataFlow
All Known Subinterfaces:
ByteClockedSignalSource
All Known Implementing Classes:
ByteClockedSignalSource.AbstractRandom, ByteDelay, ByteMultiDelay, ByteMux, BytePost, ByteProcessMux, ByteSaH, ByteSequencerColumn, ByteSignalPort, ByteSignalSourceChooser, ByteSignalSourceChooser.OfEnum, ByteSignalSourceChooser.OfEnumInt, ByteSignalSourceChooser.OfInt, ByteStoredSignalSource, CompilableByteStoredSignalSource
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ByteSignalSource extends AbstractSignalSource, ByteSupplier
Interface of a signal (time-dependent value) source of primitive type byte.

This basic interface is neutral with respect to whether values may change at arbitrary times or synchronously with respect to a clock, and to whether values are computed on the fly when demanded, or stored when available and then just retrieved.

See Also:
  • Method Details

    • getAsByte

      byte getAsByte()
      Returns the current value of this signal source.

      The value may be either computed on demand, or retrieved from storage.

      Implementations of this method should have no side effect.

      Specified by:
      getAsByte in interface ByteSupplier
      Returns:
      the current value of this signal source
    • getValueClass

      default Class<?> getValueClass()
      Returns the type of values produced by this entity.

      For signals of primitive value type, the result will be the corresponding pseudoclass.

      This implementation returns the primitive pseudoclass byte.class.

      Specified by:
      getValueClass in interface CompilableDataFlow
      Returns:
      the type of signal values that this entity produces
      See Also:
    • getConstantAsByte

      default Optional<Byte> getConstantAsByte()
      Returns the constant value of this signal source, if applicable.
      Returns:
      an Optional containing the value of this signal source if it is constant, or Optional.empty() otherwise.
    • hasConstantAsByte

      default boolean hasConstantAsByte()
      Checks whether this signal source has a constant value.
      Returns:
      true iff the value of this signal source does not change over time
    • compileDataFlow

      default Consumer<CompilationContext> compileDataFlow()
      Returns a code generator for outputting the value of this entity.

      This implementation generates code to invoke this.getAsByte().

      Specified by:
      compileDataFlow in interface CompilableDataFlow
    • constant

      static ByteSignalSource constant(byte value)
      Returns a signal source whose value is constant (never changes).
      Parameters:
      value - the value of the new signal source
      Returns:
      a signal source that always has the given value
    • map

      Returns a signal source whose values are derived from the values of this signal source by applying a unary function.

      The implementation yields a signal source that computes the derived value by applying the given function every time its getAsByte() method is invoked. If the computation is costly and the value reused often, it may be convenient to compute and store the value proactively driven by a clock.

      Parameters:
      op - the function to apply to each value
      See Also:
    • zipWith

      Returns a signal source whose values are derived from the simultaneous values of this and another signal source by applying a binary function.

      The implementation yields a signal source that computes the derived value by applying the given function every time its getAsByte() method is invoked. If the computation is costly and the value reused often, it may be convenient to compute the value proactively driven by a clock.

      Parameters:
      op - the function to apply to each pair of values
      other - the other signal source to consider
      See Also:
    • guard

      default BooleanSignalSource guard(BytePredicate pred)
      Returns a boolean signal source whose values are derived from the values of this signal source by applying a unary predicate.

      The implementation yields a signal source that computes the derived value by applying the given predicate every time its getAsByte() method is invoked. If the computation is costly and the value reused often, it may be convenient to compute the value proactively driven by a clock.

      Parameters:
      pred - the predicate to apply to each value
      See Also:
    • relateWith

      default BooleanSignalSource relateWith(ByteBiPredicate pred, ByteSignalSource other)
      Returns a boolean signal source whose values are derived from the simultaneous values of this and another signal source by applying a binary predicate.

      The implementation yields a signal source that computes the derived value by applying the given predicate every time its getAsByte() method is invoked. If the computation is costly and the value reused often, it may be convenient to compute the value proactively driven by a clock.

      Parameters:
      pred - the predicate to apply to each value
      other - the other signal source to consider
      See Also:
    • clock

      @Undocumented static ByteClockedSignalSource clock(ByteSignalSource output, Process... processes)
    • invariant

    • stored

      default ByteClockedSignalSource stored()
      Returns a new signal source that stores snapshot values of this signal source driven by a clock.

      The getAsByte() method of the returned signal source is guaranteed to be extremely fast, both in interpreted and compiled mode. The computational effort of the underlying signal source is instead spent on the Process.step() method of the returned signal source, to be invoked at each clock tick.

      If the underlying signal source is constant, the value is forwarded when the Process.init() method of the returned signal source is invoked, where as its implementation of Process.step() does nothing.

      Returns:
      a new signal source that takes value snapshots of this signal source.
    • delayed

      default ByteClockedSignalSource delayed(byte initialValue)
      Returns a new signal source that mirrors the values of this signal source delayed by one clock tick.
      Parameters:
      initialValue - the initial value to output for the first clock tick
    • delayed

      default ByteClockedSignalSource delayed(byte... initialValues)
      Returns a new signal source that mirror the values of this signal source delayed by a given number of clock ticks.

      The length of the delay in clock ticks is specified implicitly by the number of initial values.

      Parameters:
      initialValues - the initial values to output for the first clock ticks
    • delayedFeedback

      static ByteClockedSignalSource delayedFeedback(Function<? super ByteClockedSignalSource,? extends ByteSignalSource> loop, byte initialValue)
      Returns a new signal source that receives its own delayed output as input.

      The circular data flow is constructed by specifying a function that receives as its argument a delayed signal source that will be fed back from the source that it returns. The passed function is applied exactly once.

      The output signal source is used both internally for the delayed feedback, and possibly externally by a consumer. Hence its value is stored implicitly in an intermediate variable in order to avoid duplicate computations.

      Parameters:
      loop - the function that creates the output signal source, given its delayed feedback
      initialValue - the initial value of the delayed feedback
    • delayedFeedback

      @SafeVarargs static ByteClockedSignalSource delayedFeedback(Function<? super ByteClockedSignalSource,? extends ByteSignalSource> loop, byte... initialValues)
    • probe

      default Process probe(Object key)
      Returns a realtime event that, when fired, notifies the concerned observer of the current value of this signal source.
      Parameters:
      key - the key to associate the value of this signal source with
      See Also:
    • choose

      static ByteSignalSource choose(BooleanSignalSource condition, ByteSignalSource inTrue, ByteSignalSource inFalse)
      Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of a condition signal source.

      At any point in time, choose(condition, x, y).getAsInt() == (this.getAsByte() ? x : y).getAsInt() holds.

      Parameters:
      condition - the condition signal source
      inTrue - the signal source to consider when the value of the condition signal source is true
      inFalse - the signal source to consider when the value of the condition signal source is false
    • asInt

      @Undocumented default IntSignalSource asInt()
    • negate

      default ByteSignalSource negate()
      Returns a new signal source whose value is the negative of the value of this signal source.

      For a signal source that = this.negate(), at any point in time, that.getAsByte() == -this.getAsByte() holds.

    • add

      default ByteSignalSource add(ByteSignalSource other)
      Returns a new signal source whose value is the sum of the simultaneous values of this and another signal source.

      At any point in time, this.add(other).getAsByte() == this.getAsByte() + other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • multiply

      default ByteSignalSource multiply(ByteSignalSource other)
      Returns a new signal source whose value is the product of the simultaneous values of this and another signal source.

      At any point in time, this.multiply(other).getAsByte() == this.getAsByte() * other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • subtract

      default ByteSignalSource subtract(ByteSignalSource other)
      Returns a new signal source whose value is the difference of the simultaneous values of this and another signal source.

      At any point in time, this.subtract(other).getAsByte() == this.getAsByte() - other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • divide

      default ByteSignalSource divide(ByteSignalSource other)
      Returns a new signal source whose value is the quotient of the simultaneous values of this and another signal source.

      At any point in time, this.divide(other).getAsByte() == this.getAsByte() / other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • modulo

      default ByteSignalSource modulo(ByteSignalSource other)
      Returns a new signal source whose value is the division remainder of the simultaneous values of this and another signal source.

      At any point in time, this.modulo(other).getAsByte() == this.getAsByte() % other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • abs

      default ByteSignalSource abs()
      Returns a new signal source whose value is the absolute of the value of this signal source.

      At any point in time, this.abs().getAsByte() == Math.abs(this.getAsByte()) holds.

    • min

      default ByteSignalSource min(ByteSignalSource other)
      Returns a new signal source whose value is the minimum of the simultaneous values of this and another signal source.

      At any point in time, this.min(other).getAsByte() == Math.min(this.getAsByte(), other.getAsByte()) holds.

      Parameters:
      other - the other signal source to consider
    • max

      default ByteSignalSource max(ByteSignalSource other)
      Returns a new signal source whose value is the maximum of the simultaneous values of this and another signal source.

      At any point in time, this.max(other).getAsByte() == Math.max(this.getAsByte(), other.getAsByte()) holds.

      Parameters:
      other - the other signal source to consider
    • positive

      default BooleanSignalSource positive()
      Returns a new signal source whose value is true iff the value of this signal source is a positive number.

      At any point in time, this.positive().getAsBoolean() == this.getAsByte() > 0 holds.

    • negative

      default BooleanSignalSource negative()
      Returns a new signal source whose value is true iff the value of this signal source is a negative number.

      At any point in time, this.positive().getAsBoolean() == this.getAsByte() < 0 holds.

    • nonpositive

      default BooleanSignalSource nonpositive()
      Returns a new signal source whose value is true iff the value of this signal source is a nonpositive number.

      At any point in time, this.positive().getAsBoolean() == this.getAsByte() <= 0 holds.

    • nonnegative

      default BooleanSignalSource nonnegative()
      Returns a new signal source whose value is true iff the value of this signal source is a nonnegative number.

      At any point in time, this.positive().getAsBoolean() == this.getAsByte() >= 0 holds.

    • zero

      default BooleanSignalSource zero()
      Returns a new signal source whose value is true iff the value of this signal source is the number zero.

      At any point in time, this.positive().getAsBoolean() == this.getAsByte() == 0 holds.

    • nonzero

      default BooleanSignalSource nonzero()
      Returns a new signal source whose value is true iff the value of this signal source is not the number zero.

      At any point in time, this.positive().getAsBoolean() == this.getAsByte() != 0 holds.

    • lessThan

      default BooleanSignalSource lessThan(ByteSignalSource other)
      Returns a new signal source whose value is true iff the value of this signal source is less than the simultaneous value of another signal source.

      At any point in time, this.lessThan(other).getAsBoolean() == this.getAsByte() < other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • greaterThan

      default BooleanSignalSource greaterThan(ByteSignalSource other)
      Returns a new signal source whose value is true iff the value of this signal source is greater than the simultaneous value of another signal source.

      At any point in time, this.lessThan(other).getAsBoolean() == this.getAsByte() > other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • lessOrEqual

      default BooleanSignalSource lessOrEqual(ByteSignalSource other)
      Returns a new signal source whose value is true iff the value of this signal source is less than or equal to the simultaneous value of another signal source.

      At any point in time, this.lessOrEqua;(other).getAsBoolean() == this.getAsByte() <= other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • greaterOrEqual

      default BooleanSignalSource greaterOrEqual(ByteSignalSource other)
      Returns a new signal source whose value is true iff the value of this signal source is greater than or equal to the simultaneous value of another signal source.

      At any point in time, this.greaterOrEqual(other).getAsBoolean() == this.getAsByte() >= other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • equal

      default BooleanSignalSource equal(ByteSignalSource other)
      Returns a new signal source whose value is true iff the value of this signal source is equal to the simultaneous value of another signal source.

      At any point in time, this.equal(other).getAsBoolean() == this.getAsByte() == other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • nonEqual

      default BooleanSignalSource nonEqual(ByteSignalSource other)
      Returns a new signal source whose value is true iff the value of this signal source is not equal to the simultaneous value of another signal source.

      At any point in time, this.nonEqual(other).getAsBoolean() == this.getAsByte() != other.getAsByte() holds.

      Parameters:
      other - the other signal source to consider
    • choose

      static <E extends Enum<E>> ByteSignalSource choose(SignalSource<E> selector, EnumMap<E,? extends ByteSignalSource> cases)
      Returns a new signal source whose value is selected dynamically from a range of cases indexed by enum values.

      At any point in time, choose(s, m).getAsByte() == m.get(s.get()).getAsByte() holds.

      The given map cases is assumed to be immutable and to contain an entry for every possible value of the enum type E.

      Type Parameters:
      E - the type of enum values
      Parameters:
      selector - the signal source that provides the enum value
      cases - a map of enum values to signal sources to select from
    • choose

      static <E extends Enum<E>> ByteSignalSource choose(EnumSignalSource<E> selector, EnumMap<E,? extends ByteSignalSource> cases)
      Returns a new signal source whose value is selected dynamically from a range of cases indexed by enum values.

      At any point in time, choose(s, m).getAsByte() == m.get(E.values()[s.getAsInt()]).getAsByte() holds.

      The given map cases is assumed to be immutable and to contain an entry for every possible value of the enum type E.

      Type Parameters:
      E - the type of enum values
      Parameters:
      selector - the signal source that provides the ordinal number of the enum value
      cases - a map of enum values to signal sources to select from
    • choose

      @SafeVarargs static <E extends Enum<E>> ByteSignalSource choose(EnumSignalSource<E> selector, ByteSignalSource... cases)
      Returns a new signal source whose value is selected dynamically from a range of cases indexed by enum values.

      At any point in time, choose(s, a).getAsByte() == m[s.getAsInt()].getAsByte() holds.

      The given array cases is assumed to be immutable and to contain an element for every possible value of the enum type E.

      Type Parameters:
      E - the type of enum values
      Parameters:
      selector - the signal source that provides the enum value
      cases - an array signal sources to select from, in the definition order of enum elements
    • sampleAndHold

      default ByteClockedSignalSource sampleAndHold(BooleanSignalSource hold, byte initialValue)
      Returns a new clocked signal source whose value at each clock tick is either the current value of this signal source (sample mode), or its own value at the previous clock tick (hold mode), depending on the current value of a given boolean signal source.
      Parameters:
      hold - a boolean signal source that, at each clock tick, selects hold mode if its value is true, or sample mode if its value is false
      initialValue - the initial value to use if in hold mode at the first clock tick
    • power

    • compileMainSignalSource

      @Undocumented default void compileMainSignalSource(CompilationContext context)
    • publishStoredValueVariable

      @Undocumented default void publishStoredValueVariable(CompilationContext context)
    • fromArray

      static ByteSignalSource fromArray(byte[] data, IntSignalSource index)
      Returns a new signal source whose value is an element of a given array, whose index is determined by a given signal source. At execution time, the value of the index signal source must be a valid index in the array, or an exception occurs. (This implies that using an empty array as backing store results in a signal source that cannot be executed.)
      Parameters:
      data - the array to read from
      index - the signal source that determines the index
    • fromArrayCyclic

      static ByteSignalSource fromArrayCyclic(byte[] data, IntSignalSource index)
      Returns a new signal source whose value is an element of a given array, whose index is determined by a given signal source. The value of the index signal source is normalized cyclically (modulo the array length) to a valid index.
      Parameters:
      data - the array to read from
      index - the signal source that determines the index
    • DEBUG

      @Undocumented default Process DEBUG(String format)
    • asFloat

      default FloatSignalSource asFloat()
    • asDouble

      default DoubleSignalSource asDouble()