Example #1
0
def stimuli_from_source(pymodname,gconfig,vf, options,source_dir,tb_name):
        #Create stimuli source file
        try:
            flag_add_sheet = options.add_sheet
        except:
            flag_add_sheet = False
        from vhd_tb.vhd import tb_options

        opt = tb_options()
        opt.set_attrib('work_dir',options.work_dir)
        opt.set_attrib('unisim_dir',options.unisim_dir)
        opt.set_attrib('source_dir',source_dir)

        module = __import__(pymodname)
        components = pymodname.split('.')
        for comp in components[1:]:
            module = getattr(module,comp)
        doc = getattr(module,options.tb_format)(source_dir+'/'+tb_name+'.'+options.tb_format)
        if flag_add_sheet == False:
            doc.create(gconfig['tables'],vf.get_ports_dic())
        else:
            doc.add_sheet(options.prefix, gconfig['tables'], vf.get_ports_dic())

        opt.set_attrib('tb_name',tb_name)
        call_command('ghdl_import',opt)
        call_command('ghdl_compile',opt)
        tmp1 = tb_name+'.'+options.tb_format
        tmp2 = tb_name+'_'+options.tb_format
        print "Edit %s file in sources dir, after that run \'vhd_tb.py %s\' command"%(tmp1,tmp2)
Example #2
0
    def execute(self, args, options):
        tb_options_ = tb_options()
        for opt in self.tb_options_list:
            tb_options_.set_attrib(opt, self.TBConfig[opt])

        if options.work_dir != "":
            tb_options_.work_dir = options.work_dir
        if options.unisim_dir != "":
            tb_options_.unisim_dir = options.unisim_dir
        if options.stop_time != "":
            tb_options_.stop_time = options.stop_time

        flag, flag_src, new_hash, deepfiles_hash = self.stimuli_source.check_source_changes(self.TBSrcControl)
        self.__source_control = set_source_control(new_hash[0], new_hash[1], new_hash[2], deepfiles_hash)

        if flag == True:
            schd = "ports_change"
            tb_options_.set_attrib("add_sheet", True)
            tb_options_.set_attrib("file_name", self.file_name)
            tb_options_.set_attrib("prefix", "bak")
            tb_options_.set_attrib("tb_format", self.stimuli_source.get_format())
        elif flag_src == True:
            schd = "source_change"
            call_command("ghdl_import", tb_options_)
        else:
            schd = "no_change"

        for action in self.pre_actions[schd]:
            getattr(self, action)()

        for action in self.commands[schd]:
            call_command(action, tb_options_)
Example #3
0
    def execute(self, args, options):
        try:
            #flag_add_sheet = options.add_sheet
            file_name = options.file_name
            source_dir = options.source_dir
            fivhd = '/'.join([source_dir,file_name])
        except:
            #flag_add_sheet = False
            file_name = os.path.basename(args[0])
            source_dir = './'+os.path.dirname(args[0])
            fivhd = args[0]
        f = open(fivhd,'r')
        buf = f.read()
        f.close()
        command_dir = "commands"
        if os.path.exists(command_dir) == False:
            os.mkdir(command_dir)
        if options.work_dir != "":
            if os.path.exists(options.work_dir) == False:
                os.mkdir(options.work_dir)

        opt = tb_options()
        opt.set_attrib('work_dir',options.work_dir)
        opt.set_attrib('unisim_dir',options.unisim_dir)
        opt.set_attrib('source_dir',source_dir)

        call_command('ghdl_import',opt)
        #Create vhd TestBenchCommand
        vf = vhdlfile.vhdlfile(buf)
        gconfig = tb_config(vf.get_input_ports_list(),vf.get_clock_sources())
        tb_name = 'tb_%s'%vf.get_name().lower()
        command_name = "%s_%s.py"%(tb_name,options.tb_format)

        sconfig = set_config(file_name,tb_name,
                            gconfig,vf,
                            source_dir,
                            options.work_dir,
                            options.unisim_dir,
                            options.stop_time
                            )
        hashes = vf.get_hashes()
        deepfiles_hash = get_related_files_hashes(fivhd)
        source_control = set_source_control(hashes[0],hashes[1],hashes[2],deepfiles_hash)
        cmd_file = command_tb_file(tb_name,sconfig,source_control,options.tb_format)
        f = open(command_dir+'/'+command_name,'w')
        f.write(cmd_file)
        f.close()
        #Create vhd TestBench file
        vhd_tb = vhd_tb_file(gconfig,vf,tb_name,source_dir,options.tb_format)
        f = open('/'.join([source_dir,tb_name+".vhd"]),'w')
        f.write(vhd_tb)
        f.close()
        pymodname = input_format_module[options.tb_format]
        stimuli_from_source(pymodname, gconfig,vf,options, source_dir, tb_name)