URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/tags/tn_m001/or1ksim/support
- from Rev 861 to Rev 1765
- ↔ Reverse comparison
Rev 861 → Rev 1765
/simprintf.c
0,0 → 1,146
/* libc.c -- dummy C library simulation |
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org |
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
/* Debugger LIBC functions. Working, but VERY, VERY ugly written. |
I wrote following code when basic simulator started to work and I was |
desperate to use some printfs in my debugged code. And it was |
also used to get some output from Dhrystone MIPS benchmark. */ |
|
#include <stdio.h> |
#include <string.h> |
#include <errno.h> |
#include <stdarg.h> |
|
#include <abstract.h> |
#include <arch.h> |
#include "sim-config.h" |
|
/* Length of printf format string */ |
#define FMTLEN 2000 |
|
char fmtstr[FMTLEN]; |
|
char *simgetstr(unsigned long stackaddr, unsigned long regparam) |
{ |
unsigned long fmtaddr; |
FILE *f; |
int i; |
int breakpoint = 0; |
|
fmtaddr = regparam; |
|
i = 0; |
while (eval_mem8(fmtaddr,&breakpoint) != '\0') { |
fmtstr[i++] = eval_mem8(fmtaddr,&breakpoint); |
fmtaddr++; |
if (i == FMTLEN - 1) |
break; |
} |
fmtstr[i] = '\0'; |
|
return fmtstr; |
} |
|
void simprintf(unsigned long stackaddr, unsigned long regparam) |
{ |
unsigned long fmtaddr; |
FILE *f; |
int i = 0; |
int breakpoint = 0; |
|
simgetstr(stackaddr, regparam); |
|
debug(6, "simprintf: stackaddr: 0x%.8lx\n", stackaddr); |
if ((f = fopen(config.sim.fstdout, "a+"))) { |
unsigned long arg; |
unsigned long argaddr; |
unsigned char regstr[5]; |
char *fmtstrend; |
char *fmtstrpart = fmtstr; |
int tee_exe_log; |
extern long instructions; |
|
#if STACK_ARGS |
argaddr = stackaddr; |
#else |
argaddr = 3; |
#endif |
tee_exe_log = (config.sim.exe_log && (config.sim.exe_log_type == EXE_LOG_SOFTWARE || config.sim.exe_log_type == EXE_LOG_SIMPLE) |
&& config.sim.exe_log_start <= instructions && (config.sim.exe_log_end <= 0 || instructions <= config.sim.exe_log_end)); |
|
if (tee_exe_log) |
fprintf (runtime.sim.fexe_log, "SIMPRINTF: "); |
debug(6, "simprintf: %s\n", fmtstrpart); |
while(strlen(fmtstrpart)) { |
debug(6, "simprintf(): 1"); |
if ((fmtstrend = strstr(fmtstrpart + 1, "%"))) |
*fmtstrend = '\0'; |
debug(6," 2"); |
if (strstr(fmtstrpart, "%")) { |
debug(6, " 3"); |
#if STACK_ARGS |
arg = eval_mem32(argaddr,&breakpoint); |
argaddr += 4; |
#else |
sprintf(regstr, "r%u", ++argaddr); |
arg = eval_reg(regstr); |
#endif |
debug(6, " 4: fmtstrpart=%p fmtstrpart=%s arg=%p\n", fmtstrpart, fmtstrpart, arg); |
if (strncmp(fmtstrpart, "%s", 2) == 0) { |
int len = 0; |
char *str; |
for(; eval_mem8(arg++,&breakpoint); len++); |
len++; /* for null char */ |
arg -= len; |
str = (char *)malloc(len); |
len = 0; |
for(; eval_mem8(arg,&breakpoint); len++) |
*(str+len) = eval_mem8(arg++,&breakpoint); |
*(str+len) = eval_mem8(arg,&breakpoint); /* null ch */ |
debug(6, "4a: len=%d str=%s\n", len, str); |
debug(6, "4b:"); |
fprintf(f, fmtstrpart, str); |
if (tee_exe_log) fprintf(runtime.sim.fexe_log, fmtstrpart, str); |
free(str); |
} else { |
fprintf(f, fmtstrpart, arg); |
if (tee_exe_log) fprintf(runtime.sim.fexe_log, fmtstrpart, arg); |
} |
} else { |
debug(6, " 5"); |
fprintf(f, fmtstrpart); |
if (tee_exe_log) fprintf(runtime.sim.fexe_log, fmtstrpart); |
debug(6, fmtstrpart); |
} |
if (!fmtstrend) |
break; |
debug(6, " 6"); |
fmtstrpart = fmtstrend; |
*fmtstrpart = '%'; |
debug(6, " 7"); |
} |
|
debug(6," 8\n"); |
if (fclose(f)) |
perror(strerror(errno)); |
} |
else |
perror(strerror(errno)); |
|
} |
/sched.h
0,0 → 1,131
/* sched.h -- Abstract entities header file handling job scheduler |
Copyright (C) 2001 Marko Mlinar, markom@opencores.org |
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
#ifndef _SCHED_H_ |
#define _SCHED_H_ |
|
/* Scheduler debug level */ |
#define SCHED_DEBUG 0 |
|
#define SCHED_HEAP_SIZE 128 |
|
/* Structure for holding one job entry */ |
struct sched_entry { |
long time; /* Clock cycles before job starts */ |
int param; /* Parameter to pass to the function */ |
void (*func)(int); /* Function to call when time reaches 0 */ |
}; |
|
/* Heap of jobs */ |
struct scheduler_struct { |
int size; |
struct sched_entry heap[SCHED_HEAP_SIZE]; |
}; |
|
extern struct scheduler_struct scheduler; |
|
/* Dummy function, representing a guard, which protects heap from |
emptying */ |
extern void sched_guard (int i); |
|
/* Init scheduler -- clear the heap */ |
#define SCHED_INIT() {\ |
scheduler.heap[1].func = sched_guard;\ |
scheduler.heap[1].time = INT_MAX;\ |
scheduler.size = 2;\ |
} |
|
#if SCHED_DEBUG > 1 |
#define SCHED_PRINT_JOBS() {\ |
int i;\ |
for (i = 1; i < scheduler.size; i++) \ |
printf ("\t%i: %x $%i @ %i\n", i, scheduler.heap[i].func, scheduler.heap[i].param, scheduler.heap[i].time);\ |
} |
#else |
#define SCHED_PRINT_JOBS() |
#endif |
|
/* Adds new job to the queue */ |
#define SCHED_ADD(job_func, job_param, job_time) {\ |
int ___i;\ |
if (SCHED_DEBUG > 0) printf ("%s@%i:SCHED_ADD(func %x, param %i, time %i)\n", __FUNCTION__, cycles, (job_func), (job_param), (job_time));\ |
SCHED_PRINT_JOBS();\ |
if (SCHED_DEBUG > 1) printf ("--------\n");\ |
___i = scheduler.size++;\ |
while (___i > 1 && scheduler.heap[___i / 2].time > (job_time)) scheduler.heap[___i] = scheduler.heap[___i /= 2];\ |
scheduler.heap[___i].func = (job_func);\ |
scheduler.heap[___i].param = (job_param);\ |
scheduler.heap[___i].time = (job_time);\ |
SCHED_PRINT_JOBS();\ |
} |
|
/* Removes an item from the heap */ |
#define SCHED_REMOVE_ITEM(index) {\ |
struct sched_entry *tmp;\ |
int ___i = (index), ___j;\ |
if (SCHED_DEBUG > 0) printf ("%s@%i:SCHED_REMOVE%i(time %i)\n", __FUNCTION__, cycles, (index), scheduler.heap[___i].time); \ |
SCHED_PRINT_JOBS();\ |
if (SCHED_DEBUG > 1) printf ("--------\n");\ |
tmp = &scheduler.heap[--scheduler.size];\ |
while (___i <= scheduler.size / 2) {\ |
___j = 2 * ___i;\ |
if (___j < scheduler.size && scheduler.heap[___j].time > scheduler.heap[___j + 1].time) ___j++;\ |
if (scheduler.heap[___j].time >= tmp->time) break;\ |
scheduler.heap[___i] = scheduler.heap[___j];\ |
___i = ___j;\ |
}\ |
scheduler.heap[___i] = *tmp;\ |
SCHED_PRINT_JOBS();\ |
} |
|
/* Removes first item from the heap */ |
#define SCHED_REMOVE() SCHED_REMOVE_ITEM(1) |
|
/* Returns item with lowest time in the heap */ |
#define SCHED_PEEK() scheduler.heap[1] |
|
/* Returns a job with specified function and param, NULL if not found */ |
#define SCHED_FIND(f, p) ({\ |
int i;\ |
struct sched_entry *t = NULL;\ |
for (i = 1; i < scheduler.size; i++)\ |
if (scheduler.heap[i].func == (f) && scheduler.heap[i].param == (p)) {\ |
t = &scheduler.heap[i]; break;\ |
}\ |
tmp;\ |
}) |
|
/* Returns a index of the job with specified function and param, 0 if not found */ |
#define SCHED_FIND_INDEX(f, p) ({\ |
int i, found = 0;\ |
for (i = 1; i < scheduler.size; i++)\ |
if (scheduler.heap[i].func == (f) && scheduler.heap[i].param == (p)) {\ |
found = i; break;\ |
}\ |
found;\ |
}) |
|
/* Deletes job with specified function and param */ |
#define SCHED_FIND_REMOVE(f, p) {\ |
int index;\ |
index = SCHED_FIND_INDEX(f, p);\ |
if (index) SCHED_REMOVE_ITEM(index);\ |
} |
|
#endif /* _SCHED_H_ */ |
sched.h
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: Makefile.in
===================================================================
--- Makefile.in (nonexistent)
+++ Makefile.in (revision 1765)
@@ -0,0 +1,333 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# Makefile -- Makefile for cpu architecture independent simulation
+# Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
+#
+# This file is part of OpenRISC 1000 Architectural Simulator.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+BUILD_DIR = @BUILD_DIR@
+CC = @CC@
+CFLAGS = @CFLAGS@
+CPU_ARCH = @CPU_ARCH@
+INCLUDES = @INCLUDES@
+LOCAL_CFLAGS = @LOCAL_CFLAGS@
+LOCAL_DEFS = @LOCAL_DEFS@
+LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
+MAKEINFO = @MAKEINFO@
+MAKE_SHELL = @MAKE_SHELL@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+SUMVERSION = @SUMVERSION@
+TERMCAP_LIB = @TERMCAP_LIB@
+VERSION = @VERSION@
+host = @host@
+host_cpu = @host_cpu@
+host_os = @host_os@
+
+noinst_LIBRARIES = libsupport.a
+libsupport_a_SOURCES = simprintf.c dumpverilog.c profile.c sched.c
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libsupport_a_LIBADD =
+libsupport_a_OBJECTS = simprintf.o dumpverilog.o profile.o sched.o
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+DEP_FILES = .deps/dumpverilog.P .deps/profile.P .deps/sched.P \
+.deps/simprintf.P
+SOURCES = $(libsupport_a_SOURCES)
+OBJECTS = $(libsupport_a_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu support/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLIBRARIES:
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+distclean-noinstLIBRARIES:
+
+maintainer-clean-noinstLIBRARIES:
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+libsupport.a: $(libsupport_a_OBJECTS) $(libsupport_a_DEPENDENCIES)
+ -rm -f libsupport.a
+ $(AR) cru libsupport.a $(libsupport_a_OBJECTS) $(libsupport_a_LIBADD)
+ $(RANLIB) libsupport.a
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = support
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu support/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LIBRARIES)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
+ mostlyclean-tags mostlyclean-depend mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
+ clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-noinstLIBRARIES distclean-compile \
+ distclean-tags distclean-depend distclean-generic \
+ clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
+ maintainer-clean-compile maintainer-clean-tags \
+ maintainer-clean-depend maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
+clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir mostlyclean-depend \
+distclean-depend clean-depend maintainer-clean-depend info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: sched.c
===================================================================
--- sched.c (nonexistent)
+++ sched.c (revision 1765)
@@ -0,0 +1,41 @@
+/* sched.c -- Abstract entities, handling job scheduling
+ Copyright (C) 2001 Marko Mlinar, markom@opencores.org
+
+This file is part of OpenRISC 1000 Architectural Simulator.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* Abstract memory and routines that go with this. I need to
+add all sorts of other abstract entities. Currently we have
+only memory. */
+
+#include
+#include
+#include
+#include
+#include
+
+#include "config.h"
+#include "sim-config.h"
+#include "sched.h"
+
+struct scheduler_struct scheduler;
+
+/* Dummy function, representing a guard, which protects heap from
+ emptying */
+void sched_guard (int i)
+{
+ SCHED_INIT ();
+}
sched.c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: Makefile.am
===================================================================
--- Makefile.am (nonexistent)
+++ Makefile.am (revision 1765)
@@ -0,0 +1,22 @@
+# Makefile -- Makefile for cpu architecture independent simulation
+# Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
+#
+# This file is part of OpenRISC 1000 Architectural Simulator.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+noinst_LIBRARIES = libsupport.a
+libsupport_a_SOURCES = simprintf.c dumpverilog.c profile.c sched.c
Index: profile.c
===================================================================
--- profile.c (nonexistent)
+++ profile.c (revision 1765)
@@ -0,0 +1,32 @@
+/* profile.c -- functions for profiling
+ Copyright (C) 2002 Marko Mlinar, markom@opencores.org
+
+This file is part of OpenRISC 1000 Architectural Simulator.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include
+#include "profile.h"
+#include "sim-config.h"
+
+/* Adds a new entry to the memory profile file */
+void mprofile (unsigned long memaddr, unsigned char type)
+{
+ struct mprofentry_struct mp;
+ mp.addr = memaddr;
+ mp.type = type;
+ if(!fwrite (&mp, sizeof (struct mprofentry_struct), 1, runtime.sim.fmprof))
+ config.sim.mprofile = 0;
+}
profile.c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: profile.h
===================================================================
--- profile.h (nonexistent)
+++ profile.h (revision 1765)
@@ -0,0 +1,33 @@
+/* profile.c -- definitions for profiling
+ Copyright (C) 2002 Marko Mlinar, markom@opencores.org
+
+This file is part of OpenRISC 1000 Architectural Simulator.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define MPROF_READ 1
+#define MPROF_WRITE 2
+#define MPROF_FETCH 4
+#define MPROF_8 8
+#define MPROF_16 16
+#define MPROF_32 32
+
+/* Adds a new entry to the memory profile file */
+void mprofile (unsigned long memaddr, unsigned char type);
+
+struct mprofentry_struct {
+ unsigned long addr;
+ unsigned char type;
+};
profile.h
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: dumpverilog.h
===================================================================
--- dumpverilog.h (nonexistent)
+++ dumpverilog.h (revision 1765)
@@ -0,0 +1,45 @@
+#define DW 32 /* Data width of memory model generated by dumpverilog in bits */
+#define DWQ (DW/8) /* Same as DW but units are bytes */
+#define DISWIDTH 25 /* Width of disassembled message in bytes */
+
+#define OR1K_MEM_VERILOG_HEADER(MODNAME, FROMADDR, TOADDR, DISWIDTH) "\n"\
+"include \"general.h\"\n\n"\
+"`timescale 1ns/100ps\n\n"\
+"// Simple dw-wide Sync SRAM with initial content generated by or1ksim.\n"\
+"// All control, data in and addr signals are sampled at rising clock edge \n"\
+"// Data out is not registered. Address bits specify dw-word (narrowest \n"\
+"// addressed data is not byte but dw-word !). \n"\
+"// There are still some bugs in generated output (dump word aligned regions)\n\n"\
+"module %s(clk, data, addr, ce, we, disout);\n\n"\
+"parameter dw = 32;\n"\
+"parameter amin = %d;\n\n"\
+"parameter amax = %d;\n\n"\
+"input clk;\n"\
+"inout [dw-1:0] data;\n"\
+"input [31:0] addr;\n"\
+"input ce;\n"\
+"input we;\n"\
+"output [%d:0] disout;\n\n"\
+"reg [%d:0] disout;\n"\
+"reg [dw-1:0] mem [amax:amin];\n"\
+"reg [%d:0] dis [amax:amin];\n"\
+"reg [dw-1:0] dataout;\n"\
+"tri [dw-1:0] data = (ce && ~we) ? dataout : 'bz;\n\n"\
+"initial begin\n", MODNAME, FROMADDR, TOADDR, DISWIDTH-1, DISWIDTH-1, DISWIDTH-1
+
+#define OR1K_MEM_VERILOG_FOOTER "\n\
+end\n\n\
+always @(posedge clk) begin\n\
+ if (ce && ~we) begin\n\
+ dataout <= #1 mem[addr];\n\
+ disout <= #1 dis[addr];\n\
+ $display(\"or1k_mem: reading mem[%%0d]:%%h dis: %%0s\", addr, dataout, dis[addr]);\n\
+ end else\n\
+ if (ce && we) begin\n\
+ mem[addr] <= #1 data;\n\
+ dis[addr] <= #1 \"(data)\";\n\
+ $display(\"or1k_mem: writing mem[%%0d]:%%h dis: %%0s\", addr, mem[addr], dis[addr]);\n\
+ end\n\
+end\n\n\
+endmodule\n"
+
Index: dumpverilog.c
===================================================================
--- dumpverilog.c (nonexistent)
+++ dumpverilog.c (revision 1765)
@@ -0,0 +1,121 @@
+/* dumpverilog.c -- Dumps memory region as Verilog representation
+ or as hex code
+ Copyright (C) 2000 Damjan Lampret, lampret@opencores.org
+
+This file is part of OpenRISC 1000 Architectural Simulator.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* Verilog dump can be used for stimulating OpenRISC Verilog RTL models. */
+
+#include
+#include
+#include
+
+#include "config.h"
+#include "sim-config.h"
+
+#include "parse.h"
+#include "abstract.h"
+#include "labels.h"
+#include "arch.h"
+#include "execute.h"
+#include "sprs.h"
+#include "stats.h"
+#include "except.h"
+#include "dumpverilog.h"
+#include "opcode/or32.h"
+
+extern char rcsrev[];
+extern char *disassembled;
+
+void dumpverilog(char *verilog_modname, unsigned int from, unsigned int to)
+{
+ unsigned int i, done = 0;
+ struct label_entry *tmp;
+ char dis[DISWIDTH + 100];
+ struct mem_entry *entry;
+ printf("// This file was generated by or1ksim %s\n", rcsrev);
+ printf(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
+
+ for(i = from; i < to; i++)
+ {
+ unsigned int _insn = evalsim_mem32 (i);
+ int index = insn_decode(_insn);
+ if (index >= 0)
+ {
+ if (verify_memoryarea(i) && (tmp = get_label(i)))
+ if (tmp)
+ printf("\n//\t%s%s", tmp->name, LABELEND_CHAR);
+
+ printf("\n\tmem['h%x] = %d'h%.8lx;", i/DWQ, DW, evalsim_mem32(i));
+
+ disassemble_insn (_insn);
+ strcpy (dis, disassembled);
+
+ if (strlen(dis) < DISWIDTH)
+ memset(dis + strlen(dis), ' ', DISWIDTH);
+ dis[DISWIDTH] = '\0';
+ printf("\n\tdis['h%x] = {\"%s\"};", i/DWQ, dis);
+ dis[0] = '\0';
+ i += insn_len(index) - 1;
+ } else {
+ if (i % 64 == 0)
+ printf("\n");
+
+ printf("\n\tmem['h%x] = 'h%.2x;", i/DWQ, evalsim_mem8(i));
+ }
+ done = 1;
+ }
+
+ if (done)
+ {
+ printf(OR1K_MEM_VERILOG_FOOTER);
+ return;
+ }
+
+ /* this needs to be fixed */
+
+ for(i = from; i < to; i++)
+ {
+ if (i % 8 == 0)
+ printf("\n%.8x: ", i);
+
+ /* don't print ascii chars below 0x20. */
+ if (evalsim_mem32(i) < 0x20)
+ printf("0x%.2x ", (unsigned char)evalsim_mem32(i));
+ else
+ printf("0x%.2x'%c' ", (unsigned char)evalsim_mem32(i), (unsigned char)evalsim_mem32(i));
+ }
+ printf(OR1K_MEM_VERILOG_FOOTER);
+}
+
+void dumphex(unsigned int from, unsigned int to)
+{
+ unsigned int i, done = 0;
+
+ for(i = from; i < to; i++) {
+ unsigned int _insn = evalsim_mem32 (i);
+ int index = insn_decode(_insn);
+ if (index >= 0)
+ {
+ printf("%.8lx\n", evalsim_mem32(i));
+
+ i += insn_len(index) - 1;
+ }
+ else
+ printf("%.2x\n", evalsim_mem8(i));
+ }
+}
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 1765)
.
Property changes :
Added: svn:ignore
## -0,0 +1 ##
+Makefile