예제 #1
0
    def test_class_field_iff(self):
        @vsc.covergroup
        class my_cg(object):
            def __init__(self):
                self.with_sample(dict(a=vsc.uint8_t(), b=vsc.uint8_t()))
                self.cp1 = vsc.coverpoint(self.a,
                                          iff=(self.b == 9),
                                          bins={
                                              "a": vsc.bin_array([], 1, 2, 4),
                                              "b": vsc.bin_array([4], [8, 16])
                                          })

        my_cg_1 = my_cg()

        my_cg_1.sample(1, 0)
        my_cg_1.sample(2, 9)
        my_cg_1.sample(4, 0)

        report = vsc.get_coverage_report_model()
        str_report = vsc.get_coverage_report(details=True)
        print("Report:\n" + str_report)

        self.assertEquals(len(report.covergroups), 1)
        self.assertEquals(len(report.covergroups[0].coverpoints), 1)
        self.assertEquals(len(report.covergroups[0].coverpoints[0].bins), 7)
        self.assertEquals(report.covergroups[0].coverpoints[0].bins[0].count,
                          0)
        self.assertEquals(report.covergroups[0].coverpoints[0].bins[1].count,
                          1)
        self.assertEquals(report.covergroups[0].coverpoints[0].bins[2].count,
                          0)
예제 #2
0
    def test_mult_instances(self):
        @vsc.covergroup
        class my_cg(object):
            def __init__(self):
                self.with_sample(dict(a=vsc.uint8_t(), b=vsc.uint8_t()))

                self.a_cp = vsc.coverpoint(
                    self.a, bins=dict(a_bins=vsc.bin_array([4], [0, 16])))

        my_cg_1 = my_cg()
        my_cg_2 = my_cg()

        for i in range(8):
            my_cg_1.sample(i, 0)

        for i in range(16):
            my_cg_2.sample(i, 0)

        str_report = vsc.get_coverage_report(details=True)
        print("Report:\n" + str_report)

        report = vsc.get_coverage_report_model()
        self.assertEqual(1, len(report.covergroups))
        self.assertEquals(2, len(report.covergroups[0].covergroups))
        self.assertEquals(100, report.covergroups[0].coverage)
        self.assertEquals(50, report.covergroups[0].covergroups[0].coverage)
        self.assertEquals(100, report.covergroups[0].covergroups[1].coverage)
예제 #3
0
    def test_cross(self):
        @vsc.covergroup
        class my_covergroup(object):

            def __init__(self): 
                super().__init__()
                self.a=None
                self.b=None
                self.cp1 = vsc.coverpoint(lambda:self.a,
                    bins=dict(
                        a = vsc.bin_array([], [0,15])
                    ))

                self.cp2 = vsc.coverpoint(lambda:self.b, bins=dict(
                    b = vsc.bin_array([], [0,15])
                    ))
                self.cross = vsc.cross([self.cp1, self.cp2])


            #a = 0;
            #b = 0;

        cg = my_covergroup()

        cg.a = 0 
        cg.b = 0
        print("A: ",str(cg.a), " B: ", str(cg.b))
        cg.sample() # Hit the first bin of cp1 and cp2  

            
        report = vsc.get_coverage_report()
        print("Report:\n" + report)
        out = StringIO()
        vsc.write_coverage_db("cov.xml")
        print(">================== Write XML ========================")
        vsc.write_coverage_db(out)
        print("<================== Write XML ========================")
        db = XmlFactory.read(out)
        print(">================== Build Report =====================")
        report = CoverageReportBuilder.build(db)
        print("<================== Build Report =====================")
        print(">================== Text Reporter ====================")
        reporter = TextCoverageReportFormatter(report, sys.stdout)
        print("<================== Text Reporter ====================")
        reporter.details = True
        print(">================== XML Report =======================")
        reporter.report()
        print("<================== XML Report =======================")        

        
예제 #4
0
    def test_single_type_two_inst_details_text(self):
        @vsc.covergroup
        class my_cg(object):
            def __init__(self):
                self.with_sample(dict(a=vsc.uint8_t(), b=vsc.uint8_t()))

                self.a_cp = vsc.coverpoint(self.a,
                                           bins={"a": bin_array([], [0, 15])})

        my_cg_1 = my_cg()
        my_cg_2 = my_cg()

        for i in range(16):
            my_cg_1.sample(i, 0)

        report = vsc.get_coverage_report()
        print("Report:\n" + report)
