Exemplo n.º 1
0
    def _from_cache(self, cachedir, filename, config, flags):
        hts_file = "%s/%s.ssts" % (cachedir, filename)
        mi_file = "%s/%s.mi" % (cachedir, filename)
        inv_file = "%s/%s.inv" % (cachedir, filename)
        ltl_file = "%s/%s.ltl" % (cachedir, filename)

        parser = SymbolicSimpleTSParser()

        hts = parser.parse_file(hts_file, config, flags)[0]

        with open(mi_file, 'rb') as f:
            model_info = pickle.load(f)
            if model_info is not None:
                # Symbols have to be re-defined to match the current object addresses
                model_info.abstract_clock_list = [
                    (Symbol(x[0].symbol_name(), x[0].symbol_type()), x[1])
                    for x in model_info.abstract_clock_list
                ]
                model_info.clock_list = [
                    Symbol(x.symbol_name(), x.symbol_type())
                    for x in model_info.clock_list
                ]

        with open(inv_file, 'rb') as f:
            inv = pickle.load(f)

        with open(ltl_file, 'rb') as f:
            ltl = pickle.load(f)

        return (hts, inv, ltl, model_info)
Exemplo n.º 2
0
    def init_parsers():
        from cosa.encoders.btor2 import BTOR2Parser
        from cosa.encoders.coreir import CoreIRParser
        from cosa.encoders.explicit_transition_system import ExplicitTSParser
        from cosa.encoders.symbolic_transition_system import SymbolicTSParser, SymbolicSimpleTSParser
        from cosa.encoders.verilog_yosys import VerilogYosysBtorParser

        ModelParsersFactory.register_parser(BTOR2Parser())
        ModelParsersFactory.register_parser(CoreIRParser())
        ModelParsersFactory.register_parser(ExplicitTSParser())
        ModelParsersFactory.register_parser(SymbolicTSParser())
        ModelParsersFactory.register_parser(SymbolicSimpleTSParser())

        if ModelParsersFactory.verilog_encoder == VerilogEncoder.INTERNAL:
            Logger.error("Internal verilog parser support is deprecated.")

        if ModelParsersFactory.verilog_encoder == VerilogEncoder.YOSYS_BTOR:
            ModelParsersFactory.register_parser(VerilogYosysBtorParser())

        if ModelParsersFactory.verilog_encoder == VerilogEncoder.YOSYS_COREIR:
            Logger.error("Not supported")
Exemplo n.º 3
0
    def parse_model(self, \
                    relative_path, \
                    model_files, \
                    abstract_clock, \
                    symbolic_init, \
                    name=None, \
                    deterministic=False, \
                    boolean=False, \
                    no_clock=False, \
                    run_passes=True):

        hts = HTS("System 1")
        invar_props = []
        ltl_props = []

        models = model_files.split(MODEL_SP)

        for strfile in models:
            (strfile, flags) = self.get_file_flags(strfile)
            filetype = strfile.split(".")[-1]
            strfile = strfile.replace("~", os.path.expanduser("~"))
            if strfile[0] != "/":
                strfile = relative_path + strfile
            parser = None

            if filetype in CoreIRParser.get_extensions():
                parser = CoreIRParser(abstract_clock, symbolic_init, no_clock,
                                      run_passes)
                parser.boolean = boolean
                parser.deterministic = deterministic
                self.parser = parser

            if filetype in ExplicitTSParser.get_extensions():
                parser = ExplicitTSParser()

                if not self.parser:
                    self.parser = parser

            if filetype in SymbolicTSParser.get_extensions():
                parser = SymbolicTSParser()

                if not self.parser:
                    self.parser = parser

            if filetype in SymbolicSimpleTSParser.get_extensions():
                parser = SymbolicSimpleTSParser()

                if not self.parser:
                    self.parser = parser

            if filetype in BTOR2Parser.get_extensions():
                parser = BTOR2Parser()

                if not self.parser:
                    self.parser = parser

            if parser is not None:
                if not os.path.isfile(strfile):
                    Logger.error("File \"%s\" does not exist" % strfile)

                Logger.msg("Parsing file \"%s\"... " % (strfile), 0)
                (hts_a, inv_a, ltl_a) = parser.parse_file(strfile, flags)
                hts.combine(hts_a)

                invar_props += inv_a
                ltl_props += ltl_a

                Logger.log("DONE", 0)
                continue

            Logger.error("Filetype \"%s\" unsupported" % filetype)

        if Logger.level(1):
            print(hts.print_statistics(name, Logger.level(2)))

        return (hts, invar_props, ltl_props)