def do_something(params): lines = [] print(Env.Current) if '-dofile' in params: for Scenario in params['-dofile']: Fin = open(Scenario, 'r') lines += Fin.readlines() Fin.close() if ('-do' in params): for line in params['-do']: lines += [line] if ('-top' in params): for line in params['-top']: lines += ['top %s' % (line)] if ('-import' in params): for line in params['-import']: lines += ['import %s' % (line)] if ('-help_main' in params): lines += ['help_main'] if (len(lines) > 0): # print('LINES',lines,params) for line in lines: logs.log_info('do line: %s' % line) execute_line(line, Env) else: print(Env.Current) if ('-o' in params): Foutname = params['-o'][0] else: Foutname = 'dumpver.v' if dbx: logs.log_err( 'no "-do scenario_filename" given,so i proceed to dump verilog' ) dbx.dump_all_verilog(Foutname) logs.log_ending('exiting')
def run0(self): # if (len(self.queue0),len(self.seq0)) != (0,0): # logs.log_info('run0 wait0=%d until0=%s queue0=%d seq0=%d'%(self.waiting0,self.wait_until0,len(self.queue0),len(self.seq0))) if self.waiting0 > 0: self.waiting0 -= 1 return if self.wait_until0: if self.evaluateUntil(0): self.wait_until0 = False else: Expr, Trans, Timeout = self.wait_until0 if (Timeout == 1) and (Timeout != 0): logs.log_error( 'timeout of wait until "%s" "%s" happened.' % (Expr, Trans)) self.wait_until0 = False else: self.wait_until0 = Expr, Trans, Timeout - 1 return if self.seq0 != []: List = self.seq0[0] if List[0][0] == 'lock': if (apbDriver.bus_locked) and (apbDriver.bus_locked != self): return if self.seq0 != []: AA0 = self.seq0[0][0] if (len(AA0) == 3) and (AA0[0] == 'conditional'): Who = AA0[1] What = AA0[2] Val = self.peek(Who) if What != Val: return if AA0 == 'notbusy': # logs.log_info('seq0 %s %s'%(AA0,self.busy())) # if self.busy(): return self.seq0.pop(0) return List = self.seq0.pop(0) if (len(List[0]) == 3): List.pop(0) # logs.log_info('DBG0 %s'%str(List)) for (Sig, Val) in List: if Sig == 'lock': if Val == 1: apbDriver.bus_locked = self elif Val == 0: apbDriver.bus_locked = False elif Sig == 'name': self.Name = Val elif Sig == 'marker': logs.log_info('marker from APB %s' % self.Name) if Val[0] in self.markers: self.markers[Val[0]](Val[1:]) else: logs.log_error('marker %s from APB %s is not defined' % (Val, self.Name)) elif Sig == 'finish': logs.log_info('finishing from APB %s' % self.Name, 2) logs.log_ending('scores', 2) if self.finishes: self.finishes() veri.finish() sys.exit() elif Sig == 'wait': self.waiting0 = int(Val) elif Sig == 'catch': Who, Exp = Val X = self.peek(self.rename(Who)) if Exp == 'none': pass elif type(Exp) == types.FunctionType: Exp(X) elif type(Exp) == types.IntType: logs.log_ensure( (Exp == X), 'apb %s read act=%x exp=%s (0x%x) (0d%d) who=%s' % (self.Name, X, Exp, Exp, Exp, self.rename(Who)), 2) else: Exp0 = eval(Exp, self.renames) logs.log_info2( 'apb %s read act=%x exp=%s (0x%x) (0d%d) who=%s' % (self.Name, X, Exp, Exp0, Exp0, self.rename(Who))) elif Sig == 'until': self.installUntil(Val, 0) else: self.force(self.rename(Sig), Val) return if self.peek('pready') == '0': self.waiting0 = 10 return if self.queue0 != []: What = self.queue0.pop(0) if What[0] == 'write': # logs.log_info('write apb queue0 seq0 %s %s %s'%(What[0],hex(What[1]),hex(What[2]))) self.seq0.append([('lock', 1), ('psel', 1), ('paddr', What[1]), ('pwdata', What[2]), ('pwrite', 1)]) self.seq0.append([('penable', 1)]) self.seq0.append([('conditional', 'pready', 1), ('psel', 0), ('paddr', 0), ('pwdata', 0), ('pwrite', 0), ('penable', 0)]) self.seq0.append([('lock', 0), ('wait', 5)]) elif What[0] == 'read': self.seq0.append([('lock', '1'), ('psel', 1), ('paddr', What[1]), ('pwrite', 0)]) self.seq0.append([('penable', 1)]) self.seq0.append([('conditional', 'pready', 1), ('catch', ('prdata', What[2])), ('psel', 0), ('paddr', 0), ('pwrite', 0), ('penable', 0)]) self.seq0.append([('lock', '0'), ('wait', 5)]) elif What[0] == 'wait': self.seq0.append([('wait', What[1])]) elif What[0] == 'finish': self.seq0.append([('finish', 0)]) elif What[0] == 'marker': self.seq0.append([('marker', What[1])]) elif What[0] == 'name': self.seq0.append([('name', What[1])]) elif What[0] == 'until': self.seq0.append([('until', (What[1], What[2]))]) elif What[0] == 'force': self.seq0.append([(What[1], What[2])]) elif What[0] == 'notbusy': self.seq0.append(('notbusy', 0)) else: logs.log_error('apb %s: unrecognized ilia command %s' % (self.Name, str(What)))
def run0(self): if self.waiting0>0: self.waiting0 -= 1 return if self.wait_until0: if self.evaluateUntil(0): self.wait_until0=False else: Expr,Trans,Timeout = self.wait_until0 if (Timeout==1)and(Timeout!=0): logs.log_error('timeout of wait until "%s" "%s" happened.'%(Expr,Trans)) self.wait_until0=False else: self.wait_until0 = Expr,Trans,Timeout-1 return if self.seq0!=[]: List = self.seq0[0] if List[0][0]=='lock': if (apbDriver.bus_locked) and (apbDriver.bus_locked!=self): return if self.seq0==[]: self.force('psel',0) self.force('pwrite',0) self.force('penable',0) if self.seq0!=[]: AA0 = self.seq0[0][0] if (len(AA0)==3)and(AA0[0]=='conditional'): Who = AA0[1] What = AA0[2] Val = self.peek(Who) if What!=Val:return if AA0=='notbusy': # logs.log_info('seq0 %s %s'%(AA0,self.busy())) if self.busy(): return self.seq0.pop(0) return List = self.seq0[0] if (len(List[0])==3): List.pop(0) popIt = False for (Sig,Val) in List: if Sig=='lock': if Val==1: apbDriver.bus_locked=self elif Val==0: apbDriver.bus_locked=False elif Sig=='name': self.Name = Val elif Sig=='marker': logs.log_info('marker from APB %s'%self.Name) if Val[0] in self.markers: self.markers[Val[0]](Val[1:]) else: logs.log_error('marker %s from APB %s is not defined'%(Val,self.Name)) elif Sig=='finish': logs.log_info('finishing from APB %s'%self.Name,2) logs.log_ending('scores',2) if self.finishes: self.finishes() veri.finish() sys.exit() elif Sig=='wait': self.waiting0=int(Val) elif Sig=='catch': Who,Exp,Addr = Val print('EXP',Who,Addr,Exp) Act = self.peek(Who) if type(Exp) is types.FunctionType: Exp(Act) elif type(Exp) is int: logs.log_ensure((Exp==Act),'apb addr=%x %s read act=%x exp=%s (0x%x) (0d%d) who=%s'%(Addr,self.Name,Act,Exp,Exp,Exp,self.rename(Who)),2) else: logs.log_info('apb addr=%x %s read act=%x who=%s'%(Addr,self.Name,Act,self.rename(Who))) self.Backs.append((Who,Act,Addr)) elif Sig=='until': self.installUntil(Val,0) elif Sig=='popif': Who,Comp = Val if self.peek(Who) == Comp: popIt = True else: self.force(Sig,Val) if (Sig == 'penable') and (Val == 0): popIt = True if popIt or self.valid('pready'): self.seq0.pop(0) return if self.peek('pready')==0: self.waiting0 = 10 return