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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [cpu_fnc_plugin/] [cpu_riscv_func.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2016 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      CPU functional simlator class definition.
6
 */
7
 
8
#ifndef __DEBUGGER_CPU_RISCV_FUNCTIONAL_H__
9
#define __DEBUGGER_CPU_RISCV_FUNCTIONAL_H__
10
 
11
#include <riscv-isa.h>
12
#include "instructions.h"
13
#include "generic/cpu_generic.h"
14
#include "coreservices/icpuriscv.h"
15
#include "coreservices/isocinfo.h"
16
 
17
namespace debugger {
18
 
19
class CpuRiver_Functional : public CpuGeneric,
20
                            public ICpuRiscV {
21
 public:
22
    explicit CpuRiver_Functional(const char *name);
23
    virtual ~CpuRiver_Functional();
24
 
25
    /** IService interface */
26
    virtual void postinitService();
27
 
28
    /** IResetListener itnterface */
29
    virtual void reset(bool active);
30
 
31
    /** ICpuGeneric interface */
32
    virtual void raiseSignal(int idx);
33
    virtual void lowerSignal(int idx);
34
    virtual void raiseSoftwareIrq() {}
35
    virtual uint64_t getIrqAddress(int idx) { return readCSR(CSR_mtvec); }
36
 
37
    // Common River methods shared with instructions:
38
    uint64_t *getpRegs() { return portRegs_.getpR64(); }
39
    uint64_t readCSR(int idx);
40
    void writeCSR(int idx, uint64_t val);
41
 
42
 protected:
43
    /** CpuGeneric common methods */
44
    virtual EEndianessType endianess() { return LittleEndian; }
45
    virtual GenericInstruction *decodeInstruction(Reg64Type *cache);
46
    virtual void generateIllegalOpcode();
47
    virtual void handleTrap();
48
    /** Tack Registers changes during execution */
49
    virtual void trackContextStart();
50
    /** // Stop tracking and write trace file */
51
    virtual void trackContextEnd();
52
 
53
    void addIsaUserRV64I();
54
    void addIsaPrivilegedRV64I();
55
    void addIsaExtensionA();
56
    void addIsaExtensionC();
57
    void addIsaExtensionF();
58
    void addIsaExtensionM();
59
    unsigned addSupportedInstruction(RiscvInstruction *instr);
60
    uint32_t hash32(uint32_t val) { return (val >> 2) & 0x1f; }
61
    /** Compressed instruction */
62
    uint32_t hash16(uint16_t val) {
63
        uint32_t t1 = val & 0x3;
64
        return 0x20 | ((val >> 13) << 2) | t1;
65
    }
66
 
67
 private:
68
    AttributeType listExtISA_;
69
    AttributeType vendorID_;
70
    AttributeType vectorTable_;
71
 
72
    static const int INSTR_HASH_TABLE_SIZE = 1 << 6;
73
    AttributeType listInstr_[INSTR_HASH_TABLE_SIZE];
74
 
75
    GenericReg64Bank portRegs_;
76
    GenericReg64Bank portSavedRegs_;
77
    GenericReg64Bank portCSR_;
78
};
79
 
80
DECLARE_CLASS(CpuRiver_Functional)
81
 
82
}  // namespace debugger
83
 
84
#endif  // __DEBUGGER_CPU_RISCV_FUNCTIONAL_H__

powered by: WebSVN 2.1.0

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