base3Nr = base3Nr.zfill(length) return [int(x) for x in base3Nr] def toBase2(number, length): return [int(x) for x in bin(number)[2:].zfill(length)] ################################################################# taskParameter = int(sys.argv[1]) random_tag = sys.argv[2] params = {} #get logic formula for taskParameter formula = LogicFormulaCreator.createFromParameters(taskParameter) v = [ "('0', '0', '0', '0')", "('0', '0', '0', '1')", "('0', '0', '1', '0')", "('0', '0', '1', '1')", "('0', '1', '0', '0')", "('0', '1', '0', '1')", "('0', '1', '1', '0')", "('0', '1', '1', '1')", "('1', '0', '0', '0')", "('1', '0', '0', '1')", "('1', '0', '1', '0')", "('1', '0', '1', '1')", "('1', '1', '0', '0')", "('1', '1', '0', '1')", "('1', '1', '1', '0')", "('1', '1', '1', '1')" ] shuffle(v) # make test vector order random for i in range(len(v) - 1): v[i] += ","
outputsNegate=toBase2(randNegateOutputs,5) output_negation={0:"false",1:"true"} for i in range(0,5): params_outputs["ON"+str(i)]=output_negation[outputsNegate[i]] ############################## ## PARAMETER SPECIFYING TASK## ############################## taskParameters= (randGates<<41) + (randEnableInputsLvl1<<25) + (randNegateInputsLvl1<<9) + (randNegateInputsLvl2<<5) + randNegateOutputs ############### ONLY FOR TESTING ####################### #get logic formula for taskParameters expression = LogicFormulaCreator.createFromParameters(taskParameters) filename ="tmp/solution_{0}_Task{1}.txt".format(userId,taskNr) with open (filename, "w") as solution: solution.write("For TaskParameters: " + str(taskParameters) + "\n") solution.write("logic Formula:\n") solution.write(expression) solution.write("\nOr preferably use the attached gate entities :)") ######################################################### ########################################### # SET PARAMETERS FOR DESCRIPTION TEMPLATE # ########################################### paramsDesc.update(params_gates) paramsDesc.update(params_inputs)
remainder = dividend % 3 dividend = dividend // 3 base3Nr+=str(remainder) base3Nr=base3Nr.zfill(length) return [int(x) for x in base3Nr] def toBase2(number,length): return [int(x) for x in bin(number)[2:].zfill(length)] ################################################################# taskParameter=int(sys.argv[1]) params={} #get logic formula for taskParameter formula = LogicFormulaCreator.createFromParameters(taskParameter) v=[ "('0', '0', '0', '0')", "('0', '0', '0', '1')", "('0', '0', '1', '0')", "('0', '0', '1', '1')", "('0', '1', '0', '0')", "('0', '1', '0', '1')", "('0', '1', '1', '0')", "('0', '1', '1', '1')", "('1', '0', '0', '0')", "('1', '0', '0', '1')", "('1', '0', '1', '0')", "('1', '0', '1', '1')",