Esempio n. 1
0
    def test_simple_typecov(self):
        ucisdb = "file.ucis"
        db = MemFactory.create()

        testnode = db.createHistoryNode(None, "logicalName", ucisdb,
                                        UCIS_HISTORYNODE_TEST)
        td = TestData(teststatus=UCIS_TESTSTATUS_OK,
                      toolcategory="UCIS:simulator",
                      date="20200202020")
        testnode.setTestData(td)

        file = db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du = db.createScope(
            "foo.bar",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance = db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du,
            UCIS_INST_ONCE)

        cg = instance.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp = cg.createCoverpoint(
            "t",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)
        cp.setComment("Hello There")

        cp.createBin("auto[a]", SourceInfo(file, 4, 0), 1, 4, "a")

        cov_report = CoverageReportBuilder.build(db)

        print("covergroups: " + str(len(cov_report.covergroups)))
Esempio n. 2
0
    def dummy_instance(self):
        file = self.db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du = self.db.createScope(
            "foo.bar",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance = self.db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du,
            UCIS_INST_ONCE)

        return instance
Esempio n. 3
0
    def get_cg_inst(self, cg: CovergroupModel) -> Scope:
        if len(self.active_scope_s) > 0:
            return self.active_scope_s[-1]
        else:
            # Need to create a default scope
            from ucis.source_info import SourceInfo
            file = self.db.createFileHandle("dummy", os.getcwd())
            du_src_info = SourceInfo(file, 0, 0)

            cg_default_du = self.db.createScope(
                self.cg_default_du_name,
                du_src_info,
                1,  # weight
                UCIS_OTHER,  # source language
                UCIS_DU_MODULE,
                UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
                | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
                | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
                | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

            cg_default_inst = self.db.createInstance(
                self.cg_default_inst_name,
                None,  # sourceinfo
                1,  # weight
                UCIS_OTHER,  # source language
                UCIS_INSTANCE,
                cg_default_du,
                UCIS_INST_ONCE)

            self.active_scope_s.append(cg_default_inst)

            return cg_default_inst
Esempio n. 4
0
    def visit_coverpoint(self, cp : CoverpointModel):
        from ucis.source_info import SourceInfo
        active_s = self.active_scope_s[-1]
        
        cp_name = cp.name
        decl_location = None
        
        if cp.srcinfo_decl is not None:
            decl_location = SourceInfo(
                self.get_file_handle(cp.srcinfo_decl.filename),
                cp.srcinfo_decl.lineno, 0)
            
        # Obtain weight from coverpoint
        # TODO: obtain from .options vs .type_options?
        weight = cp.options.weight
        # TODO: obtain at_least from coverpoint and set on cp_scope
        at_least = cp.options.at_least
        # TODO: obtain goal from coverpoint and set on cp_scope
        # TODO: obtain comment from coverpoint and set on cp_scope
        cp_scope = active_s.createCoverpoint(
            cp_name,
            decl_location,
            weight, # weight
            UCIS_OTHER) # Source type
        self.coverpoint_m[cp.name] = cp_scope
        # TODO: setAtLeast()
#        cp_scope.set

        for bi in range(cp.get_n_bins()):
            decl_location = None
            bn_name = cp.get_bin_name(bi)
            cp_bin = cp_scope.createBin(
                bn_name,
                decl_location,
                at_least, # at_least
                cp.get_bin_hits(bi),
                bn_name,
                UCIS_CVGBIN)
            
        for bi in range(cp.get_n_ignore_bins()):
            decl_location = None
            bn_name = cp.get_ignore_bin_name(bi)
            cp_bin = cp_scope.createBin(
                bn_name,
                decl_location,
                at_least, # at_least
                cp.get_ignore_bin_hits(bi),
                bn_name,
                UCIS_IGNOREBIN)
            
        for bi in range(cp.get_n_illegal_bins()):
            decl_location = None
            bn_name = cp.get_illegal_bin_name(bi)
            cp_bin = cp_scope.createBin(
                bn_name,
                decl_location,
                at_least, # at_least
                cp.get_illegal_bin_hits(bi),
                bn_name,
                UCIS_ILLEGALBIN)
Esempio n. 5
0
    def visit_covergroup(self, cg : CovergroupModel):
        from ucis.source_info import SourceInfo
        cg_inst = self.get_cg_inst(cg)
        
        cg_name = cg.name if cg.name is not None else "<unknown>"
        inst_location = None
        
        if cg.type_cg is None:
            if cg.srcinfo_decl is not None:
                fh = self.get_file_handle(cg.srcinfo_decl.filename)
                inst_location = SourceInfo(
                    fh, 
                    cg.srcinfo_decl.lineno, 
                    0)

            # obtain weight from covergroup
            # TODO: should be .options vs .type_options
            weight = cg.options.weight
            # TODO: obtain at_least from coverpoint and set on cp_scope
            # TODO: obtain goal from coverpoint and set on cp_scope
            # TODO: obtain comment from coverpoint and set on cp_scope
            self.active_scope_s.append(cg_inst.createCovergroup(
                cg_name,
                inst_location,
                weight, # weight
                UCIS_OTHER)) # Source type
        else:
            if cg.srcinfo_inst is not None:
                fh = self.get_file_handle(cg.srcinfo_inst.filename)
                inst_location = SourceInfo(
                    fh, 
                    cg.srcinfo_inst.lineno, 
                    0)
            self.active_scope_s.append(cg_inst.createCoverInstance(
                self.get_cg_instname(cg),
                inst_location,
                1, # weight
                UCIS_OTHER)) # Source type
        
        super().visit_covergroup(cg)
        self.active_scope_s.pop()
Esempio n. 6
0
def create_coverpoint_bin(
        db,
        parent,
        name,
        filehandle,
        line,
        at_least,
        count,
        binrhs):
    coverdata = CoverData(UCIS_CVGBIN, (UCIS_IS_32BIT|UCIS_HAS_GOAL|UCIS_HAS_WEIGHT))
    coverdata.data = count
    coverdata.at_least = at_least
    coverdata.weight = 1

    srcinfo = SourceInfo(filehandle, line, 0)
    coverindex = ucis_CreateNextCover(db,parent,name, coverdata, srcinfo)
Esempio n. 7
0
 def __init__(self, parent: 'MemScope', name: str, srcinfo: SourceInfo,
              weight: int, source: SourceT, type: ScopeTypeT,
              flags: FlagsT):
     super().__init__()
     self.m_parent = parent
     self.m_name = name
     self.m_srcinfo = srcinfo if srcinfo is not None else SourceInfo(
         None, -1, -1)
     self.m_weight = weight
     self.m_source = source
     self.m_type = type
     self.m_flags = flags
     self.m_goal = -1
     self.m_source_type = 0
     self.m_is_under_du = 0
     self.m_children = []
     self.m_cover_items: List['CoverIndex'] = []
Esempio n. 8
0
def create_coverpoint(
        db,
        parent,
        name,
        filehandle,
        line) ->Scope:
    srcinfo = SourceInfo(filehandle, line, 0)
    cvp = ucis_CreateScope(db, parent, name, srcinfo,
                       1, # from type_option.weight
                       UCIS_VLOG, # source language type
                       UCIS_COVERPOINT,
                       0) # flags 
    #* Hardcoding attribute values to defaults for type_options:
    ucis_SetIntProperty(db,cvp,-1,UCIS_INT_SCOPE_GOAL,100)
    ucis_SetIntProperty(db,cvp,-1,UCIS_INT_CVG_ATLEAST,1)
    ucis_SetStringProperty(db,cvp,-1,UCIS_STR_COMMENT,"")
    
    return cvp
Esempio n. 9
0
    def visit_coverpoint_bin_array(self, bn: CoverpointBinArrayModel):
        from ucis.source_info import SourceInfo
        active_cp = self.active_scope_s[-1]
        decl_location = None

        if bn.srcinfo_decl is not None:
            decl_location = SourceInfo(
                self.get_file_handle(bn.srcinfo_decl.filename),
                bn.srcinfo_decl.lineno, 0)

        for i in range((bn.high - bn.low) + 1):
            v = bn.low + i
            bn_name = bn.name + "[%d]" % (v, )
            cp_bin = active_cp.createBin(
                bn_name,
                decl_location,
                1,  # weight
                bn.get_hits(i),
                bn.name)
Esempio n. 10
0
def create_covergroup(db,
              parent,
              name,
              filehandle,
              line):
    srcinfo = SourceInfo(filehandle, line, 0)
    cvg = ucis_CreateScope(db,parent,name,
                       srcinfo,
                       1, #/* from type_option.weight */
                       UCIS_VLOG, #/* source language type */
                       UCIS_COVERGROUP,
                       0) #/* flags */
    #/* Hardcoding attribute values for type_options: */
    ucis_SetIntProperty(db,cvg,-1,UCIS_INT_SCOPE_GOAL,100)
    ucis_SetIntProperty(db,cvg,-1,UCIS_INT_CVG_STROBE,0)
    ucis_SetIntProperty(db,cvg,-1,UCIS_INT_CVG_MERGEINSTANCES,1)
    ucis_SetStringProperty(db,cvg,-1,UCIS_STR_COMMENT,"")

    return cvg
Esempio n. 11
0
    def visit_coverpoint_cross(self, cr:CoverpointCrossModel):
        from ucis.source_info import SourceInfo
        active_s = self.active_scope_s[-1]

        cr_name = cr.name
        decl_location = None

        # Create a list of coverpoint scopes        
        coverpoint_l = []
        for cp in cr.coverpoints():
            coverpoint_l.append(self.coverpoint_m[cp.name])
        
        if cp.srcinfo_decl is not None:
            decl_location = SourceInfo(
                self.get_file_handle(cp.srcinfo_decl.filename),
                cp.srcinfo_decl.lineno, 0)
            
        # Obtain weight from coverpoint
        # TODO: obtain from .options vs .type_options?
        weight = cr.options.weight
        # TODO: obtain at_least from coverpoint and set on cp_scope
        at_least = cr.options.at_least
        # TODO: obtain goal from coverpoint and set on cp_scope
        # TODO: obtain comment from coverpoint and set on cp_scope
        cr_scope = active_s.createCross(
            cr_name,
            decl_location,
            weight, # weight
            UCIS_OTHER,
            coverpoint_l) # Source type
        # TODO: setAtLeast()
#        cp_scope.set

        for bi in range(cr.get_n_bins()):
            decl_location = None
            bn_name = cr.get_bin_name(bi)
            cr_bin = cr_scope.createBin(
                bn_name,
                decl_location,
                at_least,
                cr.get_bin_hits(bi),
                bn_name)        
Esempio n. 12
0
def create_design_unit(
        db,
        duname,
        file,
        line) -> Scope:
    srcinfo = SourceInfo(file, line, 0)
    duscope = ucis_CreateScope(db,
                           None, #/* DUs never have a parent */
                           duname,
                           srcinfo,
                           1, #/* weight */
                           UCIS_VLOG, #/* source language */
                           UCIS_DU_MODULE, #/* scope type */
                           #/* flags: */
                           UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH |
                           UCIS_ENABLED_COND | UCIS_ENABLED_EXPR |
                           UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE |
                           UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)
    ucis_SetStringProperty(db,duscope,-1,UCIS_STR_DU_SIGNATURE,"FAKE DU SIGNATURE")
    
    return duscope
Esempio n. 13
0
def create_statement(db,
            parent,
            filehandle,
            fileno, #/* 1-referenced wrt DU contributing files */
            line,   #/* 1-referenced wrt file */
            item,   #/* 1-referenced wrt statements starting on the line */
            count):
    #/* UOR name generation */
    name = "#stmt#%d#%d#%d#" % (fileno, line, item)

    coverdata = CoverData(UCIS_STMTBIN, UCIS_IS_32BIT)
    coverdata.data = count

    srcinfo = SourceInfo(filehandle, line, 17)        
    
    coverindex = ucis_CreateNextCover(db,parent,
                                  name, #/* name: statements have none */
                                  coverdata,
                                  srcinfo)
    
    ucis_SetIntProperty(db,parent,coverindex,UCIS_INT_STMT_INDEX,item)
Esempio n. 14
0
    def test_smoke(self):
        print("-- test_simplest_create")

        ucisdb = "file.ucis"
        db = MemFactory.create()

        testnode = db.createHistoryNode(None, "logicalName", ucisdb,
                                        UCIS_HISTORYNODE_TEST)
        td = TestData(teststatus=UCIS_TESTSTATUS_OK,
                      toolcategory="UCIS:simulator",
                      date="20200202020")
        testnode.setTestData(td)

        file = db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du = db.createScope(
            "foo.bar",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance = db.createInstance(
            "my_inst_scope",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du,
            UCIS_INST_ONCE)

        cg = instance.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp1 = cg.createCoverpoint(
            "cp1",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp1.createBin("v[1]", SourceInfo(file, 4, 0), 1, 4, "v")
        cp1.createBin("v[2]", SourceInfo(file, 4, 0), 1, 4, "v")

        cp2 = cg.createCoverpoint(
            "cp2",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp2.createBin("v2[1]", SourceInfo(file, 4, 0), 1, 4, "v2")
        cp2.createBin("v2[2]", SourceInfo(file, 4, 0), 1, 4, "v2")

        cr = cg.createCross("cr", SourceInfo(file, 4, 0), 1, UCIS_VLOG,
                            [cp1, cp2])

        cr.createBin("<v1[1],v2[1]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        cr.createBin("<v1[2],v2[1]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        cr.createBin("<v1[1],v2[2]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        cr.createBin("<v1[2],v2[2]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        out = StringIO()
        writer = XmlWriter()
        writer.write(out, db)

        print("XML Output:\n" + out.getvalue())
        input = StringIO(out.getvalue())
        validate_ucis_xml(input)

        input = StringIO(out.getvalue())
        reader = XmlReader()
        db2 = reader.read(input)

        out2 = StringIO()
        writer = XmlWriter()
        writer.write(out2, db2)
        print("XML Output2:\n" + out2.getvalue())
        input = StringIO(out2.getvalue())
        validate_ucis_xml(input)
Esempio n. 15
0
    def test_simplest_create_2inst(self):

        ucisdb = "file_2inst.ucis"
        db = MemFactory.create()

        testnode = db.createHistoryNode(None, "logicalName", ucisdb,
                                        UCIS_HISTORYNODE_TEST)
        td = TestData(teststatus=UCIS_TESTSTATUS_OK,
                      toolcategory="UCIS:simulator",
                      date="20200202020")
        testnode.setTestData(td)

        file = db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du1 = db.createScope(
            "foo.bar1",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        du2 = db.createScope(
            "foo.bar2",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance1 = db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du1,
            UCIS_INST_ONCE)

        cg1 = instance1.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp1 = cg1.createCoverpoint(
            "t",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp1.createBin("auto[a]", SourceInfo(file, 4, 0), 1, 4, "a")

        du2 = db.createScope(
            "foo.bar2",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance2 = db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du2,
            UCIS_INST_ONCE)

        cg2 = instance2.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp2 = cg2.createCoverpoint(
            "t",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp2.createBin("auto[a]", SourceInfo(file, 4, 0), 1, 4, "a")

        db.close()

        xmlout = StringIO()
        writer = XmlWriter()
        writer.write(xmlout, db)
        xmlin = StringIO(xmlout.getvalue())
        XmlReader.validate(xmlin)
Esempio n. 16
0
 def __init__(self, file: LibFileHandle, line: int, token: int):
     SourceInfo.__init__(self, file, line, token)
     self.obj = _LibSourceInfo(file.fh, line, token)