예제 #1
0
def node_search(
        minibuffer=Inject('gearbox/minibuffer'),
        graph=Inject('gearbox/graph')):

    items = graph.selected_items()
    if len(items) == 1:
        model = items[0].model
    else:
        model = graph.top.model

    if not model.child:
        model = model.parent

    node_name = get_minibuffer_input(
        message=f'{model.name}/', completer=node_search_completer(model))

    if not node_name:
        return

    node = graph.top.model
    for basename in node_name[1:].split('/'):
        node.view.expand()
        print('basename')
        node = node[basename]

    graph.select(node.view)
예제 #2
0
def compilation_create(
        sim_bridge=Inject('gearbox/sim_bridge'),
        compilation_log_fn=Inject('gearbox/compilation_log_fn')):

    buff = CompilationBuffer(Compilation(compilation_log_fn), 'compilation')
    show_buffer(buff)
    return buff
예제 #3
0
    def create_menus(self,
                     prefixes=Inject('gearbox/prefixes'),
                     shortcuts=Inject('gearbox/shortcuts')):
        for domain, key, callback, name in registry('gearbox/shortcuts'):
            if not isinstance(key, tuple):
                key = (key, )

            current_menu = self.menuBar()
            start_skip = 1
            if (domain is None):
                if (key[0] != QtCore.Qt.Key_Space):
                    Shortcut(domain, key, callback, name)

                start_skip = 2

            else:
                submenu = self.get_or_create_submenu(current_menu,
                                                     domain.title())
                action = self.get_subaction(current_menu, domain.title())
                action.setVisible(False)
                current_menu = submenu

            for i in range(start_skip, len(key) + 1):
                if i < len(key):
                    menu_name = prefixes.get((domain, key[:i]),
                                             'group').title()
                    current_menu = self.get_or_create_submenu(
                        current_menu, menu_name)
                else:
                    action = Action(domain, key, callback, name)
                    self.addAction(action)
                    current_menu.addAction(action)
예제 #4
0
    def __init__(self,
                 trace_fn=Inject('wavejson/trace_fn'),
                 include=Inject('debug/trace'),
                 sim=Inject('sim/simulator'),
                 outdir=Inject('results-dir'),
                 sim_map=Inject('sim/map')):
        super().__init__()
        self.sim = sim
        self.finished = False

        self.outdir = outdir
        self.trace_fn = trace_fn

        if not os.path.isabs(self.trace_fn):
            self.trace_fn = os.path.abspath(os.path.join(
                self.outdir, trace_fn))

        atexit.register(self.finish)

        self.writer = WaveJSONWriter()

        reg['WaveJSONWriter'] = self.writer

        self.handhake = set()

        v = WaveJSONHierVisitor(self.writer, include)
        v.visit(find('/'))
        self.vcd_vars = v.vcd_vars

        for intf in self.vcd_vars:
            intf.events['put'].append(self.intf_put)
            intf.events['ack'].append(self.intf_ack)
예제 #5
0
    def __init__(self,
                 view,
                 name,
                 plugins=None,
                 main=Inject('gearbox/main/inst'),
                 layout=Inject('gearbox/layout')):

        super().__init__()

        view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        menu = main.get_submenu(main.menuBar(), self.domain.title())
        if menu:
            view.customContextMenuRequested.connect(
                lambda pos: menu.popup(view.mapToGlobal(pos)))

        self.view = view
        self.name = name
        layout.add(self)

        if plugins is None:
            try:
                plugins = reg[f'gearbox/plugins/{self.domain}']
            except KeyError:
                plugins = {}

        self.plugins = {}
        for name, cls in plugins.items():
            self.add_plugin(name, cls(self))
예제 #6
0
def reload_file(sim_bridge=Inject('gearbox/sim_bridge'),
                script_fn=Inject('gearbox/model_script_name'),
                layout=Inject('gearbox/layout')):

    if script_fn:
        bind('gearbox/main/new_model_script_fn', script_fn)
        close_file()
예제 #7
0
def close_file(
        sim_bridge=Inject('gearbox/sim_bridge'),
        script_fn=Inject('gearbox/model_script_name'),
        layout=Inject('gearbox/layout')):

    if script_fn is not None:
        sim_bridge.invoke_method('close_script')
예제 #8
0
 def __init__(self,
              parent=None,
              background_color=Inject('gearbox/theme/background-color'),
              grid_color=Inject('gearbox/theme/graph-grid-color')):
     super(NodeScene, self).__init__(parent)
     self.background_color = QtGui.QColor(background_color)
     self.grid_color = grid_color
     self.grid = True
예제 #9
0
 def closeEvent(self,
                event,
                script_fn=Inject('gearbox/model_script_name'),
                sim_bridge=Inject('gearbox/sim_bridge')):
     if script_fn:
         event.ignore()
         sim_bridge.invoke_method('close_script')
     else:
         super().closeEvent(event)
