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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [common/] [generic/] [iotypes.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_IOTYPES_H__
18
#define __DEBUGGER_COMMON_GENERIC_IOTYPES_H__
19
 
20
#include <iclass.h>
21
#include <iservice.h>
22
#include "coreservices/iioport.h"
23
#include "coreservices/ireset.h"
24
#include "coreservices/iwire.h"
25
 
26
namespace debugger {
27
 
28
class IOReg8Type : public IMemoryOperation,
29
                   public IIOPort,
30
                   public IResetListener {
31
 public:
32
    IOReg8Type(IService *parent, const char *name,
33
               uint16_t addr, uint16_t len, int priority = 1);
34
 
35
    /** IMemoryOperation methods */
36
    virtual ETransStatus b_transport(Axi4TransactionType *trans);
37
 
38
    /** IIOPort */
39
    virtual void registerPortListener(IFace *listener);
40
    virtual void unregisterPortListener(IFace *listener);
41
 
42
    /** IResetListener interface */
43
    virtual void reset(bool active);
44
 
45
    /** General access methods: */
46
    const char *regName() { return regname_.to_string(); }
47
    uint8_t getValue() { return value.byte; }
48
    void setValue(uint8_t v) { value.byte = v; }
49
 
50
 protected:
51
    virtual uint8_t read();
52
    virtual void write(uint8_t val);
53
    virtual uint8_t get_direction() {return 0u; }
54
 
55
 protected:
56
    // Debug output compatibility
57
    IFace *getInterface(const char *name);
58
 
59
 protected:
60
    IService *parent_;
61
    AttributeType regname_;
62
    AttributeType portListeners_;
63
    Reg8Type value;
64
    uint8_t hard_reset_value_;
65
};
66
 
67
 
68
class IOPinType : public IIOPortListener {
69
 public:
70
    IOPinType(IService *parent, const char *name);
71
 
72
    /** IIOPortListener */
73
    virtual void readData(uint8_t *val, uint8_t mask);
74
    virtual void writeData(uint8_t val, uint8_t mask);
75
    virtual void latch();
76
 
77
    /** generic accessors */
78
    void postinit();
79
    void connectToBit(const AttributeType &cfg);
80
    void connectToWire(const AttributeType &cfg);
81
    uint8_t get_bit();
82
    void set_bit(uint8_t v);
83
 
84
 protected:
85
    virtual uint8_t aboutToRead(uint8_t val) { return val; }
86
    virtual void aboutToWrite(uint8_t prev, uint8_t val) {}
87
 
88
 protected:
89
    static const int READ_MASK = 0x1;
90
    static const int WRITE_MASK = 0x2;
91
 
92
    AttributeType pinName_;
93
    AttributeType IOPinTypeCfg_;
94
    IService *parent_;
95
    IWire *iwire_;
96
    uint8_t value_;     // triggered
97
    uint8_t prelatch_;  // not triggered value
98
    int bitIdx_;
99
    int access_;
100
};
101
 
102
class IOPinTypeDebug : public IOPinType {
103
 public:
104
    IOPinTypeDebug(IService *parent, const char *name)
105
        : IOPinType(parent, name) {}
106
 protected:
107
    // Debug output compatibility
108
    IFace *getInterface(const char *name) {
109
        return parent_->getInterface(name);
110
    }
111
};
112
 
113
}  // namespace debugger
114
 
115
#endif  // __DEBUGGER_COMMON_GENERIC_IOTYPES_H__

powered by: WebSVN 2.1.0

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