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)
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)