From c7538386fc4fe8c46dd513b2b8d4931e993dacd9 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 23 Aug 2007 18:24:51 -0700 Subject: [PATCH] Start of simulation event needed to be run after initialization events. This patch splits the end of compile and the start of simulation call backs code into two different procedures. The end of compile events are still executed at the same time they alway were. The start of simulation events are now run after initialization. --- vvp/schedule.cc | 10 +++++++--- vvp/vpi_callback.cc | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) 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;