// Test class instantiates the environment and starts it. class base_test extends uvm_test; `uvm_component_utils(base_test) function new(string name = "base_test", uvm_component parent = null); super.new(name, parent); endfunction env e0; gen_item_seq seq; virtual des_if vif; virtual function void build_phase(uvm_phase phase); super.build_phase(phase); // Create the environment e0 = env::type_id::create("e0", this); // Get virtual IF handle from top level and pass it to everything // in env level if (!uvm_config_db#(virtual des_if)::get(this, "", "des_vif", vif)) `uvm_fatal("TEST", "Did not get vif") uvm_config_db#(virtual des_if)::set(this, "e0.a0.*", "des_vif", vif); // Create sequence and randomize it seq = gen_item_seq::type_id::create("seq"); if (!seq.randomize()) `uvm_fatal("TEST", "Failed to randomize sequence") endfunction virtual task run_phase(uvm_phase phase); phase.raise_objection(this); apply_reset(); seq.start(e0.a0.s0); #200; `uvm_info("TEST_DONE", "Sequence detector test completed", UVM_LOW) phase.drop_objection(this); endtask virtual task apply_reset(); vif.reset <= 1'b1; vif.inp <= 0; repeat (5) @(posedge vif.clk); vif.reset <= 0; repeat (10) @(posedge vif.clk); endtask endclass class test_both_patterns extends base_test; `uvm_component_utils(test_both_patterns) function new(string name = "test_both_patterns", uvm_component parent = null); super.new(name, parent); endfunction virtual function void build_phase(uvm_phase phase); super.build_phase(phase); if (!seq.randomize() with {num inside {[520 : 620]};}) `uvm_fatal("TEST", "Failed to randomize sequence length") endfunction endclass