OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k/tags/rel-0-3-0-rc2/or1ksim/support
    from Rev 1753 to Rev 1765
    Reverse comparison

Rev 1753 → Rev 1765

/sched.c
0,0 → 1,191
/* sched.c -- Abstract entities, handling job scheduling
 
Copyright (C) 2001 Marko Mlinar, markom@opencores.org
Copyright (C) 2008 Embecosm Limited
 
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
 
This file is part of Or1ksim, the 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 3 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, see <http://www.gnu.org/licenses/>. */
 
/* This program is commented throughout in a fashion suitable for processing
with Doxygen. */
 
 
/* Autoconf and/or portability configuration */
#include "config.h"
#include "port.h"
 
/* System includes */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
 
/* Package includes */
#include "sched.h"
#include "debug.h"
#include "sim-config.h"
 
 
DECLARE_DEBUG_CHANNEL(sched_jobs);
 
#define SCHED_HEAP_SIZE 128
#define SCHED_TIME_MAX INT32_MAX
 
/* FIXME: Scheduler should continue from previous cycles not current ones */
 
struct scheduler_struct scheduler;
 
/* Dummy function, representing a guard, which protects heap from
emptying */
void sched_guard (void *dat)
{
if(scheduler.job_queue)
SCHED_ADD(sched_guard, dat, SCHED_TIME_MAX);
else {
scheduler.job_queue = scheduler.free_job_queue;
scheduler.free_job_queue = scheduler.free_job_queue->next;
scheduler.job_queue->next = NULL;
scheduler.job_queue->func = sched_guard;
scheduler.job_queue->time = SCHED_TIME_MAX;
}
}
 
void sched_reset(void)
{
struct sched_entry *cur, *next;
 
for(cur = scheduler.job_queue; cur; cur = next) {
next = cur->next;
cur->next = scheduler.free_job_queue;
scheduler.free_job_queue = cur;
}
scheduler.job_queue = NULL;
sched_guard(NULL);
}
 
void sched_init(void)
{
int i;
struct sched_entry *new;
 
scheduler.free_job_queue = NULL;
 
for(i = 0; i < SCHED_HEAP_SIZE; i++) {
if(!(new = malloc(sizeof(struct sched_entry)))) {
fprintf(stderr, "Out-of-memory while allocateing scheduler queue\n");
exit(1);
}
new->next = scheduler.free_job_queue;
scheduler.free_job_queue = new;
}
scheduler.job_queue = NULL;
sched_guard(NULL);
}
 
/* Executes jobs in time queue */
void do_scheduler(void)
{
struct sched_entry *tmp;
 
/* Execute all jobs till now */
do {
tmp = scheduler.job_queue;
scheduler.job_queue = tmp->next;
tmp->next = scheduler.free_job_queue;
scheduler.free_job_queue = tmp;
 
scheduler.job_queue->time += tmp->time;
 
tmp->func (tmp->param);
} while(scheduler.job_queue->time <= 0);
}
 
/* Adds new job to the queue */
void sched_add(void (*job_func)(void *), void *job_param, int32_t job_time,
const char *func)
{
struct sched_entry *cur, *prev, *new_job;
int32_t alltime;
 
cur = scheduler.job_queue;
prev = NULL;
alltime = cur->time;
while(cur && (alltime < job_time)) {
prev = cur;
cur = cur->next;
if(cur)
alltime += cur->time;
}
 
new_job = scheduler.free_job_queue;
scheduler.free_job_queue = new_job->next;
new_job->next = cur;
 
new_job->func = job_func;
new_job->param = job_param;
 
if(prev) {
new_job->time = job_time - (alltime - (cur ? cur->time : 0));
prev->next = new_job;
} else {
scheduler.job_queue = new_job;
new_job->time = job_time >= 0 ? job_time : cur->time;
}
 
if(cur)
cur->time -= new_job->time;
 
}
 
/* Returns a job with specified function and param, NULL if not found */
void sched_find_remove(void (*job_func)(void *), void *dat)
{
struct sched_entry *cur;
struct sched_entry *prev = NULL;
 
for (cur = scheduler.job_queue; cur; prev = cur, cur = cur->next) {
if ((cur->func == job_func) && (cur->param == dat)) {
if(cur->next)
cur->next->time += cur->time;
 
if(prev)
prev->next = cur->next;
else
scheduler.job_queue = cur->next;
cur->next = scheduler.free_job_queue;
scheduler.free_job_queue = cur;
break;
}
}
}
 
