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 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      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 "iface.h"
13
#include "attribute.h"
14
#include "iinstr.h"
15
 
16
namespace debugger {
17
 
18
class IsaProcessor : public IInstruction {
19
public:
20
    IsaProcessor(const char *name, const char *bits) {
21
        name_ = name;
22
        mask_ = 0;
23
        opcode_ = 0;
24
        for (int i = 0; i < 32; i++) {
25
            switch (bits[i]) {
26
            case '0':
27
                break;
28
            case '1':
29
                opcode_ |= (1 << (31 - i));
30
                break;
31
            case '?':
32
                mask_ |= (1 << (31 - i));
33
                break;
34
            default:;
35
            }
36
        }
37
        mask_ ^= ~0;
38
    }
39
 
40
    // IInstruction interface:
41
    virtual const char *name() { return name_; }
42
 
43
    virtual bool parse(uint32_t *payload) {
44
        return ((payload[0] & mask_) == opcode_);
45
    }
46
 
47
    virtual void exec(uint32_t *payload, CpuContextType *regs) =0;
48
 
49
    virtual uint32_t hash() {
50
        return (opcode_ >> 2) & 0x1F;
51
    }
52
 
53
protected:
54
    const char *name_;
55
    uint32_t mask_;
56
    uint32_t opcode_;
57
};
58
 
59
unsigned addSupportedInstruction(IsaProcessor *instr, AttributeType *out);
60
 
61
}  // namespace debugger
62
 
63
#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.