Annotation Interface SubcircuitComponent


@Retention(RUNTIME) public @interface SubcircuitComponent
Instructs CircuitSimExtension to find and inject a CircuitSim component into the annotated field in a test class.

The annotated field can be a InputPin, OutputPin, Register, MockRegister, Ram, Rom, Clock, or Button.

When you annotate such a field in a test class with this annotation, CircuitSimExtension will search the subcircuit for a suitable component matching the requirements specified by the parameters to this annotation.

If label() is "" (the default), it will search for a label matching the name of the field instead. Also, note that bits() is required for some components.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Please see type() for details on this enum.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The bit size of a matching Pin.
    The label of a matching Pin.
    boolean
    Used to tell the tester library not to look up the component by label and instead to find this component by looking for the only instance of such component present in the circuit (optionally recursively via recursiveSearch()).
    boolean
    Search for this component not only directly in the subcircuit identified with SubcircuitTest but also in any subcircuits placed in it.
    For OutputPins: The type of "pin".
  • Element Details

    • label

      String label
      The label of a matching Pin. If empty (the default), CircuitSimExtension will use the name of the field.
      Returns:
      The label of a matching Pin.
      Default:
      ""
    • bits

      int bits
      The bit size of a matching Pin.

      This parameter must be provided for InputPins, OutputPins, Registers, MockRegisters, Rams, and Roms.

      This parameter must NOT be provided for Clocks and Buttons.

      Returns:
      The bit size of the desired compoment.
      Default:
      -1
    • onlyInstance

      boolean onlyInstance
      Used to tell the tester library not to look up the component by label and instead to find this component by looking for the only instance of such component present in the circuit (optionally recursively via recursiveSearch()).
      Returns:
      true if this should be the only component of its type present in the circuit (e.g., the only register), else false
      Default:
      false
    • recursiveSearch

      boolean recursiveSearch
      Search for this component not only directly in the subcircuit identified with SubcircuitTest but also in any subcircuits placed in it.

      For example, if you are autograding a simple finite state machine homework and a student is a subcircuit enthusiast and places their actual register deep in many levels of subcircuits, this parameter would tell the autograder to go subcircuit spelunking to find the register.

      Returns:
      true to look for the desired component in subcircuits placed in this subcircuit, else false
      Default:
      false
    • type

      For OutputPins: The type of "pin". The default is a literal existing Pin component, but you can set this to TUNNEL to spy on the value of a tunnel by attaching an OutputPin to it. (The label is then the label of the tunnel you want to spy instead of the label of an existing pin.) This parameter is valid only for OutputPins.
      Returns:
      An enum value determining if this should spy on a tunnel instead of controlling a Pin component
      Default:
      INFER