URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 631 to Rev 632
- ↔ Reverse comparison
Rev 631 → Rev 632
/trunk/or1ksim/mprofiler.c
23,19 → 23,8
#include <stdio.h> |
#include <malloc.h> |
#include "support/profile.h" |
#include "mprofiler.h" |
|
/* output modes */ |
#define MODE_DETAIL 0 |
#define MODE_PRETTY 1 |
#define MODE_ACCESS 2 |
#define MODE_WIDTH 3 |
|
/* Input buffer size */ |
#define BUF_SIZE 100 |
|
/* HASH */ |
#define HASH_SIZE 0x10000 |
#define HASH_FUNC(x) ((x) & 0xffff) |
struct memory_hash { |
struct memory_hash *next; |
unsigned long addr; |
56,7 → 45,7
/* File to read from */ |
static FILE *fprof = 0; |
|
void help () |
void mp_help () |
{ |
printf ("USAGE: mprofiler <-d|-p|-a|-w> [-f filename] [-g group] from to\n"); |
printf ("\t-d\t--detail\t\tdetailed output\n"); |
196,12 → 185,16
} |
} |
|
int main (int argc, char *argv[]) |
int main_mprofiler (int mode, int group, char *fname) |
{ |
char fmprofname[50] = "sim.mprofile"; |
int param = 0; |
int mode = MODE_DETAIL; |
/*int mode = MODE_DETAIL;*/ |
|
if (!fname) fname = fmprofname; |
group_bits = group; |
|
/* |
argv++; argc--; |
while (argc > 0) { |
if (!strcmp(argv[0], "-d") || !strcmp(argv[0], "--detail")) { |
221,7 → 214,7
group_bits = strtoul (argv[0], NULL, 0); |
argv++; argc--; |
} else if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { |
help (); |
mp_help (); |
exit (0); |
} else if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--filename")) { |
argv++; argc--; |
242,11 → 235,12
argv++; argc--; param++; |
} |
} |
*/ |
|
fprof = fopen (&fmprofname[0], "rm"); |
fprof = fopen (fname, "rm"); |
|
if (!fprof) { |
fprintf (stderr, "Cannot open profile file: %s\n", &fmprofname[0]); |
fprintf (stderr, "Cannot open profile file: %s\n", fname); |
exit(1); |
} |
|
/trunk/or1ksim/sim-config.h
176,9 → 176,12
int verbose; /* Force verbose output */ |
|
int profile; /* Is profiler running */ |
int profile_mode; /* Profiler operating mode */ |
char prof_fn[STR_SIZE]; /* Profiler filename */ |
|
int mprofile; /* Is memory profiler running */ |
int mprofile_mode; /* Memory profiler operating mode */ |
int mprofile_group; /* Grouping for memory profiler */ |
char mprof_fn[STR_SIZE];/* Memory profiler filename */ |
|
int history; /* instruction stream history analysis */ |
/trunk/or1ksim/mprofiler.h
0,0 → 1,41
/* mprofiler.c -- memory profiling utility |
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. */ |
|
/* Command line utility, that displays profiling information, generated |
by or1ksim. (use --mprofile option at command line, when running or1ksim. */ |
|
#ifndef __MPROFILER_H |
#define __MPROFILER_H |
|
/* output modes */ |
#define MODE_DETAIL 0 |
#define MODE_PRETTY 1 |
#define MODE_ACCESS 2 |
#define MODE_WIDTH 3 |
|
/* Input buffer size */ |
#define BUF_SIZE 100 |
|
/* HASH */ |
#define HASH_SIZE 0x10000 |
#define HASH_FUNC(x) ((x) & 0xffff) |
|
int main_mprofiler(int mode, int group, char *fname); |
|
#endif /* not __MPROFILER_H */ |
/trunk/or1ksim/sim.cfg
342,9 → 342,9
section sim |
/* verbose = 1 */ |
debug = 0 |
profile = 0 |
profile = 1 |
prof_fn = "sim.profile" |
mprofile = 0 |
mprofile = 1 |
mprof_fn = "sim.mprofile" |
|
history = 1 |
351,7 → 351,7
/* iprompt = 0 */ |
exe_log = 0 |
exe_log_fn = "executed.log" |
spr_log = 0 |
spr_log = 0 |
spr_log_fn = "spr.log" |
clkcycle = 100ns |
end |
/trunk/or1ksim/profiler.c
21,10 → 21,8
by or1ksim. (use --profile option at command line, when running or1ksim. */ |
|
#include <stdio.h> |
#include "profiler.h" |
|
#define MAX_STACK 1024 |
#define MAX_FUNCS 1024 |
|
struct stack_struct { |
/* Function address */ |
unsigned int addr; |
80,13 → 78,22
/* File to read from */ |
static FILE *fprof = 0; |
|
int main (int argc, char *argv[]) { |
int main_profile (int mode, char *fname) { |
char fprofname[50] = "sim.profile"; |
int line = 0; |
|
/* |
if (argc > 4 || argc < 2) { |
fprintf (stderr, "USAGE: profiler [--cumulative|-c] [--quiet|-q] --generate|-g [profile_file_name]\n"); |
exit(1); |
} |
*/ |
|
if (mode && PROF_CUMULATIVE) cumulative = 1; |
if (mode && PROF_QUIET) quiet = 1; |
if (!fname) fname = fprofname; |
|
/* |
argv++; argc--; |
while (argc > 0) { |
if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) { |
106,11 → 113,12
} |
} |
} |
*/ |
|
fprof = fopen (&fprofname[0], "rt"); |
fprof = fopen (fname, "rt"); |
|
if (!fprof) { |
fprintf (stderr, "Cannot open profile file: %s\n", &fprofname[0]); |
fprintf (stderr, "Cannot open profile file: %s\n", fname); |
exit(1); |
} |
|
/trunk/or1ksim/profiler.h
0,0 → 1,33
/* profiler.h -- profiling utility |
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. */ |
|
/* Command line utility, that displays profiling information, generated |
by or1ksim. (use --profile option at command line, when running or1ksim. */ |
|
#ifndef __PROFILER_H |
#define __PROFILER_H |
|
#define MAX_STACK 1024 |
#define MAX_FUNCS 1024 |
|
#define PROF_CUMULATIVE 0x01 |
#define PROF_QUIET 0x02 |
|
int main_profile (int mode, char *fname); |
#endif /* not __PROFILER_H */ |
/trunk/or1ksim/Makefile.am
9,7 → 9,7
bin_PROGRAMS = sim |
EXTRA_PROGRAMS = profiler mprofiler |
|
sim_SOURCES = toplevel.c sim-config.c |
sim_SOURCES = toplevel.c sim-config.c sim-config.h profiler.c mprofiler.c profiler.h mprofiler.h |
sim_LDADD = cpu/common/libcommon.a cpu/$(CPU_ARCH)/libarch.a \ |
cpu/or1k/libor1k.a support/libsupport.a mmu/libmmu.a \ |
bpb/libbpb.a cache/libcache.a peripheral/libperipheral.a \ |
/trunk/or1ksim/toplevel.c
50,8 → 50,11
#include "debug_unit.h" |
#include "coff.h" |
|
#include "profiler.h" |
#include "mprofiler.h" |
|
/* CVS revision number. */ |
const char rcsrev[] = "$Revision: 1.72 $"; |
const char rcsrev[] = "$Revision: 1.73 $"; |
|
/* Continuos run versus single step tracing switch. */ |
int cont_run; |
185,7 → 188,7
fprintf(stderr, "ERROR: Problems opening profile file.\n"); |
exit (1); |
} else |
fprintf(runtime.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF main\n"); |
fprintf(runtime.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF total\n"); |
} |
|
if (config.sim.mprofile) { |
340,11 → 343,18
extern int cycles; |
fprintf(runtime.sim.fprof,"-%08X FFFFFFFF\n", cycles); |
fclose(runtime.sim.fprof); |
|
main_profile(config.sim.profile_mode, config.sim.prof_fn); |
} |
|
if (config.sim.mprofile) |
if (config.sim.mprofile) { |
fclose(runtime.sim.fmprof); |
|
main_mprofiler(config.sim.mprofile_mode, |
config.sim.mprofile_group, |
config.sim.mprof_fn); |
} |
|
if (config.sim.exe_log) fclose(runtime.sim.fexe_log); |
if (runtime.vapi.enabled) vapi_done (); |
done_memory_table (); |
351,6 → 361,11
exit(0); |
} |
|
|
|
/*############################################### |
| MAIN |
###############################################*/ |
int main(argc, argv) |
int argc; |
char *argv[]; |
366,16 → 381,16
if (parse_args(argc, argv)) { |
printf("Usage: %s [options] <filename>\n", argv[0]); |
printf("Options:\n"); |
printf(" -v version and copyright note\n"); |
printf(" -i enable interactive command prompt\n"); |
printf(" --nosrv do not launch JTAG proxy server\n"); /* (CZ) */ |
printf(" --srv <n> launch JTAG proxy server on port <n>; [random]\n"); /* (CZ) */ |
printf(" -v version and copyright note\n"); |
printf(" -i enable interactive command prompt\n"); |
printf(" --nosrv do not launch JTAG proxy server\n"); /* (CZ) */ |
printf(" --srv <n> launch JTAG proxy server on port <n>; [random]\n"); /* (CZ) */ |
#if !FAST_SIM |
printf(" -f or --file load script file [sim.cfg]\n"); |
printf(" --profile enable profiling\n"); |
printf(" --mprofile enable memory profiling\n"); |
printf(" -f or --file load script file [sim.cfg]\n"); |
printf(" --profile <[c]|[q]> enable profiling. c - cumulative, q - quiet\n"); |
printf(" --mprofile <[c]|[q]> enable memory profiling. c - cumulative, q - quiet\n"); |
#endif |
printf(" --output-cfg prints C structure of current configuration to standard output\n"); |
printf(" --output-cfg prints C structure of current configuration to standard output\n"); |
exit(-1); |
} |
|
/trunk/or1ksim/sim-config.c
29,6 → 29,9
#include "icache_model.h" |
#include "dcache_model.h" |
|
#include "profiler.h" |
#include "mprofiler.h" |
|
#define WARNING(s) fprintf (stderr, "WARNING: config.%s: %s\n", sections[section].name, (s)) |
#define ERROR(s) {fprintf (stderr, "ERROR: config.%s:%s\n", sections[section].name, s); if (runtime.sim.init) exit (1);} |
#define MERROR(s) {fprintf (stderr, "ERROR: %s\n", s); if (runtime.sim.init) exit (1);} |
59,6 → 62,9
config.sim.debug = 0; |
config.sim.verbose = 1; |
|
config.sim.profile_mode = 0; |
config.sim.mprofile_mode = 0; |
config.sim.mprofile_group = 2; |
strcpy (config.sim.prof_fn, "sim.profile"); |
strcpy (config.sim.mprof_fn, "sim.mprofile"); |
strcpy (runtime.sim.script_fn, "(default)"); |
205,11 → 211,37
if (strcmp(*argv, "--profile") == 0) { |
config.sim.profile = 1; |
argv++; argc--; |
if (argv[0][0] != '-') { |
if ((argv[0][0] == 'c') || (argv[0][1] == 'c')) config.sim.profile_mode |= PROF_CUMULATIVE; |
if ((argv[0][0] == 'q') || (argv[0][1] == 'q')) config.sim.profile_mode |= PROF_QUIET; |
argv++; argc--; |
} |
} else |
if (strcmp(*argv, "--mprofile") == 0) { |
if (strcmp(*argv, "--mprofile_d") == 0) { |
config.sim.mprofile = 1; |
config.sim.mprofile_mode = MODE_DETAIL; |
argv++; argc--; |
} else |
if (strcmp(*argv, "--mprofile_p") == 0) { |
config.sim.mprofile = 1; |
config.sim.mprofile_mode = MODE_PRETTY; |
argv++; argc--; |
} else |
if (strcmp(*argv, "--mprofile_a") == 0) { |
config.sim.mprofile = 1; |
config.sim.mprofile_mode = MODE_ACCESS; |
argv++; argc--; |
} else |
if (strcmp(*argv, "--mprofile_w") == 0) { |
config.sim.mprofile = 1; |
config.sim.mprofile_mode = MODE_WIDTH; |
argv++; argc--; |
} else |
if (!strcmp(argv[0], "-g") || !strcmp(argv[0], "--group")) { |
argv++; argc--; |
config.sim.mprofile_group = strtoul(argv[0], NULL, 0); |
argv++; argc--; |
} |
#endif |
if (strcmp(*argv, "--output-cfg") == 0) { |
runtime.sim.output_cfg = 1; |