Browse Source

Visualize algebraic loops as well (colour blue) and prevent simulation

Yentl Van Tendeloo 8 years ago
parent
commit
79853a1405
2 changed files with 10 additions and 29 deletions
  1. 8 29
      integration/code/cbd_semantics.alc
  2. 2 0
      interface/CBD/main.py

+ 8 - 29
integration/code/cbd_semantics.alc

@@ -138,22 +138,6 @@ Element function create_schedule(model : Element):
 	while (read_nr_out(nodes) > 0):
 		strongconnect(set_pop(nodes), values)
 
-	log("Computed SCC!")
-	log("Print list:")
-	Integer i
-	Integer j
-	Element lst
-	i = 0
-	while (i < read_nr_out(values["SCC"])):
-		log("[")
-		lst = list_read(values["SCC"], i)
-		j = 0
-		while (j < read_nr_out(lst)):
-			log("    " + cast_v2s(list_read(lst, j)))
-			j = j + 1
-		log("]")
-		i = i + 1
-	log("=== END")
 	return values["SCC"]!
 
 Void function dict_overwrite(d : Element, key : Element, value : Element):
@@ -174,8 +158,6 @@ Integer function min(a : Integer, b : Integer):
 Void function strongconnect(v : String, values : Element):
 	if (dict_in(values["indices"], v)):
 		return!
-	log("Compute strong connected components")
-	log("Source: " + v)
 
 	dict_overwrite(values["indices"], v, values["index"])
 	dict_overwrite(values["lowlink"], v, values["index"])
@@ -189,32 +171,24 @@ Void function strongconnect(v : String, values : Element):
 	successors = values["successors"][v]
 	while (read_nr_out(successors) > 0):
 		w = set_pop(successors)
-		log("Found successor " + w)
 		if (bool_not(dict_in(values["indices"], w))):
-			log("Recurse!")
 			strongconnect(w, values)
 			dict_overwrite(values["lowlink"], v, min(values["lowlink"][v], values["lowlink"][w]))
 		elif (dict_in(values["onStack"], w)):
-			log("Check on stack")
 			if (values["onStack"][w]):
-				log("Is on stack, so update")
 				dict_overwrite(values["lowlink"], v, min(values["lowlink"][v], values["indices"][w]))
-	log("Done")
 	
 	if (value_eq(values["lowlink"][v], values["indices"][v])):
-		log("Start new SCC block")
 		Element scc
 		scc = create_node()
 		// It will always differ now
 		w = list_pop(values["S"])
 		list_append(scc, w)
 		dict_overwrite(values["onStack"], w, False)
-		log("REMOVE from stack: " + w)
 		while (w != v):
 			w = list_pop(values["S"])
 			list_append(scc, w)
 			dict_overwrite(values["onStack"], w, False)
-			log("REMOVE from stack: " + w)
 		list_insert(values["SCC"], scc, 0)
 
 	return!
@@ -241,6 +215,7 @@ Void function step_simulation(model : Element, schedule : Element):
 	Element memory_blocks
 	Integer i
 	Float delta_t
+	Element scc
 
 	time = "time"
 	delta_t = 0.1
@@ -249,9 +224,15 @@ Void function step_simulation(model : Element, schedule : Element):
 	output("SIM_TIME " + cast_v2s(read_attribute(model, time, "current_time")))
 	i = 0
 	while (i < read_nr_out(schedule)):
-		block = list_read(schedule, i)
+		scc = list_read(schedule, i)
 		i = i + 1
 
+		if (list_len(scc) > 1):
+			output("ALGEBRAIC_LOOP")
+			return !
+		else:
+			block = set_pop(scc)
+
 		// Execute "block"
 		blocktype = readType(model, block)
 		if (blocktype == "ConstantBlock"):
@@ -451,9 +432,7 @@ Void function execute_cbd(design_model : Element):
 				// Conforming, so do the retyping and sanitization step
 				runtime_model = retype_to_runtime(design_model)
 				runtime_model = sanitize(runtime_model, old_runtime_model)
-				log("Create schedule")
 				schedule_init = create_schedule(runtime_model)
-				log("Remove schedule")
 				schedule_run = read_root()
 				old_runtime_model = runtime_model
 				output("CONFORMANCE_OK")

+ 2 - 0
interface/CBD/main.py

@@ -99,6 +99,8 @@ def poll(address):
             root.configure(background="grey")
         elif (returnvalue.startswith("CONFORMANCE_FAIL")):
             root.configure(background="red")
+        elif (returnvalue.startswith("ALGEBRAIC_LOOP")):
+            root.configure(background="blue")
         else:
             print("Error: got unknown result: " + returnvalue)