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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [socsim_plugin/] [uart.h] - 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
 */
16
 
17
#ifndef __DEBUGGER_SOCSIM_PLUGIN_UART_H__
18
#define __DEBUGGER_SOCSIM_PLUGIN_UART_H__
19
 
20
#include "iclass.h"
21
#include "iservice.h"
22
#include "coreservices/imemop.h"
23
#include "coreservices/iserial.h"
24
#include "coreservices/iwire.h"
25
#include "coreservices/irawlistener.h"
26
#include "coreservices/iclock.h"
27
#include <string>
28
 
29
namespace debugger {
30
 
31
class UART : public IService,
32
             public IMemoryOperation,
33
             public ISerial {
34
 public:
35
    UART(const char *name);
36
    ~UART();
37
 
38
    /** IService interface */
39
    virtual void postinitService();
40
 
41
    /** IMemoryOperation */
42
    virtual ETransStatus b_transport(Axi4TransactionType *trans);
43
 
44
    /** ISerial */
45
    virtual int writeData(const char *buf, int sz);
46
    virtual void registerRawListener(IFace *listener);
47
    virtual void unregisterRawListener(IFace *listener);
48
    virtual void getListOfPorts(AttributeType *list);
49
    virtual int openPort(const char *port, AttributeType settings);
50
    virtual void closePort();
51
 
52
 private:
53
    AttributeType irqctrl_;
54
    AttributeType listeners_;  // non-registering attribute
55
    AttributeType autoTestEna_;
56
    AttributeType testCases_;
57
    IWire *iwire_;
58
 
59
    std::string input_;
60
    static const int RX_FIFO_SIZE = 16;
61
    char rxfifo_[RX_FIFO_SIZE];
62
    char *p_rx_wr_;
63
    char *p_rx_rd_;
64
    int rx_total_;
65
    mutex_def mutexListeners_;
66
 
67
    struct uart_map {
68
        volatile uint32_t status;
69
        volatile uint32_t scaler;
70
        uint32_t rsrv[2];
71
        volatile uint32_t data;
72
    } regs_;
73
 
74
  private:
75
    class AutoTest : public IClockListener {
76
     public:
77
        AutoTest(ISerial *parent, AttributeType *tests);
78
 
79
        /** IClockListener */
80
        virtual void stepCallback(uint64_t t);
81
     private:
82
        ISerial *parent_;
83
        AttributeType tests_;
84
        unsigned testcnt_;
85
    };
86
    AutoTest *pautotest_;
87
};
88
 
89
DECLARE_CLASS(UART)
90
 
91
}  // namespace debugger
92
 
93
#endif  // __DEBUGGER_SOCSIM_PLUGIN_UART_H__

powered by: WebSVN 2.1.0

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