Explain the differences between value constraints and order constraints.
Explain the need for constraints.
Explain the differences between random testing and directed-random testing.
Define a struct named "instruction" that contains the fields: opcode: 8 bits, op1: 8 bits and op2: 8 bits. Define the following constraints.
opcode should be in the ranges 5..10 and 20..25.
op1 should be in the range 10..100.
op2 should not be in the ranges 3..8 and 100..200.
op1 should not be equal to op2 times 2.
If opcode is 5, then op1 should be in the range 20..45.
If opcode is 8, then op2 should be in the range 150..160.
Extend the definition of struct instruction by adding a field kind_op2 that is a field of enumerated type with two values, imm and reg. (Hint: You may need to define an enumerated type before you add the field.) Define the following constraints:
If kind_op2 is imm, the op2 field should be restricted to the range 120..180.
Add an explicit user-defined order constraint that generates kind_op2 before op2. (Hint: Use keep gen before.)
Extend the definition of the predefined struct sys by adding the field l_instructions to be a list of struct instruction. For each instruction in the l_instructions list, define a weighted constraint as follows:
Weight =4, opcode = 5.
Weight =6, opcode =8.
Define a struct packet that contains the field len of the type byte and a field addr of the type byte. For the field len, define a weighted constraint as follows:
Weight = 7, len is in the range 0..15.
Weight = 3, len is in the range 16..63.
Weight = 10, len == 64.
Soft constraint on field addr to be in the range 0..7.
Extend the definition of struct packet and do the following:
Reset the soft constraint on len field.
Add a constraint for len > 63.
Reset the soft constraint on addr field.
Add a constraint for addr in range 8..15.
Extend the definition of the predefined struct sys by adding the field l_packets to be a list of packet. Define the following constraints in the struct sys for list l_packets.
First packet should have addr ==8.
Second packet should have addr == 9.
Remaining packets should have addr in the range 10..15.
Load all code from exercises 4 to 9 into Specman Elite and verify that it loads without error.