예제 #5
0
    def test_iff(self):
        @vsc.covergroup
        class my_cg(object):
            def __init__(self):
                self.with_sample(dict(a=vsc.uint8_t(), b=vsc.uint8_t()))
                self.cp1 = vsc.coverpoint(self.a,
                                          iff=self.b,
                                          bins={
                                              "a": vsc.bin_array([], 1, 2, 4),
                                              "b": vsc.bin_array([4], [8, 16])
                                          })

        my_cg_1 = my_cg()

        for i in range(8):
            my_cg_1.sample(i, 0)

        str_report = vsc.get_coverage_report(details=True)
        print("Report:\n" + str_report)
예제 #6
0
    def test_single_type_two_inst_xml(self):
        @vsc.covergroup
        class my_cg(object):
            def __init__(self):
                self.with_sample(dict(a=vsc.uint8_t(), b=vsc.uint8_t()))

                self.a_cp = vsc.coverpoint(self.a,
                                           bins={"a": bin_array([], [0, 15])})

        my_cg_1 = my_cg()
        my_cg_2 = my_cg()

        for i in range(8):
            my_cg_1.sample(2 * i, 0)
            if i % 2 == 0:
                my_cg_1.sample(2 * i, 0)
            my_cg_2.sample(2 * i + 1, 0)
            if i % 3 == 0:
                my_cg_2.sample(2 * i + 1, 0)
                my_cg_2.sample(2 * i + 1, 0)

        print(">================== Text Report ======================")
        print("Report:\n" + vsc.get_coverage_report(True))
        print("<================== Text Report ======================")
        out = StringIO()
        vsc.write_coverage_db("cov.xml")
        print(">================== Write XML ========================")
        vsc.write_coverage_db(out)
        print("<================== Write XML ========================")
        db = XmlFactory.read(out)
        print(">================== Build Report =====================")
        report = CoverageReportBuilder.build(db)
        print("<================== Build Report =====================")
        print(">================== Text Reporter ====================")
        reporter = TextCoverageReportFormatter(report, sys.stdout)
        print("<================== Text Reporter ====================")
        reporter.details = True
        print(">================== XML Report =======================")
        reporter.report()
        print("<================== XML Report =======================")
예제 #7
0
 def get_coverage_report(self):
     model = vsc.get_coverage_report_model()
     cov_dir = cfg.argv.log_file_name.split("/")[0]
     file = open('{}/CoverageGroups.txt'.format(cov_dir), 'w')
     file.write("CoverGroups, CoverPoints and Bins Summary\n")
     str_report = vsc.get_coverage_report(details=True)
     file.write("{}\n".format(str_report))
     file.close()
     file = open('{}/CoverageReport.txt'.format(cov_dir), 'w')
     file.write("Groups Coverage Summary\n")
     file.write("Total groups in report: {}\n".format(
         len(model.covergroups)))
     headers = ["SCORE", "WEIGHT", "NAME"]
     table = []
     for cg in model.covergroups:
         table.append([cg.coverage, cg.weight, cg.name])
     file.write(tabulate(table, headers, tablefmt="grid",
                         numalign="center", stralign="center"))
     file.close()
     # If enabled, write in xml format to be read by pyucis-viewer (visualization)
     if cfg.argv.enable_visualization:
         vsc.write_coverage_db("{}/cov_db.xml".format(cov_dir))
예제 #8
0
    def test_class_field_cross_iff(self):
        @vsc.covergroup
        class my_cg(object):
            def __init__(self):
                self.with_sample(
                    dict(a=vsc.uint8_t(), b=vsc.uint8_t(), c=vsc.bool_t()))
                self.cp1 = vsc.coverpoint(
                    self.a, bins={"a": vsc.bin_array([], 1, 2, 4, 8)})
                self.cp2 = vsc.coverpoint(
                    self.b, bins={"b": vsc.bin_array([], 1, 2, 4, 8)})
                self.cr = vsc.cross([self.cp1, self.cp2], iff=self.c)
#                self.cr = vsc.cross([self.cp1, self.cp2])

        my_cg_1 = my_cg()

        for i in [1, 2, 4, 8]:
            for j in [1, 2, 4, 8]:
                my_cg_1.sample(i, j, i == j)

        report = vsc.get_coverage_report_model()
        str_report = vsc.get_coverage_report(details=True)
        print("Report:\n" + str_report)

        self.assertEquals(len(report.covergroups), 1)
        self.assertEquals(len(report.covergroups[0].coverpoints), 2)
        self.assertEquals(len(report.covergroups[0].crosses), 1)
        for ii, i in enumerate([1, 2, 4, 8]):
            for ji, j in enumerate([1, 2, 4, 8]):
                if i == j:
                    self.assertEquals(
                        report.covergroups[0].crosses[0].bins[4 * ii +
                                                              ji].count, 1)
                else:
                    self.assertEquals(
                        report.covergroups[0].crosses[0].bins[4 * ii +
                                                              ji].count, 0)