OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [gui_plugin/] [CpuWidgets/] [RegsViewWidget.cpp] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/*
2
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15 3 sergeykhbr
 */
16
 
17
#include "RegWidget.h"
18
#include "RegsViewWidget.h"
19
#include "moc_RegsViewWidget.h"
20
 
21
#include <memory>
22
 
23
namespace debugger {
24
 
25
RegsViewWidget::RegsViewWidget(IGui *igui, QWidget *parent)
26
    : QWidget(parent) {
27
    igui_ = igui;
28
 
29
    gridLayout = new QGridLayout(this);
30
    gridLayout->setSpacing(4);
31
    gridLayout->setHorizontalSpacing(10);
32
    gridLayout->setVerticalSpacing(0);
33
    gridLayout->setContentsMargins(4, 4, 4, 4);
34
    setLayout(gridLayout);
35
    cmdRegs_.make_string("regs");
36
    waitingResp_ = false;
37
 
38 4 sergeykhbr
    const AttributeType &cfg = (*igui_->getpConfig())["RegsViewWidget"];
39
    if (!cfg.is_dict()) {
40
        return;
41
    }
42
    const AttributeType &reglist = cfg["RegList"];
43
    const AttributeType &regwidth = cfg["RegWidthBytes"];
44
 
45
    if (!reglist.is_list()) {
46
        return;
47
    }
48
 
49
    for (unsigned row = 0; row < reglist.size(); row++) {
50
        const AttributeType &rowcfg = reglist[row];
51
        for (unsigned col = 0; col < rowcfg.size(); col++) {
52
            const AttributeType &regname = rowcfg[col];
53
            if (regname.size() == 0) {
54
                continue;
55
            }
56
            addRegWidget(row, col, regwidth.to_int(), regname.to_string());
57 3 sergeykhbr
        }
58
    }
59 4 sergeykhbr
    gridLayout->setColumnStretch(2*reglist.size() + 1, 10);
60 3 sergeykhbr
}
61
 
62
RegsViewWidget::~RegsViewWidget() {
63
    igui_->removeFromQueue(static_cast<IGuiCmdHandler *>(this));
64
}
65
 
66
void RegsViewWidget::handleResponse(AttributeType *req, AttributeType *resp) {
67
    resp_ = *resp;
68
    emit signalHandleResponse(&resp_);
69
    waitingResp_ = false;
70
}
71
 
72
void RegsViewWidget::slotUpdateByTimer() {
73
    if (!isVisible()) {
74
        return;
75
    }
76
    if (waitingResp_) {
77
        return;
78
    }
79
    igui_->registerCommand(static_cast<IGuiCmdHandler *>(this),
80
                            &cmdRegs_, true);
81
    waitingResp_ = true;
82
}
83
 
84
void RegsViewWidget::slotRegChanged(AttributeType *wrcmd) {
85
    igui_->registerCommand(0, wrcmd, true);
86
}
87
 
88 4 sergeykhbr
void RegsViewWidget::addRegWidget(int row, int col, int bytes,
89
                                  const char *name) {
90
    QWidget *pnew = new RegWidget(name, bytes, this);
91
    gridLayout->addWidget(pnew, row + 1, col);
92 3 sergeykhbr
 
93
    connect(this, SIGNAL(signalHandleResponse(AttributeType *)),
94
            pnew, SLOT(slotHandleResponse(AttributeType *)));
95
 
96
    connect(pnew, SIGNAL(signalChanged(AttributeType *)),
97
            this, SLOT(slotRegChanged(AttributeType *)));
98
}
99
 
100
}  // namespace debugger

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.