def _wire_parser(self, line): fragment = fragment_split(line) if len(fragment) == 2: self.target.add_wire(fragment[1].strip()) else: self.target.add_wire(fragment[2].strip(), int(get_between(fragment[1], '[', ':')))
def _module_parser(self, line): essential = get_between(line, "module ") fragment = fragment_split(essential) if len(fragment) == 1: module_name = fragment[0].split('(')[0].strip() else: module_name = fragment[0].strip() if module_name not in self._modules.keys(): self._modules[module_name] = Module(module_name) self.target = self._modules.get(module_name) module_part = get_between(essential, '(', ')').strip() self.target.set_interface(module_part.split(','))
def _instance_parser(self, line): fragment = fragment_split(line) cell = self._cells.get(fragment[0].strip()) if len(fragment) == 2: name = fragment[1].split('(')[0].strip() ports = get_between(fragment[1], '(', ')').split(',') else: name = fragment[1].strip() ports = get_between(fragment[2], '(', ')').split(',') if cell is not None: mapping = dict() if '(' not in ports[0]: mapping = dict(zip(cell.interface, [p.strip() for p in ports])) else: for p in ports: mapping[get_between(p, '.', '(').strip()] = get_between( p, '(', ')').strip() self.target.add_instance(name, cell, mapping) else: print("cell {} undefined".format(fragment[0]))