def test_inst_override(self): cs = UVMCoreService.get() fact = UVMDefaultFactory() cs.set_factory(fact) XXX = createXXX() LastOverride = createLastOverride() fact.set_inst_override_by_type(XXX.get_type(), LastOverride.get_type(), 'top.my_inst.is_override') self.assertTrue( fact.check_inst_override_exists(XXX.get_type(), LastOverride.get_type(), 'top.my_inst.is_override')) self.assertFalse( fact.check_inst_override_exists(XXX.get_type(), LastOverride.get_type(), 'top.my_inst2')) obj = fact.create_object_by_type(XXX.get_type(), 'top.my_inst', 'is_override') obj2 = fact.create_object_by_type(XXX.get_type(), 'top.my_inst2', 'is_xxx') self.assertEqual(obj.get_name(), 'is_override') self.assertEqual(obj.get_type_name(), 'LastOverride') self.assertEqual(obj2.get_name(), 'is_xxx') self.assertEqual(obj2.get_type_name(), 'XXX')
def test_override(self): cs = UVMCoreService.get() fact = UVMDefaultFactory() cs.set_factory(fact) XXX = createXXX() YYY = createYYY() fact.set_type_override_by_name('XXX', 'YYY') ovrd = fact.find_override_by_type(requested_type=XXX.get_type(), full_inst_path='') self.assertIsNotNone(ovrd, 'Override XXX->YYY should exist') self.assertEqual(ovrd.get_type_name(), 'YYY')
def test_create_component_by_name(self): cs = UVMCoreService.get() factory = UVMFactory.get() cs.set_factory(factory) class MyTest123(UVMTest): def __init__(self, name, parent): UVMTest.__init__(self, name, parent) uvm_component_utils(MyTest123) test_name = 'MyTest123' uvm_test_top = factory.create_component_by_name( test_name, "", "uvm_test_top", None) self.assertEqual(uvm_test_top.get_full_name(), "uvm_test_top")
def test_override(self): cs = UVMCoreService.get() fact = UVMDefaultFactory() cs.set_factory(fact) class XXX(UVMObject): pass uvm_object_utils(XXX) class YYY(UVMObject): pass uvm_object_utils(YYY) fact.set_type_override_by_name('XXX', 'YYY') ovrd = fact.find_override_by_type(requested_type=XXX.get_type(), full_inst_path='') self.assertIsNotNone(ovrd, 'Override XXX->YYY should exist') self.assertEqual(ovrd.get_type_name(), 'YYY')
def test_module_top(dut): mu = myunit("mu", None) bar = mydata() cs_ = UVMCoreService.get() factory = cs_.get_factory() UVMConfigDb.set(None, "mu.*", "data", 101) UVMConfigDb.set(None, "mu.*", "str", "hi") UVMConfigDb.set(None, "mu.l1", "data", 55) UVMConfigDb.set(None, "mu.*", "obj", bar) mu.print_config_settings("", None, 1) uvm_default_printer = uvm_default_tree_printer mu.print() factory.print(1) mu.print() # Fork 2 initial tasks task1 = cocotb.fork(initial1()) task2 = cocotb.fork(initial2(mu)) yield [task1.join(), task2.join()]
def test_type_double_override(self): cs = UVMCoreService.get() fact = UVMDefaultFactory() cs.set_factory(fact) XXX = createXXX() YYY = createYYY() LastOverride = createLastOverride() fact.set_type_override_by_name('XXX', 'YYY') fact.set_type_override_by_name('XXX', 'LastOverride') self.assertFalse(fact.check_inst_override_exists(XXX.get_type(), LastOverride.get_type(), '')) ovrd = fact.find_override_by_type(requested_type=XXX.get_type(), full_inst_path='') self.assertIsNotNone(ovrd, 'Override XXX->LastOverride should exist') self.assertEqual(ovrd.get_type_name(), 'LastOverride') fact.set_type_override_by_name('YYY', 'LastOverride') ovrd = fact.find_override_by_type(requested_type=YYY.get_type(), full_inst_path='') self.assertIsNotNone(ovrd, 'Override YYY->LastOverride should exist') self.assertEqual(ovrd.get_type_name(), 'LastOverride')
async def test_test(dut): ep = UVMEventPool("ep") cs_ = UVMCoreService.get() e = None e = ep.get("fred") e = ep.get("george") e_data = ep.get('evt_data') uvm_default_table_printer.knobs.reference = 0 ep.print_obj() trig_proc = cocotb.fork(trig_event(e)) cocotb.fork(trig_data_event(e_data)) await e_data.wait_trigger() await e.wait_on() e.reset() await Timer(1, "NS") trig_proc = cocotb.fork(trig_event(e)) evt_proc = cocotb.fork(wait_on_evt(e)) await sv.fork_join([trig_proc, evt_proc]) svr = None # uvm_report_server svr = cs_.get_report_server() svr.report_summarize() time_ok = sv.realtime("NS") == 202 data_ok = e_data.get_trigger_data() == 0x1234 if data_ok and time_ok and (svr.get_severity_count(UVM_FATAL) + svr.get_severity_count(UVM_ERROR) == 0): print("** UVM TEST PASSED **\n") else: if data_ok is False: uvm_error( "DATA_ERROR", "Exp: {}, Got: {}".format(0x1234, e_data.get_trigger_data())) if time_ok is False: uvm_error("TIME_ERROR", "Exp: {}, Got: {}".format(202, sv.realtime("NS"))) raise Exception("!! UVM TEST FAILED !!\n")
async def test_module_top(dut): mu = myunit("mu", None) bar = mydata() cs_ = UVMCoreService.get() factory = cs_.get_factory() UVMConfigDb.set(None, "mu.*", "data", 101) UVMConfigDb.set(None, "mu.*", "str", "hi") UVMConfigDb.set(None, "mu.l1", "data", 55) UVMConfigDb.set(None, "mu.*", "obj", bar) mu.print_config_settings("", None, 1) uvm_default_printer = uvm_default_tree_printer mu.print_obj() factory.print_factory(1) mu.print_obj() # tpoikela: Clock required by ghdl, otherwise scheduler throws error cocotb.fork(Clock(dut.clk, 10, "NS").start()) # Fork 2 initial tasks task1 = cocotb.fork(initial1()) task2 = cocotb.fork(initial2(mu)) await sv.fork_join([task1, task2])