예제 #1
0
파일: myPODEM_v2.py 프로젝트: cpr888/PODEM
def D_fronteir():

	global faulty_edge_list
	D_fronteir_li	=[]


	if(G[faulty_edge_list[0]][faulty_edge_list[1]]['value_non_fault']=='x'):	#Sensitize the fault
		print "faulty edge is added to D_fronteir_list"
		D_fronteir_li.append((faulty_edge_list[0],faulty_edge_list[1]))

	for i in G.nodes:
#		print i
		flag1 =False
		flag2 =False

		if(G.nodes[i]['type']=='gate'):
			#print "ioaefjpeiofljpowef'''''"
			gate_op_edge = list(G.out_edges(nbunch=i, data=False))
			gate_ip_edge = list(G.in_edges(nbunch=i, data=False))
			
			if(G.edges[gate_op_edge[0]]['value_non_fault']=='x' or G.edges[gate_op_edge[0]]['value_faulty']=='x'):		#Output is 'x'
				for j in gate_ip_edge:
					if(G.edges[j]['value_non_fault']=='1' and G.edges[j]['value_faulty'] =='0') or (G.edges[j]['value_non_fault']=='0' and G.edges[j]['value_faulty'] =='1'): #Input is D or D_bar check
						flag1=True	
						print " d or d_bar in nodes:",j
					if(G.edges[j]['value_non_fault']=='x' or G.edges[j]['value_faulty']=='x'):							#one of the Other Inputs is 'x'
						flag2= True
			
			if(flag1==True and flag2 ==True):
							print "D_fronteir in the_ ", j
							D_fronteir_li.insert(0,gate_op_edge[0])
							print "D_fronteir in the_appened case ", D_fronteir_li
			
	
	return D_fronteir_li
예제 #2
0
파일: myPODEM_v2.py 프로젝트: cpr888/PODEM
def primary_input():
	PIedge_list= []
	
	for item in G.nodes(data=True):
		
		if(item[1]['type']=='input'):
			list_outedge =list(G.out_edges(nbunch=item[0], data=False))	
			PIedge_list.append(list_outedge[0])
	return PIedge_list
예제 #3
0
파일: myPODEM_v2.py 프로젝트: cpr888/PODEM
def Observability_init(node):
#	for outgoing in G.successors(node):
#		if  (G.[outgoing]['type']='output'):
#			return
	global G 
#	for edge in G.edges(data=True):
#		print edge[0],edge[1],edge[2]['CO']
	#print "###########################################################################################################"
	if G.node[node]['type'] == 'output' :
		for incoming_edge in G.in_edges(node):
		#		print "node = output ,so CO=0"
				G.edges[incoming_edge]['CO'] = 0;
	elif G.node[node]['type'] == 'input':
		for incoming_edge in G.in_edges(node):
			for outgoing_edge in G.out_edges(node):
				G.edges[incoming_edge]['CO']=G.edges[outgoing_edge]['CO']

	else:
		successorsC0_list=[]
		for outgoing_edge in G.out_edges(node):
			if (G.edges[outgoing_edge]['CO'] == 'x'):
		#	 	print "going in Observability_init(", outgoing_edge[1],")"
			 	Observability_init(outgoing_edge[1])			#out_egde will be list = [ (Start node,end node )]
		#	 	print "Finished in Observability_init(", outgoing_edge[1],")"
			
			successorsC0_list.append(G.edges[outgoing_edge]['CO'])

			 	

		if G.node[node]['type'] =='fanout':
			for stem in G.in_edges(node):
				G.edges[stem]['CO']= min(successorsC0_list)

		else:
			if G.node[node]['gate_type'] =='and' or G.node[node]['gate_type']=='nand':
				for incoming_edge in G.in_edges(node):
		#			predecessorCC0_list=[]
					predecessorCC1_list=[]
					for other_incoming_edge in G.in_edges(node):

						if other_incoming_edge!= incoming_edge :
		#					print other_incoming_edge,incoming_edge,"test"
		#					predecessorCC0_list.append(G.node[other_incoming_edge[0]]['cc0'])	 
							predecessorCC1_list.append(G.node[other_incoming_edge[0]]['cc1'])
		#			print node
		#			print successorsC0_list[0] 
		#			print sum(predecessorCC1_list) 	
					G.edges[incoming_edge]['CO']=successorsC0_list[0] + sum(predecessorCC1_list) +1	


			elif G.node[node]['gate_type'] =='or' or G.node[node]['gate_type']=='nor':
				
				for incoming_edge in G.in_edges(node):
					predecessorCC0_list=[]
		#			predecessorCC1_list=[]
					for other_incoming_edge in G.in_edges(node):
						if other_incoming_edge!= incoming_edge :
							predecessorCC0_list.append(G.node[other_incoming_edge[0]]['cc0'])	 
		#					predecessorCC1_list.append(G.node[other_incoming_edge[0]]['cc1'])

					G.edges[incoming_edge]['CO']=successorsC0_list[0] + sum(predecessorCC0_list) +1	

			elif G.node[node]['gate_type'] =='not': 
				for stem in G.in_edges(node):
					G.edges[stem]['CO']= successorsC0_list[0] + 1 
