예제 #1
0
파일: cutils.py 프로젝트: tsk/vhd_tb
def get_related_files_hashes(file, fdic={}, files_in_dir=[], submodules=[]):
    if files_in_dir == []:
        if os.path.exists(file):
            abspath = os.path.abspath(file)
            dname = os.path.dirname(abspath)
            for f in os.listdir(dname):
                if os.path.isfile(os.path.join(dname, f)):
                    if len(f.split(".")) > 1:
                        if f.split(".")[1] in ("vhdl", "VHDL", "vhd", "VHD"):
                            files_in_dir.append(os.path.join(dname, f))
        fi = open(file)
        fb = fi.read()
        fi.close()
        fvhd = vhdlfile.vhdlfile(fb)
        submodules = fvhd.get_submodules()

    for f in files_in_dir:
        fi = open(f)
        fb = fi.read()
        fi.close()
        hash_ = hashlib.sha1(fb).hexdigest()
        fvhd = vhdlfile.vhdlfile(fb)
        modname = fvhd.get_name()
        if modname in submodules:
            fdic[ ` os.path.basename(f) `] = hash_
            fdic = get_related_files_hashes(f, fdic, files_in_dir,
                                            fvhd.get_submodules())

    return fdic
예제 #2
0
파일: cutils.py 프로젝트: manasdas17/vhd_tb
def get_related_files_hashes(file, fdic = {} , files_in_dir=[], submodules = []):
    if files_in_dir == []:
        if os.path.exists(file):
            abspath = os.path.abspath(file)
            dname = os.path.dirname(abspath)
            for f in os.listdir(dname):
                if os.path.isfile(os.path.join(dname,f)):
                    if len(f.split(".")) > 1:
                        if f.split(".")[1] in ("vhdl","VHDL","vhd","VHD"):
                            files_in_dir.append(os.path.join(dname,f))
        fi = open(file)
        fb = fi.read()
        fi.close()
        fvhd = vhdlfile.vhdlfile(fb)
        submodules = fvhd.get_submodules()

    for f in files_in_dir:
        fi = open(f)
        fb = fi.read()
        fi.close()
        hash_ = hashlib.sha1(fb).hexdigest()
        fvhd = vhdlfile.vhdlfile(fb)
        modname = fvhd.get_name()
        if modname in submodules:
            fdic[`os.path.basename(f)`] = hash_
            fdic = get_related_files_hashes(f,fdic,files_in_dir,
                                            fvhd.get_submodules())

    return fdic
예제 #3
0
파일: cutils.py 프로젝트: tsk/vhd_tb
def get_related_files(file, submodules, files_in_dir, dst):
    for f in files_in_dir:
        fi = open(f)
        fb = fi.read()
        fi.close()
        fvhd = vhdlfile.vhdlfile(fb)
        modname = fvhd.get_name()
        if modname in submodules:
            shutil.copy(f, dst)
            get_related_files(f, fvhd.get_submodules(), files_in_dir, dst)
예제 #4
0
파일: cutils.py 프로젝트: manasdas17/vhd_tb
def get_related_files(file, submodules, files_in_dir,dst):
    for f in files_in_dir:
        fi = open(f)
	fb = fi.read()
	fi.close()
	fvhd = vhdlfile.vhdlfile(fb)
	modname = fvhd.get_name()
	if modname in submodules:
	    shutil.copy(f,dst)
	    get_related_files(f,fvhd.get_submodules(),files_in_dir,dst)
예제 #5
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)
예제 #6
0
파일: cutils.py 프로젝트: tsk/vhd_tb
def extract_data4tb(vhdl_file):
    try:
        f = open(vhdl_file, 'r')
        buf = f.read()
        f.close()
    except IOError:
        print "Error: File does not exist\n"
        sys.exit(1)
    vf = vhdlfile.vhdlfile(buf)
    modname = vf.get_name()
    pdic = vf.get_ports_dic()
    clk_source = get_clock_sources(buf, pdic)
    return pdic, clk_source
예제 #7
0
파일: cutils.py 프로젝트: manasdas17/vhd_tb
def extract_data4tb(vhdl_file):
    try:
        f = open(vhdl_file,'r')
        buf = f.read()
        f.close()
    except IOError:
        print "Error: File does not exist\n"
        sys.exit(1)
    vf = vhdlfile.vhdlfile(buf)
    modname = vf.get_name()
    pdic = vf.get_ports_dic()
    clk_source = get_clock_sources(buf, pdic)
    return pdic, clk_source
