1997-04-02 04:52:31 +00:00
|
|
|
|
This is a loose collection of notes for people hacking on simulators.
|
1997-09-02 22:07:54 +00:00
|
|
|
|
If this document gets big enough it can be prettied up then.
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
|
|
|
|
Contents
|
|
|
|
|
|
|
|
|
|
- The "common" directory
|
|
|
|
|
- Common Makefile Support
|
1997-09-02 22:07:54 +00:00
|
|
|
|
- TAGS support
|
1997-04-02 04:52:31 +00:00
|
|
|
|
- Generating "configure" files
|
1997-09-02 22:07:54 +00:00
|
|
|
|
- tconfig.in
|
1998-04-24 21:00:29 +00:00
|
|
|
|
- C Language Assumptions
|
|
|
|
|
- "dump" commands under gdb
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
|
|
|
|
The "common" directory
|
|
|
|
|
======================
|
|
|
|
|
|
|
|
|
|
The common directory contains:
|
|
|
|
|
|
|
|
|
|
- common documentation files (e.g. run.1, and maybe in time .texi files)
|
|
|
|
|
- common source files (e.g. run.c)
|
|
|
|
|
- common Makefile fragment and configury (e.g. Make-common.in, aclocal.m4).
|
|
|
|
|
|
|
|
|
|
In addition "common" contains portions of the system call support
|
|
|
|
|
(e.g. callback.c, nltvals.def).
|
|
|
|
|
|
|
|
|
|
Even though no files are built in this directory, it is still configured
|
|
|
|
|
so support for regenerating nltvals.def is present.
|
|
|
|
|
|
|
|
|
|
Common Makefile Support
|
|
|
|
|
=======================
|
|
|
|
|
|
|
|
|
|
A common configuration framework is available for simulators that want
|
|
|
|
|
to use it. The common framework exists to remove a lot of duplication
|
|
|
|
|
in configure.in and Makefile.in, and it also provides a foundation for
|
|
|
|
|
enhancing the simulators uniformly (e.g. the more they share in common
|
|
|
|
|
the easier a feature added to one is added to all).
|
|
|
|
|
|
|
|
|
|
The configure.in of a simulator using the common framework should look like:
|
|
|
|
|
|
|
|
|
|
--- snip ---
|
|
|
|
|
dnl Process this file with autoconf to produce a configure script.
|
|
|
|
|
AC_PREREQ(2.5)dnl
|
|
|
|
|
AC_INIT(Makefile.in)
|
|
|
|
|
|
|
|
|
|
SIM_AC_COMMON
|
|
|
|
|
|
|
|
|
|
... target specific additions ...
|
|
|
|
|
|
|
|
|
|
SIM_AC_OUTPUT
|
|
|
|
|
--- snip ---
|
|
|
|
|
|
|
|
|
|
SIM_AC_COMMON:
|
|
|
|
|
|
|
|
|
|
- invokes the autoconf macros most often used by the simulators
|
|
|
|
|
- defines --enable/--with options usable by all simulators
|
|
|
|
|
- initializes sim_link_files/sim_link_links as the set of symbolic links
|
|
|
|
|
to set up
|
|
|
|
|
|
|
|
|
|
SIM_AC_OUTPUT:
|
|
|
|
|
|
|
|
|
|
- creates the symbolic links defined in sim_link_{files,links}
|
|
|
|
|
- creates config.h
|
|
|
|
|
- creates the Makefile
|
|
|
|
|
|
|
|
|
|
The Makefile.in of a simulator using the common framework should look like:
|
|
|
|
|
|
|
|
|
|
--- snip ---
|
|
|
|
|
# Makefile for blah ...
|
|
|
|
|
# Copyright blah ...
|
|
|
|
|
|
|
|
|
|
## COMMON_PRE_CONFIG_FRAG
|
|
|
|
|
|
|
|
|
|
# These variables are given default values in COMMON_PRE_CONFIG_FRAG.
|
|
|
|
|
# We override the ones we need to here.
|
|
|
|
|
# Not all of these need to be mentioned, only the necessary ones.
|
1997-09-02 22:07:54 +00:00
|
|
|
|
# In fact it is better to *not* mention ones if the value is the default.
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
|
|
|
|
# List of object files, less common parts.
|
|
|
|
|
SIM_OBJS =
|
1997-09-02 22:07:54 +00:00
|
|
|
|
# List of extra dependencies.
|
|
|
|
|
# Generally this consists of simulator specific files included by sim-main.h.
|
|
|
|
|
SIM_EXTRA_DEPS =
|
1997-04-02 04:52:31 +00:00
|
|
|
|
# List of flags to always pass to $(CC).
|
|
|
|
|
SIM_EXTRA_CFLAGS =
|
|
|
|
|
# List of extra libraries to link with.
|
|
|
|
|
SIM_EXTRA_LIBS =
|
|
|
|
|
# List of extra program dependencies.
|
|
|
|
|
SIM_EXTRA_LIBDEPS =
|
|
|
|
|
# List of main object files for `run'.
|
|
|
|
|
SIM_RUN_OBJS = run.o
|
|
|
|
|
# Dependency of `all' to build any extra files.
|
|
|
|
|
SIM_EXTRA_ALL =
|
|
|
|
|
# Dependency of `install' to install any extra files.
|
|
|
|
|
SIM_EXTRA_INSTALL =
|
|
|
|
|
# Dependency of `clean' to clean any extra files.
|
|
|
|
|
SIM_EXTRA_CLEAN =
|
|
|
|
|
|
|
|
|
|
## COMMON_POST_CONFIG_FRAG
|
|
|
|
|
|
|
|
|
|
# Rules need to build $(SIM_OBJS), plus whatever else the target wants.
|
|
|
|
|
|
|
|
|
|
... target specific rules ...
|
|
|
|
|
--- snip ---
|
|
|
|
|
|
|
|
|
|
COMMON_{PRE,POST}_CONFIG_FRAG are markers for SIM_AC_OUTPUT to tell it
|
|
|
|
|
where to insert the two pieces of common/Make-common.in.
|
|
|
|
|
The resulting Makefile is created by doing autoconf substitions on
|
|
|
|
|
both the target's Makefile.in and Make-common.in, and inserting
|
|
|
|
|
the two pieces of Make-common.in into the target's Makefile.in at
|
|
|
|
|
COMMON_{PRE,POST}_CONFIG_FRAG.
|
1997-09-02 22:07:54 +00:00
|
|
|
|
|
|
|
|
|
Note that SIM_EXTRA_{INSTALL,CLEAN} could be removed and "::" targets
|
|
|
|
|
could be used instead. However, it's not clear yet whether "::" targets
|
|
|
|
|
are portable enough.
|
|
|
|
|
|
|
|
|
|
TAGS support
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
Many files generate program symbols at compile time.
|
|
|
|
|
Such symbols can't be found with grep nor do they normally appear in
|
|
|
|
|
the TAGS file. To get around this, source files can add the comment
|
|
|
|
|
|
|
|
|
|
/* TAGS: foo1 foo2 */
|
|
|
|
|
|
|
|
|
|
where foo1, foo2 are program symbols. Symbols found in such comments
|
|
|
|
|
are greppable and appear in the TAGS file.
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
|
|
|
|
Generating "configure" files
|
|
|
|
|
============================
|
|
|
|
|
|
1998-04-26 21:44:25 +00:00
|
|
|
|
For targets using the common framework, "configure" can be generated
|
|
|
|
|
by running `autoconf'.
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
|
|
|
|
To regenerate the configure files for all targets using the common framework:
|
|
|
|
|
|
|
|
|
|
$ cd devo/sim
|
1998-04-24 21:00:29 +00:00
|
|
|
|
$ make -f Makefile.in SHELL=/bin/sh autoconf-common
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
|
|
|
|
To add a change-log entry to the ChangeLog file for each updated
|
|
|
|
|
directory (WARNING - check the modified new-ChangeLog files before
|
|
|
|
|
renaming):
|
|
|
|
|
|
1998-04-24 21:00:29 +00:00
|
|
|
|
$ make -f Makefile.in SHELL=/bin/sh autoconf-changelog
|
1997-04-02 04:52:31 +00:00
|
|
|
|
$ more */new-ChangeLog
|
1998-04-24 21:00:29 +00:00
|
|
|
|
$ make -f Makefile.in SHELL=/bin/sh autoconf-install
|
1997-04-02 04:52:31 +00:00
|
|
|
|
|
1997-04-03 02:22:52 +00:00
|
|
|
|
In a similar vein, both the configure and config.in files can be
|
|
|
|
|
updated using the sequence:
|
|
|
|
|
|
|
|
|
|
$ cd devo/sim
|
1998-04-24 21:00:29 +00:00
|
|
|
|
$ make -f Makefile.in SHELL=/bin/sh autoheader-common
|
|
|
|
|
$ make -f Makefile.in SHELL=/bin/sh autoheader-changelog
|
1997-04-03 02:22:52 +00:00
|
|
|
|
$ more */new-ChangeLog
|
1998-04-24 21:00:29 +00:00
|
|
|
|
$ make -f Makefile.in SHELL=/bin/sh autoheader-install
|
1997-09-02 22:07:54 +00:00
|
|
|
|
|
|
|
|
|
tconfig.in
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
File tconfig.in defines one or more target configuration macros
|
|
|
|
|
(e.g. a tm.h file). There are very few that need defining.
|
|
|
|
|
For a list of all of them, see common/tconfig.in.
|
|
|
|
|
It contains them all, commented out.
|
|
|
|
|
The intent is that a new port can just copy this file and
|
|
|
|
|
define the ones it needs.
|
1997-09-03 07:34:59 +00:00
|
|
|
|
|
|
|
|
|
C Language Assumptions
|
|
|
|
|
======================
|
|
|
|
|
|
|
|
|
|
The programmer may assume that the simulator is being built using an
|
|
|
|
|
ANSI C compiler that supports a 64 bit data type. Consequently:
|
|
|
|
|
|
|
|
|
|
o prototypes can be used (although using
|
|
|
|
|
PARAMS() and K&R declarations wouldn't
|
|
|
|
|
go astray).
|
|
|
|
|
|
|
|
|
|
o If sim-types.h is included, the two
|
|
|
|
|
types signed64 and unsigned64 are
|
|
|
|
|
available.
|
|
|
|
|
|
|
|
|
|
o The type `unsigned' is valid.
|
|
|
|
|
|
1998-04-24 21:00:29 +00:00
|
|
|
|
However, the user should be aware of the following:
|
1997-09-03 07:34:59 +00:00
|
|
|
|
|
1998-04-24 21:00:29 +00:00
|
|
|
|
o GCC's `<number>LL' is NOT acceptable.
|
|
|
|
|
Microsoft-C doesn't reconize it.
|
1997-09-03 07:34:59 +00:00
|
|
|
|
|
1998-04-24 21:00:29 +00:00
|
|
|
|
o MSC's `<number>i64' is NOT acceptable.
|
|
|
|
|
GCC doesn't reconize it.
|
|
|
|
|
|
|
|
|
|
o GCC's `long long' MSC's `_int64' can
|
|
|
|
|
NOT be used to define 64 bit integer data
|
|
|
|
|
types.
|
|
|
|
|
|
|
|
|
|
o An empty array (eg int a[0]) is not valid.
|
|
|
|
|
|
|
|
|
|
When building with GCC it is effectivly a requirement that
|
|
|
|
|
--enable-sim-warnings be specified during configuration.
|
|
|
|
|
|
|
|
|
|
"dump" commands under gdb
|
|
|
|
|
=========================
|
|
|
|
|
|
|
|
|
|
gdbinit.in contains the following
|
|
|
|
|
|
|
|
|
|
define dump
|
|
|
|
|
set sim_debug_dump ()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Simulators that define the sim_debug_dump function can then have their
|
|
|
|
|
internal state pretty printed from gdb.
|
|
|
|
|
|
|
|
|
|
FIXME: This can obviously be made more elaborate. As needed it will be.
|
|
|
|
|
|
|
|
|
|
"dump" commands under gdb
|
|
|
|
|
=========================
|
|
|
|
|
|
|
|
|
|
gdbinit.in contains the following
|
|
|
|
|
|
|
|
|
|
define dump
|
|
|
|
|
set sim_debug_dump ()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Simulators that define the sim_debug_dump function can then have their
|
|
|
|
|
internal state pretty printed from gdb.
|
|
|
|
|
|
|
|
|
|
FIXME: This can obviously be made more elaborate. As needed it will be.
|