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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [common/] [generic/] [mapreg.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 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
 */
16
 
17
#ifndef __DEBUGGER_COMMON_GENERIC_MAPREG_H__
18
#define __DEBUGGER_COMMON_GENERIC_MAPREG_H__
19
 
20
#include <iclass.h>
21
#include <iservice.h>
22
#include "coreservices/imemop.h"
23
#include "coreservices/ireset.h"
24
 
25
namespace debugger {
26
 
27
class MappedReg64Type : public IMemoryOperation,
28
                        public IResetListener {
29
 public:
30
    MappedReg64Type(IService *parent, const char *name,
31
                    uint64_t addr, int len = 8, int priority = 1);
32
 
33
    /** IMemoryOperation methods */
34
    virtual ETransStatus b_transport(Axi4TransactionType *trans);
35
 
36
    /** IResetListener interface */
37
    virtual void reset(bool active);
38
 
39
    /** General access methods: */
40
    const char *regName() { return regname_.to_string(); }
41
    Reg64Type getValue() { return value_; }
42
    void setValue(Reg64Type v) { value_ = v; }
43
    void setValue(uint64_t v) { value_.val = v; }
44
 
45
 protected:
46
    /** Possible side effects handlers:  */
47
    virtual uint64_t aboutToRead(uint64_t cur_val) {
48
        return cur_val;
49
    }
50
    virtual uint64_t aboutToWrite(uint64_t new_val) {
51
        return new_val;
52
    }
53
 protected:
54
    // Debug output compatibility
55
    IFace *getInterface(const char *name);
56
 
57
 protected:
58
    IService *parent_;
59
    AttributeType regname_;
60
    AttributeType portListeners_;
61
    Reg64Type value_;
62
    uint64_t hard_reset_value_;
63
};
64
 
65
 
66
class GenericReg64Bank : public IMemoryOperation {
67
 public:
68
    GenericReg64Bank(IService *parent, const char *name,
69
                    uint64_t addr, int len) {
70
        parent->registerPortInterface(name,
71
                                      static_cast<IMemoryOperation *>(this));
72
        regs_ = 0;
73
        bankName_.make_string(name);
74
        baseAddress_.make_uint64(addr);
75
        setRegTotal(len);
76
    }
77
    virtual ~GenericReg64Bank() {
78
        if (regs_) {
79
            delete [] regs_;
80
        }
81
    }
82
 
83
    /** IMemoryOperation methods */
84
    virtual ETransStatus b_transport(Axi4TransactionType *trans);
85
 
86
    /** IResetListener interface */
87
    virtual void reset();
88
 
89
    /** General access methods: */
90
    void setRegTotal(int len);
91
    Reg64Type read(int idx) { return regs_[idx]; }
92
    void write(int idx, Reg64Type val) { regs_[idx] = val; }
93
    void write(int idx, uint64_t val) { regs_[idx].val = val; }
94
    Reg64Type *getp() { return regs_; }
95
    uint64_t *getpR64() { return &regs_[0].val; }
96
 
97
 protected:
98
    AttributeType bankName_;
99
    Reg64Type *regs_;
100
};
101
 
102
}  // namespace debugger
103
 
104
#endif  // __DEBUGGER_COMMON_GENERIC_MAPREG_H__

powered by: WebSVN 2.1.0

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