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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [cpu_fnc_plugin/] [instructions.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 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Instruction object declaration.
6
 */
7
 
8
#ifndef __DEBUGGER_CPU_RISCV_INSTRUCTIONS_H__
9
#define __DEBUGGER_CPU_RISCV_INSTRUCTIONS_H__
10
 
11
#include <inttypes.h>
12
#include "generic/cpu_generic.h"
13
 
14
namespace debugger {
15
 
16
class CpuRiver_Functional;
17
 
18
class RiscvInstruction : public GenericInstruction {
19
public:
20
    RiscvInstruction(CpuRiver_Functional *icpu, const char *name,
21
                    const char *bits);
22
 
23
    // IInstruction interface:
24
    virtual const char *name() { return name_.to_string(); }
25
 
26
    virtual bool parse(uint32_t *payload) {
27
        return ((payload[0] & mask_) == opcode_);
28
    }
29
 
30
    virtual uint32_t hash() {
31
        return (opcode_ >> 2) & 0x1F;
32
    }
33
 
34
    uint16_t hash16() {
35
        uint16_t t1 = static_cast<uint16_t>(opcode_) & 0x3;
36
        return 0x20 | ((static_cast<uint16_t>(opcode_) >> 13) << 2) | t1;
37
    }
38
 
39
protected:
40
    AttributeType name_;
41
    CpuRiver_Functional *icpu_;
42
    uint32_t mask_;
43
    uint32_t opcode_;
44
    uint64_t *R;
45
};
46
 
47
class RiscvInstruction16 : public RiscvInstruction {
48
public:
49
    RiscvInstruction16(CpuRiver_Functional *icpu, const char *name,
50
                    const char *bits) : RiscvInstruction(icpu, name, bits) {}
51
 
52
    // IInstruction interface:
53
    virtual uint32_t hash() {
54
        uint16_t t1 = static_cast<uint16_t>(opcode_) & 0x3;
55
        return 0x20 | ((static_cast<uint16_t>(opcode_) >> 13) << 2) | t1;
56
    }
57
};
58
 
59
 
60
}  // namespace debugger
61
 
62
#endif  // __DEBUGGER_CPU_RISCV_INSTRUCTIONS_H__

powered by: WebSVN 2.1.0

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