Overview
In the cited multi-class randomization architecture for an instruction generator, a wrapper class is presented as a likely solution for cases where the test layer directly controls items in lower-level subclasses. The architecture otherwise uses knobs or switches at the upper layer to choose an opcode category first, allowing the generator to allocate the correct subclass object before randomization.
Role in multi-class randomization
The instruction generator described in the evidence was split from a single large opcode class into multiple smaller opcode-category classes to reduce the size of the randomization problem. A base instruction class held data members, common constraints, and shared methods, while each child class contained constraints specific to its opcode category.
A wrapper class becomes relevant when the test layer directly constrains lower-level subclass variables. In that situation, the evidence states that decisions about which subclass to randomize must be made first. The wrapper class would constrain all variables controlled by the tests, be randomized first, and then the correct subclass object would be allocated and randomized in a second generation phase.
Generation sequence
The wrapper-class flow described by the source is:
- The test-controlled variables are constrained in the wrapper class.
- The wrapper class is randomized first.
- The appropriate subclass object is selected or allocated based on the wrapper-level result.
- The selected subclass object is randomized in a second phase.
Design implication
The wrapper class is therefore not described as part of the default multi-class generator when only upper-layer knobs select opcode categories. Instead, it is described as a likely requirement when test-layer constraints reach into lower-level subclass-specific data, because subclass-selection decisions must precede subclass randomization.