summaryrefslogtreecommitdiffstats
path: root/func.c
diff options
context:
space:
mode:
authorJiri Gaisler <jiri@gaisler.se>2020-10-25 11:21:21 -0400
committerJiri Gaisler <jiri@gaisler.se>2020-10-25 11:21:21 -0400
commit511bfc5dd1b679e5a99850290ba29313995b0fb1 (patch)
tree5899416dc45a052e60e3e3cb282e5745fc95f0e2 /func.c
parentUpdate to version 2.22 (diff)
downloadsis-511bfc5dd1b679e5a99850290ba29313995b0fb1.tar.bz2
Add -rt option to synch sim to wall time
* Active during cpu power-down to avoid run-away sim time. Useful for interactive applications.
Diffstat (limited to 'func.c')
-rw-r--r--func.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/func.c b/func.c
index 23bc31a..07f585c 100644
--- a/func.c
+++ b/func.c
@@ -63,6 +63,7 @@ uint32 last_load_addr = 0;
int nouartrx = 0;
int port = 1234;
int sim_run = 0;
+int sync_rt = 0;
/* RAM and ROM for all systems */
char romb[ROM_SIZE];
@@ -1054,6 +1055,23 @@ pwd_enter (struct pstate *sregs)
sregs->hold += delta;
}
+void
+rt_sync()
+{
+ double walltime, realtime, dtime;
+ int64 stime;
+ stime = ebase.simtime - ebase.simstart; /* Total simulated time */
+ realtime = (double) ((stime) / 1000000.0 / ebase.freq);
+ walltime = ebase.tottime + get_time () - ebase.starttime;
+ dtime = (realtime - walltime);
+ if (dtime > 0.001)
+ {
+ if (dtime > 1.0)
+ dtime = 0.1;
+ usleep ((useconds_t) (dtime * 1E6));
+ }
+}
+
int
check_bpt (sregs)
struct pstate *sregs;