예제 #4
0
파일: myPODEM_v2.py 프로젝트: cpr888/PODEM
def Forward_Implication(node1,node2):
	global G
	print "\n \n \n node1",node1,"node2",node2
	list_outedges =list(G.out_edges(nbunch=node2, data=False))				
	list_inedges =list(G.in_edges(nbunch=node2, data=False))
	print "faulty_edge_list[:2]",faulty_edge_list[:2]
			
	
	if(G.nodes[node2]['type']=='fanout'):

		print "faulty_edge_list[:2]",faulty_edge_list[:2]
		print "G[node1][node2]['value_faulty']",G[node1][node2]['value_faulty']
		for i in range(len(list_outedges)):
		
			G.edges[list_outedges[i]]['value_non_fault']  = G[node1][node2]['value_non_fault']
			if(faulty_edge_list[0]!=list_outedges[i][0] or faulty_edge_list[1]!=list_outedges[i][1]):
				G.edges[list_outedges[i]]['value_faulty']  = G[node1][node2]['value_faulty']
			
			next_node1		=list_outedges[i][0]
			next_node2		=list_outedges[i][1]
			print "new_node1 new_node2",next_node1,next_node2,G.edges[list_outedges[i]]['value_faulty'] 	
			if(G.nodes[next_node2]['type']=='gate' or G.nodes[next_node2]['type']=='fanout'):
				Forward_Implication(next_node1,next_node2)
			
			#next_node1	= node1
			#next_node2	= node2
	elif(G.nodes[node2]['type']=='gate'):
		list_input_non_faulty =[]
		list_input_faulty	  =[]
		print G.nodes[node2]['gate_type'],node2	
		for i in range(len(list_inedges)):
			list_input_non_faulty.append(G.edges[list_inedges[i]]['value_non_fault'])
			list_input_faulty.append(G.edges[list_inedges[i]]['value_faulty'])
		print "fault list",list_input_faulty 
		print "nonfault list",list_input_non_faulty
		
		if(G.nodes[node2]['gate_type']=='and'):
			output_non_faulty_value = gates_lib.AND_gate(list_input_non_faulty)
			output_faulty_value	  = gates_lib.AND_gate(list_input_faulty)
		elif(G.nodes[node2]['gate_type']=='or'):
			output_non_faulty_value =	gates_lib.OR_gate(list_input_non_faulty)
			output_faulty_value	  =	gates_lib.OR_gate(list_input_faulty)
		elif(G.nodes[node2]['gate_type']=='nand'):
			output_non_faulty_value =	gates_lib.NAND_gate(list_input_non_faulty)
			output_faulty_value	  = gates_lib.NAND_gate(list_input_faulty)
		elif(G.nodes[node2]['gate_type']=='nor'):
			output_non_faulty_value =	gates_lib.NOR_gate(list_input_non_faulty)
			output_faulty_value      =gates_lib.NOR_gate(list_input_faulty)
		elif(G.nodes[node2]['gate_type']=='xor'):
			output_non_faulty_value =	gates_lib.XOR_gate(list_input_non_faulty)
			output_faulty_value      =gates_lib.XOR_gate(list_input_faulty)
		elif(G.nodes[node2]['gate_type']=='xnor'):
			output_non_faulty_value =	gates_lib.XNOR_gate(list_input_non_faulty)
			output_faulty_value      =gates_lib.XNOR_gate(list_input_faulty)
		elif(G.nodes[node2]['gate_type']=='not'):
			output_non_faulty_value =	gates_lib.NOT_gate(list_input_non_faulty[0])
			output_faulty_value	  = gates_lib.NOT_gate(list_input_faulty[0])
			#print "OUTPUT",output_non_faulty_value
		#Assign the value_non_fault to the output_non_faulty_value nodes
		print output_non_faulty_value,"non_faulty)output @",list_outedges[0]
		G.edges[list_outedges[0]]['value_non_fault'] = output_non_faulty_value 
				
		print "list_outedge",list_outedges[0] ,"and the faulty_edge_list=",faulty_edge_list	
		print "list_outedge[0][0]",list_outedges[0][0] ,"and the faulty_edge_list[0]=",faulty_edge_list[0]

		print "list_outedge[0][1]",list_outedges[0][1] ,"and the faulty_edge_list[1]=",faulty_edge_list[1]	
		print 

		if(faulty_edge_list[0] !=list_outedges[0][0] or faulty_edge_list[1] !=list_outedges[0][1]): 		#in case of the Gates, the output egdes will have only one element(tuple)
			G.edges[list_outedges[0]]['value_faulty'] = output_faulty_value 
			print output_faulty_value,"faulty_output @",list_outedges[0]
		
			
		next_node1 =list(G.out_edges(nbunch=node2, data=False))[0][0]
		next_node2 =list(G.out_edges(nbunch=node2, data=False))[0][1]
		#print "node1 node2",node1,node2
		if(G.nodes[node2]['type']!='output'):		#Check whether Fault Propagated to Primary output_non_faulty_value
			Forward_Implication(next_node1,next_node2)