/* Schedules the next job so that it will run after the next instruction */
void sched_next_insn(void (*func)(void *), void *dat)
{
int32_t cycles = 1;
struct sched_entry *cur = scheduler.job_queue;
 
/* The cycles count of the jobs may go into negatives. If this happens, func
* will get called before the next instruction has executed. */
while(cur && (cur->time < 0)) {
cycles -= cur->time;
cur = cur->next;
}
 
SCHED_ADD(func, dat, cycles);
}
 
 
sched.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sched.h =================================================================== --- sched.h (nonexistent) +++ sched.h (revision 1765) @@ -0,0 +1,69 @@ +/* sched.h -- Abstract entities header file handling job scheduler + + Copyright (C) 2001 Marko Mlinar, markom@opencores.org + Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef _SCHED_H_ +#define _SCHED_H_ + +/*! Macro to add a job to the scheduler */ +#define SCHED_ADD(job_func, job_param, job_time) sched_add(job_func, job_param, job_time, #job_func) + +/*! Macro to remove a job from the scheduler */ +#define SCHED_FIND_REMOVE(f, p) sched_find_remove(f, p) + +/*! Structure for holding one job entry */ +struct sched_entry +{ + int32_t time; /* Clock cycles before job starts */ + void *param; /* Parameter to pass to the function */ + void (*func) (void *); /* Function to call when time reaches 0 */ + struct sched_entry *next; +}; + +/*! Heap of jobs */ +struct scheduler_struct +{ + struct sched_entry *free_job_queue; + struct sched_entry *job_queue; +}; + +/* Global data structures for external use */ +extern struct scheduler_struct scheduler; + +/* Function prototypes for external use */ +extern void sched_init (); +extern void sched_reset (); +extern void sched_next_insn (void (*func) (void *), + void *dat); +extern void sched_find_remove (void (*job_func) (void *), + void *dat); +extern void sched_add (void (*job_func) (void *), + void *job_param, + int32_t job_time, + const char *func); +extern void do_scheduler (); + +#endif /* _SCHED_H_ */
sched.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: simprintf.c =================================================================== --- simprintf.c (nonexistent) +++ simprintf.c (revision 1765) @@ -0,0 +1,189 @@ +/* simprintf.c -- Simulator printf implementation + + Copyright (C) 1999 Damjan Lampret, lampret@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +/* 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. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include + +/* Package includes */ +#include "sim-config.h" +#include "arch.h" +#include "debug.h" +#include "abstract.h" +#include "execute.h" + + +/* Should args be passed on stack for simprintf + * + * FIXME: do not enable this since it causes problems + * in some cases (an example beeing cbasic test + * from orp testbench). the problems is in + * + * or1k/support/simprintf.c + * + * #if STACK_ARGS + * arg = eval_mem32(argaddr,&breakpoint); + * argaddr += 4; + * #else + * sprintf(regstr, "r%u", ++argaddr); + * arg = evalsim_reg(atoi(regstr)); + * #endif + * + * the access to memory should be without any + * checks (ie not like or32 application accessed it) + * + */ +#define STACK_ARGS 0 + +/* Length of PRINTF format string */ +#define FMTLEN 2000 + +char fmtstr[FMTLEN]; + +static char * +simgetstr (oraddr_t stackaddr, unsigned long regparam) +{ + oraddr_t fmtaddr; + int i; + + fmtaddr = regparam; + + i = 0; + while (eval_direct8 (fmtaddr, 1, 0) != '\0') + { + fmtstr[i++] = eval_direct8 (fmtaddr, 1, 0); + fmtaddr++; + if (i == FMTLEN - 1) + break; + } + fmtstr[i] = '\0'; + + return fmtstr; +} + +void +simprintf (oraddr_t stackaddr, unsigned long regparam) +{ + uint32_t arg; + oraddr_t argaddr; + char *fmtstrend; + char *fmtstrpart = fmtstr; + int tee_exe_log; + + simgetstr (stackaddr, regparam); + +#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 <= runtime.cpu.instructions + && (config.sim.exe_log_end <= 0 + || runtime.cpu.instructions <= config.sim.exe_log_end)); + + if (tee_exe_log) + fprintf (runtime.sim.fexe_log, "SIMPRINTF: "); + while (strlen (fmtstrpart)) + { + if ((fmtstrend = strstr (fmtstrpart + 1, "%"))) + *fmtstrend = '\0'; + if (strstr (fmtstrpart, "%")) + { + char *tmp; + int string = 0; +#if STACK_ARGS + arg = eval_direct32 (argaddr, 1, 0); + argaddr += 4; +#else + { + /* JPB. I can't see how the original code ever worked. It does trash + the file pointer by overwriting the end of regstr. In any case + why create a string, only to turn it back into an integer! */ + + /* orig: char regstr[5]; */ + /* orig: */ + /* orig: sprintf(regstr, "r%"PRIxADDR, ++argaddr); */ + /* orig: arg = evalsim_reg(atoi(regstr)); */ + + arg = evalsim_reg (++argaddr); + } +#endif + tmp = fmtstrpart; + if (*tmp == '%') + { + tmp++; + while (*tmp == '-' || (*tmp >= '0' && *tmp <= '9')) + tmp++; + if (*tmp == 's') + string = 1; + } + if (string) + { + int len = 0; + char *str; + for (; eval_direct8 (arg++, 1, 0); len++); + len++; /* for null char */ + arg -= len; + str = (char *) malloc (len); + len = 0; + for (; eval_direct8 (arg, 1, 0); len++) + *(str + len) = eval_direct8 (arg++, 1, 0); + *(str + len) = eval_direct8 (arg, 1, 0); /* null ch */ + printf (fmtstrpart, str); + if (tee_exe_log) + fprintf (runtime.sim.fexe_log, fmtstrpart, str); + free (str); + } + else + { + printf (fmtstrpart, arg); + if (tee_exe_log) + fprintf (runtime.sim.fexe_log, fmtstrpart, arg); + } + } + else + { + printf (fmtstrpart); + if (tee_exe_log) + fprintf (runtime.sim.fexe_log, fmtstrpart); + } + if (!fmtstrend) + break; + fmtstrpart = fmtstrend; + *fmtstrpart = '%'; + } +} Index: dumpverilog.c =================================================================== --- dumpverilog.c (nonexistent) +++ dumpverilog.c (revision 1765) @@ -0,0 +1,183 @@ +/* dumpverilog.c -- Dumps memory region as Verilog representation + or as hex code + + Copyright (C) 2000 Damjan Lampret, lampret@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +/* Verilog dump can be used for stimulating OpenRISC Verilog RTL models. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" + +/* Package includes */ +#include "sim-config.h" +#include "arch.h" +#include "abstract.h" +#include "labels.h" +#include "opcode/or32.h" + + +#define DW 32 /* Data width of mem 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 = %" PRIdREG ";\n\n"\ +"parameter amax = %" PRIdREG ";\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" + +#define LABELEND_CHAR ":" + +void +dumpverilog (char *verilog_modname, oraddr_t from, oraddr_t to) +{ + unsigned int i, done = 0; + struct label_entry *tmp; + char dis[DISWIDTH + 100]; + uint32_t insn; + int index; + PRINTF ("// This file was generated by or1ksim version %s\n", + PACKAGE_VERSION); + PRINTF (OR1K_MEM_VERILOG_HEADER + (verilog_modname, from / DWQ, to / DWQ, (DISWIDTH * 8))); + + for (i = from; i < to; i++) + { + if (!(i & 3)) + { + insn = eval_direct32 (i, 0, 0); + 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%.8" PRIx32 ";", i / DWQ, DW, + eval_direct32 (i, 0, 0)); + + 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; + done = 1; + continue; + } + } + + if (i % 64 == 0) + PRINTF ("\n"); + + PRINTF ("\n\tmem['h%x] = 'h%.2x;", i / DWQ, eval_direct8 (i, 0, 0)); + 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 (eval_direct32 (i, 0, 0) < 0x20) + PRINTF ("0x%.2x ", (uint8_t) eval_direct32 (i, 0, 0)); + else + PRINTF ("0x%.2x'%c' ", (uint8_t) eval_direct32 (i, 0, 0), + (char) eval_direct32 (i, 0, 0)); + } + PRINTF (OR1K_MEM_VERILOG_FOOTER); +} + +void +dumphex (oraddr_t from, oraddr_t to) +{ + oraddr_t i; + uint32_t insn; + int index; + + for (i = from; i < to; i++) + { + if (!(i & 3)) + { + insn = eval_direct32 (i, 0, 0); + index = insn_decode (insn); + if (index >= 0) + { + PRINTF ("%.8" PRIx32 "\n", eval_direct32 (i, 0, 0)); + i += insn_len (index) - 1; + continue; + } + } + PRINTF ("%.2x\n", eval_direct8 (i, 0, 0)); + } +} Index: misc.h =================================================================== --- misc.h (nonexistent) +++ misc.h (revision 1765) @@ -0,0 +1,34 @@ +/* misc.h -- Misc. routines that just don't fit anywhere else + + Copyright (C) 1999 Damjan Lampret, lampret@opencores.org + Copyright (C) 2002 Marko Mlinar, markom@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +#ifndef MISC__H +#define MISC__H + +/* Function prototypes for external use */ +extern int log2_int (unsigned long x); +extern int is_power2 (int x); + +#endif /* MISC__H */ Index: profile.c =================================================================== --- profile.c (nonexistent) +++ profile.c (revision 1765) @@ -0,0 +1,48 @@ +/* profile.c -- functions for profiling + + Copyright (C) 2002 Marko Mlinar, markom@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" + +/* System includes */ +#include + +/* Package includes */ +#include "profile.h" +#include "sim-config.h" +#include "arch.h" + + +/* Adds a new entry to the memory profile file */ +void +mprofile (oraddr_t 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: simprintf.h =================================================================== --- simprintf.h (nonexistent) +++ simprintf.h (revision 1765) @@ -0,0 +1,36 @@ +/* simprintf.h -- Simulator printf implementation header + + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef SIMPRINTF__H +#define SIMPRINTF__H + +/* Package includes */ +#include "arch.h" + +/* Function prototypes for external use */ +extern void simprintf (oraddr_t stackaddr, + unsigned long regparam); + +#endif /* SIMPRINTF__H */ Index: Makefile.in =================================================================== --- Makefile.in (nonexistent) +++ Makefile.in (revision 1765) @@ -0,0 +1,488 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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. + +@SET_MAKE@ + +# Makefile -- Makefile for cpu architecture independent simulation +# +# Copyright (C) 1999 Damjan Lampret, lampret@opencores.org +# Copyright (C) 2008 Embecosm Limited +# +# Contributor Jeremy Bennett +# +# 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 3 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, see . + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = support +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libsupport_la_LIBADD = +am_libsupport_la_OBJECTS = simprintf.lo dumpverilog.lo profile.lo \ + sched.lo debug.lo misc.lo +libsupport_la_OBJECTS = $(am_libsupport_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libsupport_la_SOURCES) +DIST_SOURCES = $(libsupport_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +ARFLAGS = @ARFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_DIR = @BUILD_DIR@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPU_ARCH = @CPU_ARCH@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEBUGFLAGS = @DEBUGFLAGS@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INCLUDES = @INCLUDES@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LOCAL_CFLAGS = @LOCAL_CFLAGS@ +LOCAL_DEFS = @LOCAL_DEFS@ +LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MAKE_SHELL = @MAKE_SHELL@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SUMVERSION = @SUMVERSION@ +TERMCAP_LIB = @TERMCAP_LIB@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LTLIBRARIES = libsupport.la +libsupport_la_SOURCES = simprintf.c \ + dumpverilog.c \ + profile.c \ + sched.c \ + debug.c \ + misc.c \ + dbchs.h \ + debug.h \ + dumpverilog.h \ + misc.h \ + profile.h \ + sched.h \ + simprintf.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu support/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu support/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libsupport.la: $(libsupport_la_OBJECTS) $(libsupport_la_DEPENDENCIES) + $(LINK) $(libsupport_la_OBJECTS) $(libsupport_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dumpverilog.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simprintf.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# 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: dumpverilog.h =================================================================== --- dumpverilog.h (nonexistent) +++ dumpverilog.h (revision 1765) @@ -0,0 +1,42 @@ +/* dumpverilog.h -- Dumps memory region as Verilog representation header + or as hex code + + Copyright (C) 2000 Damjan Lampret, lampret@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +/* Verilog dump can be used for stimulating OpenRISC Verilog RTL models. */ + + +#ifndef DUMPVERILOG__H +#define DUMPVERILOG__H + + +/* Package includes */ +#include "arch.h" + + +/* Function prototypes for external use */ +extern void dumpverilog (char *verilog_modname, oraddr_t from, oraddr_t to); +extern void dumphex (oraddr_t from, oraddr_t to); + +#endif /* DUMPVERILOG__H */ Index: profile.h =================================================================== --- profile.h (nonexistent) +++ profile.h (revision 1765) @@ -0,0 +1,49 @@ +/* profile.c -- definitions for profiling + + Copyright (C) 2002 Marko Mlinar, markom@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef PROFILE__H +#define PROFILE__H + +/* Package includes */ +#include "arch.h" + + +#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 (oraddr_t memaddr, unsigned char type); + +struct mprofentry_struct { + oraddr_t addr; + unsigned char type; +}; + +#endif /* PROFILE__H */
profile.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: debug.c =================================================================== --- debug.c (nonexistent) +++ debug.c (revision 1765) @@ -0,0 +1,177 @@ +/* debug.c -- Debug channel support code + + Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include +#include +#include + +/* Package includes */ +#include "arch.h" +#include "sim-config.h" + +#define __ORSIM_NO_DEC_DBCH +#include "debug.h" + +#define DECLARE_DEBUG_CHANNEL(dbch) char __orsim_dbch_##dbch[] = "\0"#dbch; +#include "dbchs.h" +#undef DECLARE_DEBUG_CHANNEL + +#define DECLARE_DEBUG_CHANNEL(dbch) __orsim_dbch_##dbch, +static char *__orsim_dbchs[] = { +#include "dbchs.h" +NULL }; +#undef DECLARE_DEBUG_CHANNEL + +static const char *debug_classes[] = { "trace", "fixme", "warn", "err" }; + + +void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, + const char *function, const char *format, ...) +{ + va_list ap; + static int last_lf = 1; /* There *has* to be a better way */ + + if(last_lf) { + if(!TRACE_ON(cycles)) + fprintf(stderr, "%s:%s:%s: ", debug_classes[dbcl], dbch + 1, function); + else + fprintf(stderr, "%lld:%s:%s:%s: ", runtime.sim.cycles, + debug_classes[dbcl], dbch + 1, function); + } + last_lf = format[strlen(format) - 1] == '\n'; /* This is wrong... */ + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); +} + +void orsim_dbcl_set(enum __ORSIM_DEBUG_CLASS dbcl, char *dbch, int on) +{ + if(on) + dbch[0] |= 1 << dbcl; + else + dbch[0] &= ~(1 << dbcl); +} + +void orsim_dbcl_set_name(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, int on) +{ + char **dbchs = __orsim_dbchs; + + for(dbchs = __orsim_dbchs; *dbchs; dbchs++) { + if(!strcmp(*dbchs + 1, dbch)) { + orsim_dbcl_set(dbcl, *dbchs, on); + break; + } + } +} + +void parse_dbchs(const char *str) +{ + enum __ORSIM_DEBUG_CLASS dbcl = 0; + int i; + int disen; + int all; + const char *cend; + const char *chan_end; + + while(*str) { + cend = strpbrk(str, "+-"); + chan_end = strchr(str, ','); + if(!chan_end) + chan_end = str + strlen(str); + + if(!cend || (cend > chan_end)) { + disen = 1; + cend = --str; + } else + disen = *cend == '+' ? 1 : 0; + + if(cend == str) { + all = 1; + } else { + for(i = 0; i < 4; i++) { + if(!strncmp(str, debug_classes[i], cend - str)) { + dbcl = i; + break; + } + } + if(i >= 4) + fprintf(stderr, "Unknown class specified\n"); + all = 0; + } + cend++; + + for(i = 0; __orsim_dbchs[i]; i++) + if(!strncmp(cend, __orsim_dbchs[i] + 1, chan_end - cend)) + break; + + if(!__orsim_dbchs[i]) + fprintf(stderr, "Unknown channel specified\n"); + else if(all) { + orsim_dbcl_set(__ORSIM_DBCL_TRACE, __orsim_dbchs[i], disen); + orsim_dbcl_set(__ORSIM_DBCL_FIXME, __orsim_dbchs[i], disen); + orsim_dbcl_set(__ORSIM_DBCL_WARN, __orsim_dbchs[i], disen); + orsim_dbcl_set(__ORSIM_DBCL_ERR, __orsim_dbchs[i], disen); + } else + orsim_dbcl_set(dbcl, __orsim_dbchs[i], disen); + if(*chan_end) + str = chan_end + 1; + else + str = chan_end; + } +} + + +/*---------------------------------------------------------------------------*/ +/*!Internal debug function + + Print the message if the level is greater than or equal to that specified + in the configuration. + + @param[in] level The debug level of this message + @param[in] format Varargs format string + @param[in] ... The varargs required by the string */ +/*---------------------------------------------------------------------------*/ +void +debug (int level, + const char *format, + ...) +{ + if (config.sim.debug >= level) + { + va_list ap; + + va_start (ap, format); + vfprintf (runtime.sim.fout, format, ap); + fflush (runtime.sim.fout); + } +} /* debug() */ + + Index: Makefile.am =================================================================== --- Makefile.am (nonexistent) +++ Makefile.am (revision 1765) @@ -0,0 +1,37 @@ +# Makefile -- Makefile for cpu architecture independent simulation +# +# Copyright (C) 1999 Damjan Lampret, lampret@opencores.org +# Copyright (C) 2008 Embecosm Limited +# +# Contributor Jeremy Bennett +# +# 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 3 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, see . + + +noinst_LTLIBRARIES = libsupport.la +libsupport_la_SOURCES = simprintf.c \ + dumpverilog.c \ + profile.c \ + sched.c \ + debug.c \ + misc.c \ + dbchs.h \ + debug.h \ + dumpverilog.h \ + misc.h \ + profile.h \ + sched.h \ + simprintf.h Index: dbchs.h =================================================================== --- dbchs.h (nonexistent) +++ dbchs.h (revision 1765) @@ -0,0 +1,50 @@ +/* dbchs.h -- Debug channel declarations + + Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +/* NOTE. Don't protect this with #ifndef. It may be included more than once. */ + +/* Declarations of all debug channels */ + +DECLARE_DEBUG_CHANNEL(sched) +DECLARE_DEBUG_CHANNEL(except) +DECLARE_DEBUG_CHANNEL(cycles) +DECLARE_DEBUG_CHANNEL(sched_jobs) +DECLARE_DEBUG_CHANNEL(spr) +DECLARE_DEBUG_CHANNEL(immu) +DECLARE_DEBUG_CHANNEL(dmmu) +DECLARE_DEBUG_CHANNEL(pic) +DECLARE_DEBUG_CHANNEL(tick) +DECLARE_DEBUG_CHANNEL(generic) /* JPB */ +DECLARE_DEBUG_CHANNEL(uart) +DECLARE_DEBUG_CHANNEL(eth) +DECLARE_DEBUG_CHANNEL(config) +DECLARE_DEBUG_CHANNEL(ata) +DECLARE_DEBUG_CHANNEL(gpio) +DECLARE_DEBUG_CHANNEL(mc) +DECLARE_DEBUG_CHANNEL(dma) +DECLARE_DEBUG_CHANNEL(vapi) +DECLARE_DEBUG_CHANNEL(simprintf) +DECLARE_DEBUG_CHANNEL(jtag) +DECLARE_DEBUG_CHANNEL(coff) Index: debug.h =================================================================== --- debug.h (nonexistent) +++ debug.h (revision 1765) @@ -0,0 +1,98 @@ +/* debug.h -- Trace function declarations + + Copyright 1999 Patrik Stridvall (for the wine project: www.winehq.com) + Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef DEBUG__H +#define DEBUG__H + +enum __ORSIM_DEBUG_CLASS { + __ORSIM_DBCL_TRACE, + __ORSIM_DBCL_FIXME, + __ORSIM_DBCL_WARN, + __ORSIM_DBCL_ERR, +}; + +void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, + const char *function, const char *format, ...) + __attribute__((format(printf, 4, 5))); +void orsim_dbcl_set_name(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, int on); +void parse_dbchs(const char *str); + +#ifndef __ORSIM_DBG_USE_FUNC +#define __ORSIM_DBG_USE_FUNC __FUNCTION__ +#endif + +#define __ORSIM_GET_DEBUGGING_TRACE(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_TRACE)) +#define __ORSIM_GET_DEBUGGING_WARN(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_WARN)) +#define __ORSIM_GET_DEBUGGING_FIXME(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_FIXME)) +#define __ORSIM_GET_DEBUGGING_ERR(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_ERR)) + +#define __ORSIM_GET_DEBUGGING(dbcl,dbch) __ORSIM_GET_DEBUGGING##dbcl(dbch) + +#define __ORSIM_DPRINTF(dbcl, dbch) \ + do { if(__ORSIM_GET_DEBUGGING(dbcl,(dbch))) { \ + const char * const __dbch = dbch; \ + const enum __ORSIM_DEBUG_CLASS __dbcl = __ORSIM_DBCL##dbcl; \ + __ORSIM_DEBUG_LOG + +#define __ORSIM_DEBUG_LOG(args...) \ + orsim_dbg_log(__dbcl, __dbch, __ORSIM_DBG_USE_FUNC, args); } } while(0) + +#define TRACE_(ch) __ORSIM_DPRINTF(_TRACE, __orsim_dbch_##ch) +#define FIXME_(ch) __ORSIM_DPRINTF(_FIXME, __orsim_dbch_##ch) +#define WARN_(ch) __ORSIM_DPRINTF(_WARN, __orsim_dbch_##ch) +#define ERR_(ch) __ORSIM_DPRINTF(_ERR, __orsim_dbch_##ch) + +#define TRACE __ORSIM_DPRINTF(_TRACE, __orsim_dbch___default) +#define FIXME __ORSIM_DPRINTF(_FIXME, __orsim_dbch___default) +#define WARN __ORSIM_DPRINTF(_WARN, __orsim_dbch___default) +#define ERR __ORSIM_DPRINTF(_ERR, __orsim_dbch___default) + +#define TRACE_ON(ch) __ORSIM_GET_DEBUGGING(_TRACE,__orsim_dbch_##ch) +#define WARN_ON(ch) __ORSIM_GET_DEBUGGING(_WARN,__orsim_dbch_##ch) +#define FIXME_ON(ch) __ORSIM_GET_DEBUGGING(_FIXME,__orsim_dbch_##ch) +#define ERR_ON(ch) __ORSIM_GET_DEBUGGING(_ERR,__orsim_dbch_##ch) + +#define DEFAULT_DEBUG_CHANNEL(dbch) \ + extern char __orsim_dbch_##dbch[]; \ + static char * const __orsim_dbch___default = __orsim_dbch_##dbch; + +#ifndef __ORSIM_NO_DEC_DBCH +#define DECLARE_DEBUG_CHANNEL(dbch) extern char __orsim_dbch_##dbch[]; +#endif + +/* For debugging purposes (of Or1ksim itself), it helps if debug can take + advantage of the GNU C __attribute__ feature. */ +#ifdef __GNUC__ +void debug(int level, + const char *format,...) + __attribute__((format(printf, 2, 3))); +#else +void debug(int level, + const char *format,...); +#endif + +#endif /* DEBUG__H */ Index: misc.c =================================================================== --- misc.c (nonexistent) +++ misc.c (revision 1765) @@ -0,0 +1,53 @@ +/* misc.c -- Misc. routines that just don't fit anywhere else + + Copyright (C) 1999 Damjan Lampret, lampret@opencores.org + Copyright (C) 2002 Marko Mlinar, markom@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the 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 3 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, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" + + +/* returns log2(x) */ +/* Call this log2_int, because there is a library function named log2 */ +int +log2_int (unsigned long x) +{ + int c = 0; + if (!x) + return 0; /* not by the book, but practical */ + while (x != 1) + x >>= 1, c++; + return c; +} + +int +is_power2 (int x) +{ + if (!x) + return 0; + while (!(x & 1)) + x >>= 1; + return x == 1; +} Index: . =================================================================== --- . (nonexistent) +++ . (revision 1765)
. Property changes : Added: svn:ignore ## -0,0 +1,2 ## +Makefile +.deps

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.