Example #1
0
 def __init__(self, input_file, reuse):
     self.scope = {}
     self.function = None
     self.loop = None
     self.tokens = Tokens(input_file)
     self.allocator = Allocator(reuse)
     self.structs = []
Example #2
0
 def __init__(self, cfg_list):
     self.allocator_list = []
     self.event_list = []
     for cfg in cfg_list:
         event = Event()
         cfg.update({'poison': event})
         self.allocator_list.append(Allocator(**cfg))
         self.event_list.append(event)
Example #3
0
    def __init__(self, model, kp, kd, primer_state):
        self.model = model
        self.kp = np.array(kp, dtype=np.float64)
        self.kd = np.array(kd, dtype=np.float64)

        if self.model.gmag == 0:
            self.ascent_dir = np.array([0, 0, 1], dtype=np.float64)
        else:
            self.ascent_dir = -self.model.gdir

        self.reset(primer_state)
        self.allocator = Allocator(self.model, verbose=False)
Example #4
0
def _compile(chip_name,
             chip_id,
             input_file,
             options,
             parameters,
             reuse,
             initialize_memory,
             sn=0):
    if "is_asm" in options:
        name = chip_name + "_main" + "_%s" % sn
        allocator = Allocator(False)
        asm_program = get_instructions_from_asm(input_file, allocator, options)
    else:
        # Optimize for area
        parser = Parser(input_file, reuse, initialize_memory, parameters)
        allocator = parser.allocator
        process = parser.parse_process()
        name = chip_name + "_" + process.main.name + "_%s" % sn
        asm_program = process.generate()
        asm_program.program_instrs = expand_macros(asm_program.instructions,
                                                   parser.allocator)

    if "dump" in options:
        print_instructions(sys.stdout, asm_program.instructions)
    if "dump_to" in options:
        with open(options["dump_to"], "w") as instruction_dump_file:
            print_instructions(instruction_dump_file, asm_program.instructions)

    asm_program.set_stack_size(options.get("stack_size", 300))
    print "%s: used memory size: %s (stack: %s, globals: %s)" % (
        chip_name, asm_program.memory_size_in_bytes,
        asm_program.stack_size_bytes, asm_program.globals_size_bytes)

    asm_program.set_names(chip_id, chip_name, name)
    asm_program.set_io_ports(allocator.input_names, allocator.output_names)

    return asm_program
def allocator():
    return Allocator()