diff --git a/vvp/schedule.cc b/vvp/schedule.cc index 933d6f668..a844727ed 100644 --- a/vvp/schedule.cc +++ b/vvp/schedule.cc @@ -565,7 +565,8 @@ static vvp_time64_t schedule_time; vvp_time64_t schedule_simtime(void) { return schedule_time; } -extern void vpiPresim(); +extern void vpiEndOfCompile(); +extern void vpiStartOfSim(); extern void vpiPostsim(); extern void vpiNextSimTime(void); @@ -600,8 +601,8 @@ void schedule_simulate(void) { schedule_time = 0; - // Execute pre-simulation callbacks - vpiPresim(); + // Execute end of compile callbacks + vpiEndOfCompile(); // Execute initialization events. while (schedule_init_list) { @@ -612,6 +613,9 @@ void schedule_simulate(void) delete cur; } + // Execute start of simulation callbacks + vpiStartOfSim(); + signals_capture(); while (sched_list) { diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index 1af0b0f9f..7f7dccbd7 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -286,7 +286,7 @@ static struct __vpiCallback*EndOfCompile = NULL; static struct __vpiCallback*StartOfSimulation = NULL; static struct __vpiCallback*EndOfSimulation = NULL; -void vpiPresim(void) { +void vpiEndOfCompile(void) { struct __vpiCallback* cur; /* @@ -303,6 +303,19 @@ void vpiPresim(void) { delete_vpi_callback(cur); } + vpi_mode_flag = VPI_MODE_NONE; +} + +void vpiStartOfSim(void) { + struct __vpiCallback* cur; + + /* + * Walk the list of register callbacks, executing them and + * freeing them when done. + */ + assert(vpi_mode_flag == VPI_MODE_NONE); + vpi_mode_flag = VPI_MODE_RWSYNC; + while (StartOfSimulation) { cur = StartOfSimulation; StartOfSimulation = cur->next;