| 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_RIVER_TOP_H__
|
| 18 |
|
|
#define __DEBUGGER_RIVER_TOP_H__
|
| 19 |
|
|
|
| 20 |
|
|
#include <systemc.h>
|
| 21 |
|
|
#include "river_cfg.h"
|
| 22 |
|
|
#include "core/proc.h"
|
| 23 |
|
|
#include "cache/cache_top.h"
|
| 24 |
|
|
|
| 25 |
|
|
namespace debugger {
|
| 26 |
|
|
|
| 27 |
|
|
SC_MODULE(RiverTop) {
|
| 28 |
|
|
sc_in<bool> i_clk; // CPU clock
|
| 29 |
|
|
sc_in<bool> i_nrst; // Reset: active LOW
|
| 30 |
|
|
// Memory interface:
|
| 31 |
|
|
sc_in<bool> i_req_mem_ready; // System Bus is ready to accept memory operation request
|
| 32 |
|
|
sc_out<bool> o_req_mem_valid; // AXI memory request is valid
|
| 33 |
|
|
sc_out<bool> o_req_mem_write; // AXI memory request is write type
|
| 34 |
|
|
sc_out<sc_uint<BUS_ADDR_WIDTH>> o_req_mem_addr; // AXI memory request address
|
| 35 |
|
|
sc_out<sc_uint<BUS_DATA_BYTES>> o_req_mem_strob; // Writing strob. 1 bit per Byte
|
| 36 |
|
|
sc_out<sc_uint<BUS_DATA_WIDTH>> o_req_mem_data; // Writing data
|
| 37 |
|
|
sc_in<bool> i_resp_mem_data_valid; // AXI response is valid
|
| 38 |
|
|
sc_in<sc_uint<BUS_DATA_WIDTH>> i_resp_mem_data; // Read data
|
| 39 |
|
|
/** Interrupt line from external interrupts controller (PLIC). */
|
| 40 |
|
|
sc_in<bool> i_ext_irq;
|
| 41 |
|
|
sc_out<sc_uint<64>> o_time; // Clock/Step counter depending attribute "GenerateRef"
|
| 42 |
|
|
// Debug interface
|
| 43 |
|
|
sc_in<bool> i_dport_valid; // Debug access from DSU is valid
|
| 44 |
|
|
sc_in<bool> i_dport_write; // Write command flag
|
| 45 |
|
|
sc_in<sc_uint<2>> i_dport_region; // Registers region ID: 0=CSR; 1=IREGS; 2=Control
|
| 46 |
|
|
sc_in<sc_uint<12>> i_dport_addr; // Register idx
|
| 47 |
|
|
sc_in<sc_uint<RISCV_ARCH>> i_dport_wdata; // Write value
|
| 48 |
|
|
sc_out<bool> o_dport_ready; // Response is ready
|
| 49 |
|
|
sc_out<sc_uint<RISCV_ARCH>> o_dport_rdata; // Response value
|
| 50 |
|
|
|
| 51 |
|
|
RiverTop(sc_module_name name_);
|
| 52 |
|
|
virtual ~RiverTop();
|
| 53 |
|
|
|
| 54 |
|
|
void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
|
| 55 |
|
|
void generateRef(bool v) { proc0->generateRef(v); }
|
| 56 |
|
|
private:
|
| 57 |
|
|
|
| 58 |
|
|
Processor *proc0;
|
| 59 |
|
|
CacheTop *cache0;
|
| 60 |
|
|
|
| 61 |
|
|
// Control path:
|
| 62 |
|
|
sc_signal<bool> w_req_ctrl_ready;
|
| 63 |
|
|
sc_signal<bool> w_req_ctrl_valid;
|
| 64 |
|
|
sc_signal<sc_uint<BUS_ADDR_WIDTH>> wb_req_ctrl_addr;
|
| 65 |
|
|
sc_signal<bool> w_resp_ctrl_valid;
|
| 66 |
|
|
sc_signal<sc_uint<BUS_ADDR_WIDTH>> wb_resp_ctrl_addr;
|
| 67 |
|
|
sc_signal<sc_uint<32>> wb_resp_ctrl_data;
|
| 68 |
|
|
sc_signal<bool> w_resp_ctrl_ready;
|
| 69 |
|
|
// Data path:
|
| 70 |
|
|
sc_signal<bool> w_req_data_ready;
|
| 71 |
|
|
sc_signal<bool> w_req_data_valid;
|
| 72 |
|
|
sc_signal<bool> w_req_data_write;
|
| 73 |
|
|
sc_signal<sc_uint<BUS_ADDR_WIDTH>> wb_req_data_addr;
|
| 74 |
|
|
sc_signal<sc_uint<2>> wb_req_data_size; // 0=1bytes; 1=2bytes; 2=4bytes; 3=8bytes
|
| 75 |
|
|
sc_signal<sc_uint<RISCV_ARCH>> wb_req_data_data;
|
| 76 |
|
|
sc_signal<bool> w_resp_data_valid;
|
| 77 |
|
|
sc_signal<sc_uint<BUS_ADDR_WIDTH>> wb_resp_data_addr;
|
| 78 |
|
|
sc_signal<sc_uint<RISCV_ARCH>> wb_resp_data_data;
|
| 79 |
|
|
sc_signal<bool> w_resp_data_ready;
|
| 80 |
|
|
sc_signal<sc_uint<2>> wb_istate;
|
| 81 |
|
|
sc_signal<sc_uint<2>> wb_dstate;
|
| 82 |
|
|
sc_signal<sc_uint<2>> wb_cstate;
|
| 83 |
|
|
};
|
| 84 |
|
|
|
| 85 |
|
|
|
| 86 |
|
|
} // namespace debugger
|
| 87 |
|
|
|
| 88 |
|
|
#endif // __DEBUGGER_RIVER_TOP_H__
|