Line 1... |
Line 1... |
/**
|
/*
|
* @file
|
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
|
* @copyright Copyright 2016 GNSS Sensor Ltd. All right reserved.
|
*
|
* @author Sergey Khabarov - sergeykhbr@gmail.com
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
* @brief SystemC CPU wrapper. To interact with the SoC simulator. */
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
#ifndef __DEBUGGER_RTL_WRAPPER_H__
|
#ifndef __DEBUGGER_RTL_WRAPPER_H__
|
#define __DEBUGGER_RTL_WRAPPER_H__
|
#define __DEBUGGER_RTL_WRAPPER_H__
|
|
|
#include "async_tqueue.h"
|
#include "async_tqueue.h"
|
#include "coreservices/ibus.h"
|
#include "coreservices/imemop.h"
|
|
#include "coreservices/ireset.h"
|
|
#include "coreservices/icpugen.h"
|
#include "coreservices/icpuriscv.h"
|
#include "coreservices/icpuriscv.h"
|
#include "coreservices/iclklistener.h"
|
#include "coreservices/iclklistener.h"
|
#include "riverlib/river_cfg.h"
|
#include "riverlib/river_cfg.h"
|
#include <systemc.h>
|
#include <systemc.h>
|
#include "api_utils.h"
|
#include "api_utils.h"
|
|
|
namespace debugger {
|
namespace debugger {
|
|
|
class RtlWrapper : public sc_module,
|
class RtlWrapper : public sc_module,
|
|
public IResetListener,
|
|
public ICpuGeneric,
|
public ICpuRiscV {
|
public ICpuRiscV {
|
public:
|
public:
|
sc_clock o_clk;
|
sc_clock o_clk;
|
sc_out<bool> o_nrst;
|
sc_out<bool> o_nrst;
|
// Timer:
|
// Timer:
|
Line 72... |
Line 86... |
virtual ~RtlWrapper();
|
virtual ~RtlWrapper();
|
|
|
public:
|
public:
|
void generateRef(bool v) { generate_ref_ = v; }
|
void generateRef(bool v) { generate_ref_ = v; }
|
void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
|
void generateVCD(sc_trace_file *i_vcd, sc_trace_file *o_vcd);
|
void setBus(IBus *v) { ibus_ = v; }
|
void setBus(IMemoryOperation *v) { ibus_ = v; }
|
/** Default time resolution 1 picosecond. */
|
/** Default time resolution 1 picosecond. */
|
void setClockHz(double hz);
|
void setClockHz(double hz);
|
|
|
/** ICpuRiscV interface */
|
/** ICpuGeneric interface */
|
virtual void registerStepCallback(IClockListener *cb, uint64_t t);
|
|
virtual void raiseSignal(int idx);
|
virtual void raiseSignal(int idx);
|
virtual void lowerSignal(int idx);
|
virtual void lowerSignal(int idx);
|
virtual void nb_transport_debug_port(DebugPortTransactionType *trans,
|
virtual void nb_transport_debug_port(DebugPortTransactionType *trans,
|
IDbgNbResponse *cb);
|
IDbgNbResponse *cb);
|
|
|
|
/** IClock */
|
|
virtual void registerStepCallback(IClockListener *cb, uint64_t t);
|
|
|
|
/** IResetListener */
|
|
virtual void reset(bool active) {
|
|
o_nrst.write(!active);
|
|
}
|
|
|
|
|
private:
|
private:
|
IFace *getInterface(const char *name) { return iparent_; }
|
IFace *getInterface(const char *name) { return iparent_; }
|
uint64_t mask2offset(uint8_t mask);
|
uint64_t mask2offset(uint8_t mask);
|
uint32_t mask2size(uint8_t mask); // nask with removed offset
|
uint32_t mask2size(uint8_t mask); // nask with removed offset
|
|
|
private:
|
private:
|
IBus *ibus_;
|
IMemoryOperation *ibus_;
|
IFace *iparent_; // pointer on parent module object (used for logging)
|
IFace *iparent_; // pointer on parent module object (used for logging)
|
int clockCycles_; // default in [ps]
|
int clockCycles_; // default in [ps]
|
AsyncTQueueType step_queue_;
|
ClockAsyncTQueueType step_queue_;
|
uint64_t step_cnt_z;
|
|
bool generate_ref_;
|
bool generate_ref_;
|
|
|
sc_uint<32> t_trans_idx_up;
|
sc_uint<32> t_trans_idx_up;
|
sc_uint<32> t_trans_idx_down;
|
sc_uint<32> t_trans_idx_down;
|
|
|