예제 #10
0
def reload_file_save_layout(
        sim_bridge=Inject('gearbox/sim_bridge'),
        script_fn=Inject('gearbox/model_script_name'),
        layout=Inject('gearbox/layout')):

    if script_fn:
        save()
        reg['gearbox/main/new_model_script_fn'] = script_fn
        close_file()
예제 #11
0
    def complete(self,
                 message=None,
                 completer=None,
                 main=Inject('gearbox/main/inst'),
                 domain=Inject('gearbox/domain')):
        self.previous_domain = domain
        main.change_domain('minibuffer')
        self.input_box.setDisabled(False)

        self.timer.stop()

        self.complete_cont(message, completer)
예제 #12
0
def save_expanded(buffer_init_commands,
                  root=Inject('gearbox/graph_model'),
                  graph=Inject('gearbox/graph')):
    expanded = list(GraphStatusSaver().visit(root))

    selected = graph.selected_items()
    if selected:
        selected = selected[0]

    buffer_init_commands['graph'].append('expand')

    return load_str_template(expand_func_template).render({
        'expanded': expanded,
        'selected': selected
    })
예제 #13
0
def send_to_wave(
        graph=Inject('gearbox/graph'), gtkwave=Inject('gearbox/gtkwave/inst')):

    added = []
    selected_item = graph.selected_items()
    for item in selected_item:
        try:
            added.append(gtkwave.show_item(item.model))
        except ItemNotTraced:
            pass

    if (len(selected_item) == 1) and (len(added) == 0):
        message(f'WARNING: {item.model.name} not traced')
    else:
        message('Waves added: ' + ' '.join(added))
예제 #14
0
    def on_error_path(self, sim_bridge=Inject('gearbox/sim_bridge')):
        issue_path = sim_bridge.cur_model_issue_path
        if (self.parent is not None and issue_path
                and self.rtl.gear.is_descendent(issue_path[-1])):
            return True

        return False
예제 #15
0
    def __init__(self, main=Inject('gearbox/main/inst')):
        super().__init__()
        self.view = QtWidgets.QHBoxLayout()

        self.msgLabel = QtWidgets.QLabel()
        self.msgLabel.setAccessibleName("minibuffer-message")
        self.msgLabel.setVisible(False)

        self.input_box = InputBox()
        self.input_box.tab_key_event.connect(self.tab_key_event)
        self.input_box.cancel.connect(self.cancel)
        self.input_box.textEdited.connect(self._singled_out)
        self.input_box.returnPressed.connect(self._on_search_submitted)

        self.view.addWidget(self.msgLabel)
        self.view.addWidget(self.input_box)
        self.view.setSpacing(0)
        self.view.setContentsMargins(0, 0, 0, 0)

        main.key_cancel.connect(self.cancel)

        self.timer = QtCore.QTimer()
        self.timer.setInterval(3000)
        self.timer.timeout.connect(self.message_cleanup)
        self.timer.setSingleShot(True)
예제 #16
0
 def setSource(self, url, sim_bridge=Inject('gearbox/sim_bridge')):
     if url.scheme() == 'file':
         lineno = int(url.fragment())
         describe_file(url.path(), lineno=slice(lineno, lineno + 1))
     elif url.scheme() == 'err':
         issue_id = int(url.fragment())
         sim_bridge.invoke_method('set_err_model', issue_id=issue_id)
예제 #17
0
def split_vertically(layout=Inject('gearbox/layout')):
    window = layout.active_window()
    new_window = window.split_vertically()
    for b in layout.buffers:
        if not b.visible:
            new_window.place_buffer(b)
            return
예제 #18
0
    def build(self, intfs=Inject('sim/svsock/intfs')):

        base_addr = os.path.dirname(__file__)
        env = jinja2.Environment(loader=jinja2.FileSystemLoader(base_addr),
                                 trim_blocks=True,
                                 lstrip_blocks=True)
        env.globals.update(zip=zip,
                           int=int,
                           print=print,
                           issubclass=issubclass)

        context = {'port': self.port}
        for phase in [
                'declaration', 'init', 'set_data', 'read', 'ack', 'reset',
                'sys_reset'
        ]:
            context[phase] = {}
            for i, intf in enumerate(intfs):
                if not hasattr(intf, phase):
                    continue

                phase_sv = getattr(intf, phase)()

                if phase_sv is not None:
                    context[phase][i] = phase_sv

        res = env.get_template('svsock_top.j2').render(context)
        save_file('_top.sv', self.outdir, res)
예제 #19
0
파일: vcd.py 프로젝트: bogdanvuk/pygears
 def __init__(self, include, vcd_tlm, sim_map=Inject('sim/map')):
     self.include = include
     self.vcd_tlm = vcd_tlm
     self.sim_map = sim_map
     self.vcd_vars = {}
     self.end_consumers = {}
     self.indent = 0
