update cpu seq item constraints and weighting biases
This commit is contained in:
@@ -6,7 +6,10 @@
|
|||||||
* All cpu_seq_item transactions get converted into cpu_xbar_item transactions by
|
* All cpu_seq_item transactions get converted into cpu_xbar_item transactions by
|
||||||
* the sequencer.
|
* the sequencer.
|
||||||
*/
|
*/
|
||||||
class cpu_seq_item #(int DataSize=32, int AddrSize=14);
|
class cpu_seq_item #(
|
||||||
|
int DataSize = 32,
|
||||||
|
int AddrSize = 14
|
||||||
|
);
|
||||||
|
|
||||||
// Randomizable instruction fields
|
// Randomizable instruction fields
|
||||||
rand instr_e op;
|
rand instr_e op;
|
||||||
@@ -26,20 +29,37 @@ class cpu_seq_item #(int DataSize=32, int AddrSize=14);
|
|||||||
logic [REG_COUNT-1:0][31:0] reg_snapshot;
|
logic [REG_COUNT-1:0][31:0] reg_snapshot;
|
||||||
|
|
||||||
// Keep generated instructions within the supported instruction set
|
// Keep generated instructions within the supported instruction set
|
||||||
constraint c_opcode {
|
constraint c_opcode {op inside {OP_ADD, OP_ADDI, OP_SUB, OP_SLL, OP_SRL, OP_LW, OP_SW, OP_BEQ};}
|
||||||
op inside {OP_ADD, OP_ADDI, OP_SUB, OP_SLL, OP_SRL, OP_LW, OP_SW, OP_BEQ};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Weighted distributions for registers to increase likelihood of register x0 in testing
|
// Weighted distributions for registers to increase likelihood of register x0 in testing
|
||||||
constraint c_reg_bias {
|
constraint c_reg_bias {
|
||||||
rd dist { 0 :/ 5, [1:7] :/ 70, [8:31] :/ 25 };
|
rd dist {
|
||||||
rs1 dist { 0 :/ 10, [1:7] :/ 70, [8:31] :/ 20 };
|
0 :/ 5,
|
||||||
rs2 dist { 0 :/ 10, [1:7] :/ 70, [8:31] :/ 20 };
|
[1 : 7] :/ 70,
|
||||||
|
[8 : 31] :/ 25
|
||||||
|
};
|
||||||
|
rs1 dist {
|
||||||
|
0 :/ 10,
|
||||||
|
[1 : 7] :/ 70,
|
||||||
|
[8 : 31] :/ 20
|
||||||
|
};
|
||||||
|
rs2 dist {
|
||||||
|
0 :/ 10,
|
||||||
|
[1 : 7] :/ 70,
|
||||||
|
[8 : 31] :/ 20
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Complete the immediate constraint
|
|
||||||
constraint c_imm_range {
|
constraint c_imm_range {
|
||||||
|
(op inside {OP_ADDI, OP_SW, OP_LW}) -> {
|
||||||
imm >= -2048;
|
imm >= -2048;
|
||||||
|
imm <= 2047;
|
||||||
|
}
|
||||||
|
|
||||||
|
(op == OP_BEQ) -> {
|
||||||
|
imm >= -4096;
|
||||||
|
imm <= 4094;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep each load/store effective byte address word-aligned and inside
|
// Keep each load/store effective byte address word-aligned and inside
|
||||||
@@ -60,23 +80,27 @@ class cpu_seq_item #(int DataSize=32, int AddrSize=14);
|
|||||||
|
|
||||||
// Immediate values are constrained to 0 during these register-only instructions
|
// Immediate values are constrained to 0 during these register-only instructions
|
||||||
constraint c_imm_unused {
|
constraint c_imm_unused {
|
||||||
(op inside {OP_ADD, OP_SUB, OP_SLL, OP_SRL}) -> imm == 0;
|
(op inside {OP_ADD, OP_SUB, OP_SLL, OP_SRL}) ->
|
||||||
|
imm == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Complete the branch constraint to avoid loops
|
|
||||||
constraint c_branch_target {
|
constraint c_branch_target {
|
||||||
(op == OP_BEQ) -> (imm % 4 == 0) && (imm >= 4);
|
(op == OP_BEQ) -> {
|
||||||
|
imm % 4 == 0;
|
||||||
|
imm >= 4;
|
||||||
|
imm <= (prog_len - idx - 1) * 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent a branch in the final generated slot
|
// Prevent a branch in the final generated slot
|
||||||
constraint c_no_branch_at_end {
|
constraint c_no_branch_at_end {(prog_len - idx < 2) -> op != OP_BEQ;}
|
||||||
(prog_len - idx < 2) -> op != OP_BEQ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Randomly-generated registers rarely compare equal. Bias the operands
|
|
||||||
// so both branch outcomes occur often enough to close coverage.
|
|
||||||
constraint c_branch_taken_bias {
|
constraint c_branch_taken_bias {
|
||||||
1;
|
(op == OP_BEQ) ->
|
||||||
|
rs2 dist {
|
||||||
|
[rs1 : rs1] :/ 40,
|
||||||
|
[ 0 : 31] :/ 60
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user