예제 #8
0
파일: cutils.py 프로젝트: tsk/vhd_tb
def isolate_file(file, dst):
    fdic = {}
    if os.path.exists(file):
        files_in_dir = []
        abspath = os.path.abspath(file)
        dname = os.path.dirname(abspath)
        for f in os.listdir(dname):
            if os.path.isfile(os.path.join(dname, f)):
                if f.split(".")[1] in ("vhdl", "VHDL", "vhd", "VHD"):
                    files_in_dir.append(os.path.join(dname, f))
        ifdic = {}
        fi = open(file)
        fb = fi.read()
        fi.close()
        fvhd = vhdlfile.vhdlfile(fb)
        submodules = fvhd.get_submodules()
        shutil.copy(file, dst)
        get_related_files(file, submodules, files_in_dir, dst)
예제 #9
0
파일: cutils.py 프로젝트: manasdas17/vhd_tb
def isolate_file(file, dst):
    fdic = {}
    if os.path.exists(file):
        files_in_dir = []
        abspath = os.path.abspath(file)
	dname = os.path.dirname(abspath)
	for f in os.listdir(dname):
	    if os.path.isfile(os.path.join(dname,f)):
		if f.split(".")[1] in ("vhdl","VHDL","vhd","VHD"):
		    files_in_dir.append(os.path.join(dname,f))
	ifdic = {}
	fi = open(file)
	fb = fi.read()
	fi.close()
	fvhd = vhdlfile.vhdlfile(fb)
	submodules = fvhd.get_submodules()
        shutil.copy(file,dst)
	get_related_files(file,submodules,files_in_dir,dst)
예제 #10
0
파일: stimuli.py 프로젝트: tsk/vhd_tb
    def check_source_changes(self, TestBenchSrcControl):
        flag = False
        flag_src = False
        new_vhd_file = vhdlfile.vhdlfile(open(self.vhd_file_name, 'r').read())
        new_hashes = new_vhd_file.get_hashes()

        if new_hashes[0] != TestBenchSrcControl['hash_src']:
            flag_src = True
            if new_hashes[1] != TestBenchSrcControl['hash_src_ports']:
                flag_src_ports = True
                hash_ind_ports = TestBenchSrcControl['hash_ind_ports']
                if len(new_hashes[2]) != len(hash_ind_ports):
                    flag = True
                else:
                    for port in new_hashes[2]:
                        try:
                            old_port_hash = hash_ind_ports[ports]
                        except:
                            flag = True
                            break
                        if new_hashes[2][port] != hash_ind_ports[port]:
                            flag = True
                            break
        deepfiles_hash = get_related_files_hashes(self.vhd_file_name)
        old_deepfiles_hash = TestBenchSrcControl['deepfiles_hash']
        if len(deepfiles_hash) != len(old_deepfiles_hash):
            flag_src = True
        else:
            for deepfile in deepfiles_hash:
                try:
                    old_deepfile_hash = old_deepfiles_hash[deepfile]
                except:
                    flag_src = True
                    break
                if deepfiles_hash[deepfile] != old_deepfile_hash:
                    flag_src = True
                    break

        return flag, flag_src, new_hashes, deepfiles_hash
예제 #11
0
    def check_source_changes(self, TestBenchSrcControl):
        flag = False
        flag_src = False
        new_vhd_file = vhdlfile.vhdlfile(open(self.vhd_file_name,'r').read())
        new_hashes = new_vhd_file.get_hashes()
        
        if new_hashes[0] != TestBenchSrcControl['hash_src']:
            flag_src = True
            if new_hashes[1] != TestBenchSrcControl['hash_src_ports']:
                flag_src_ports = True
                hash_ind_ports = TestBenchSrcControl['hash_ind_ports']
                if len(new_hashes[2]) != len(hash_ind_ports):
                    flag = True
                else:
                    for port in new_hashes[2]:
                        try:
                            old_port_hash = hash_ind_ports[ports]
                        except:
                            flag = True
                            break;
                        if new_hashes[2][port] != hash_ind_ports[port]:
                            flag = True
                            break;
        deepfiles_hash = get_related_files_hashes(self.vhd_file_name)
        old_deepfiles_hash = TestBenchSrcControl['deepfiles_hash']
        if len(deepfiles_hash) != len(old_deepfiles_hash):
            flag_src = True
        else:
            for deepfile in deepfiles_hash:
                try:
                    old_deepfile_hash = old_deepfiles_hash[deepfile]
                except:
                    flag_src = True
                    break;
                if deepfiles_hash[deepfile] != old_deepfile_hash:
                    flag_src = True
                    break;

        return flag,flag_src,new_hashes, deepfiles_hash