Overview
Backward Branch Loop Control is a stimulus-generation technique for processor verification that constrains how backward branches are formed in generated instruction streams. The technique focuses on making a backward branch behave like a controlled loop by ensuring that the branch operands are initialized and updated in a predictable way.
Core control pattern
A controlled backward-branch loop can be created by placing an ADDI operation before the backward branch using the same operands and a small negative value. One operand acts as the loop index and is incremented by 1 inside the loop immediately before the branch operation.
To preserve the intended loop behavior, the registers used as branch operands should not be modified elsewhere inside the loop. In particular, no other destination register in the loop should be one of the branch operand registers.
Boundary-condition handling
Backward branch generation also needs boundary-condition controls. For example, a branch such as BGT R1, R2, LABEL_X can become always taken if R2 contains the smallest possible number. Testbenches should include constraints or checks that prevent such cases when they would create invalid or unhelpful stimulus.
Role in constrained-random stimulus
Backward Branch Loop Control fits into a constrained-random verification strategy. SystemVerilog constraints can be used to describe instruction-scenario constraints over a dynamic array of instruction objects, and foreach array constraints are useful for specifying scenario-wide rules. A scenario generator can then select and randomize scenario objects until a user-specified stopping condition is reached.
Relationship to directed stimulus
Although the overall stimulus-generation strategy can center on constrained randomization, directed-random and directed scenarios may also be used. Directed scenarios can be loaded from pre-assembled program traces, which is useful when specific branch behavior or software-team tests need to be exercised directly.