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 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2016 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      UART functional model.
6
 */
7
 
8
#ifndef __DEBUGGER_SOCSIM_PLUGIN_UART_H__
9
#define __DEBUGGER_SOCSIM_PLUGIN_UART_H__
10
 
11
#include "iclass.h"
12
#include "iservice.h"
13
#include "coreservices/imemop.h"
14
#include "coreservices/iserial.h"
15
#include "coreservices/iwire.h"
16
#include "coreservices/irawlistener.h"
17
#include <string>
18
 
19
namespace debugger {
20
 
21
class UART : public IService,
22
             public IMemoryOperation,
23
             public ISerial {
24
public:
25
    UART(const char *name);
26
    ~UART();
27
 
28
    /** IService interface */
29
    virtual void postinitService();
30
 
31
    /** IMemoryOperation */
32
    virtual void b_transport(Axi4TransactionType *trans);
33
 
34
    virtual uint64_t getBaseAddress() {
35
        return baseAddress_.to_uint64();
36
    }
37
    virtual uint64_t getLength() {
38
        return length_.to_uint64();
39
    }
40
 
41
    /** ISerial */
42
    virtual int writeData(const char *buf, int sz);
43
    virtual void registerRawListener(IFace *listener);
44
    virtual void unregisterRawListener(IFace *listener);
45
 
46
private:
47
    AttributeType baseAddress_;
48
    AttributeType length_;
49
    AttributeType irqLine_;
50
    AttributeType irqctrl_;
51
    AttributeType listeners_;  // non-registering attribute
52
    IWire *iwire_;
53
 
54
    std::string input_;
55
    static const int RX_FIFO_SIZE = 16;
56
    char rxfifo_[RX_FIFO_SIZE];
57
    char *p_rx_wr_;
58
    char *p_rx_rd_;
59
    int rx_total_;
60
    mutex_def mutexListeners_;
61
 
62
    struct uart_map {
63
        volatile uint32_t status;
64
        volatile uint32_t scaler;
65
        uint32_t rsrv[2];
66
        volatile uint32_t data;
67
    } regs_;
68
};
69
 
70
DECLARE_CLASS(UART)
71
 
72
}  // namespace debugger
73
 
74
#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.