Beruflich Dokumente
Kultur Dokumente
Abstract— Random instruction sequence (RIS) tools are widely paper describes the tool used for generating the random
used across the industry for processor verification and validation. instructions and also the capability of inserting directed
These tools are often used to find design bugs in a relatively instruction sequence blocks into these random instruction
stable but not yet mature RTL design. RIS tools are very sequences.
effective in generating test scenarios that are hard to envision.
However, quite often completely random instruction sequences
are of little test value for exposing corner cases in the design,
II. THE TOOL
especially if the bug involves a sequence of events happening in a
narrow timing window. Macros can help enhance the test quality
of the generated instruction sequences by providing controlled This section discusses 3 main aspects of the tool.
randomness around a specific sequence of instructions targeting A. Instruction sequence generator
a specific area in the processor architecture. B. Bare metal kernel
Index Terms—Random instruction sequences, macros, directed
C. Results checking engine
testing A. Instruction sequence generator
COMMON_BASE_REGS :[
{
REGISTER :7
SIZE : 64
WEIGHT : 25
},
{
REGISTER :9
SIZE : 64
WEIGHT : 5
}
]
PREDICTABLE_TARGET_REGS : [0, 1, 2, 3]
UNPREDICTABLE_TARGET_REGS : [4, 5]
PREDICTABLE_TARGET_S_REGS : [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
UNPREDICTABLE_TARGET_S_REGS : [0, 1, 2, 3, 4, 5, 6, 7]
PREDICTABLE_TARGET_D_REGS : [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
UNPREDICTABLE_TARGET_D_REGS : [0, 1, 2, 3]
74
Fig. 3: An example test snippet generated using the in C++. The FUNCs bring in another level of randomization to
resource partition shown in Fig. 2. the generated instruction stream. An example of a function is a
cache evictor function that gets invoked from the test case in
4) Memory Attributes the course of a test run. The execution jumps to the start of the
function through a branch instruction inserted in the random
ARM architecture supports various attributes for memory instruction sequence and returns back to the next immediate
access. The configuration file has support for specifying instruction after the branch once the function returns.
weights to these memory attributes. Based on the weights, Functions give users the capability to write complex
memory attributes are picked for the common and private algorithms for stressing/verifying the CPUS, but on the other
memory areas of the test. The attributes for the memory used hand, a call to a function involves some overhead of saving and
by the test is selected by the generator during the generation of restoring the intermediate context of the test.
the test. The instruction behavior can also be affected based on
the attributes of the memory area. For, example a memory Fig. 4: An example test snippet showing call to a function.
access instruction will fault on un-aligned address access to
region of memory marked as Device. The tool can generate
additional instructions to make sure that the memory accesses
to these regions are always aligned.
B. Bare metal kernel
75
overcome the short coming of the generators in these areas,
verification engineers usually resort to directed testing of these
areas. Directed tests are manpower intensive with a limited
amount of reuse across projects. Usually, directed tests cannot
be run with randomly generated instructions, hence they lose
out on the goodness of randomly generated stimulus.
a. Case Study 1
An example is the randomization of the registers. The base
register used for loads and stores in the macro could match
with the ones being used by the generated test. Hence the areas
of memory the macro and the test act could be the same. One
scenario could be that, the macro is acting on the data which is
present in the same cache-line as the one the test just loaded or
stored.
Here is an example of an atomic-increment macro.
76
This is a tight sequence of atomic increment generated
from the macro without the need for any save and restore
instructions. The instructions (in bold) generated from the
macro uses the same register R7 used by the test. This will
give good tighter sequence of instructions without the overhead
involved in calling a FUNC.
b. Case Study 2
Here is a high level description of a bug related to page
table and ASID switch (context switch).
The bug is that the load after the context switch still
hits the TLB of the old context. The LDRNE is speculatively
executed by the core. But the CMP operation results in an
opposite condition EQ. The load is cancelled but the page table
walk continues to happen in the background. The page table
walks returns after the context switch and gets allocated to the
TLB. So there is a virtual to physical address mapping in the
TLB is of the older context. The LDR marked by the arrow
gets the value from an older mapping.
Adding a FUNC to perform the context switching sequence
would not hit the bug. This was because the FUNC added its Above figure shows the rendered macro. The instructions in
own register save overhead which made it hard to meet the bold are the exact instructions rendered by the macro. There is
timing. Here is the macro that hit the bug. no overhead of saving and restoring the registers used by the
‘test’. The sequence is very tight which resulted in exposing
the bug.
V. CONCLUSION
Macros provide a technique for inserting well-crafted blocks
of code into a random sequence of instructions. This capability
of the tool will allow the tool to cover scenarios that would be
very hard to generate if the tool was to generate only random
instruction sequences. There are interesting ways in which
macros can be extended. Instructions could be grouped based
on their functionality. Instead of specifying an instruction in
the macro we could specify an instruction group and an
instruction from that group will be picked when the macro is
rendered. This will give varying flavors of instruction
sequences for a macro. The users also can create their own
instruction groups and use them in the macros. Instruction
sequence length could also be specified along with the macro.
This will aid the tool to pick an instruction from the group
repeatedly based on the length of the sequence. These
instruction sequences are hard to generate with the tool.
Macros could be scaled to work on Multi-core processors.
77