URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 939 to Rev 940
- ↔ Reverse comparison
Rev 939 → Rev 940
/trunk/or1ksim/profiler.c
22,6 → 22,7
|
#include <stdio.h> |
#include "profiler.h" |
#include "sim-config.h" |
|
static struct stack_struct stack[MAX_STACK]; |
|
69,8 → 70,14
int prof_acquire (char *fprofname) |
{ |
int line = 0; |
fprof = fopen (fprofname, "rt"); |
|
int reopened = 0; |
|
if (runtime.sim.fprof) { |
fprof = runtime.sim.fprof; |
reopened = 1; |
rewind (fprof); |
} else fprof = fopen (fprofname, "rt"); |
|
if (!fprof) { |
fprintf (stderr, "Cannot open profile file: %s\n", fprofname); |
return 1; |
141,7 → 148,39
} else |
break; |
} |
fclose(fprof); |
|
/* If we have reopened the file, we need to add end of "[outside functions]" */ |
if (reopened) { |
prof_cycles = runtime.sim.cycles; |
/* pop everything above current from stack, |
if more than one, something went wrong */ |
while (nstack > 0) { |
int j; |
long time; |
nstack--; |
time = runtime.sim.cycles - stack[nstack].cycles; |
/* Whether in normal mode, we must substract called function from execution time. */ |
if (!cumulative) |
for (j = 0; j < nstack; j++) stack[j].cycles += time; |
|
for (j = 0; j < prof_nfuncs; j++) |
if (stack[nstack].addr == prof_func[j].addr) { /* function exists, append. */ |
prof_func[j].cum_cycles += time; |
prof_func[j].calls++; |
nfunccalls++; |
break; |
} |
if (j >= prof_nfuncs) { /* function does not yet exist, create new. */ |
prof_func[prof_nfuncs].cum_cycles = time; |
prof_func[prof_nfuncs].calls = 1; |
nfunccalls++; |
prof_func[prof_nfuncs].addr = stack[nstack].addr; |
strcpy (prof_func[prof_nfuncs].name, stack[nstack].name); |
prof_nfuncs++; |
} |
} |
} else fclose(fprof); |
return 0; |
} |
|
/* Print out profiling data */ |
/trunk/or1ksim/cuc/cuc.h
287,7 → 287,7
void schedule_memory (cuc_func *func, int otype); |
|
/* Generates verilog file out of insn dataflow */ |
void output_verilog (cuc_func *func, char *filename); |
void output_verilog (cuc_func *func, char *filename, char *funcname); |
|
/* Recalculates bb[].cnt values, based on generated profile file */ |
void recalc_cnts (cuc_func *f, char *bb_filename); |
/trunk/or1ksim/cuc/bb.c
1065,8 → 1065,14
int mlsum = 0; |
int mscnt = 0; |
int mlcnt = 0; |
int reopened = 0; |
|
assert (fi = fopen (mp_filename, "rb")); |
/* Use already opened stream? */ |
if (runtime.sim.fmprof) { |
fi = runtime.sim.fmprof; |
reopened = 1; |
rewind (fi); |
} else assert (fi = fopen (mp_filename, "rb")); |
assert (fo = fopen (bb_filename, "wb+")); |
|
assert (bb_start = (unsigned long *) malloc (sizeof (unsigned long) * f->num_bb)); |
1120,7 → 1126,7
runtime.cuc.mdelay[1] = (1. * mlsum) / mlcnt; |
runtime.cuc.mdelay[2] = runtime.cuc.mdelay[3] = 1; |
f->num_runs = f->bb[0].cnt; |
fclose (fi); |
if (!reopened) fclose (fi); |
fclose (fo); |
free (buf); |
free (bb_end); |
/trunk/or1ksim/cuc/verilog.c
204,7 → 204,7
} |
|
/* Generates verilog file out of insn dataflow */ |
void output_verilog (cuc_func *f, char *filename) |
void output_verilog (cuc_func *f, char *filename, char *funcname) |
{ |
FILE *fo; |
int b, i, j; |
229,7 → 229,7
/* output header */ |
GEN ("/* %s -- generated by OpenRISC Custom Unit Compiler\n", tmp); |
GEN (" (C) 2002 OpenCores http://www.opencores.org/\n"); |
GEN (" function \"%s\"\n", filename); |
GEN (" function \"%s\"\n", funcname); |
GEN (" at %08x - %08x\n", f->start_addr, f->end_addr); |
GEN (" num BBs %i */\n\n", f->num_bb); |
GEN ("module %s (clk, rst,\n", filename); |
/trunk/or1ksim/cuc/cuc.c
565,7 → 565,7
int i, j; |
char tmp1[256]; |
char filename_cut[256]; |
for (i = 0; i < 256; i++) { |
for (i = 0; i < sizeof (filename_cut); i++) { |
if (isalpha(filename[i])) filename_cut[i] = filename[i]; |
else { |
filename_cut[i] = '\0'; |