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] - Diff between revs 3 and 4

Show entire file | Details | Blame | View Log

Rev 3 Rev 4
Line 1... Line 1...
/**
/*
 * @file
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
 * @copyright  Copyright 2016 GNSS Sensor Ltd. All right reserved.
 *
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
 *  Licensed under the Apache License, Version 2.0 (the "License");
 * @brief      Single CPU register form.
 *  you may not use this file except in compliance with the License.
 
 *  You may obtain a copy of the License at
 
 *
 
 *      http://www.apache.org/licenses/LICENSE-2.0
 
 *
 
 *  Unless required by applicable law or agreed to in writing, software
 
 *  distributed under the License is distributed on an "AS IS" BASIS,
 
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
 *  See the License for the specific language governing permissions and
 
 *  limitations under the License.
 */
 */
 
 
#include "RegWidget.h"
#include "RegWidget.h"
#include "RegsViewWidget.h"
#include "RegsViewWidget.h"
#include "moc_RegsViewWidget.h"
#include "moc_RegsViewWidget.h"
 
 
#include <memory>
#include <memory>
 
 
namespace debugger {
namespace debugger {
 
 
/** Layout of register by name */
 
static const char *REG_NAMES_LAYOUT[] = {
 
    "ra", "s0",  "a0",
 
    "sp", "s1",  "a1",
 
    "gp", "s2",  "a2",
 
    "tp", "s3",  "a3",
 
    ""  , "s4",  "a4",
 
    "t0", "s5",  "a5",
 
    "t1", "s6",  "a6",
 
    "t2", "s7",  "a7",
 
    "t3", "s8",  "",
 
    "t4", "s9",  "",
 
    "t5", "s10", "pc",
 
    "t6", "s11", "npc",
 
    "break"
 
};
 
 
 
RegsViewWidget::RegsViewWidget(IGui *igui, QWidget *parent)
RegsViewWidget::RegsViewWidget(IGui *igui, QWidget *parent)
    : QWidget(parent) {
    : QWidget(parent) {
    igui_ = igui;
    igui_ = igui;
 
 
    gridLayout = new QGridLayout(this);
    gridLayout = new QGridLayout(this);
Line 41... Line 33...
    gridLayout->setContentsMargins(4, 4, 4, 4);
    gridLayout->setContentsMargins(4, 4, 4, 4);
    setLayout(gridLayout);
    setLayout(gridLayout);
    cmdRegs_.make_string("regs");
    cmdRegs_.make_string("regs");
    waitingResp_ = false;
    waitingResp_ = false;
 
 
    int n = 0;
    const AttributeType &cfg = (*igui_->getpConfig())["RegsViewWidget"];
    while (strcmp(REG_NAMES_LAYOUT[n], "break")) {
    if (!cfg.is_dict()) {
        if (REG_NAMES_LAYOUT[n][0] == '\0') {
        return;
            n++;
    }
 
    const AttributeType &reglist = cfg["RegList"];
 
    const AttributeType &regwidth = cfg["RegWidthBytes"];
 
 
 
    if (!reglist.is_list()) {
 
        return;
 
    }
 
 
 
    for (unsigned row = 0; row < reglist.size(); row++) {
 
        const AttributeType &rowcfg = reglist[row];
 
        for (unsigned col = 0; col < rowcfg.size(); col++) {
 
            const AttributeType &regname = rowcfg[col];
 
            if (regname.size() == 0) {
            continue;
            continue;
        }
        }
        addRegWidget(n, REG_NAMES_LAYOUT[n]);
            addRegWidget(row, col, regwidth.to_int(), regname.to_string());
        n++;
 
    }
    }
}
}
 
    gridLayout->setColumnStretch(2*reglist.size() + 1, 10);
 
}
 
 
RegsViewWidget::~RegsViewWidget() {
RegsViewWidget::~RegsViewWidget() {
    igui_->removeFromQueue(static_cast<IGuiCmdHandler *>(this));
    igui_->removeFromQueue(static_cast<IGuiCmdHandler *>(this));
}
}
 
 
Line 78... Line 83...
 
 
void RegsViewWidget::slotRegChanged(AttributeType *wrcmd) {
void RegsViewWidget::slotRegChanged(AttributeType *wrcmd) {
    igui_->registerCommand(0, wrcmd, true);
    igui_->registerCommand(0, wrcmd, true);
}
}
 
 
void RegsViewWidget::addRegWidget(int idx, const char *name) {
void RegsViewWidget::addRegWidget(int row, int col, int bytes,
    int line = idx / 3;
                                  const char *name) {
    int col = idx - 3 * line;
    QWidget *pnew = new RegWidget(name, bytes, this);
 
    gridLayout->addWidget(pnew, row + 1, col);
    QWidget *pnew = new RegWidget(name, this);
 
    gridLayout->addWidget(pnew, line + 1, col);
 
 
 
    connect(this, SIGNAL(signalHandleResponse(AttributeType *)),
    connect(this, SIGNAL(signalHandleResponse(AttributeType *)),
            pnew, SLOT(slotHandleResponse(AttributeType *)));
            pnew, SLOT(slotHandleResponse(AttributeType *)));
 
 
    connect(pnew, SIGNAL(signalChanged(AttributeType *)),
    connect(pnew, SIGNAL(signalChanged(AttributeType *)),

powered by: WebSVN 2.1.0

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