pub(super) fn choose_opcode_selector(
pass: Pass,
sub_cycle: SubCycle,
) -> OpcodeSelectorExpand description
Choose the next OpcodeSelector.
HashX uses a repeating pattern of opcode selectors, based on the current sub_cycle timestamp simulated for instruction fetch/decode. This gives a roughly constant program layout since most instructions do only take one sub-cycle to decode, but we do skip a sub-cycle every time there’s a 2-op instruction (wide mul, target, branch). The repeating selector pattern is designed to ensure these skipped selectors are always the Normal type, so the overall number of multiply and branch instructions stays constant.
The basic pattern is (Mul, Normal, Normal) but Branch, Target,
and WideMul operations are mixed in at fixed locations in a 36-cycle
repetition.
Normal cycles are all replaced by ImmediateSrc if this is the retry
pass, so that retries won’t need to attempt source register selection
in this case.