UVM Code Pattern 1011
UVM Code Pattern 1011
VERIFICATION
WITH
Design
Test Plan
011011011010
101011100
111011011
Design v1.0
module det_1011 (
input clk,
input rstn,
input in,
output out
);
parameter IDLE = 0,
S1 = 1,
S10 = 2,
S101 = 3,
S1011 = 4;
reg [2:0] cur_state, next_state;
endinterface
Sequence Item
constraint c1 {
in dist {
0 :/ 20,
1 :/ 80
};
}
endclass
Sequence
constraint c1 {
soft num inside { [10 : 50] };
}
Driver
Monitor
// Always check that expected out value is the actual observed value
// Since it takes 1 clock for out to be updated after pattern match,
// do the check first and then update exp_out value
if (item.out != exp_out) begin
`uvm_error("SCBD", $sformatf("ERROR ! out=%0d exp=%0d", item.out,
exp_out))
end else begin
`uvm_info("SCBD", $sformatf("PASS ! out=%0d exp=%0d", item.out,
exp_out), UVM_HIGH)
end
// If current index has reached the full pattern, then set exp_out to
be 1
// which will be checked in the next clock. If pattern is not
complete, keep
// exp_out to zero
if (!(ref_pattern ^ act_pattern)) begin
`uvm_info("SCBD", $sformatf("Pattern found to match, next out
should be 1"), UVM_LOW)
exp_out = 1;
end else begin
exp_out = 0;
end
endfunction
endclass
Agent
Environment
Test
Since we want to reuse the same verification environment for detecting patterns
other than "1011", it needs to be flexible enough to easily change the pattern.
1. Pattern Representation:
o The pattern is represented as an N-bit value.
o N is defined by the macro LENGTH, set to 4.
2. Base Test Setup:
o Sets up the environment, config_db, and other parameters.
o Derived tests only need to provide a new pattern and the total
number of data items to be sent to the DUT as the input stream.
3. Data Items:
o The number of data items to the DUT is randomized.
o This value is part of the sequence and is randomized differently in
each derived test.
env e0;
bit [`LENGTH - 1 : 0] pattern = 4'b1011;
gen_item_seq seq;
virtual des_if vif;
Testbench Top
module tb;
reg clk;
det_1011 u0 (
.clk(clk),
.rstn(_if.rstn),
.in(_if.in),
.out(_if.out)
);
initial begin
clk <= 0;
run_test("test_1011");
end
endmodule