예제 #20
0
def reloader(outdir=MayInject('sim/artifacts_dir'),
             plugin=Inject('sim/gearbox')):
    if plugin.reload:
        try:
            runpy.run_path(get_save_file_path())
        except Exception as e:
            print(f'Loading save file failed: {e}')
예제 #21
0
 def __init__(self, top, sim=Inject('sim/simulator')):
     sim.events['before_run'].append(self.before_run)
     sim.events['after_run'].append(self.after_run)
     reg['sim/activity'] = self
     self.blockers = {}
     self.handshakes = set()
     self.hooks = {}
예제 #22
0
    def __init__(self,
                 name,
                 layout,
                 parent=None,
                 model=None,
                 graph=Inject('gearbox/graph')):
        super().__init__(name)

        self._layout = layout
        self.parent = parent
        self.graph = graph
        self.model = model
        self.layout_graph = pgv.AGraph(directed=True,
                                       rankdir='LR',
                                       splines='true',
                                       strict=False)

        self.layout_pipe_map = {}

        self._text_item = QtWidgets.QGraphicsTextItem(self.name, self)
        self._input_items = {}
        self._output_items = {}
        self._nodes = []
        self.pipes = []
        self.minimum_size = (80, 80)

        self.layout_vertices = {}
        self.layout_root_vertices = []
        self.layout_edges = []
        self.layout_inport_vertices = {}
        self.layout_outport_vertices = {}

        self.collapsed = False if parent is None else True
        self.layers = []
예제 #23
0
    def __init__(self,
                 max_width=500,
                 max_height=500,
                 main=Inject('gearbox/main/inst')):
        super().__init__()
        self.setParent(main)
        self.max_width = max_width
        self.buff = None

        # self.max_height = max_height
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        main.key_cancel.connect(self.cancel)
        self.setWordWrapMode(QtGui.QTextOption.WrapAtWordBoundaryOrAnywhere)
        self.timeout_timer = QtCore.QTimer()
        self.timeout_timer.timeout.connect(self.cancel)
        self.timeout_timer.setSingleShot(True)

        self.delay_timer = QtCore.QTimer()
        self.delay_timer.timeout.connect(self.show)
        self.delay_timer.setSingleShot(True)
        self.document().setDefaultStyleSheet(
            QtWidgets.QApplication.instance().styleSheet() +
            '\n.highlight  { background: rgba(255, 255, 255, 0);}')
        self.setReadOnly(True)

        self.setStyleSheet("""
        border: 2px solid rgba(170, 140, 0, 255);
        background-color: rgba(100, 100, 100, 100);
        inset grey;
        """)
예제 #24
0
    def activate(self, layout=Inject('gearbox/layout')):
        layout.window_activated(self)

        if self.buff:
            self.buff.activate()

        self.activated.emit()
예제 #25
0
def gktwave_delete(timekeep=Inject('gearbox/timekeep')):
    print('Gtkwave deleted')
    gtkwave = registry('gearbox/gtkwave/inst')
    timekeep.timestep_changed.disconnect(gtkwave.update)
    for b in gtkwave.buffers:
        b.delete()

    bind('gearbox/gtkwave/inst', None)
예제 #26
0
    def __init__(self, writer, include, sim_map=Inject('sim/map')):

        self.include = include
        self.vcd_tlm = False
        self.sim_map = sim_map
        self.vcd_vars = {}
        self.writer = writer
        self.indent = 0
예제 #27
0
    def related_issues(self, issues=Inject('trace/issues')):
        rel_issues = []
        for issue in issues:
            if (self.parent is not None and hasattr(issue, 'gear')
                    and issue.gear is self.rtl.gear):
                rel_issues.append(issue)

        return rel_issues
예제 #28
0
 def wait(self,
          message=None,
          completer=None,
          minibuffer=Inject('gearbox/minibuffer')):
     minibuffer.complete(message, completer)
     minibuffer.completed.connect(self.completed)
     self.exec_()
     return self.resp
예제 #29
0
    def configure(self, timekeep=Inject('gearbox/timekeep')):
        # TODO: Investiget why this is needed here
        if self.buff.window is None:
            return

        self.buff.window.modeline.add_field('timestep', '')
        timekeep.timestep_changed.connect(self.update)
        self.update()
예제 #30
0
파일: sniper.py 프로젝트: Risto97/gearbox
    def snipe_cancel(self, graph=Inject('gearbox/graph')):
        self.main.key_cancel.disconnect(self.snipe_cancel)
        for text, s in snipe_shortcuts:
            s.setParent(None)
            graph.scene().removeItem(text)

        self.main.change_domain('graph')
        snipe_shortcuts.clear()