def comp(input_file, options={}, parameters={}, sn=0): reuse = "no_reuse" not in options initialize_memory = "no_initialize_memory" not in options generate_library() try: # Optimize for area parser = Parser(input_file, reuse, initialize_memory, parameters) process = parser.parse_process() name = process.main.name + "_%s" % sn instructions = process.generate() instructions = expand_macros(instructions, parser.allocator) if "dump" in options: for i in instructions: print ( i.get("op", "-"), i.get("z", "-"), i.get("a", "-"), i.get("b", "-"), i.get("literal", "-"), i.get("trace"), ) output_file = name + ".v" output_file = open(output_file, "w") inputs, outputs = generate_CHIP_area( input_file, name, instructions, output_file, parser.allocator, initialize_memory, int(options.get("memory_size", 4096))) output_file.close() except C2CHIPError as err: print "Error in file:", err.filename, "at line:", err.lineno print err.message sys.exit(-1) return name, inputs, outputs, ""
def compile(c_buffer): input_file = open("main.c", 'w') input_file.write(c_buffer) input_file.close() parser = Parser("main.c", False, False, []) process = parser.parse_process() name = process.main.name instructions = process.generate() instructions = expand_macros(instructions, parser.allocator) output_file = StringIO.StringIO() inputs, outputs = generate_CHIP_area( input_file, name, instructions, output_file, parser.allocator, False) return output_file.getvalue()
def comp(input_file, options={}, parameters={}, sn=0): reuse = "no_reuse" not in options initialize_memory = "no_initialize_memory" not in options generate_library() try: # Optimize for area parser = Parser(input_file, reuse, initialize_memory, parameters) process = parser.parse_process() name = process.main.name + "_%s" % sn instructions = process.generate() instructions = expand_macros(instructions, parser.allocator) if "dump" in options: for i in instructions: print( i.get("op", "-"), i.get("z", "-"), i.get("a", "-"), i.get("b", "-"), i.get("literal", "-"), i.get("trace"), ) output_file = name + ".v" output_file = open(output_file, "w") inputs, outputs = generate_CHIP_area( input_file, name, instructions, output_file, parser.allocator, initialize_memory, int(options.get("memory_size", 4096))) output_file.close() except C2CHIPError as err: print "Error in file:", err.filename, "at line:", err.lineno print err.message sys.exit(-1) return name, inputs, outputs, ""
def comp(input_file, options=[]): reuse = "no_reuse" not in options initialize_memory = "no_initialize_memory" not in options try: if "speed" not in options: #Optimize for area parser = Parser(input_file, reuse, initialize_memory) process = parser.parse_process() name = process.main.name instructions = process.generate() instructions = cleanup_functions(instructions) instructions, registers = cleanup_registers(instructions, parser.allocator.all_registers) output_file = name + ".v" output_file = open(output_file, "w") inputs, outputs = generate_CHIP_area( input_file, name, instructions, output_file, registers, parser.allocator.memory_size_2, parser.allocator.memory_size_4, initialize_memory, parser.allocator.memory_content_2, parser.allocator.memory_content_4) output_file.close() else: #Optimize for speed parser = Parser(input_file, reuse, initialize_memory) process = parser.parse_process() name = process.main.name instructions = process.generate() instructions = cleanup_functions(instructions) instructions, registers = cleanup_registers(instructions, parser.allocator.all_registers) if "no_concurrent" in sys.argv: frames = [[i] for i in instructions] else: frames = parallelise(instructions) output_file = name + ".v" output_file = open(output_file, "w") inputs, outputs = generate_CHIP_speed( input_file, name, frames, output_file, registers, parser.allocator.memory_size_2, parser.allocator.memory_size_4, initialize_memory, parser.allocator.memory_content_2, parser.allocator.memory_content_4) output_file.close() generate_library() except C2CHIPError as err: print "Error in file:", err.filename, "at line:", err.lineno print err.message sys.exit(-1) return name, inputs, outputs, ""