Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add two api to support cpy pmp regs and pmp cfg regs #70

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions difftest/difftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,28 @@ const std::vector<std::pair<reg_t, abstract_device_t*>> DifftestRef::create_devi
};
}

void DifftestRef::pmp_cfg_cpy(reg_t *dut, bool direction) {
auto xlen = p->get_isa().get_max_xlen();
for (int i = 0; i < state->max_pmp; i += xlen / 8) {
reg_t addr = CSR_PMPCFG0 + i / 4;
if (direction == DIFFTEST_TO_REF) {
state->csrmap[addr]->write(dut[addr]);
} else {
dut[addr] = state->csrmap[addr]->read();
}
}
}

void DifftestRef::pmpcpy(reg_t* dut, bool direction) {
for (int i = 0; i < CONFIG_PMP_NUM; i++) {
if (direction == DIFFTEST_TO_REF) {
state->pmpaddr[i]->write(dut[i]);
}else{
dut[i] = state->pmpaddr[i]->read();
}
}
}

sim_t *DifftestRef::create_sim(const cfg_t *cfg) {
sim_t *s = new sim_t(
// const cfg_t *cfg,
Expand Down Expand Up @@ -544,7 +566,15 @@ void difftest_regcpy(diff_context_t* dut, bool direction, bool on_demand) {
}

void difftest_csrcpy(void *dut, bool direction) {
}


void difftest_pmpcpy(void *dut, bool direction) {
ref->pmpcpy((reg_t*)dut, direction);
}

void difftest_pmp_cfg_cpy(void *dut, bool direction) {
ref->pmp_cfg_cpy((reg_t*)dut, direction);
}

void difftest_uarchstatus_sync(void *dut) {
Expand Down
2 changes: 2 additions & 0 deletions difftest/difftest.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class DifftestRef {
~DifftestRef();
void step(uint64_t n);
void skip_one(bool isRVC, bool wen, uint32_t wdest, uint64_t wdata);
void pmpcpy(reg_t *dut, bool direction);
void pmp_cfg_cpy(reg_t *dut, bool direction);
void get_regs(diff_context_t *ctx);
void set_regs(diff_context_t *ctx, bool on_demand);
void memcpy_from_dut(reg_t dest, void* src, size_t n);
Expand Down
Loading