vvp: Optimise the code for walking the NextSimTime callback list.

This commit is contained in:
Martin Whitaker 2024-02-05 17:53:01 +00:00
parent c0e9b73d1c
commit cae337231c
1 changed files with 5 additions and 14 deletions

View File

@ -589,30 +589,21 @@ void vpiPostsim(void) {
void vpiNextSimTime(void) void vpiNextSimTime(void)
{ {
simulator_callback* cur; simulator_callback* cur;
simulator_callback* last_cb = NextSimTime; simulator_callback* next = NextSimTime;
NextSimTime = 0;
assert(vpi_mode_flag == VPI_MODE_NONE); assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_RWSYNC; vpi_mode_flag = VPI_MODE_RWSYNC;
/* Find the last event currently in the list. Remember this callback so while (next) {
* we don't call additional NextSimTime CB's generated during this timestep. cur = next;
*/ next = dynamic_cast<simulator_callback*>(cur->next);
while (last_cb && last_cb->next) {
last_cb = dynamic_cast<simulator_callback*>(last_cb->next);
}
while (NextSimTime) {
cur = NextSimTime;
NextSimTime = dynamic_cast<simulator_callback*>(cur->next);
if (cur->cb_data.cb_rtn != 0) { if (cur->cb_data.cb_rtn != 0) {
// only vpiSimTime implemented right now // only vpiSimTime implemented right now
vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime()); vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime());
(cur->cb_data.cb_rtn)(&cur->cb_data); (cur->cb_data.cb_rtn)(&cur->cb_data);
} }
delete cur; delete cur;
if (cur == last_cb) {
break;
}
} }
vpi_mode_flag = VPI_MODE_NONE; vpi_mode_flag = VPI_MODE_NONE;