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/] [csr.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/*
2
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15 3 sergeykhbr
 */
16
 
17
#ifndef __DEBUGGER_RIVERLIB_CSR_H__
18
#define __DEBUGGER_RIVERLIB_CSR_H__
19
 
20
#include <systemc.h>
21
#include "../river_cfg.h"
22
 
23
namespace debugger {
24
 
25
SC_MODULE(CsrRegs) {
26
    sc_in<bool> i_clk;                      // Clock signal
27
    sc_in<bool> i_nrst;                     // Reset (active low)
28
    sc_in<bool> i_xret;                     // XRet instruction signals mode switching
29
    sc_in<sc_uint<12>> i_addr;              // CSR address, if xret=1 switch mode accordingly
30
    sc_in<bool> i_wena;                     // Write enable
31
    sc_in<sc_uint<RISCV_ARCH>> i_wdata;     // CSR writing value
32
    sc_out<sc_uint<RISCV_ARCH>> o_rdata;    // CSR read value
33
    sc_in<bool> i_break_mode;               // Behaviour on EBREAK instruction: 0 = halt; 1 = generate trap
34
    sc_in<bool> i_breakpoint;               // Breakpoint (Trap or not depends of mode)
35
    sc_in<bool> i_trap_ena;                 // Trap pulse
36
    sc_in<sc_uint<5>> i_trap_code;          // bit[4] : 1=interrupt; 0=exception; bits[3:0]=code
37
    sc_in<sc_uint<BUS_ADDR_WIDTH>> i_trap_pc;// trap on pc
38
 
39
    sc_out<bool> o_ie;                      // Interrupt enable bit
40
    sc_out<sc_uint<2>> o_mode;              // CPU mode
41
    sc_out<sc_uint<BUS_ADDR_WIDTH>> o_mtvec;// Interrupt descriptors table
42
 
43
    sc_in<bool> i_dport_ena;                  // Debug port request is enabled
44
    sc_in<bool> i_dport_write;                // Debug port Write enable
45
    sc_in<sc_uint<12>> i_dport_addr;          // Debug port CSR address
46
    sc_in<sc_uint<RISCV_ARCH>> i_dport_wdata; // Debug port CSR writing value
47
    sc_out<sc_uint<RISCV_ARCH>> o_dport_rdata;// Debug port CSR read value
48
 
49
    void comb();
50
    void registers();
51
 
52
    SC_HAS_PROCESS(CsrRegs);
53
 
54
    CsrRegs(sc_module_name name_);
55
 
56
    void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
57
 
58
private:
59
    struct RegistersType {
60
        sc_signal<sc_uint<RISCV_ARCH>> mtvec;
61
        sc_signal<sc_uint<RISCV_ARCH>> mscratch;
62
        sc_signal<sc_uint<BUS_ADDR_WIDTH>> mbadaddr;
63
        sc_signal<sc_uint<2>> mode;
64
        sc_signal<bool> uie;                    // User level interrupts ena for current priv. mode
65
        sc_signal<bool> mie;                    // Machine level interrupts ena for current priv. mode
66
        sc_signal<bool> mpie;                   // Previous MIE value
67
        sc_signal<sc_uint<2>> mpp;              // Previous mode
68
        sc_signal<sc_uint<RISCV_ARCH>> mepc;
69
 
70
        sc_signal<bool> trap_irq;
71
        sc_signal<sc_uint<4>> trap_code;
72
    } v, r;
73
 
74
    void procedure_RegAccess(uint64_t iaddr, bool iwena,
75
                             sc_uint<RISCV_ARCH> iwdata,
76
                             RegistersType &ir, RegistersType *ov,
77
                             sc_uint<RISCV_ARCH> *ordata);
78
};
79
 
80
 
81
}  // namespace debugger
82
 
83
#endif  // __DEBUGGER_RIVERLIB_CSR_H__

powered by: WebSVN 2.1.0

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