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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [cpu_sysc_plugin/] [riverlib/] [core/] [decoder.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      CPU Instruction Decoder stage.
6
 */
7
 
8
#ifndef __DEBUGGER_RIVERLIB_DECODER_H__
9
#define __DEBUGGER_RIVERLIB_DECODER_H__
10
 
11
#include <systemc.h>
12
#include "../river_cfg.h"
13
 
14
namespace debugger {
15
 
16
const uint8_t OPCODE_LB     = 0x00; // 00000: LB, LH, LW, LD, LBU, LHU, LWU
17
const uint8_t OPCODE_FENCE  = 0x03; // 00011: FENCE, FENCE_I
18
const uint8_t OPCODE_ADDI   = 0x04; // 00100: ADDI, ANDI, ORI, SLLI, SLTI, SLTIU, SRAI, SRLI, XORI
19
const uint8_t OPCODE_AUIPC  = 0x05; // 00101: AUIPC
20
const uint8_t OPCODE_ADDIW  = 0x06; // 00110: ADDIW, SLLIW, SRAIW, SRLIW
21
const uint8_t OPCODE_SB     = 0x08; // 01000: SB, SH, SW, SD
22
const uint8_t OPCODE_ADD    = 0x0C; // 01100: ADD, AND, OR, SLT, SLTU, SLL, SRA, SRL, SUB, XOR, DIV, DIVU, MUL, REM, REMU
23
const uint8_t OPCODE_LUI    = 0x0D; // 01101: LUI
24
const uint8_t OPCODE_ADDW   = 0x0E; // 01110: ADDW, SLLW, SRAW, SRLW, SUBW, DIVW, DIVUW, MULW, REMW, REMUW
25
const uint8_t OPCODE_BEQ    = 0x18; // 11000: BEQ, BNE, BLT, BGE, BLTU, BGEU
26
const uint8_t OPCODE_JALR   = 0x19; // 11001: JALR
27
const uint8_t OPCODE_JAL    = 0x1B; // 11011: JAL
28
const uint8_t OPCODE_CSRR   = 0x1C; // 11100: CSRRC, CSRRCI, CSRRS, CSRRSI, CSRRW, CSRRWI, URET, SRET, HRET, MRET
29
 
30
SC_MODULE(InstrDecoder) {
31
    sc_in<bool> i_clk;
32
    sc_in<bool> i_nrst;                         // Reset active low
33
    sc_in<bool> i_any_hold;                     // Hold pipeline by any reason
34
    sc_in<bool> i_f_valid;                      // Fetch input valid
35
    sc_in<sc_uint<BUS_ADDR_WIDTH>> i_f_pc;      // Fetched pc
36
    sc_in<sc_uint<32>> i_f_instr;               // Fetched instruction value
37
 
38
    sc_out<bool> o_valid;                       // Current output values are valid
39
    sc_out<sc_uint<BUS_ADDR_WIDTH>> o_pc;       // Current instruction pointer value
40
    sc_out<sc_uint<32>> o_instr;                // Current instruction value
41
    sc_out<bool> o_memop_store;                 // Store to memory operation
42
    sc_out<bool> o_memop_load;                  // Load from memoru operation
43
    sc_out<bool> o_memop_sign_ext;              // Load memory value with sign extending
44
    sc_out<sc_uint<2>> o_memop_size;            // Memory transaction size
45
    sc_out<bool> o_rv32;                        // 32-bits instruction
46
    sc_out<bool> o_unsigned_op;                 // Unsigned operands
47
    sc_out<sc_bv<ISA_Total>> o_isa_type;        // Instruction format accordingly with ISA
48
    sc_out<sc_bv<Instr_Total>> o_instr_vec;     // One bit per decoded instruction bus
49
    sc_out<bool> o_exception;
50
 
51
    void comb();
52
    void registers();
53
 
54
    SC_HAS_PROCESS(InstrDecoder);
55
 
56
    InstrDecoder(sc_module_name name_);
57
 
58
    void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
59
 
60
private:
61
    struct RegistersType {
62
        sc_signal<bool> valid;
63
        sc_signal<sc_uint<BUS_ADDR_WIDTH>> pc;
64
        sc_bv<ISA_Total> isa_type;
65
        sc_bv<Instr_Total> instr_vec;
66
        sc_signal<sc_uint<32>> instr;
67
        sc_signal<bool> memop_store;
68
        sc_signal<bool> memop_load;
69
        sc_signal<bool> memop_sign_ext;
70
        sc_signal<sc_uint<2>> memop_size;
71
        sc_signal<bool> unsigned_op;
72
        sc_signal<bool> rv32;
73
 
74
        sc_signal<bool> instr_unimplemented;
75
    } v, r;
76
};
77
 
78
 
79
}  // namespace debugger
80
 
81
#endif  // __DEBUGGER_RIVERLIB_DECODER_H__

powered by: WebSVN 2.1.0

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