-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing callbacks in sail-riscv for state-changing events
Pushed all the rv_enable_callbacks into the callback functions.
- Loading branch information
1 parent
5adc0bd
commit 09acccc
Showing
20 changed files
with
142 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
/* The model assumes that these functions do not change the state of the model. | ||
*/ | ||
int mem_update_callback(uint64_t addr, uint64_t width, lbits value, | ||
bool is_exception) | ||
{ | ||
} | ||
int mem_read_callback(uint64_t addr, uint64_t width, lbits value, | ||
bool is_exception) | ||
{ | ||
} | ||
int xreg_update_callback(unsigned reg, uint64_t value) { } | ||
int freg_update_callback(unsigned reg, uint64_t value) { } | ||
int csr_update_callback(const char *reg_name, uint64_t value) { } | ||
int csr_read_callback(const char *reg_name, uint64_t value) { } | ||
int vreg_update_callback(unsigned reg, lbits value) { } | ||
int pc_update_callback(uint64_t value) { } | ||
int mem_write_callback(uint64_t addr, uint64_t width, lbits value) { } | ||
int mem_read_callback(uint64_t addr, uint64_t width, lbits value) { } | ||
int mem_exception_callback(uint64_t addr, uint64_t num_of_exception) { } | ||
int xreg_write_callback(unsigned reg, uint64_t value) { } | ||
int freg_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_read_callback(unsigned reg, uint64_t value) { } | ||
int vreg_write_callback(unsigned reg, lbits value) { } | ||
int pc_write_callback(uint64_t value) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
int zrvfi_write(uint64_t addr, int64_t width, lbits value, bool is_exception); | ||
int zrvfi_read(uint64_t addr, sail_int width, lbits value, bool is_exception); | ||
#include "riscv_config.h" | ||
|
||
int zrvfi_write(uint64_t addr, int64_t width, lbits value); | ||
int zrvfi_read(uint64_t addr, sail_int width, lbits value); | ||
int zrvfi_mem_exception(uint64_t addr); | ||
int zrvfi_wX(int64_t reg, uint64_t value); | ||
|
||
int mem_update_callback(uint64_t addr, uint64_t width, lbits value, | ||
bool is_exception) | ||
int mem_write_callback(uint64_t addr, uint64_t width, lbits value) | ||
{ | ||
if (rv_enable_callbacks) | ||
zrvfi_write(addr, width, value); | ||
} | ||
int mem_read_callback(uint64_t addr, uint64_t width, lbits value) | ||
{ | ||
zrvfi_write(addr, width, value, is_exception); | ||
if (rv_enable_callbacks) { | ||
sail_int len; | ||
CREATE(sail_int)(&len); | ||
CONVERT_OF(sail_int, mach_int)(&len, width); | ||
zrvfi_read(addr, len, value); | ||
KILL(sail_int)(&len); | ||
} | ||
} | ||
int mem_read_callback(uint64_t addr, uint64_t width, lbits value, | ||
bool is_exception) | ||
int mem_exception_callback(uint64_t addr, uint64_t num_of_exception) | ||
{ | ||
sail_int len; | ||
CREATE(sail_int)(&len); | ||
CONVERT_OF(sail_int, mach_int)(&len, width); | ||
zrvfi_read(addr, len, value, is_exception); | ||
KILL(sail_int)(&len); | ||
if (rv_enable_callbacks) | ||
zrvfi_mem_exception(addr); | ||
} | ||
int xreg_update_callback(unsigned reg, uint64_t value) | ||
int xreg_write_callback(unsigned reg, uint64_t value) | ||
{ | ||
zrvfi_wX(reg, value); | ||
if (rv_enable_callbacks) | ||
zrvfi_wX(reg, value); | ||
} | ||
int freg_update_callback(unsigned reg, uint64_t value) { } | ||
int csr_update_callback(const char *reg_name, uint64_t value) { } | ||
int csr_read_callback(const char *reg_name, uint64_t value) { } | ||
int vreg_update_callback(unsigned reg, lbits value) { } | ||
int pc_update_callback(uint64_t value) { } | ||
int freg_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_read_callback(unsigned reg, uint64_t value) { } | ||
int vreg_write_callback(unsigned reg, lbits value) { } | ||
int pc_write_callback(uint64_t value) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.